StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
largestPairMass.cc
1 //
2 // $Id: largestPairMass.cc,v 1.2 2004/07/29 23:06:13 calderon Exp $
3 //
4 // Author: Manuel Calderon de la Barca Sanchez
5 //
6 // Calculates the largest invariant mass of track pairs
7 // from StEvent primary tracks.
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 // p>1 GeV/c
15 //
16 // $Log: largestPairMass.cc,v $
17 // Revision 1.2 2004/07/29 23:06:13 calderon
18 // Changed adc cut to match towers to 360 ADC counts,
19 // and documented the origin.
20 // Added Description to cxx file.
21 // Removed unnecessary static_cast for StDetectorId
22 //
23 //
24 
25 #include "StEvent.h"
26 #include "StPrimaryVertex.h"
27 #include "StContainers.h"
28 #include "StPrimaryTrack.h"
29 #include "StTrackGeometry.h"
30 #include "StTrackFitTraits.h"
31 
32 #include "StLorentzVectorF.hh"
33 
34 float largestPairMass(StEvent* event) {
35 
36  // first, protect against funny business..
37  if (!event) return -9999;
38  if (!(event->primaryVertex())) return -9999;
39 
40 
41  // Set up the parameters we'll need
42  // This just takes one constant, the
43  // mass of the electron in GeV/c^2
44  //
45  const float eMass = 0.00051099906; //
46 
47  // Set the initial Invariant Mass Seed:
48  float mostGargantuanMass = 0.0;
49 
50  // Get primary track container
51  const StSPtrVecPrimaryTrack& trackArray = event->primaryVertex()->daughters();
52 
53  // Construct pairs of tracks:
54  //
55  //
56  for (unsigned int ipr1=0; ipr1<trackArray.size(); ++ipr1) {
57  StPrimaryTrack* const ptrack1 = trackArray[ipr1];
58 
59  // check track 1 for cuts:
60  if (!ptrack1) continue; // valid pointer
61  if (ptrack1->flag()<=0) continue; // valid flag
62  if (ptrack1->fitTraits().numberOfFitPoints(kTpcId)<15) continue; // enough fit points
63  StThreeVectorF mom1 = ptrack1->geometry()->momentum();
64  if (mom1.mag()<1.) continue; //use tracks with p>1
65  if (fabs(mom1.pseudoRapidity())>1.5) continue; // use tracks with |eta|<1.5
66 
67  // at this point, track passed cuts,
68  // make pairs with the rest of the
69  // tracks in the container
70  // Note: loop MUST start with ipr1+1 to avoid double counting
71  //
72  for (unsigned int ipr2=ipr1+1; ipr2<trackArray.size(); ++ipr2) {
73  StPrimaryTrack* const ptrack2 = trackArray[ipr2];
74 
75  // same as for track 1, check track 2 for cuts:
76  if (!ptrack2) continue;
77  if (ptrack2->flag()<=0) continue;
78  if (ptrack2->fitTraits().numberOfFitPoints(kTpcId)<15) continue;
79  StThreeVectorF mom2 = ptrack2->geometry()->momentum();
80  if (mom2.mag()<1.) continue;
81  if (fabs(mom2.pseudoRapidity())>1.5) continue;
82 
83  // Ok, at this point we have a pair.
84  // There is no further selection on the charge.
85  // Now we calculate the invariant mass.
86  // This takes 3 lines of code using Lorentz Vectors
87  StLorentzVectorF fmom1(mom1,mom1.massHypothesis(eMass));
88  StLorentzVectorF fmom2(mom2,mom2.massHypothesis(eMass));
89  float mass = (fmom1 + fmom2).m();
90  if (mass>mostGargantuanMass) {
91  mostGargantuanMass = mass;
92  }
93  }// 2nd track loop
94  }// first track loop
95  return mostGargantuanMass;
96 }