StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HistMaker.cxx
1 
2 //std
3 #include "Stiostream.h"
4 #include <cmath>
5 #include <vector>
6 using namespace std;
7 
8 //ROOT
9 #include "TH1.h"
10 #include "TH2.h"
11 
12 //SCL
13 #include "SystemOfUnits.h"
14 #include "PhysicalConstants.h"
15 #include "StThreeVectorF.hh"
16 #include "StLorentzVectorF.hh"
17 
18 //StMuDSTMaker
19 #include "StMuDSTMaker/COMMON/StMuTrack.h"
20 
21 //UpsilonAna
22 #include "StJetMuEvent.h"
23 #include "HistMaker.h"
24 
25 ClassImp(HistMaker)
26 
27 HistMaker::HistMaker() : mdEtaVsdPhi(0)
28 {
29  cout <<"HistMaker::HistMaker()"<<endl;
30 }
31 
32 HistMaker::~HistMaker()
33 {
34  cout <<"HistMaker::~HistMaker()"<<endl;
35 }
36 
37 void HistMaker::fill(StJetMuEvent* e)
38 {
39  if (mCuts.verbose) {
40  cout <<"HistMaker::fill(StJetMuEvent*)"<<endl;
41  }
42 
43  if (!e) {
44  cout <<"StHistMaker::fill(StUpsilonEvent*). ERROR:\t"
45  <<"null event. Return w/o action"<<endl;
46  }
47 
48  typedef vector<StMuTrack*> TrackVec;
49  TrackVec vec;
50 
51  int n = e->tracks()->GetLast()+1; // get number of primary tracks
52  //cout <<"n="<<n<<"\tverbose:\t"<<mCuts.verbose<<endl;
53  TClonesArray& tracks = *(e->tracks());
54 
55  StMuTrack* trigger = 0;
56  double maxPt=0;
57 
58  for (int i=0; i<n; ++i) {
59  StMuTrack* track = static_cast<StMuTrack*>(tracks[i]); // get pointer to primary track
60 
61  if (acceptTrack(track)) {
62  //push back vector
63  if ( (track->pt()>maxPt) && (isTrigger(track)) ) {
64  maxPt = track->pt();
65  trigger = track;
66  }
67 
68  vec.push_back(track);
69  }
70  }
71 
72  if (!trigger) {
73  //cout <<"Error, no trigger particle found. Abort"<<endl;
74  return;
75  }
76 
77  if (mCuts.verbose) {
78  cout <<"\t Accepted "<<vec.size()<<" tracks of "<<n<<" possible"<<endl;
79  }
80 
81  //Now fill histogram
82  StThreeVectorF triggerP = trigger->momentum();
83  for (TrackVec::iterator it=vec.begin(); it!=vec.end(); ++it) {
84  StMuTrack* track = *it;
85  if (track!=trigger) {
86  StThreeVectorF p = track->momentum();
87  double dPhi = triggerP.phi() - p.phi();
88  double dEta = triggerP.pseudoRapidity() - p.pseudoRapidity();
89  mdEtaVsdPhi->Fill(dPhi, dEta);
90  }
91  }
92 }
93 
94 bool HistMaker::isTrigger(StMuTrack* track)
95 {
96  return (track->pt() >= mCuts.triggerPtCut);
97 }
98 
99 bool HistMaker::acceptTrack(StMuTrack* track)
100 {
101  if (track->flag() >= 0 &&
102  track->momentum().perp() > mCuts.ptCut &&
103  fabs(track->momentum().pseudoRapidity()) < mCuts.pseudoRapidityCutOff &&
104  track->nHitsFit() >= mCuts.minNumberOfFitPoints &&
105  track->nHits() >= mCuts.minNumberOfPoints) {
106  return true;
107  }
108  else {
109  return false;
110  }
111 }
Double_t pt() const
Returns pT at point of dca to primary vertex.
Definition: StMuTrack.h:256
UShort_t nHitsFit() const
Return total number of hits used in fit.
Definition: StMuTrack.h:239
short flag() const
Returns flag, (see StEvent manual for type information)
Definition: StMuTrack.h:230
const StThreeVectorF & momentum() const
Returns 3-momentum at dca to primary vertex.
Definition: StMuTrack.h:260
UShort_t nHits() const
Bingchu.
Definition: StMuTrack.h:237