00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "StHbtMaker/Infrastructure/StHbtLikeSignAnalysis.h"
00016 #include "StHbtMaker/Infrastructure/StHbtParticleCollection.hh"
00017 #include "StHbtMaker/Base/StHbtTrackCut.h"
00018 #include "StHbtMaker/Base/StHbtV0Cut.h"
00019 #include "StHbtMaker/Infrastructure/StHbtPicoEventCollectionVector.hh"
00020 #include "StHbtMaker/Infrastructure/StHbtPicoEventCollectionVectorHideAway.hh"
00021 #include "Stiostream.h"
00022
00023 #ifdef __ROOT__
00024 ClassImp(StHbtLikeSignAnalysis)
00025 #endif
00026
00027
00028
00029
00030
00031 extern void FillHbtParticleCollection(StHbtParticleCut* partCut,
00032 StHbtEvent* hbtEvent,
00033 StHbtParticleCollection* partCollection);
00034
00035
00036
00037 StHbtLikeSignAnalysis::StHbtLikeSignAnalysis(unsigned int bins, double min, double max) : StHbtAnalysis() {
00038 mVertexBins = bins;
00039 mVertexZ[0] = min;
00040 mVertexZ[1] = max;
00041 mUnderFlow = 0;
00042 mOverFlow = 0;
00043 if (mMixingBuffer) delete mMixingBuffer;
00044 mPicoEventCollectionVectorHideAway = new StHbtPicoEventCollectionVectorHideAway(mVertexBins,mVertexZ[0],mVertexZ[1]);
00045
00046 }
00047
00048 StHbtLikeSignAnalysis::StHbtLikeSignAnalysis(const StHbtLikeSignAnalysis& a) : StHbtAnalysis(a) {
00049 mVertexBins = a.mVertexBins;
00050 mVertexZ[0] = a.mVertexZ[0];
00051 mVertexZ[1] = a.mVertexZ[1];
00052 mUnderFlow = 0;
00053 mOverFlow = 0;
00054 if (mMixingBuffer) delete mMixingBuffer;
00055 mPicoEventCollectionVectorHideAway = new StHbtPicoEventCollectionVectorHideAway(mVertexBins,mVertexZ[0],mVertexZ[1]);
00056 }
00057
00058 StHbtLikeSignAnalysis::~StHbtLikeSignAnalysis(){
00059 delete mPicoEventCollectionVectorHideAway; mPicoEventCollectionVectorHideAway=0;
00060 }
00061
00062 StHbtString StHbtLikeSignAnalysis::Report()
00063 {
00064 char Ctemp[200];
00065 cout << "StHbtLikeSignAnalysis - constructing Report..."<<endl;
00066 StHbtString temp = "-----------\nHbt Analysis Report:\n";
00067 sprintf(Ctemp,"Events are mixed in %d bins in the range %E cm to %E cm.\n",mVertexBins,mVertexZ[0],mVertexZ[1]);
00068 temp += Ctemp;
00069 sprintf(Ctemp,"Events underflowing: %d\n",mUnderFlow);
00070 temp += Ctemp;
00071 sprintf(Ctemp,"Events overflowing: %d\n",mOverFlow);
00072 temp += Ctemp;
00073 sprintf(Ctemp,"Now adding StHbtAnalysis(base) Report\n");
00074 temp += Ctemp;
00075 temp += "Adding StHbtAnalysis(base) Report now:\n";
00076 temp += StHbtAnalysis::Report();
00077 temp += "-------------\n";
00078 StHbtString returnThis=temp;
00079 return returnThis;
00080 }
00081
00082 void StHbtLikeSignAnalysis::ProcessEvent(const StHbtEvent* hbtEvent) {
00083
00084 double vertexZ = hbtEvent->PrimVertPos().z();
00085 mMixingBuffer = mPicoEventCollectionVectorHideAway->PicoEventCollection(vertexZ);
00086 if (!mMixingBuffer) {
00087 if ( vertexZ < mVertexZ[0] ) mUnderFlow++;
00088 if ( vertexZ > mVertexZ[1] ) mOverFlow++;
00089 return;
00090 }
00091
00092
00093 EventBegin(hbtEvent);
00094
00095 bool tmpPassEvent = mEventCut->Pass(hbtEvent);
00096 mEventCut->FillCutMonitor(hbtEvent, tmpPassEvent);
00097 if (tmpPassEvent) {
00098 mNeventsProcessed++;
00099 cout << "StHbtLikeSignAnalysis::ProcessEvent() - " << hbtEvent->TrackCollection()->size();
00100 cout << " #track=" << hbtEvent->TrackCollection()->size();
00101
00102 StHbtPicoEvent* picoEvent = new StHbtPicoEvent;
00103 FillHbtParticleCollection(mFirstParticleCut,(StHbtEvent*)hbtEvent,picoEvent->FirstParticleCollection());
00104 if ( !(AnalyzeIdenticalParticles()) )
00105 FillHbtParticleCollection(mSecondParticleCut,(StHbtEvent*)hbtEvent,picoEvent->SecondParticleCollection());
00106 cout <<" #particles in First, Second Collections: " <<
00107 picoEvent->FirstParticleCollection()->size() << " " <<
00108 picoEvent->SecondParticleCollection()->size() << endl;
00109
00110 if (picoEvent->SecondParticleCollection()->size()*picoEvent->FirstParticleCollection()->size()==0) {
00111 delete picoEvent;
00112 cout << "StHbtLikeSignAnalysis - picoEvent deleted due to empty collection " <<endl;
00113 return;
00114 }
00115
00116
00117
00118
00119
00120
00121 StHbtPair* ThePair = new StHbtPair;
00122
00123 StHbtParticleIterator PartIter1;
00124 StHbtParticleIterator PartIter2;
00125 StHbtCorrFctnIterator CorrFctnIter;
00126 StHbtParticleIterator StartOuterLoop = picoEvent->FirstParticleCollection()->begin();
00127 StHbtParticleIterator EndOuterLoop = picoEvent->FirstParticleCollection()->end();
00128 StHbtParticleIterator StartInnerLoop;
00129 StHbtParticleIterator EndInnerLoop;
00130 if (AnalyzeIdenticalParticles()) {
00131 EndOuterLoop--;
00132 EndInnerLoop = picoEvent->FirstParticleCollection()->end() ;
00133 }
00134 else {
00135 StartInnerLoop = picoEvent->SecondParticleCollection()->begin();
00136 EndInnerLoop = picoEvent->SecondParticleCollection()->end() ;
00137 }
00138
00139 for (PartIter1=StartOuterLoop;PartIter1!=EndOuterLoop;PartIter1++){
00140 if (AnalyzeIdenticalParticles()){
00141 StartInnerLoop = PartIter1;
00142 StartInnerLoop++;
00143 }
00144 ThePair->SetTrack1(*PartIter1);
00145 for (PartIter2 = StartInnerLoop; PartIter2!=EndInnerLoop;PartIter2++){
00146 ThePair->SetTrack2(*PartIter2);
00147
00148
00149
00150
00151
00152 if (mPairCut->Pass(ThePair)){
00153 for (CorrFctnIter=mCorrFctnCollection->begin();
00154 CorrFctnIter!=mCorrFctnCollection->end();CorrFctnIter++){
00155 StHbtLikeSignCorrFctn* CorrFctn = dynamic_cast<StHbtLikeSignCorrFctn*>(*CorrFctnIter);
00156 if (CorrFctn) CorrFctn->AddRealPair(ThePair);
00157 }
00158 }
00159 }
00160 }
00161 #ifdef STHBTDEBUG
00162 cout << "StHbtLikeSignAnalysis::ProcessEvent() - reals done" << endl;
00163 #endif
00164
00165 StHbtParticleIterator nextIter;
00166 StHbtParticleIterator prevIter;
00167
00168
00169 prevIter = EndOuterLoop;
00170 prevIter--;
00171 for (PartIter1=StartOuterLoop;PartIter1!=prevIter;PartIter1++){
00172 ThePair->SetTrack1(*PartIter1);
00173 nextIter = PartIter1;
00174 nextIter++;
00175 for (PartIter2 = nextIter; PartIter2!=EndOuterLoop;PartIter2++){
00176 ThePair->SetTrack2(*PartIter2);
00177
00178
00179
00180
00181
00182 if (mPairCut->Pass(ThePair)){
00183 for (CorrFctnIter=mCorrFctnCollection->begin();
00184 CorrFctnIter!=mCorrFctnCollection->end();CorrFctnIter++){
00185 StHbtLikeSignCorrFctn* CorrFctn = dynamic_cast<StHbtLikeSignCorrFctn*>(*CorrFctnIter);
00186 if (CorrFctn) CorrFctn->AddLikeSignPositivePair(ThePair);
00187 }
00188 }
00189 }
00190 }
00191 #ifdef STHBTDEBUG
00192 cout << "StHbtLikeSignAnalysis::ProcessEvent() - like sign first collection done" << endl;
00193 #endif
00194
00195 prevIter = EndInnerLoop;
00196 prevIter--;
00197 for (PartIter1=StartInnerLoop;PartIter1!=prevIter;PartIter1++){
00198 ThePair->SetTrack1(*PartIter1);
00199 nextIter = PartIter1;
00200 nextIter++;
00201 for (PartIter2 = nextIter; PartIter2!=EndInnerLoop;PartIter2++){
00202 ThePair->SetTrack2(*PartIter2);
00203
00204
00205
00206
00207
00208 if (mPairCut->Pass(ThePair)){
00209 for (CorrFctnIter=mCorrFctnCollection->begin();
00210 CorrFctnIter!=mCorrFctnCollection->end();CorrFctnIter++){
00211 StHbtLikeSignCorrFctn* CorrFctn = dynamic_cast<StHbtLikeSignCorrFctn*>(*CorrFctnIter);
00212 if (CorrFctn) CorrFctn->AddLikeSignNegativePair(ThePair);
00213 }
00214 }
00215 }
00216 }
00217 #ifdef STHBTDEBUG
00218 cout << "StHbtLikeSignAnalysis::ProcessEvent() - like sign second collection done" << endl;
00219 #endif
00220
00221 if (MixingBufferFull()){
00222 #ifdef STHBTDEBUG
00223 cout << "Mixing Buffer is full - lets rock and roll" << endl;
00224 #endif
00225 }
00226 else {
00227 cout << "Mixing Buffer not full -gotta wait " << MixingBuffer()->size() << endl;
00228 }
00229 if (MixingBufferFull()){
00230 StartOuterLoop = picoEvent->FirstParticleCollection()->begin();
00231 EndOuterLoop = picoEvent->FirstParticleCollection()->end();
00232 StHbtPicoEvent* storedEvent;
00233 StHbtPicoEventIterator picoEventIter;
00234 for (picoEventIter=MixingBuffer()->begin();picoEventIter!=MixingBuffer()->end();picoEventIter++){
00235 storedEvent = *picoEventIter;
00236 if (AnalyzeIdenticalParticles()){
00237 StartInnerLoop = storedEvent->FirstParticleCollection()->begin();
00238 EndInnerLoop = storedEvent->FirstParticleCollection()->end();
00239 }
00240 else{
00241 StartInnerLoop = storedEvent->SecondParticleCollection()->begin();
00242 EndInnerLoop = storedEvent->SecondParticleCollection()->end();
00243 }
00244 for (PartIter1=StartOuterLoop;PartIter1!=EndOuterLoop;PartIter1++){
00245 ThePair->SetTrack1(*PartIter1);
00246 for (PartIter2=StartInnerLoop;PartIter2!=EndInnerLoop;PartIter2++){
00247 ThePair->SetTrack2(*PartIter2);
00248
00249 if (mPairCut->Pass(ThePair)){
00250
00251 for (CorrFctnIter=mCorrFctnCollection->begin();
00252 CorrFctnIter!=mCorrFctnCollection->end();CorrFctnIter++){
00253 StHbtLikeSignCorrFctn* CorrFctn = dynamic_cast<StHbtLikeSignCorrFctn*>(*CorrFctnIter);
00254 if (CorrFctn) {
00255 CorrFctn->AddMixedPair(ThePair);
00256
00257 }
00258 }
00259 }
00260 }
00261 }
00262 }
00263
00264
00265 delete MixingBuffer()->back();
00266 MixingBuffer()->pop_back();
00267 }
00268 delete ThePair;
00269 MixingBuffer()->push_front(picoEvent);
00270 }
00271 EventEnd(hbtEvent);
00272
00273 }
00274
00275
00276