00001 // 00002 // $Id: countTrackTowerMatches.cc,v 1.3 2004/07/30 18:46:27 calderon Exp $ 00003 // 00004 // Author: Manuel Calderon de la Barca Sanchez 00005 // 00006 // Counts the number of tracks that point to a tower 00007 // in an event. 00008 // 00009 // For use in the creation of the Heavy Flavor Tags 00010 // Track cuts are: 00011 // flag>0 00012 // tpc fit points >=15 00013 // |eta|<1.5 00014 // momentum > 2 GeV 00015 // Note: the momentum cut here is slightly larger than 00016 // the one used for the invariant mass tag, because this is for 00017 // a single track. The invariant mass tag should be helpful 00018 // for J/Psi in pp and dAu, so one needs to go lower than half of 00019 // the J/Psi mass in momentum for that tag. 00020 // 00021 // Requirements on the tower are: 00022 // adc-30>360 00023 // The mean pedestal is 30 adc counts (ref. Alex Suaide) 00024 // The value of 360 is slightly lower than the ~416 from the High-Tower-13 00025 // conversion. 00026 // I arrived at 360 via looking at 10 events in the AuAu62 run. 00027 // I summed the adc values (after subtracting 30 from all of them) 00028 // and I summed the energy of each tower (only taking those that give me a positive energy) 00029 // then divided the two numbers, arriving at 00030 // 0.0083 GeV/adc, which gives 360 adc's for a 3 GeV tower. 00031 // 00032 // $Log $ 00033 // 00034 00035 #include "StEvent.h" 00036 #include "StPrimaryVertex.h" 00037 #include "StContainers.h" 00038 #include "StPrimaryTrack.h" 00039 #include "StTrackGeometry.h" 00040 #include "StTrackFitTraits.h" 00041 #include "StEventSummary.h" 00042 #include "StEmcCollection.h" 00043 #include "StEmcDetector.h" 00044 #include "StEmcModule.h" 00045 #include "StEmcRawHit.h" 00046 00047 00048 #include "StThreeVectorD.hh" 00049 00050 #include "StEmcUtil/geometry/StEmcGeom.h" 00051 #include "StEmcUtil/projection/StEmcPosition.h" 00052 00053 int countTrackTowerMatches(StEvent* event) { 00054 00055 // first, protect against funny business.. 00056 if (!event) return -9999; 00057 if (!(event->primaryVertex())) return -9999; 00058 if (!(event->emcCollection())) return -9999; 00059 if (!(event->emcCollection()->detector(kBarrelEmcTowerId))) return -9999; 00060 00061 // Set up the parameters we'll need 00062 // Use the bemc radius ("bemc", or det=1 in call to getEmcGeom 00063 // look in StRoot/StEmcUtil/geometry/StEmcGeom.cxx for implementation. 00064 // Initialize counters 00065 StEmcGeom* bemcGeom = StEmcGeom::getEmcGeom("bemc"); 00066 const double Radius = bemcGeom->Radius(); 00067 int trackTowerPairs = 0; 00068 00069 // Get primary track container and BEMC detector pointer from StEvent 00070 const StSPtrVecPrimaryTrack& trackArray = event->primaryVertex()->daughters(); 00071 StEmcDetector* stBEMCDetector= event->emcCollection()->detector(kBarrelEmcTowerId); 00072 00073 // Loop over primary tracks 00074 // find towers matching this track inside the loop 00075 // 00076 // cout << "countTrackTowerMatches: trackArray.size() " << trackArray.size() << endl; 00077 for (unsigned int ipr1=0; ipr1<trackArray.size(); ++ipr1) { 00078 StPrimaryTrack* const ptrack1 = trackArray[ipr1]; 00079 00080 // check track 1 for cuts: 00081 if (!ptrack1) continue; // valid pointer 00082 if (ptrack1->flag()<=0) continue; // valid flag 00083 if (ptrack1->fitTraits().numberOfFitPoints(kTpcId)<15) continue; // enough fit points 00084 StThreeVectorF mom1 = ptrack1->geometry()->momentum(); 00085 if (mom1.mag()<2.) continue; //use tracks with p>2 (NOT THE SAME AS FOR INV MASS TAG) 00086 if (fabs(mom1.pseudoRapidity())>1.5) continue; // use tracks with |eta|<1.5 00087 00088 // at this point, track passed cuts, 00089 // try the track extrapolation 00090 00091 StThreeVectorD trackMomentum, trackPosition; 00092 StEmcPosition emcPos; 00093 bool tok = emcPos.trackOnEmc(&trackPosition, &trackMomentum, ptrack1, 00094 event->summary()->magneticField(), Radius); 00095 // if it doesn't extrapolate to the BEMC, go on to the next track. 00096 if (!tok) continue; 00097 00098 // cout << "countTrackTowerMatches: Track phi,eta at BEMC " << trackPosition.phi() << ", " << trackPosition.pseudoRapidity() << endl; 00099 00100 // At this point, it extrapolates, so now look to see if the 00101 // adc value is 416 which corresponds to roughly 3 GeV. 00102 // Note 1: if the calibration above doesn't hold, then this tag is suspect 00103 // Note 2: one must also take into account pedestal subtraction (roughly 30 ADC) 00104 00105 int moduleH, etaH, subH, id; 00106 bemcGeom->getBin(trackPosition.phi(), trackPosition.pseudoRapidity(), moduleH, etaH, subH); 00107 bemcGeom->getId(moduleH, etaH, subH, id); 00108 00109 // cout << "countTrackTowerMatches: Module, Eta, Sub " << moduleH << ", " << etaH << ", " << subH << endl; 00110 // can I find the tower by Id? That would be faster 00111 // Looks like I have to loop over all the towers in the module... 00112 StEmcModule* module = stBEMCDetector->module(moduleH); 00113 const StSPtrVecEmcRawHit& modHits = module->hits(); 00114 for (size_t i=0; i<modHits.size();++i) { 00115 StEmcRawHit* hit = modHits[i]; 00116 // The StEmcGeom::getBin code returns the eta number as an int, but 00117 // StEmcRawHit::eta() returns an unsigned int, so one must 00118 // do some kludgy type-casting... 00119 // The StEmcGeom::getBin code actually does not return negative eta indices, so 00120 // this should be safe... look in StEmcUtil/geometry/StEmcGeom.h 00121 // cout << "countTrackTowerMatches: Hit " << i << " eta()= " << hit->eta() << ", sub()= " << hit->sub() << ", adc()= " << hit->adc() << ", energy()= " << hit->energy() << endl; 00122 if (hit->eta()==static_cast<unsigned int>(etaH) && hit->sub()==subH) { 00123 // This is the hit that the track extrapolates to. 00124 // Check it's adc value, if it's greater 00125 // than 416 AFTER pedestal subtraction, 00126 // we have a match 00127 00128 // we will convert the adc into an int because we will subtract 00129 // the pedestal, if we keep it as an unsigned int 00130 // we might get huge numbers after the subtraction. 00131 int adc = static_cast<int>(hit->adc()); 00132 // cout << "countTrackTowerMatches: Found the tower, it has adc-30 = " << adc-30 << endl; 00133 if (adc-30>360) ++trackTowerPairs; 00134 } // found the hit that track extrapolates to 00135 }// hits in module loop 00136 00137 00138 }// track loop 00139 return trackTowerPairs; 00140 }
1.5.9