StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEStructOneBuffer.cxx
1 /**********************************************************************
2  *
3  * $Id: StEStructOneBuffer.cxx,v 1.2 2011/08/02 20:34:03 prindle Exp $
4  *
5  * Author: Duncan Prindle
6  *
7  **********************************************************************
8  *
9  * Description: Data buffer to hold events for mixing in case where events are presorted.
10  *
11  * The algorithm is such that looping over events eventually returns the element,
12  * mEvent[MAXBUFFERSIZE]=NULL
13  *
14  * The buffer is filled from [0] to [MAX.. -1] and numEvent counter
15  * then stays and MAX-1 (so it should be called 'numEventIndex').
16  * Once filled, event in [MAX-1] is deleted, all events are moved
17  * 'down' in the array and current event is added at [0].
18  *
19  * To include a delta-N cut (mixed event multiplicity difference), I needed
20  * to increase the buffer size. So now the actual size is defined by MAXBUFFERSIZE,
21  * and _MAXEBYEBUFFER_ is the number of mixed events we will try to make.
22  *
23  * The delta-N cut is currently hard-coded to 100.
24  *
25  ***********************************************************************/
26 #include "StEStructOneBuffer.h"
27 #include "StEStructPool/EventMaker/StEStructEvent.h"
28 #include "StEStructMaxB.h"
29 
30 ClassImp(StEStructOneBuffer);
31 
32 StEStructOneBuffer::StEStructOneBuffer(int nMix, int deltaMultMax, float deltaZMax, float deltaRateMax) {
33  mNumMixed = nMix;
34  mcurEvent = -1;
35  mDeltaMultMax = deltaMultMax;
36  mDeltaZMax = deltaZMax;
37  mDeltaRateMax = deltaRateMax;
38  mEvent=new StEStructEvent*[mNumMixed+1];
39  for (int i=0;i<=mNumMixed;i++) {
40  mEvent[i] = NULL;
41  }
42 }
43 
44 
45 StEStructOneBuffer::~StEStructOneBuffer() {
46  for (int i=0;i<=mNumMixed;i++) {
47  if (mEvent[i]) {
48  delete mEvent[i];
49  }
50  }
51  delete [] mEvent;
52 }
53 
54 void StEStructOneBuffer::addEvent(StEStructEvent* event) {
55  if (!event) {
56  return;
57  }
58  if (mEvent[mNumMixed-1]) {
59  delete mEvent[mNumMixed-1];
60  }
61  for (int i=mNumMixed-1;i>0;i--) {
62  mEvent[i] = mEvent[i-1];
63  }
64  mEvent[0] = event;
65 }
66 
67 StEStructEvent* StEStructOneBuffer::nextEvent(int mult, float vz, float coinc) {
68  // Return next event within mDeltaMultMax and mDeltaZMax of input.
69  mcurEvent++;
70  while(mEvent[mcurEvent]) {
71  if(abs(mult - mEvent[mcurEvent]->Ntrack()) <= mDeltaMultMax &&
72  fabs(vz-mEvent[mcurEvent]->VertexZ()) <= mDeltaZMax &&
73  fabs(coinc-mEvent[mcurEvent]->ZDCCoincidence()) <= mDeltaRateMax) {
74  break;
75  }
76  mcurEvent++;
77  if(mcurEvent > mNumMixed) {
78  // This shouldn't happen, since mEvent[mNumMixed] == 0.
79  return 0;
80  }
81  }
82  return mEvent[mcurEvent];
83 }
84 
85 
86 /***********************************************************************
87  *
88  * $Log: StEStructOneBuffer.cxx,v $
89  * Revision 1.2 2011/08/02 20:34:03 prindle
90  * More detailed histograms for event mixing.
91  * Buffer: increased mixed events to 4 (from 2)
92  * CutBin: added mode 9 for exploration of p_t space, fixed place in mode 5 where
93  * histogram was written before checking it existed.
94  * OneBuffer: added ZDC coincidence rate to event sorting space.
95  *
96  * Revision 1.1 2010/09/02 21:54:03 prindle
97  * OneBuffer: When we sort on z-vertex and multiplicity we can use a single event mixing buffer.
98  *
99  * Revision 1.5 2006/04/04 22:10:11 porter
100  * a handful of changes (specific to correlations)
101  * - added StEStructQAHists so that if NOT input frm Maker, each analysis has its own
102  * - used ability to get any max,min val from the cut class - or z-vertex binning
103  * - put z-vertex binning into 1 place
104  * - switched back 1st line of pair cut method to keep pair if good, not to reject if bad.
105  * - Pair cut object is now pointer in correlations
106  * - some diagnostic printouts available from macro
107  * - Duncan's delta-phi binning change
108  *
109  * Revision 1.4 2005/09/14 17:14:22 msd
110  * Large update, added new pair-cut system, added pair density plots for new analysis mode (4), added event mixing cuts (rewrote buffer for this)
111  *
112  * Revision 1.3 2005/03/28 22:59:08 porter
113  * I opened a memory leak on last ci due to forgetting how StEStructBuffer
114  * actually worked! This is now fixed with explaination in description.
115  *
116  * Revision 1.2 2005/03/03 01:30:43 porter
117  * updated StEStruct2ptCorrelations to include pt-correlations and removed
118  * old version of pt-correlations from chunhuih (StEStruct2ptPtNbar)
119  *
120  * Revision 1.1 2003/10/15 18:20:46 porter
121  * initial check in of Estruct Analysis maker codes.
122  *
123  *
124  *********************************************************************/
125 
126 
127 
128 
129