StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
countTrackTowerMatches.cc
1 //
2 // $Id: countTrackTowerMatches.cc,v 1.3 2004/07/30 18:46:27 calderon Exp $
3 //
4 // Author: Manuel Calderon de la Barca Sanchez
5 //
6 // Counts the number of tracks that point to a tower
7 // in an event.
8 //
9 // For use in the creation of the Heavy Flavor Tags
10 // Track cuts are:
11 // flag>0
12 // tpc fit points >=15
13 // |eta|<1.5
14 // momentum > 2 GeV
15 // Note: the momentum cut here is slightly larger than
16 // the one used for the invariant mass tag, because this is for
17 // a single track. The invariant mass tag should be helpful
18 // for J/Psi in pp and dAu, so one needs to go lower than half of
19 // the J/Psi mass in momentum for that tag.
20 //
21 // Requirements on the tower are:
22 // adc-30>360
23 // The mean pedestal is 30 adc counts (ref. Alex Suaide)
24 // The value of 360 is slightly lower than the ~416 from the High-Tower-13
25 // conversion.
26 // I arrived at 360 via looking at 10 events in the AuAu62 run.
27 // I summed the adc values (after subtracting 30 from all of them)
28 // and I summed the energy of each tower (only taking those that give me a positive energy)
29 // then divided the two numbers, arriving at
30 // 0.0083 GeV/adc, which gives 360 adc's for a 3 GeV tower.
31 //
32 // $Log $
33 //
34 
35 #include "StEvent.h"
36 #include "StPrimaryVertex.h"
37 #include "StContainers.h"
38 #include "StPrimaryTrack.h"
39 #include "StTrackGeometry.h"
40 #include "StTrackFitTraits.h"
41 #include "StEventSummary.h"
42 #include "StEmcCollection.h"
43 #include "StEmcDetector.h"
44 #include "StEmcModule.h"
45 #include "StEmcRawHit.h"
46 
47 
48 #include "StThreeVectorD.hh"
49 
50 #include "StEmcUtil/geometry/StEmcGeom.h"
51 #include "StEmcUtil/projection/StEmcPosition.h"
52 
53 int countTrackTowerMatches(StEvent* event) {
54 
55  // first, protect against funny business..
56  if (!event) return -9999;
57  if (!(event->primaryVertex())) return -9999;
58  if (!(event->emcCollection())) return -9999;
59  if (!(event->emcCollection()->detector(kBarrelEmcTowerId))) return -9999;
60 
61  // Set up the parameters we'll need
62  // Use the bemc radius ("bemc", or det=1 in call to getEmcGeom
63  // look in StRoot/StEmcUtil/geometry/StEmcGeom.cxx for implementation.
64  // Initialize counters
65  StEmcGeom* bemcGeom = StEmcGeom::getEmcGeom("bemc");
66  const double Radius = bemcGeom->Radius();
67  int trackTowerPairs = 0;
68 
69  // Get primary track container and BEMC detector pointer from StEvent
70  const StSPtrVecPrimaryTrack& trackArray = event->primaryVertex()->daughters();
71  StEmcDetector* stBEMCDetector= event->emcCollection()->detector(kBarrelEmcTowerId);
72 
73  // Loop over primary tracks
74  // find towers matching this track inside the loop
75  //
76 // cout << "countTrackTowerMatches: trackArray.size() " << trackArray.size() << endl;
77  for (unsigned int ipr1=0; ipr1<trackArray.size(); ++ipr1) {
78  StPrimaryTrack* const ptrack1 = trackArray[ipr1];
79 
80  // check track 1 for cuts:
81  if (!ptrack1) continue; // valid pointer
82  if (ptrack1->flag()<=0) continue; // valid flag
83  if (ptrack1->fitTraits().numberOfFitPoints(kTpcId)<15) continue; // enough fit points
84  StThreeVectorF mom1 = ptrack1->geometry()->momentum();
85  if (mom1.mag()<2.) continue; //use tracks with p>2 (NOT THE SAME AS FOR INV MASS TAG)
86  if (fabs(mom1.pseudoRapidity())>1.5) continue; // use tracks with |eta|<1.5
87 
88  // at this point, track passed cuts,
89  // try the track extrapolation
90 
91  StThreeVectorD trackMomentum, trackPosition;
92  StEmcPosition emcPos;
93  bool tok = emcPos.trackOnEmc(&trackPosition, &trackMomentum, ptrack1,
94  event->summary()->magneticField(), Radius);
95  // if it doesn't extrapolate to the BEMC, go on to the next track.
96  if (!tok) continue;
97 
98 // cout << "countTrackTowerMatches: Track phi,eta at BEMC " << trackPosition.phi() << ", " << trackPosition.pseudoRapidity() << endl;
99 
100  // At this point, it extrapolates, so now look to see if the
101  // adc value is 416 which corresponds to roughly 3 GeV.
102  // Note 1: if the calibration above doesn't hold, then this tag is suspect
103  // Note 2: one must also take into account pedestal subtraction (roughly 30 ADC)
104 
105  int moduleH, etaH, subH, id;
106  bemcGeom->getBin(trackPosition.phi(), trackPosition.pseudoRapidity(), moduleH, etaH, subH);
107  bemcGeom->getId(moduleH, etaH, subH, id);
108 
109 // cout << "countTrackTowerMatches: Module, Eta, Sub " << moduleH << ", " << etaH << ", " << subH << endl;
110  // can I find the tower by Id? That would be faster
111  // Looks like I have to loop over all the towers in the module...
112  StEmcModule* module = stBEMCDetector->module(moduleH);
113  const StSPtrVecEmcRawHit& modHits = module->hits();
114  for (size_t i=0; i<modHits.size();++i) {
115  StEmcRawHit* hit = modHits[i];
116  // The StEmcGeom::getBin code returns the eta number as an int, but
117  // StEmcRawHit::eta() returns an unsigned int, so one must
118  // do some kludgy type-casting...
119  // The StEmcGeom::getBin code actually does not return negative eta indices, so
120  // this should be safe... look in StEmcUtil/geometry/StEmcGeom.h
121 // cout << "countTrackTowerMatches: Hit " << i << " eta()= " << hit->eta() << ", sub()= " << hit->sub() << ", adc()= " << hit->adc() << ", energy()= " << hit->energy() << endl;
122  if (hit->eta()==static_cast<unsigned int>(etaH) && hit->sub()==subH) {
123  // This is the hit that the track extrapolates to.
124  // Check it's adc value, if it's greater
125  // than 416 AFTER pedestal subtraction,
126  // we have a match
127 
128  // we will convert the adc into an int because we will subtract
129  // the pedestal, if we keep it as an unsigned int
130  // we might get huge numbers after the subtraction.
131  int adc = static_cast<int>(hit->adc());
132 // cout << "countTrackTowerMatches: Found the tower, it has adc-30 = " << adc-30 << endl;
133  if (adc-30>360) ++trackTowerPairs;
134  } // found the hit that track extrapolates to
135  }// hits in module loop
136 
137 
138  }// track loop
139  return trackTowerPairs;
140 }
Bool_t trackOnEmc(StThreeVectorD *position, StThreeVectorD *momentum, const StTrack *const track, Double_t magField, Double_t emcRadius=225.405) const
Track projection utility.
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const
Definition: StEmcGeom.h:321