/[PAMELA software]/PamelaLevel2/doc/examples/My-Histos-0.cpp
ViewVC logotype

Annotation of /PamelaLevel2/doc/examples/My-Histos-0.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Mon Jan 15 11:51:39 2007 UTC (17 years, 11 months ago) by pam-fi
Branch: MAIN
Changes since 1.1: +16 -40 lines
v3r00 **NEW**

1 pam-fi 1.1 ////////////////////////////////////////////////////////////////
2     //
3     // Histogram set for tracker-efficiency study.
4     //
5     // It contains the functions:
6     //
7     // - CreateHistos()
8     // - FillHistos(PamLevel2* event)
9     // - Save Histos()
10     //
11     // Usage (example):
12     // [] .L My-histo-set-macro.C+
13     // [] .L My-selection.C+
14     // [] .L Loop.C+
15     // [] Loop("data-dir/","file-list.txt",100000,"+ALL fillTree fillHistos","output-file.root")
16     //
17     ////////////////////////////////////////////////////////////////
18    
19     #if !defined(__CINT__) || defined(__MAKECINT__)
20    
21     #include <TString.h>
22     #include <TH1F.h>
23     #include <TH2F.h>
24     #include <TMath.h>
25     #include <TLine.h>
26     #include <TPolyMarker.h>
27     #include <TSelector.h>
28     #include <TFile.h>
29    
30     #include <stdlib.h>
31     #include <iostream>
32     using namespace std;
33    
34     #include <PamLevel2.h>
35     #include <CaloAxis.h>
36    
37     #endif
38     //======================
39     // HITOGRAMS declaration
40     //======================
41     TH1F *hresangx;
42     TH1F *hresangy;
43     //===============================================================
44     // Create histograms
45     //===============================================================
46     void CreateHistos( TFile* outf ){
47    
48     gROOT->cd();//create histos in memory
49    
50     hresangx = new TH1F("hresangx","Angular residual on the top calo plane (x)",400,-40.,40.);
51     hresangy = new TH1F("hresangy","Angular residual on the top calo plane (y)",400,-40.,40.);
52    
53     }
54    
55     //===============================================================
56     // Fill histograms (called event-by-event)
57     //===============================================================
58    
59     void FillHistos( PamLevel2* event ){
60     // ----------------------------------
61     // retrieve histos
62     // ----------------------------------
63     // hresangx = dynamic_cast<TH1F*>(gDirectory->FindObject("hresangx"));
64     // hresangy = dynamic_cast<TH1F*>(gDirectory->FindObject("hresangy"));
65    
66    
67     float caloangx = 0;
68     float caloangy = 0;
69    
70     CaloStrip top = CaloStrip();
71     top.Set(0,0,48);
72     float zcalotop = top.GetZ();
73    
74 pam-fi 1.2
75 pam-fi 1.1
76     // ----------------------------------
77     // tracker variables
78     // ----------------------------------
79    
80     float resangx = -999;
81     float resangy = -999;
82 pam-fi 1.2 if( event->GetTrkLevel2()->GetNTracks()==1 ){
83 pam-fi 1.1
84     PamTrack *track = event->GetTrack(0);
85 pam-fi 1.2 if( track->GetTrkTrack()->chi2 >0 ){
86 pam-fi 1.1
87     Float_t ztraj[13];
88    
89     Int_t i=0;
90 pam-fi 1.2 ztraj[i++] = event->GetToFLevel2()->GetZTOF(11);
91     ztraj[i++] = event->GetToFLevel2()->GetZTOF(12);
92     ztraj[i++] = event->GetToFLevel2()->GetZTOF(21);
93     ztraj[i++] = event->GetToFLevel2()->GetZTOF(22);
94     ztraj[i++] = event->GetTrkLevel2()->GetZTrk(1);
95     ztraj[i++] = event->GetTrkLevel2()->GetZTrk(2);
96     ztraj[i++] = event->GetTrkLevel2()->GetZTrk(3);
97     ztraj[i++] = event->GetTrkLevel2()->GetZTrk(4);
98     ztraj[i++] = event->GetTrkLevel2()->GetZTrk(5);
99     ztraj[i++] = event->GetTrkLevel2()->GetZTrk(6);
100     ztraj[i++] = event->GetToFLevel2()->GetZTOF(31);
101     ztraj[i++] = event->GetToFLevel2()->GetZTOF(32);
102 pam-fi 1.1 ztraj[i++] = zcalotop;
103     Trajectory traj = Trajectory(13,ztraj);
104 pam-fi 1.2 traj.DoTrack2( track->GetTrkTrack()->al );
105 pam-fi 1.1
106     resangx = caloangx - traj.thx[12];
107     resangy = caloangy - traj.thy[12];
108    
109     }
110     }
111    
112     // ----------------------------------
113     // fill histograms
114     // ----------------------------------
115     hresangx->Fill(resangx);
116     hresangy->Fill(resangy);
117    
118    
119     }
120     //===============================================================
121     // Save histograms
122     //===============================================================
123     void SaveHistos( TFile * outf ){
124    
125     gROOT->cd();
126     // ----------------------------------
127     // retrieve histos
128     // ----------------------------------
129     // hresangx = dynamic_cast<TH1F*>(gDirectory->FindObject("hresangx"));
130     // hresangy = dynamic_cast<TH1F*>(gDirectory->FindObject("hresangy"));
131    
132     // ----------------------------------
133     // save on file
134     // ----------------------------------
135    
136     outf->cd();
137    
138     if(hresangx) hresangx->Write();
139     if(hresangy) hresangy->Write();
140     }
141    

  ViewVC Help
Powered by ViewVC 1.1.23