1 #define DIFF_CUT_OFF 1.
3 #include "StHbtMaker/Reader/StHbtAssociationReader.h"
4 #include "StHbtMaker/Infrastructure/StHbtTrackCollection.hh"
5 #include "StHbtMaker/Infrastructure/StHbtV0Collection.hh"
6 #include "StEventUtilities/StuRefMult.hh"
8 #include "StHbtMaker/Infrastructure/StHbtEvent.hh"
9 #include "StHbtMaker/Base/StHbtEventCut.h"
10 #include "StHbtMaker/Base/StHbtTrackCut.h"
11 #include "StHbtMaker/Base/StHbtV0Cut.h"
12 #include "StHbtMaker/Base/StHbtKinkCut.h"
15 #include "TOrdCollection.h"
17 #include "StEventTypes.h"
18 #include "StParticleTypes.hh"
19 #include "SystemOfUnits.h"
20 #include "StTpcDedxPidAlgorithm.h"
35 #include "StAssociationMaker/StAssociationMaker.h"
37 #include "StStrangeMuDstMaker/StStrangeEvMuDst.hh"
38 #include "StStrangeMuDstMaker/StV0MuDst.hh"
40 #include "StMcEventTypes.hh"
41 #include "StMcEvent.hh"
42 #include "PhysicalConstants.h"
43 #include "SystemOfUnits.h"
44 #include "StThreeVector.hh"
45 #include "StThreeVectorF.hh"
46 #include "StThreeVectorD.hh"
49 #include "St_DataSet.h"
50 #include "St_DataSetIter.h"
52 #include "g2t_event.h"
53 #include "g2t_ftp_hit.h"
54 #include "g2t_svt_hit.h"
55 #include "g2t_tpc_hit.h"
56 #include "g2t_track.h"
57 #include "g2t_vertex.h"
59 #include "tables/St_g2t_event_Table.h"
60 #include "tables/St_g2t_ftp_hit_Table.h"
61 #include "tables/St_g2t_svt_hit_Table.h"
62 #include "tables/St_g2t_tpc_hit_Table.h"
63 #include "tables/St_g2t_track_Table.h"
64 #include "tables/St_g2t_vertex_Table.h"
73 #include "StAssociationMaker/StTrackPairInfo.hh"
74 #include "StParticleDefinition.hh"
75 #include "StPhysicalHelix.hh"
78 #ifndef ST_NO_NAMESPACES
79 using namespace units;
87 StHbtAssociationReader::StHbtAssociationReader() : mPerfectPID(true) {
88 mDiffCurrent =
new StHbt1DHisto(
"Diff_current",
" (p_real - p_mc ) / p_real ",100,-1.,1.);
89 mDiff =
new StHbt1DHisto(
"Diff",
" (p_real - p_mc ) / p_real ",100,-1.,1.);
90 mDiffMean =
new StHbt1DHisto(
"Diff_mean",
" mean of (p_real - p_mc ) / p_real ",100,-1.,1.);
91 mDiffRMS =
new StHbt1DHisto(
"Diff_sigma",
" sigma of (p_real - p_mc ) / p_real ",100,0.,1.);
99 StHbtAssociationReader::~StHbtAssociationReader(){
100 cout <<
" StHbtAssociationReader::~StHbtAssociationReader() " << endl;
101 if (mEventCut)
delete mEventCut;
102 if (mTrackCut)
delete mTrackCut;
105 StHbtString StHbtAssociationReader::Report(){
106 StHbtString temp =
"\n This is the StHbtAssociationReader\n";
107 temp +=
"---> EventCuts in Reader: ";
109 temp += mEventCut->Report();
114 temp +=
"\n---> TrackCuts in Reader: ";
116 temp += mTrackCut->Report();
125 StHbtEvent* StHbtAssociationReader::ReturnHbtEvent(){
126 cout <<
" **************************************************************************************" << endl;
127 cout <<
" StHbtAssociationReader::ReturnHbtEvent() : Seconds elapsed since last call : " << difftime( time(0), timeStamp ) << endl;
128 cout <<
" **************************************************************************************" << endl;
139 StEvent* rEvent = (
StEvent*) StMaker::GetChain()->GetDataSet(
"StEvent");
142 cout <<
"StHbtAssociationReader - No StEvent!!! " << endl;
145 cout <<
" StEvent " << endl;
157 mEvent = (
StMcEvent*) StMaker::GetChain()->GetDataSet(
"StMcEvent");
161 cout <<
"StHbtAssociationReader - No StMcEvent!!! " << endl;
164 cout <<
" McEvent " << endl;
172 cout <<
"StHbtAssociationReader - No StAssociationMaker!!! " << endl;
173 cout <<
"StHbtAssociationReader - assoc " << assoc <<endl;
176 rcTpcHitMapType* theHitMap = 0;
179 cout <<
"StHbtAssociationReader - No tpcHitMap!!! " << endl;
180 cout <<
"StHbtAssociationReader - theHitMap " << theHitMap <<endl;
183 rcTrackMapType* theTrackMap = 0;
184 theTrackMap = assoc->rcTrackMap();
186 cout <<
"StHbtAssociationReader - No trackMap!!! " << endl;
187 cout <<
"StHbtAssociationReader - theTrackMap " << theTrackMap <<endl;
190 rcV0MapType* theV0Map = 0;
191 theV0Map = assoc->rcV0Map();
193 cout <<
"StHbtAssociationReader - No v0Map!!! " << endl;
194 cout <<
"StHbtAssociationReader - theV0Map " << theV0Map <<endl;
198 if ( !(rEvent->primaryVertex()) ||
199 (mEvent->primaryVertex()->position().x() == mEvent->primaryVertex()->position().y() &&
200 mEvent->primaryVertex()->position().y() == mEvent->primaryVertex()->position().z() ) ||
201 ::isnan(rEvent->primaryVertex()->position().x())
203 cout <<
"StHbtAssociationReader - bad vertex !!! " << endl;
216 cout <<
" **********************" << endl;
217 cout <<
" StHbtAssociationReader" << endl;
218 cout <<
" **********************" << endl;
219 unsigned long mRunNumber = mEvent->runNumber();
220 unsigned long rRunNumber = rEvent->runId();
221 cout <<
" DST run: #" << rRunNumber << endl;
222 cout <<
" MC run: #" << mRunNumber << endl;
223 unsigned long rEventNumber = 0;
224 unsigned long mEventNumber = mEvent->eventNumber();
225 cout <<
" DST event: #" << rEventNumber << endl;
226 cout <<
" MC event: #" << mEventNumber << endl;
227 int rMult = rEvent->trackNodes().size();
228 int mMult = mEvent->tracks().size();
229 cout <<
" DST mult: #" << rMult << endl;
230 cout <<
" MC mult: #" << mMult << endl;
231 if ( !rEvent->primaryVertex() )
return 0;
232 if ( !mEvent->primaryVertex() )
return 0;
235 cout <<
" DST primary Vertex #" << rVertexPosition << endl;
236 cout <<
" MC primary Vertex #" << mVertexPosition << endl;
238 cout <<
"StHbtAssociationReader::ReturnHbtEvent - We have " << rMult <<
" tracks to store - we skip tracks with nhits==0" << endl;
244 mDiffCurrent->Reset();
250 hbtEvent->SetEventNumber(rEventNumber);
251 hbtEvent->SetUncorrectedNumberOfPositivePrimaries(uncorrectedNumberOfPositivePrimaries(*rEvent));
252 hbtEvent->SetUncorrectedNumberOfNegativePrimaries(uncorrectedNumberOfNegativePrimaries(*rEvent));
253 hbtEvent->SetCtbMult(0);
254 hbtEvent->SetZdcAdcEast(0);
255 hbtEvent->SetZdcAdcWest(0);
256 hbtEvent->SetNumberOfTpcHits(0);
257 hbtEvent->SetNumberOfTracks(rMult);
258 hbtEvent->SetReactionPlane(0.);
259 hbtEvent->SetReactionPlaneSubEventDifference(0.);
260 hbtEvent->SetPrimVertPos(rVertexPosition);
273 if (!PidAlgorithm) cout <<
" StStandardHbtEventReader::ReturnHbtEvent() - Whoa!! No PidAlgorithm!! " << endl;
276 StElectron* Electron = StElectron::instance();
279 StProton* Proton = StProton::instance();
281 {
for (rcTrackMapIter tIter=theTrackMap->begin(); tIter!=theTrackMap->end(); ++tIter){
289 int nhits = rTrack->detectorInfo()->numberOfPoints(kTpcId);
299 int numberOfassociatedTracks = theTrackMap->count(rTrack);
300 if (numberOfassociatedTracks !=1) {
317 const StMcTrack* mTrack = (*tIter).second->partnerMcTrack();
321 int motherPdgCode = 0;
322 int daughterPdgCode =0;
323 int motherTrackId =0;
324 if (CheckPdgIdLists()) {
326 if (!mTrack->particleDefinition()) {
327 cout <<
" track has no particle definiton " << endl;
330 pdgCode = mTrack->particleDefinition()->pdgEncoding();
333 if (mTrack->parent()) {
334 motherPdgCode = mTrack->parent()->pdgId();
335 motherTrackId = mTrack->parent()->key();
337 if (motherPdgCode) cout <<
" motherPdgCode :" << motherPdgCode << endl;
338 else cout <<
" mother has no pdgId "<< endl;
339 if ( mTrack->stopVertex() == 0 ) {
340 check += CheckPdgIdList(pdgCode,motherPdgCode,0);
343 for (
unsigned int iDaughter=0; iDaughter < mTrack->stopVertex()->daughters().size()-1; iDaughter++) {
344 daughterPdgCode = mTrack->stopVertex()->daughters()[iDaughter]->pdgId();
345 check += CheckPdgIdList(pdgCode,motherPdgCode,daughterPdgCode);
354 int geantId = mTrack->geantId();
363 pathlength = rTrack->geometry()->helix().
pathLength( rVertexPosition );
365 p = rTrack->geometry()->momentum();
366 mp = mTrack->momentum();
369 diff = (p.mag()-mp.mag()) / p.mag();
371 if ( fabs(diff) > DIFF_CUT_OFF ) {
376 mDiff->Fill(diff,1.);
377 mDiffCurrent->Fill(diff,1.);
385 hbtTrack->SetTrackId((
int)(rTrack->key()+motherTrackId*::pow(2,16)));
387 hbtTrack->SetNHits(nhits);
393 hbtTrack->SetNSigmaElectron(0.);
394 hbtTrack->SetNSigmaPion(-999);
395 hbtTrack->SetNSigmaKaon(-999.);
396 hbtTrack->SetNSigmaProton(-999.);
400 hbtTrack->SetNSigmaElectron(999.);
401 hbtTrack->SetNSigmaPion(0.);
402 hbtTrack->SetNSigmaKaon(-999.);
403 hbtTrack->SetNSigmaProton(-999.);
407 hbtTrack->SetNSigmaElectron(999.);
408 hbtTrack->SetNSigmaPion(999.0);
409 hbtTrack->SetNSigmaKaon(0.);
410 hbtTrack->SetNSigmaProton(-999.);
414 hbtTrack->SetNSigmaElectron(999.);
415 hbtTrack->SetNSigmaPion(999.);
416 hbtTrack->SetNSigmaKaon(999.);
417 hbtTrack->SetNSigmaProton(0.);
420 hbtTrack->SetNSigmaElectron(999.);
421 hbtTrack->SetNSigmaPion(999.);
422 hbtTrack->SetNSigmaKaon(999.);
423 hbtTrack->SetNSigmaProton(999.);
428 hbtTrack->SetNSigmaElectron(PidAlgorithm->numberOfSigma(Electron));
429 hbtTrack->SetNSigmaPion(PidAlgorithm->numberOfSigma(Pion));
430 hbtTrack->SetNSigmaKaon(PidAlgorithm->numberOfSigma(Kaon));
431 hbtTrack->SetNSigmaProton(PidAlgorithm->numberOfSigma(Proton));
436 hbtTrack->SetdEdx(PidAlgorithm->traits()->mean());
438 double pathlength = rTrack->geometry()->helix().
pathLength(rVertexPosition);
444 StHbtThreeVector DCAxyz = rTrack->geometry()->helix().at(pathlength)-rVertexPosition;
446 hbtTrack->SetDCAxy( DCAxyz.perp() );
447 hbtTrack->SetDCAz( DCAxyz.z() );
449 hbtTrack->SetChiSquaredXY( rTrack->fitTraits().chi2(0) );
450 hbtTrack->SetChiSquaredZ( rTrack->fitTraits().chi2(1) );
453 hbtTrack->SetHelix( helix );
455 float pt = ::sqrt(p[0]*p[0]+p[1]*p[1]);
461 int charge = ( rTrack->geometry()->charge() );
463 hbtTrack->SetCharge(charge);
465 hbtTrack->SetTopologyMap( 0, rTrack->topologyMap().data(0) );
466 hbtTrack->SetTopologyMap( 1, rTrack->topologyMap().data(1) );
472 if (!(mTrackCut->Pass(hbtTrack))){
478 hbtEvent->TrackCollection()->push_back(hbtTrack);
482 hbtEvent->SetNumberOfGoodTracks(hbtEvent->TrackCollection()->size());
484 cout <<
" StHbtAssociationReader::ReturnEvent() : mean of momenta diff (accepted tracks)= " << mDiffCurrent->GetMean() << endl;
485 cout <<
" StHbtAssociationReader::ReturnEvent() : rms of momenta diff (accepted tracks)= " << mDiffCurrent->GetRMS() << endl;
486 mDiffMean->Fill(mDiffCurrent->GetMean(),1.);
487 mDiffRMS->Fill(mDiffCurrent->GetRMS(),1.);
488 cout <<
" StHbtAssociationReader::ReturnEvent() : DiffCurrent (p_real - p_mc ) / p_real " << mDiffCurrent << endl;
489 cout <<
" StHbtAssociationReader::ReturnEvent() : Diff (p_real - p_mc ) / p_real " << mDiff << endl;
490 cout <<
" StHbtAssociationReader::ReturnEvent() : DiffMean mean of (p_real - p_mc ) / p_real " << mDiffMean << endl;
491 cout <<
" StHbtAssociationReader::ReturnEvent() : DiffSigma sigma of (p_real - p_mc ) / p_real " << mDiffRMS << endl;
497 {
for (rcV0MapIter tIter=theV0Map->begin(); tIter!=theV0Map->end(); ++tIter){
499 StV0MuDst v0MuDst(rV0Vertex,&strangeEvMuDst);
500 cout <<
" StHbtAssociationEventReader::ReturnHbtEvent() " << theV0Map->count(rV0Vertex) <<
" associated V0s " << endl;
502 pair<rcV0MapIter, rcV0MapIter> boundsV0 = theV0Map->equal_range(rV0Vertex);
503 for (rcV0MapIter v0Iter = boundsV0.first; v0Iter!= boundsV0.second; v0Iter++){
507 if (!(mV0Cut->Pass(hbtV0))) {
512 hbtEvent->V0Collection()->push_back(hbtV0);
515 cout <<
" StHbtAssociationReader::ReturnHbtEvent() - " << hbtEvent->V0Collection()->size();
516 cout <<
" V0s pushed in collection " << endl;
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
rcTpcHitMapType * rcTpcHitMap()
Diff btw global r and phi coords of FTPC hits.
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...