13 #include "StEStructMuDstReader.h"
15 #include "StEStructEventCuts.h"
16 #include "StEStructTrackCuts.h"
17 #include "StEStructPool/EventMaker/StEStructEvent.h"
18 #include "StEStructPool/EventMaker/StEStructTrack.h"
19 #include "StEStructPool/EventMaker/StEStructCentrality.h"
20 #include "StBTofPidTraits.h"
21 #include "StMuDSTMaker/COMMON/StMuBTofPidTraits.h"
24 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
25 #include "StMuDSTMaker/COMMON/StMuDst.h"
26 #include "StMuDSTMaker/COMMON/StMuEvent.h"
27 #include "StMuDSTMaker/COMMON/StMuTrack.h"
28 #include "StDetectorId.h"
31 StEStructMuDstReader::StEStructMuDstReader() {
35 mhasVertexRadiusCuts = 0;
41 mUseGlobalTracks=
false;
44 StEStructMuDstReader::StEStructMuDstReader(
StMuDstMaker* maker,
50 mhasVertexRadiusCuts = 0;
56 mUseGlobalTracks=
false;
61 StEStructMuDstReader::~StEStructMuDstReader() {
65 void StEStructMuDstReader::setMuDstMaker(
StMuDstMaker* maker,
bool inChain){
72 if (!mECuts->doFillHists()) {
80 if ( mECuts->hasToFFractionCut() ) {
82 ToFBefore =
new TH2F(
"dEdxToFNoCut2D",
"dEdxToFNoCut2D",50,1,1000,50,1,750);
83 ToFAfter =
new TH2F(
"dEdxToFCut2D",
"dEdxToFCut2D",50,1,1000,50,1,750);
84 mECuts->addCutHists(ToFBefore, ToFAfter,
"ToFPlots2D");
86 if ( mECuts->hasPrimaryFractionCut() ) {
88 PrimaryBefore =
new TH2F(
"PrimVGlobNoCut2D",
"PrimVGlobNoCut2D",120,1,1200,200,1,2000);
89 PrimaryAfter =
new TH2F(
"PrimVGlobCut2D",
"PrimVGlobCut2D",120,1,1200,200,1,2000);
90 mECuts->addCutHists(PrimaryBefore, PrimaryAfter,
"PrimaryPlots2D");
92 if ( mECuts->hasPrimaryVertexRadiusCut() ) {
93 mhasVertexRadiusCuts = 1;
94 VRadiusBefore =
new TH2F(
"VertexRadiusNoCut2D",
"VertexRadiusNoCut2D",50,-10,10,50,-10,10);
95 VRadiusAfter =
new TH2F(
"VertexRadiusCut2D",
"VertexRadiusCut2D",50,-10,10,50,-10,10);
96 mECuts->addCutHists(VRadiusBefore, VRadiusAfter,
"VertexRadiusPlots2D");
101 if (!mTCuts->doFillHists()) {
104 if ( mTCuts->hasElectronCut() ) {
106 dEdxBefore =
new TH2F(
"dEdxNoCut2D",
"dEdxNoCut2D",150,-1.5,1.5,150,0,0.000015);
107 dEdxAfter =
new TH2F(
"dEdxCut2D",
"dEdxCut2D",150,-1.5,1.5,150,0,0.000015);
108 mTCuts->addCutHists(dEdxBefore, dEdxAfter,
"dEdxPlots2D");
110 dEdxBetaBefore =
new TH3F(
"dEdxBetaNoCut3D",
"dEdxBetaNoCut3D",100,-2.0,2.0,100,0.0000015,0.000006,100,0.55,1.05);
111 dEdxBetaAfter =
new TH3F(
"dEdxBetaCut3D",
"dEdxBetaCut3D",100,-2.0,2.0,100,0.0000015,0.000006,100,0.55,1.05);
112 mTCuts->addCutHists(dEdxBetaBefore, dEdxBetaAfter,
"dEdxBetaPlots3D");
114 void StEStructMuDstReader::setUseGlobalTracks(
bool global) {
115 mUseGlobalTracks=global;
118 inline bool StEStructMuDstReader::setInChain(
bool inChain) {
122 inline bool StEStructMuDstReader::InChain(){
return mInChain; };
123 bool StEStructMuDstReader::hasMaker() {
return (mMaker) ?
true : false ; }
130 if(!mMaker)
return retVal;
132 int iret=mMaker->
Make();
138 if(!mMaker->
muDst())
return retVal;
161 if(!muEvent)
return retVal;
170 bool useEvent =
true;
173 x = muEvent->eventSummary().primaryVertexPosition().x();
174 y = muEvent->eventSummary().primaryVertexPosition().y();
175 z = muEvent->eventSummary().primaryVertexPosition().z();
177 if (muEvent->eventSummary().numberOfVertices()>1) {
187 if ((fabs(x) < 1e-5) && (fabs(y) < 1e-5) && (fabs(z) < 1e-5)) {
189 }
else if ( !mECuts->goodTrigger(muDst) ||
190 !mECuts->goodPrimaryVertexZ(z) ) {
195 if (!mECuts->goodPrimaryVertexRadius(sqrt(x*x+y*y))) {
201 vpdZ = btofHeader->vpdVz();
202 if (!mECuts->goodVPDVertex(z-vpdZ)) {
209 int nTracks = countGoodTracks(&ndEdx, &nToF);
210 if (!mECuts->goodToFFraction(ndEdx, nToF)) {
215 if (!mECuts->goodPrimaryFraction(nPrimary, nGlobal)) {
225 retVal->SetCentrality((
double)nTracks);
226 if(!mECuts->goodCentrality(retVal->Centrality())) useEvent=
false;
228 retVal->SetRefMult( muEvent->
refMult() );
229 retVal->SetctbMult( muEvent->ctbMultiplicity() );
230 retVal->SetNumPrim( muEvent->eventSummary().numberOfGoodPrimaryTracks() );
234 retVal->SetEventID(muEvent->eventNumber());
235 retVal->SetRunID(muEvent->runNumber());
236 retVal->SetVertex(x,y,z);
237 retVal->SetZDCe((
float)muEvent->zdcAdcAttentuatedSumEast());
238 retVal->SetZDCw((
float)muEvent->zdcAdcAttentuatedSumWest());
243 retVal->SetZDCCoincidence((
float)muEvent->runInfo().zdcCoincidenceRate());
244 retVal->SetBField((
float)muEvent->magneticField());
246 if (!fillTracks(retVal)) useEvent=
false;
251 const StTriggerId& l0Nom = muEvent->triggerIdCollection().nominal();
253 for (
unsigned int idx=0;idx<l0Nom.maxTriggerIds();idx++) {
254 if (0 == l0Nom.triggerId(idx)) {
259 for (
int idx=0;idx<nTrig;idx++) {
260 mECuts->fillHistogram(mECuts->triggerWordName(),l0Nom.triggerId(idx),useEvent);
261 for (
int idy=idx+1;idy<nTrig;idy++) {
262 mECuts->fillHistogram(mECuts->triggerWordName(),l0Nom.triggerId(idx),l0Nom.triggerId(idy),useEvent);
265 mECuts->fillHistogram(mECuts->primaryVertexZName(),z,useEvent);
267 mECuts->fillHistogram(mECuts->primaryVPDVertexName(),z-vpdZ,useEvent);
269 mECuts->fillHistogram(mECuts->centralityName(),(float)nTracks,useEvent);
270 mECuts->fillHistogram(mECuts->goodtoffractionName(),(float)ndEdx,(
float)nToF,useEvent);
272 mECuts->fillHistogram(
"ToFPlots",(
double)ndEdx,(
double)nToF,useEvent);
273 mECuts->fillHistogram(
"PrimaryPlots",(
double)nPrimary,(
double)nGlobal,useEvent);
274 mECuts->fillHistogram(
"VertexRadiusPlots",x,y,useEvent);
279 if (useEvent && mECuts->hasZVertMatchCut()) {
281 int nPile = mPileup->find(muDst);
282 if ((nPile > 0) && (6 == mPileup->flag(0))) {
283 double zd1 = z - mPileup->z(0,2);
284 double zd2 = z - mPileup->z(0,3);
285 zDist = (fabs(zd1) < fabs(zd2)) ? zd1 : zd2;
286 if (!mECuts->goodZVertMatch(zDist)) {
289 mECuts->fillHistogram(mECuts->zVertMatchName(),zDist,useEvent);
293 if (useEvent && mECuts->hasZVertSepCut()) {
297 nPile = mPileup->nearest(muDst,z,&zDist,&mPile);
298 if (nPile > 0 && !mECuts->goodZVertSep(zDist)) {
301 mECuts->fillHistogram(mECuts->zVertSepName(),zDist,useEvent);
308 if (retVal) retVal->FillChargeCollections();
315 bool StEStructMuDstReader::fillTracks(
StEStructEvent* estructEvent) {
325 if (mUseGlobalTracks) {
335 for(
int i=0; i<numTracks; i++) {
337 eTrack->SetInComplete();
339 if (mUseGlobalTracks) {
350 float ptot = track->
charge() * track->
p().magnitude();
352 float beta = dProb.beta();
354 useTrack = isTrackGoodToUse( track );
355 mTCuts->fillHistograms(useTrack);
357 mTCuts->fillHistogram(
"dEdxPlots",ptot,track->
dEdx(),useTrack);
359 mTCuts->fillHistogram(
"dEdxBetaPlots",ptot,track->
dEdx(),beta,useTrack);
363 fillEStructTrack(eTrack,track);
364 estructEvent->AddTrack(eTrack);
373 bool StEStructMuDstReader::isTrackGood(
StMuTrack* track) {
379 if (mUseGlobalTracks) {
382 const StThreeVectorF &pvert = muEvent->eventSummary().primaryVertexPosition();
388 mEta = dir.pseudoRapidity();
394 mDCA = track->
dcaGlobal(mPrimaryVertexId).magnitude();
398 useTrack = (mTCuts->goodEta(mEta) && useTrack);
399 useTrack = (mTCuts->goodFlag(track->
flag()) && useTrack);
400 useTrack = (mTCuts->goodCharge(track->
charge()) && useTrack);
401 useTrack = (mTCuts->goodNFitPoints(track->
nHitsFit()) && useTrack);
402 useTrack = (mTCuts->goodNFitNMax((
float)((
float)track->
nHitsFit()/(float)track->
nHitsPoss())) && useTrack);
403 useTrack = (mTCuts->goodGlobalDCA(mDCA) && useTrack);
404 useTrack = (mTCuts->goodChi2(track->
chi2()) && useTrack);
405 useTrack = (mTCuts->goodPhi(mPhi) && useTrack);
406 if(track->
pt() < 0.15) useTrack =
false;
422 if (mhasdEdxCuts && mTCuts->goodElectron( track->
nSigmaElectron() ) && useTrack ) {
423 float p = (track->
p()).mag();
424 if( (p>0.2 && p<0.45) || (p>0.7 && p<0.8) ) {
441 bool StEStructMuDstReader::isTrackGoodToUse(
StMuTrack* track){
443 bool useTrack=isTrackGood(track);
446 float pt = track->
pt();
447 useTrack = (mTCuts->goodPt(pt) && useTrack);
449 float yt=log(sqrt(1+_r*_r)+_r);
450 useTrack = (mTCuts->goodYt(yt) && useTrack);
451 float mt = sqrt(pt*pt + 0.139*0.139);
452 float xt = 1 - exp( -1*(mt-0.139)/0.4 );
453 useTrack = (mTCuts->goodXt(xt) && useTrack);
463 int StEStructMuDstReader::countGoodTracks(
int *ndEdx,
int *nToF) {
469 if (mUseGlobalTracks) {
486 for(
int i=0; i<numTracks; i++) {
487 if (mUseGlobalTracks) {
496 if ((fabs(dProb.sigmaPion()) < 2) ||
497 (fabs(dProb.sigmaKaon()) < 2) ||
498 (fabs(dProb.sigmaProton()) < 2)) {
511 if ((fabs(dProb.sigmaPion()) < 2) ||
512 (fabs(dProb.sigmaKaon()) < 2) ||
513 (fabs(dProb.sigmaProton()) < 2)) {
523 return mNumGoodTracks;
530 eTrack->SetPx(p.x());
531 eTrack->SetPy(p.y());
532 eTrack->SetPz(p.z());
535 eTrack->SetBx(b.x());
536 eTrack->SetBy(b.y());
537 eTrack->SetBz(b.z());
542 if (mUseGlobalTracks) {
548 if (0 == gb.x() && 0 == gb.y() && 0 == gb.z()) {
549 printf(
"Found track with dca = (0,0,0)\n");
551 eTrack->SetBxGlobal(gb.x());
552 eTrack->SetByGlobal(gb.y());
553 eTrack->SetBzGlobal(gb.z());
555 eTrack->SetEta(mEta);
556 eTrack->SetPhi(mPhi);
557 eTrack->SetDedx(mTrack->
dEdx());
558 eTrack->SetChi2(mTrack->
chi2());
559 if (mUseGlobalTracks) {
562 eTrack->SetHelix(mTrack->
helix());
572 eTrack->SetPIDd_dEdx(10000.);
577 eTrack->SetPIDpi_ToF(dProb.sigmaPion());
578 eTrack->SetPIDp_ToF(dProb.sigmaProton());
579 eTrack->SetPIDk_ToF(dProb.sigmaKaon());
580 eTrack->SetPIDd_ToF(999);
581 eTrack->SetBeta(dProb.beta());
583 eTrack->SetNFitPoints(mTrack->
nHitsFit());
584 eTrack->SetNFoundPoints(mTrack->
nHits());
585 eTrack->SetNMaxPoints(mTrack->
nHitsPoss());
589 eTrack->SetTopologyMapTPCNHits(map.numberOfHits(kTpcId));
590 eTrack->SetTopologyMapData(0,map.data(0));
591 eTrack->SetTopologyMapData(1,map.data(1));
593 eTrack->SetDetectorID(1);
594 eTrack->SetFlag(mTrack->
flag());
595 eTrack->SetCharge(mTrack->
charge());
static TObjArray * globalTracks()
returns pointer to the global tracks list
Double_t pt() const
Returns pT at point of dca to primary vertex.
Double_t chi2() const
Returns chi2 of fit.
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
StPhysicalHelixD helix() const
Returns inner helix (first measured point)
UShort_t nHitsFit() const
Return total number of hits used in fit.
short flag() const
Returns flag, (see StEvent manual for type information)
Short_t charge() const
Returns charge.
const StThreeVectorF & p() const
Returns 3-momentum at dca to primary vertex.
Double_t nSigmaPion() const
Returns Craig's distance to the calculated dE/dx band for pions in units of sigma.
Double_t eta() const
Returns pseudo rapidity at point of dca to primary vertex.
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
unsigned short refMult(int vtx_id=-1)
Reference multiplicity of charged particles as defined in StEventUtilities/StuRefMult.hh for vertex vtx_id (-1 is default index from StMuDst)
Double_t nSigmaElectron() const
Returns Craig's distance to the calculated dE/dx band for electrons in units of sigma.
UShort_t nHitsPoss() const
Return number of possible hits on track.
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
UShort_t nHits() const
Bingchu.
StThreeVectorF dca(Int_t vtx_id=-1) const
Returns 3D distance of closest approach to primary vertex.
Double_t dEdx() const
Returns measured dE/dx value.
static StBTofHeader * btofHeader()
returns pointer to the btofHeader - dongx
Double_t phi() const
Returns phi at point of dca to primary vertex.
Double_t nSigmaProton() const
Returns Craig's distance to the calculated dE/dx band for protons in units of sigma.
float sigmaElectron() const
PID functions.
static Int_t currentVertexIndex()
Get the index number of the current primary vertex.
StThreeVectorF dcaGlobal(Int_t vtx_id=-1) const
Returns 3D distance of closest approach to primary vertex of associated global track.
Double_t nSigmaKaon() const
Returns Craig's distance to the calculated dE/dx band for kaons in units of sigma.
StPhysicalHelixD outerHelix() const
Returns outer helix (last measured point)
StTrackTopologyMap topologyMap() const
Returns topology map.