]>
Commit | Line | Data |
---|---|---|
dc7ca31d | 1 | #define esdAna_cxx |
2 | // The class definition in esdAna.h has been generated automatically | |
3 | // by the ROOT utility TTree::MakeSelector(). This class is derived | |
4 | // from the ROOT class TSelector. For more information on the TSelector | |
5 | // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual. | |
6 | ||
7 | // The following methods are defined in this file: | |
8 | // Begin(): called everytime a loop on the tree starts, | |
9 | // a convenient place to create your histograms. | |
10 | // SlaveBegin(): called after Begin(), when on PROOF called only on the | |
11 | // slave servers. | |
12 | // Process(): called for each event, in this function you decide what | |
13 | // to read and fill your histograms. | |
14 | // SlaveTerminate: called at the end of the loop on the tree, when on PROOF | |
15 | // called only on the slave servers. | |
16 | // Terminate(): called at the end of the loop on the tree, | |
17 | // a convenient place to draw/fit your histograms. | |
18 | // | |
19 | // To use this file, try the following session on your Tree T: | |
20 | // | |
21 | // Root > T->Process("esdAna.C") | |
22 | // Root > T->Process("esdAna.C","some options") | |
23 | // Root > T->Process("esdAna.C+") | |
24 | // | |
25 | ||
26 | #include "esdAna.h" | |
27 | #include <TH1.h> | |
28 | ||
29 | void esdAna::Begin(TTree *) | |
30 | { | |
31 | // The Begin() function is called at the start of the query. | |
32 | // When running with PROOF Begin() is only called on the client. | |
33 | // The tree argument is deprecated (on PROOF 0 is passed). | |
34 | ||
35 | h1 = new TH1F("hRealVertex","Primary vertex",100,-20,20); | |
36 | h3 = new TH1F("hT0vertex","T0vertex",100,-20,20); | |
37 | h2 = new TH1F("hT0start","T0 start time",100,12400,12600); | |
38 | TString option = GetOption(); | |
39 | } | |
40 | ||
41 | void esdAna::SlaveBegin(TTree *tree) | |
42 | { | |
43 | // The SlaveBegin() function is called after the Begin() function. | |
44 | // When running with PROOF SlaveBegin() is called on each slave server. | |
45 | // The tree argument is deprecated (on PROOF 0 is passed). | |
46 | ||
47 | ||
48 | Init(tree); | |
49 | ||
50 | TString option = GetOption(); | |
51 | ||
52 | } | |
53 | ||
54 | Bool_t esdAna::Process(Long64_t entry) | |
55 | { | |
56 | ||
57 | // The Process() function is called for each entry in the tree (or possibly | |
58 | // keyed object in the case of PROOF) to be processed. The entry argument | |
59 | // specifies which entry in the currently loaded tree is to be processed. | |
60 | // It can be passed to either TTree::GetEntry() or TBranch::GetEntry() | |
61 | // to read either all or the required parts of the data. When processing | |
62 | // keyed objects with PROOF, the object is already loaded and is available | |
63 | // via the fObject pointer. | |
64 | // | |
65 | // This function should contain the "body" of the analysis. It can contain | |
66 | // simple or elaborate selection criteria, run algorithms on the data | |
67 | // of the event and typically fill histograms. | |
68 | ||
69 | // WARNING when a selector is used with a TChain, you must use | |
70 | // the pointer to the current TTree to call GetEntry(entry). | |
71 | // The entry is always the local entry number in the current tree. | |
72 | // Assuming that fChain is the pointer to the TChain being processed, | |
73 | // use fChain->GetTree()->GetEntry(entry). | |
74 | // fChain->GetTree()->GetEntry(entry); | |
75 | b_ESD_fEventNumber->GetEvent(entry); | |
76 | b_ESD_fPrimaryVertex_fPosition->GetEntry(entry); | |
77 | b_ESD_fT0zVertex->GetEntry(entry); | |
78 | b_ESD_fT0timeStart->GetEntry(entry); | |
79 | printf("Processing Entry %lld %d %f %f %f \n",entry,fEventNumber,fT0zVertex,fPrimaryVertex_fPosition[2], fT0timeStart ); | |
80 | ||
81 | h2->Fill(fT0timeStart); | |
82 | h1->Fill(fPrimaryVertex_fPosition[2]); | |
83 | h3->Fill(fT0zVertex/2.); | |
84 | ||
85 | ||
86 | return kTRUE; | |
87 | } | |
88 | ||
89 | void esdAna::SlaveTerminate() | |
90 | { | |
91 | // The SlaveTerminate() function is called after all entries or objects | |
92 | // have been processed. When running with PROOF SlaveTerminate() is called | |
93 | // on each slave server. | |
94 | fOutput->Add(h1) ; | |
95 | fOutput->Add(h2) ; | |
96 | fOutput->Add(h3) ; | |
97 | } | |
98 | ||
99 | void esdAna::Terminate() | |
100 | { | |
101 | // The Terminate() function is the last function to be called during | |
102 | // a query. It always runs on the client, it can be used to present | |
103 | // the results graphically or save the results to file. | |
104 | Float_t mean = h2->GetMean(); | |
105 | printf ("mean time T0 ps %f ",mean); | |
106 | if (mean > 12600 || mean <12400 ) | |
107 | printf (" !!!!!!!!!!-----events sample is WRONG - T0 unreal -------"); | |
108 | hfile = TFile::Open("esdAna.root","RECREATE"); | |
109 | TFile * file = TFile::Open("esdAna.root", "RECREATE"); | |
110 | h1->Write(); | |
111 | h2->Write(); | |
112 | h3->Write(); | |
113 | file->Close(); | |
114 | } |