StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEStructBuffer.cxx
1 /**********************************************************************
2  *
3  * $Id: StEStructBuffer.cxx,v 1.5 2006/04/04 22:10:11 porter Exp $
4  *
5  * Author: Jeff Porter
6  *
7  **********************************************************************
8  *
9  * Description: Data buffer to hold events for mixing per z-vertex
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 "StEStructBuffer.h"
27 #include "StEStructPool/EventMaker/StEStructEvent.h"
28 #include "StEStructMaxB.h"
29 
30 
31 StEStructBuffer::StEStructBuffer(){
32 
33  mnumEvents=mnumDeleted=mnumInput=0;
34  mEvent=new StEStructEvent*[MAXBUFFERSIZE+1];
35  for(int i=0;i<=MAXBUFFERSIZE;i++)mEvent[i]=NULL;
36  resetCounter();
37 
38 }
39 
40 
41 StEStructBuffer::~StEStructBuffer(){
42 
43  for(int i=0;i<=mnumEvents;i++)delete mEvent[i];
44  delete [] mEvent;
45 
46 }
47 
48 void StEStructBuffer::addEvent(StEStructEvent* event){
49 
50  if(!event)return;
51  if(mnumEvents==MAXBUFFERSIZE-1){
52  if(mEvent[mnumEvents]){
53  delete mEvent[mnumEvents];
54  mEvent[mnumEvents]=NULL;
55  mnumDeleted++;
56  }
57  } else {
58  mnumEvents++;
59  }
60  //for(int i=mnumEvents-1;i>0;i--)mEvent[i]=mEvent[i-1];
61  for(int i=mnumEvents;i>0;i--)mEvent[i]=mEvent[i-1];
62  mEvent[0]=event;
63  mnumInput++;
64 
65 }
66 
67 StEStructEvent* StEStructBuffer::nextEvent(int mult){
68  // Searches for an event with multiplicity difference from mult less than DELTANMAX
69  // Finish if number of returned events = _MAXEBYEBUFFER_ or we run out of buffer
70 
71  if(mnumMixed==_MAXEBYEBUFFER_) return NULL; // are we already done?
72  mcurEvent++;
73  while(mEvent[mcurEvent]) {
74  if(abs(mult - mEvent[mcurEvent]->Ntrack()) <= DELTANMAX) break;
75  mcurEvent++;
76  if(mcurEvent>MAXBUFFERSIZE) cout << " *** ERROR ***: BUFFER OVERFLOW" << endl; // should never happen
77  }
78  mnumMixed++;
79  return mEvent[mcurEvent];
80 
81 }
82 
83 
84 void StEStructBuffer::Print(){
85  for(int i=0;i<=MAXBUFFERSIZE;i++) {
86  if (mEvent[i]) cout << i <<": " << mEvent[i]->Ntrack() << "\t";
87  else cout << i <<": NULL" << "\t";
88  }
89  cout << endl;
90 
91 }
92 
93 /***********************************************************************
94  *
95  * $Log: StEStructBuffer.cxx,v $
96  * Revision 1.5 2006/04/04 22:10:11 porter
97  * a handful of changes (specific to correlations)
98  * - added StEStructQAHists so that if NOT input frm Maker, each analysis has its own
99  * - used ability to get any max,min val from the cut class - or z-vertex binning
100  * - put z-vertex binning into 1 place
101  * - switched back 1st line of pair cut method to keep pair if good, not to reject if bad.
102  * - Pair cut object is now pointer in correlations
103  * - some diagnostic printouts available from macro
104  * - Duncan's delta-phi binning change
105  *
106  * Revision 1.4 2005/09/14 17:14:22 msd
107  * Large update, added new pair-cut system, added pair density plots for new analysis mode (4), added event mixing cuts (rewrote buffer for this)
108  *
109  * Revision 1.3 2005/03/28 22:59:08 porter
110  * I opened a memory leak on last ci due to forgetting how StEStructBuffer
111  * actually worked! This is now fixed with explaination in description.
112  *
113  * Revision 1.2 2005/03/03 01:30:43 porter
114  * updated StEStruct2ptCorrelations to include pt-correlations and removed
115  * old version of pt-correlations from chunhuih (StEStruct2ptPtNbar)
116  *
117  * Revision 1.1 2003/10/15 18:20:46 porter
118  * initial check in of Estruct Analysis maker codes.
119  *
120  *
121  *********************************************************************/
122 
123 
124 
125 
126