StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StReadRare.cxx
1 //
2 //
3 // author: struck
4 //
5 // read rare tree and fill histos
6 #include "StReadRare.h"
7 #include "StRareEvent.h"
8 #include "StRareTrack.h"
9 #include "StL3RareTrack.h"
10 #include "StEventTypes.h"
11 
12 ClassImp(StReadRare)
13 
14 
16 {
17  mNEvents = 1000000;
18 
19  // L3 trigger cut parameters
20  mCutFraction = 0.8;
21  mMinHits = 27;
22  mMaxDCA = 5;
23  mMinP = 0.5;
24  mMaxDedx = 60;
25 
26  // Offline cut parameters
27  mMinHitsOffline = 29;
28  mDEdxnHitsRatio = 0.3;
29 
30  //reset chain
31  mChain = 0;
32 
33  // histo file
34  mHistoFile = new TString("/direct/star+data01/pwg/spectra/struck/2001/RarePlots.root");
35 }
36 
37 
38 StReadRare::StReadRare(Int_t nEvents, const Char_t* histoFileName)
39 {
40  mNEvents = nEvents;
41 
42  // L3 trigger cut parameters
43  mCutFraction = 0.8;
44  mMinHits = 27;
45  mMaxDCA = 5;
46  mMinP = 0.5;
47  mMaxDedx = 60;
48 
49  // Offline cut parameters
50  mMinHitsOffline = 29;
51  mDEdxnHitsRatio = 0.3;
52 
53  //reset chain
54  mChain = 0;
55 
56  // histo file
57  mHistoFile = new TString(histoFileName);
58 }
59 
60 
61 void StReadRare::Init()
62 {
63  // Histograms
64  hOffP = new TH1F("hOffP", "offline p", 100, 0, 10);
65  hL3P = new TH1F("hL3P", "L3 p", 100, 0, 10);
66 
67  hL3Dca = new TH1F("hL3Dca", "dca l3 tracks", 400, 0, 20);
68 
69  hOffdEdx = new TH2F("hOffdEdx", "dedx offline tracks", 1000, 0, 2.5, 1200, 0, 50);
70  hL3dEdx = new TH2F("hL3dEdx", "dedx l3 tracks", 1000, 0, 2.5, 1200, 0, 50);
71 
72  hOffZ = new TH1F("hOffZ", "Z=ln(I_m/I_expect(anti-He3)), offline", 60, -3, 3);
73  hL3Z = new TH1F("hL3Z", "Z=ln(I_m/I_expect(anti-He3)), L3", 60, -3, 3);
74 
75  hCandidateMatch = new TH1F("hCandidateMatch", "0:offline-L3 match, -1:offline only, +1:L3 only", 10, -2.5, 2.5);
76  hOffCandidatedEdx = new TH2F("hOffCandidatedEdx", "dedx offline candidate tracks", 800, 0, 5, 1200, 0, 60);
77  hOffCandidateZ = new TH1F("hOffCandidateZ", "Z=ln(I_m/I_expect(anti-He3)), offline candidate", 60, -3, 3);
78  hL3CandidatedEdx = new TH2F("hL3CandidatedEdx", "dedx L3 candidate tracks", 800, 0, 5, 1200, 0, 60);
79  hL3CandidatedEdxMatch = new TH2F("hL3CandidatedEdxMatch", "dedx L3 candidate tracks, match to offline", 800, 0, 5, 1200, 0, 60);
80  hL3CandidatedEdxTriggeredMatch = new TH2F("hL3CandidatedEdxTriggeredMatch", "dedx L3 candidate tracks, match to offline, triggered", 800, 0, 5, 1200, 0, 60);
81  hL3CandidateDca = new TH1F("hL3CandidateDca", "dca l3 candidate tracks", 400, 0, 10);
82  hL3CandidateZ = new TH1F("hL3CandidateZ", "Z=ln(I_m/I_expect(anti-He3)), l3 candidate tracks", 60, -3, 3);
83 
84 
85  // generate chain
86  mChain = new TChain("RareTree");
87  mChain->Add("/direct/star+data02/scratch/struck/test/new291/st_phys*.root");
88  mChain->Add("/direct/star+data02/scratch/struck/test/new292/st_phys*.root");
89  mChain->Add("/direct/star+data02/scratch/struck/test/new294/st_phys*.root");
90  //mChain->Add("data/new291/st_physics_2291023_raw_0012.rareTree.root");
91  //mChain->Add("data/new291/st_physics_2291032_raw_0012.rareTree.root");
92  //mChain->Add("data/new292/st_physics_2292004_raw_0012.rareTree.root");
93  //mChain->Add("/direct/star+data01/pwg/spectra/struck/2001/RareEventTest.root");
94  //mChain->Add("RareEvent.root");
95 
96  // set number of events
97  mNEvents = (Int_t) mChain->GetEntries();
98  printf("Total # events: %i\n", mNEvents);
99 }
100 
101 
102 Int_t StReadRare::Run()
103 {
104  StRareEvent *event = new StRareEvent(); //we create the event object once outside the loop
105  mChain->SetBranchAddress("StRareEvent", &event);
106  printf("StReadRare::Start Run.\nTotal # events: %i\n", mNEvents);
107 
108  for (int i=0; i<mNEvents; i++) {
109  printf("Event:%d\n",i);
110  mChain->GetEvent(i);
111  //printf(" nTracks: %i; L3: %i\n",
112  // event->numberOfGoodPrimaryTracks(),
113  // event->numberOfL3Tracks());
114 
115  if (event->l3Flag()==kTRUE) {
116  printf(" event TRIGGERED!!\n");
117  }
118 
119  int candidateIndex = 0;
120  bool candidateEvent = kFALSE;
121 
122  // offline tracks
123  for (int j=0; j<event->numberOfTracks(); j++) {
124  StRareTrack *track = (StRareTrack* )event->getTracks()->At(j);
125  float p = track->p();
126  float dedx = track->dedx();
127  hOffP->Fill(p);
128  if (dedx>0
129  && (track->npntfit()>=mMinHitsOffline)
130  && track->chargesign()<0
131  && (((float)track->ndedx())/((float)track->npntfit())>=mDEdxnHitsRatio)) {
132  // dE/dx spectrum, all tracks
133  hOffdEdx->Fill(p, dedx);
134  // Z, all negative tracks
135  float ionExpected = 2 * 4.598 * (1 + 7.89177 / (4 * p*p));
136  hOffZ->Fill(TMath::Log(dedx/ionExpected));
137  // candidate tracks
138  if (dedx>(mCutFraction * ionExpected)) {
139  hOffCandidatedEdx->Fill(p, dedx);
140  hOffCandidateZ->Fill(TMath::Log(dedx/ionExpected));
141  candidateIndex--;
142  candidateEvent = kTRUE;
143  }
144  }
145  } // offline tracks
146 
147  // L3 tracks
148  for (int j=0; j<event->numberOfL3Tracks(); j++) {
149  StL3RareTrack *l3track = (StL3RareTrack* )event->getL3Tracks()->At(j);
150  float p = l3track->p();
151  float dedx = l3track->dedx();
152  hL3P->Fill(p);
153  hL3Dca->Fill(l3track->dca2d());
154  if (dedx>0
155  && (l3track->npntfit()>=mMinHits)
156  && (l3track->chargesign()<0)
157  && (l3track->dca2d()<mMaxDCA)) {
158  // dE/dx spectrum, all tracks
159  hL3dEdx->Fill(p, dedx);
160  // Z, all negative tracks
161  float ionExpected = 2 * 4.598 * (1 + 7.89177 / (4 * p*p));
162  hL3Z->Fill(TMath::Log(dedx/ionExpected));
163  // candidate tracks
164  if ((p>mMinP)
165  && (dedx<mMaxDedx)
166  && (dedx>(mCutFraction*ionExpected))) {
167  hL3CandidatedEdx->Fill(p, dedx);
168  hL3CandidateZ->Fill(TMath::Log(dedx/ionExpected));
169  // match to offline?
170  if (candidateEvent==kTRUE) {
171  hL3CandidatedEdxMatch->Fill(p, dedx);
172  // and triggered?
173  if (event->l3Flag()==kTRUE)
174  hL3CandidatedEdxTriggeredMatch->Fill(p, dedx);
175  }
176  candidateIndex++;
177  candidateEvent = kTRUE;
178  hL3CandidateDca->Fill(l3track->dca2d());
179  }
180  }
181  } // l3 tracks
182 
183  // fill 'candidate-match' histogram
184  if (candidateEvent==kTRUE)
185  hCandidateMatch->Fill(candidateIndex);
186 
187  } // event loop
188  return 0;
189 }
190 
191 
192 Int_t StReadRare::Finish()
193 {
194  TFile *rFile = new TFile(mHistoFile->Data(),"RECREATE");
195  hOffP->Write();
196  hL3P->Write();
197  hL3Dca->Write();
198  hOffdEdx->Write();
199  hL3dEdx->Write();
200  hOffZ->Write();
201  hL3Z->Write();
202  hCandidateMatch->Write();
203  hOffCandidatedEdx->Write();
204  hOffCandidateZ->Write();
205  hL3CandidatedEdx->Write();
206  hL3CandidatedEdxMatch->Write();
207  hL3CandidatedEdxTriggeredMatch->Write();
208  hL3CandidateDca->Write();
209  hL3CandidateZ->Write();
210  rFile->Close();
211 
212  return 0;
213 }