1 #include "StHbtMaker/Infrastructure/StParityAnalysis.h"
2 #include "StHbtMaker/Infrastructure/StHbtParticleCollection.hh"
3 #include "StHbtMaker/Base/StHbtTrackCut.h"
4 #include "StHbtMaker/Base/StHbtV0Cut.h"
19 StHbtParticleCollection* partCollection)
21 switch (partCut->Type()) {
26 StHbtTrackIterator pIter;
27 StHbtTrackIterator startLoop = hbtEvent->TrackCollection()->begin();
28 StHbtTrackIterator endLoop = hbtEvent->TrackCollection()->end();
29 for (pIter=startLoop;pIter!=endLoop;pIter++){
31 bool tmpPassParticle = pCut->Pass(pParticle);
32 pCut->FillCutMonitor(pParticle, tmpPassParticle);
35 partCollection->push_back(particle);
44 StHbtV0Iterator pIter;
45 StHbtV0Iterator startLoop = hbtEvent->V0Collection()->begin();
46 StHbtV0Iterator endLoop = hbtEvent->V0Collection()->end();
48 for (pIter=startLoop;pIter!=endLoop;pIter++){
50 bool tmpPassV0 = pCut->Pass(pParticle);
51 pCut->FillCutMonitor(pParticle,tmpPassV0);
54 partCollection->push_back(particle);
60 cout <<
"FillHbtParticleCollection2 function (in StParityAnalysis.cxx) - undefined Particle Cut type!!! \n";
64 StParityAnalysis::StParityAnalysis(){
66 mFirstParticleCut = 0;
67 mSecondParticleCut = 0;
69 mCorrFctnCollection= 0;
70 mCorrFctnCollection =
new StHbtCorrFctnCollection;
71 mNeventsProcessed = 0;
78 mFirstParticleCut = 0;
79 mSecondParticleCut = 0;
81 mCorrFctnCollection= 0;
82 mCorrFctnCollection =
new StHbtCorrFctnCollection;
83 mNeventsProcessed = 0;
86 mEventCut = a.mEventCut->Clone();
88 mFirstParticleCut = a.mFirstParticleCut->Clone();
90 if (a.mFirstParticleCut==a.mSecondParticleCut!=0)
91 SetSecondParticleCut(mSecondParticleCut);
93 mSecondParticleCut = a.mSecondParticleCut->Clone();
95 mPairCut = a.mPairCut->Clone();
98 SetEventCut(mEventCut);
99 cout <<
" StParityAnalysis::StParityAnalysis(const StParityAnalysis& a) - event cut set " << endl;
101 if ( mFirstParticleCut ) {
102 SetFirstParticleCut(mFirstParticleCut);
103 cout <<
" StParityAnalysis::StParityAnalysis(const StParityAnalysis& a) - first particle cut set " << endl;
105 if ( mSecondParticleCut ) {
106 SetSecondParticleCut(mSecondParticleCut);
107 cout <<
" StParityAnalysis::StParityAnalysis(const StParityAnalysis& a) - second particle cut set " << endl;
109 SetPairCut(mPairCut);
110 cout <<
" StParityAnalysis::StParityAnalysis(const StParityAnalysis& a) - pair cut set " << endl;
113 StHbtCorrFctnIterator iter;
114 for (iter=a.mCorrFctnCollection->begin(); iter!=a.mCorrFctnCollection->end();iter++){
115 cout <<
" StParityAnalysis::StParityAnalysis(const StParityAnalysis& a) - looking for correlation functions " << endl;
117 if (fctn) AddCorrFctn(fctn);
118 else cout <<
" StParityAnalysis::StParityAnalysis(const StParityAnalysis& a) - correlation function not found " << endl;
121 mNumEventsToMix = a.mNumEventsToMix;
123 cout <<
" StParityAnalysis::StParityAnalysis(const StParityAnalysis& a) - analysis copied " << endl;
127 StParityAnalysis::~StParityAnalysis(){
130 delete mFirstParticleCut ;
131 delete mSecondParticleCut ;
134 StHbtCorrFctnIterator iter;
135 for (iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
138 delete mCorrFctnCollection;
142 if ( n<0 || n > (
int)mCorrFctnCollection->size() )
144 StHbtCorrFctnIterator iter=mCorrFctnCollection->begin();
145 for (
int i=0; i<n ;i++){
151 StHbtString StParityAnalysis::Report()
153 cout <<
"StParityAnalysis - constructing Report..."<<endl;
154 string temp =
"-----------\nHbt Analysis Report:\n";
155 temp +=
"\nEvent Cuts:\n";
156 temp += mEventCut->Report();
157 temp +=
"\nParticle Cuts - First Particle:\n";
158 temp += mFirstParticleCut->Report();
159 temp +=
"\nParticle Cuts - Second Particle:\n";
160 temp += mSecondParticleCut->Report();
161 temp +=
"\nPair Cuts:\n";
162 temp += mPairCut->Report();
163 temp +=
"\nCorrelation Functions:\n";
164 StHbtCorrFctnIterator iter;
165 if ( mCorrFctnCollection->size()==0 ) {
166 cout <<
"StParityAnalysis-Warning : no correlations functions in this analysis " << endl;
168 for (iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
169 temp += (*iter)->Report();
172 temp +=
"-------------\n";
173 StHbtString returnThis=temp;
183 ParityBuff MinusSame;
184 ParityBuff PlusMixed;
185 ParityBuff MinusMixed;
187 static ParityBuff PlusBuffer[BUFFERSIZ];
188 static ParityBuff MinusBuffer[BUFFERSIZ];
189 static long nEvent = 0;
192 EventBegin(hbtEvent);
194 bool tmpPassEvent = mEventCut->Pass(hbtEvent);
195 mEventCut->FillCutMonitor(hbtEvent, tmpPassEvent);
197 cout <<
"StParityAnalysis::ProcessEvent() - Event has passed cut - build picoEvent from " <<
198 hbtEvent->TrackCollection()->size() <<
" tracks in TrackCollection" << endl;
201 FillHbtParticleCollection2(mFirstParticleCut,(
StHbtEvent*)hbtEvent,picoEvent->FirstParticleCollection());
202 FillHbtParticleCollection2(mSecondParticleCut,(
StHbtEvent*)hbtEvent,picoEvent->SecondParticleCollection());
203 cout <<
"StParityAnalysis::ProcessEvent - #particles in First, Second Collections: " <<
204 picoEvent->FirstParticleCollection()->size() <<
" " <<
205 picoEvent->SecondParticleCollection()->size() << endl;
210 StHbtParticleIterator PartIter1;
211 StHbtParticleIterator PartIter2;
212 StHbtParticleIterator StartOuterLoop = picoEvent->FirstParticleCollection()->begin();
213 StHbtParticleIterator EndOuterLoop = picoEvent->FirstParticleCollection()->end();
214 StHbtParticleIterator StartInnerLoop;
215 StHbtParticleIterator EndInnerLoop;
216 StartInnerLoop = picoEvent->SecondParticleCollection()->begin();
217 EndInnerLoop = picoEvent->SecondParticleCollection()->end() ;
221 int evtMod = (nEvent%BUFFERSIZ);
223 int bufferIndex = evtMod;
224 if (nEvent >= BUFFERSIZ ) {
225 bufferIndex = (BUFFERSIZ - 1);
230 PlusBuffer[bufferIndex].clear();
232 for (PartIter1=StartOuterLoop;PartIter1!=EndOuterLoop;PartIter1++){
233 pParticle = *PartIter1;
234 PlusBuffer[bufferIndex].push_back(pParticle->FourMomentum() ) ;
236 int newPlusSize = PlusBuffer[bufferIndex].size();
237 if (newPlusSize == 0){cout <<
" 0 tracks copied to buffer for particle 1!!!"<< endl ;}
239 MinusBuffer[bufferIndex].clear();
241 for (PartIter2 = StartInnerLoop; PartIter2!=EndInnerLoop;PartIter2++){
242 pParticle = *PartIter2;
243 MinusBuffer[bufferIndex].push_back(pParticle->FourMomentum() ) ;
245 int newMinusSize = MinusBuffer[bufferIndex].size();
246 if (newMinusSize == 0){cout <<
" 0 tracks copied to buffer for particle 2!!!"<< endl ;}
253 {
for (
int iii = 0;iii<newPlusSize;iii++){
254 if (PlusBuffer[bufferIndex][iii].z() > 0 ) RxnPlaneVec += PlusBuffer[bufferIndex][iii].vect();
255 if (PlusBuffer[bufferIndex][iii].z() < 0 ) RxnPlaneVec -= PlusBuffer[bufferIndex][iii].vect();
257 {
for (
int iii = 0;iii<newMinusSize;iii++){
258 if (MinusBuffer[bufferIndex][iii].z() > 0 ) RxnPlaneVec += MinusBuffer[bufferIndex][iii].vect();
259 if (MinusBuffer[bufferIndex][iii].z() < 0 ) RxnPlaneVec -= MinusBuffer[bufferIndex][iii].vect();
262 double phi_rxn_plane = acos(RxnPlaneVec.x()/RxnPlaneVec.mag());
263 if (RxnPlaneVec.y() < 0) phi_rxn_plane = -phi_rxn_plane;
269 {
for (
int iii = 0;iii<newPlusSize;iii++){
271 tempVct = PlusBuffer[bufferIndex][iii].vect();
272 tempVct.rotateZ(-phi_rxn_plane);
273 (PlusBuffer[bufferIndex][iii]).setX(tempVct.x());
274 (PlusBuffer[bufferIndex][iii]).setY(tempVct.y());
277 {
for (
int iii = 0;iii<newMinusSize;iii++){
279 tempVct = MinusBuffer[bufferIndex][iii].vect();
280 tempVct.rotateZ(-phi_rxn_plane);
281 (MinusBuffer[bufferIndex][iii]).setX(tempVct.x());
282 (MinusBuffer[bufferIndex][iii]).setY(tempVct.y());
289 {
for (
int iii = 0;iii<2;iii++){
290 for (
int iii = 0;iii<newPlusSize;iii++){
291 int switchto = (rand() % newPlusSize);
293 PlusBuffer[bufferIndex][iii] = PlusBuffer[bufferIndex][switchto];
294 PlusBuffer[bufferIndex][switchto] = tempVec;
298 {
for (
int iii = 0;iii<2;iii++){
299 for (
int iii = 0;iii<newMinusSize;iii++){
300 int switchto = (rand() % newMinusSize);
302 MinusBuffer[bufferIndex][iii] = MinusBuffer[bufferIndex][switchto];
303 MinusBuffer[bufferIndex][switchto] = tempVec;
311 {
for (
int jjj = 0; jjj < newPlusSize; jjj++){
312 PlusSame.push_back(PlusBuffer[bufferIndex][jjj]);
314 {
for (
int jjj = 0; jjj < newMinusSize; jjj++){
315 MinusSame.push_back(MinusBuffer[bufferIndex][jjj]);
321 if (nEvent >= BUFFERSIZ ) {
326 if (nEvent >= BUFFERSIZ ) {
332 {
for (
int jjj = 0; jjj < newPlusSize; jjj++){
333 mixedenum = (rand() % BUFFERSIZ);
334 mixedtnum = (rand() % PlusBuffer[mixedenum].size());
335 vTemp = PlusBuffer[mixedenum][mixedtnum];
336 PlusBuffer[mixedenum][mixedtnum] = PlusBuffer[bufferIndex][jjj];
337 PlusBuffer[bufferIndex][jjj] = vTemp;
339 {
for (
int jjj = 0; jjj < newMinusSize; jjj++){
340 mixedenum = (rand() % BUFFERSIZ);
341 mixedtnum = (rand() % MinusBuffer[mixedenum].size());
342 vTemp = MinusBuffer[mixedenum][mixedtnum];
343 MinusBuffer[mixedenum][mixedtnum] = MinusBuffer[bufferIndex][jjj];
344 MinusBuffer[bufferIndex][jjj] = vTemp;
348 {
for (
int jjj = 0; jjj < newPlusSize; jjj++){
349 PlusMixed.push_back(PlusBuffer[bufferIndex][jjj]);
351 {
for (
int jjj = 0; jjj < newMinusSize; jjj++){
352 MinusMixed.push_back(MinusBuffer[bufferIndex][jjj]);
359 mPairCut->ParityPairCuts(&PlusSame, &MinusSame);
360 if (nEvent >= BUFFERSIZ ) {
361 mPairCut->ParityPairCuts(&PlusMixed, &MinusMixed);
367 if (nEvent >= BUFFERSIZ ) {
369 while (PlusMixed.size() > PlusSame.size()){
370 eraseMe = (rand() % PlusMixed.size());
371 PlusMixed.erase(PlusMixed.begin()+eraseMe);
373 while (MinusMixed.size() > MinusSame.size() ){
374 eraseMe = (rand() % MinusMixed.size());
375 MinusMixed.erase(MinusMixed.begin()+eraseMe);
377 while (PlusSame.size() > PlusMixed.size()){
378 eraseMe = (rand() % PlusSame.size());
379 PlusSame.erase(PlusSame.begin()+eraseMe);
381 while (MinusSame.size() > MinusMixed.size() ){
382 eraseMe = (rand() % MinusSame.size());
383 MinusSame.erase(MinusSame.begin()+eraseMe);
386 cout <<
" sizes:plussame minussame plusmixed minusmixed" << PlusSame.size()<<
","
387 <<MinusSame.size()<<
","
388 <<PlusMixed.size()<<
","
389 <<MinusMixed.size()<< endl ;
394 StHbtCorrFctnIterator CorrFctnIter;
395 for (CorrFctnIter=mCorrFctnCollection->begin();CorrFctnIter!=mCorrFctnCollection->end();CorrFctnIter++){
397 CorrFctn->ParityCompute(&PlusSame, &MinusSame, SAME );
398 if (nEvent >= BUFFERSIZ ) {
399 CorrFctn->ParityCompute(&PlusMixed, &MinusMixed, MIXED );
411 cout <<
"StParityAnalysis::ProcessEvent() - return to caller ... " << endl;
414 void StParityAnalysis::EventBegin(
const StHbtEvent* ev){
415 mFirstParticleCut->EventBegin(ev);
416 mSecondParticleCut->EventBegin(ev);
418 for (StHbtCorrFctnIterator iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
419 (*iter)->EventBegin(ev);
423 void StParityAnalysis::EventEnd(
const StHbtEvent* ev){
424 mFirstParticleCut->EventEnd(ev);
425 mSecondParticleCut->EventEnd(ev);
427 for (StHbtCorrFctnIterator iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
428 (*iter)->EventEnd(ev);
432 void StParityAnalysis::Finish(){
433 StHbtCorrFctnIterator iter;
434 for (iter=mCorrFctnCollection->begin(); iter!=mCorrFctnCollection->end();iter++){
439 void StParityAnalysis::AddEventProcessed() {
virtual void ProcessEvent(const StHbtEvent *)
returns reports of all cuts applied and correlation functions being done