33 void setupHists(TH1F** , TH2F** , Int_t , Int_t *, Int_t *);
34 void moreHists(TH1F** , TH2F** , Int_t , Int_t *, Int_t *, Float_t *);
36 int main(
int argc,
char **argv) {
39 char InFile[128] =
"trackanal.root";
41 INF =
new TFile(InFile);
46 Int_t ThrownPType[200];
47 Float_t ThrownPp[200];
57 Int_t MaxT, MaxC, MaxF;
58 Int_t trlistPtype[250];
59 Int_t trlistcand[250];
60 Float_t trlistPp[250];
61 Float_t trlistFOM[250];
62 Float_t trlistchisq[250];
66 TTree *TrackTree = (TTree*)INF->Get(
"TrackTree");
69 TrackTree->SetBranchAddress(
"EventNum", &EventNum);
70 TrackTree->SetBranchAddress(
"MaxT", &MaxT);
71 TrackTree->SetBranchAddress(
"MaxC", &MaxC);
72 TrackTree->SetBranchAddress(
"MaxF", &MaxF);
74 TrackTree->SetBranchAddress(
"NTrThrown", &NTrThrown);
75 TrackTree->SetBranchAddress(
"ThrownPType", ThrownPType);
76 TrackTree->SetBranchAddress(
"ThrownPp", ThrownPp);
77 TrackTree->SetBranchAddress(
"ThrownQ", ThrownQ);
79 TrackTree->SetBranchAddress(
"NTrCand", &NTrCand);
80 TrackTree->SetBranchAddress(
"TrCandQ", TrCandQ);
81 TrackTree->SetBranchAddress(
"TrCandP", TrCandP);
82 TrackTree->SetBranchAddress(
"TrCandN", TrCandN);
83 TrackTree->SetBranchAddress(
"TrCandM", TrCandM);
85 TrackTree->SetBranchAddress(
"NTrFit", &NTrFit);
86 TrackTree->SetBranchAddress(
"trlistPtype", trlistPtype);
87 TrackTree->SetBranchAddress(
"trlistFOM", trlistFOM);
88 TrackTree->SetBranchAddress(
"trlistchisq", trlistchisq);
89 TrackTree->SetBranchAddress(
"trlistPp", trlistPp);
90 TrackTree->SetBranchAddress(
"trlistcand", trlistcand);
92 TrackTree->SetBranchAddress(
"NTrCandHits", &NTrCandHits);
93 TrackTree->SetBranchAddress(
"nh", nh);
94 TrackTree->SetBranchAddress(
"ptypes", ptypes);
96 Int_t Offset[5] = {0, 0, 0, 0, 0};
97 for (
int j=0;j<MaxF;j++){
98 for (
int i=0;i<MaxF;i++){
99 ptypes[j*MaxF+i] = 0.0 ;
104 Long64_t nentries = TrackTree->GetEntries();
105 cout<<
"Number of Entries: "<<nentries<<endl;
109 for (Int_t j = 0;j<50;j++){
114 for (Long64_t i=0; i<nentries;i++) {
118 TrackTree->GetEntry(i);
126 for (Int_t k = 0;k<NTrThrown;k++){
127 if (ThrownPp[k]>PMax[k])
128 PMax[k] = ThrownPp[k];
132 hist[0]->Fill((Float_t)NTrThrown);
133 hist[2]->Fill((Float_t)NTrCand);
137 Int_t MostHits[MaxC];
139 memset(MostHits,0,4*MaxC);
140 memset(TotHits,0,4*MaxC);
142 Int_t MultCount[NTrThrown];
144 for (Int_t j=0;j<NTrThrown;j++){
153 for (Int_t j=0;j<NTrCand;j++){
161 hist[Offset[4]-1]->Fill(TrCandM[j]/TrCandN[j]);
163 for (Int_t k=0;k<NTrThrown+1;k++){
165 SumHits += nh[j*SZ+k];
166 if (((Int_t)nh[j*SZ+k])>MaxHits){
167 MaxHits = nh[j*SZ+k];
171 for (Int_t k=0;k<SZ;k++){
172 if (((Int_t)ptypes[j*SZ+k])>MaxHits1){
173 MaxHits1 = ptypes[j*SZ+k];
178 MostHits[j] = nh[j*SZ+idx];
181 TotHits[j] = SumHits;
182 hist[3]->Fill((Float_t)SumHits);
184 hist[4]->Fill(SumHits);
188 Float_t rat = (Float_t)MostHits[j]/(Float_t) TotHits[j]*100.;
189 hist[Offset[2]+idx-1]->Fill(rat);
190 hist[4+idx]->Fill(SumHits);
200 for (Int_t k=0;k<NTrFit;k++){
201 if (trlistcand[k]==j+1){
202 if (chi2>trlistchisq[k]){
203 chi2 = trlistchisq[k];
206 if (FOM<trlistFOM[k]){
224 for (Int_t kk=0;kk<NTrThrown;kk++){
225 test1 += ((idx==kk+1) && (ptype==ThrownPType[kk]));
228 if ( test1 && idx>0) {
229 Int_t trptype = trlistPtype[
index];
230 Float_t prat = ((Float_t)trptype)/((Float_t)ptype);
231 Float_t ptrack = trlistPp[
index];
232 Float_t ptrue = ThrownPp[idx-1];
233 hist[Offset[0]+idx-1]->Fill(ptrack/ptrue);
234 hist[Offset[1]+idx-1]->Fill(prat);
235 hist2d[0+idx-1]->Fill(ptrack/ptrue, (Float_t)nh[j*SZ+idx]);
236 hist2d[Offset[5]+idx]->Fill(prat, (Float_t)nh[j*SZ+idx]);
238 Int_t trptype = trlistPtype[
index];
239 Float_t prat = ((Float_t)trptype)/((Float_t)ptype);
240 hist[Offset[2]-1]->Fill(prat);
241 hist2d[Offset[5]]->Fill(prat, (Float_t)nh[j*SZ+idx]);
245 cout<<j<<
" "<<idx<<
" ";
247 cout<<nh[j*SZ+idx]/SumHits*100.<<
" "<<SumHits<<endl;
249 cout<<
" ?/SumHits "<<SumHits<<endl;
255 for (Int_t j=0;j<NTrFit;j++){
256 cout<< i<<
" "<< j <<
" " << trlistcand[j]<<
" " <<trlistFOM[j] <<
" " <<
257 trlistchisq[j]<<
" "<<trlistPp[j]<<
" "<<trlistPtype[j]<<endl;
264 for (Int_t k=0; k<NTrThrown; k++){
265 hist[Offset[3]+k]->Fill((Float_t)MultCount[k]);
275 Offset, ThrownPType, PMax);
277 for (Long64_t i=0; i<nentries;i++) {
281 TrackTree->GetEntry(i);
283 for (Int_t k=0;k<NTrThrown;k++){
284 hist[Offset[4]+k]->Fill(ThrownPp[k]);
292 sprintf(fnam,
"histograms_trackanal.root");
293 TFile *fout =
new TFile(fnam,
"RECREATE");
296 Int_t Nhist = Offset[4] + NTrThrown;
297 cout<<
"Number of 1D histos: "<<Nhist<<endl;
298 for (Int_t j=0;j<Nhist;j++){
299 hist_list->Add(
hist[j]);
303 Int_t Nhist2d = Offset[5] + NTrThrown;
304 cout<<
"Number of 2D histos: "<<Nhist2d<<endl;
305 for (Int_t j=0;j<Nhist2d;j++){
306 hist2d_list->Add(
hist2d[j]);
309 hist_list->Write(
"hist_list", TObject::kSingleKey);
310 hist2d_list->Write(
"hist2d_list", TObject::kSingleKey);
323 Int_t *Offset, Int_t *ThrownPType){
327 hist[0] =
new TH1F(
"hist0",
"All Tracks Thrown", 16, -0.5, 15.5);
328 hist[1] =
new TH1F(
"hist1",
"Charged Tracks Thrown", 16, -0.5, 15.5);
329 hist[2] =
new TH1F(
"hist2",
"Track Candidates", 16, -0.5, 15.5);
330 hist[3] =
new TH1F(
"hist3",
"Tracking Hits of Candidates ", 41, -0.5, 40.5);
331 hist[0]->GetXaxis()->SetTitle(
"Number of track per event");
332 hist[1]->GetXaxis()->SetTitle(
"Number of track per event");
333 hist[2]->GetXaxis()->SetTitle(
"Number of track per event");
334 hist[3]->GetXaxis()->SetTitle(
"Number of hits for track candidates");
336 for (Int_t i=0;i<NTrThrown;i++) {
340 sprintf(str2,
"Thrown Track %d, Ptype=%d : Cand Hits ",i+1,ThrownPType[i]);
341 hist[i+5] =
new TH1F(str1, str2, 41, -0.5, 40.5);
342 hist[i+5]->GetXaxis()->SetTitle(
"Number of hits per track");
346 sprintf(str1,
"hist%d",4+NTrThrown);
347 sprintf(str2,
"Track X Cand Hits ");
349 hist[4] =
new TH1F(
"hist4", str2, 41, -0.5, 40.5);
352 Offset[0] = NTrThrown + 4 + 1;
353 for (Int_t i=0;i<NTrThrown;i++) {
356 sprintf(str1,
"hist%d",i+Offset[0]);
357 sprintf(str2,
"Track %d Candidate p_det/p_true",i+1);
358 hist[i+Offset[0]] =
new TH1F(str1, str2,160, -2., 2.);
359 hist[i+Offset[0]]->GetXaxis()->SetTitle(
"p_det/p_true");
363 Offset[1] = Offset[0] + NTrThrown;
365 for (Int_t i=0;i<NTrThrown;i++) {
368 sprintf(str1,
"hist%d",i+Offset[1]);
369 sprintf(str2,
"PID_Tracking/True_PID Thrown Track %d",i+1);
370 hist[i+Offset[1]] =
new TH1F(str1, str2, 50, -0.5, 2.5);
371 hist[i+Offset[1]]->GetXaxis()->SetTitle(
"pid_det/pid_gen");
375 sprintf(str1,
"hist%d",k+1+Offset[1]);
376 hist[k+1+Offset[1]] =
new TH1F(str1,
"PID_Tracking/True_PID secondary Track X", 50, -0.5, 2.5);
377 hist[k+1+Offset[1]]->GetXaxis()->SetTitle(
"pid_det/pid_gen");
379 Offset[2] = Offset[1] + NTrThrown + 1;
381 for (Int_t i=0;i<NTrThrown;i++) {
384 sprintf(str1,
"hist%d",i+Offset[2]);
385 sprintf(str2,
"Thrown Track %d PType=%d : NHits/TotHits",i+1,ThrownPType[i]);
386 hist[i+Offset[2]] =
new TH1F(str1, str2, 20, 40., 100.1);
387 hist[i+Offset[2]]->GetXaxis()->SetTitle(
"% of hits from thrown particle");
391 Offset[3] = Offset[2] + NTrThrown;
393 for (Int_t i=0;i<NTrThrown;i++) {
396 sprintf(str1,
"hist%d",i+Offset[3]);
397 sprintf(str2,
"Thrown Track %d PType=%d : Candidates",i+1,ThrownPType[i] );
398 hist[i+Offset[3]] =
new TH1F(str1, str2, 6, -0.5, 5.5);
399 hist[i+Offset[3]]->GetXaxis()->SetTitle(
"Candidate Multiplicity");
403 Offset[4] = Offset[3] + NTrThrown;
405 sprintf(str1,
"hist%d",Offset[4]);
406 hist[Offset[4]] =
new TH1F(str1,
"Matched_Hits/Hits", 100, 0.5, 1.5);
407 hist[Offset[4]]->GetXaxis()->SetTitle(
"Ratio Associated_Hits/All_Hits");
411 for (Int_t i=0;i<NTrThrown;i++) {
415 sprintf(str2,
"Thrown track %d NHits vs. #Delta p/p", i+1);
416 hist2d[i] =
new TH2F(str1, str2, 160, -2.,2.,41, -0.5,40.5);
417 hist2d[i]->GetXaxis()->SetTitle(
"(p_det/p_gen)");
418 hist2d[i]->GetYaxis()->SetTitle(
"Number of Hits");
421 Offset[5] = NTrThrown;
423 for (Int_t i=0;i<NTrThrown;i++) {
426 sprintf(str1,
"hist2d%d",i+Offset[5]+1);
427 sprintf(str2,
"Thrown track %d NHits vs.ID/TRUE_ID", i+1);
428 hist2d[i+Offset[5]+1] =
new TH2F(str1, str2, 50, -.5,2.5, 41, -0.5,40.5);
429 hist2d[i+Offset[5]+1]->GetXaxis()->SetTitle(
"ID_det/ID_true");
430 hist2d[i+Offset[5]+1]->GetYaxis()->SetTitle(
"Number of Hits");
433 sprintf(str1,
"hist2d%d",Offset[5]);
434 hist2d[Offset[5]] =
new TH2F(str1,
"TrX NHits vs. ID/TRUE_ID X",50, -.5,2.5, 41, -0.5,40.5);
435 hist2d[Offset[5]]->GetXaxis()->SetTitle(
"ID_det/ID_true");
436 hist2d[Offset[5]]->GetYaxis()->SetTitle(
"Number of Hits");
443 Int_t *Offset, Int_t *ThrownPType, Float_t *PMax){
448 for (Int_t i=0;i<NTrThrown;i++) {
449 sprintf(str1,
"hist%d",i+Offset[4]);
450 sprintf(str2,
"Thrown Track %d PType=%d",i+1,ThrownPType[i]);
451 hist[i+Offset[4]] =
new TH1F(str1, str2, 50, 0.0, PMax[i]*1.1);
452 hist[i+Offset[4]]->GetXaxis()->SetTitle(
"Track Momentum [GeV/c]");
void moreHists(TH1F **, TH2F **, Int_t, Int_t *, Int_t *, Float_t *)
sprintf(text,"Post KinFit Cut")
static char index(char c)
void setupHists(TH1F **, TH2F **, Int_t, Int_t *, Int_t *)
int main(int argc, char *argv[])