]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/AliComparisonSelector.cxx
Made valid calibrations w/range 0-999999 - note oversampling is 4
[u/mrichter/AliRoot.git] / PWG1 / AliComparisonSelector.cxx
CommitLineData
36f9c31d 1// The class definition in esdClus.h has been generated automatically
2// by the ROOT utility TTree::MakeSelector(). This class is derived
3// from the ROOT class TSelector. For more information on the TSelector
4// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
5
6// The following methods are defined in this file:
7// Begin(): called everytime a loop on the tree starts,
8// a convenient place to create your histograms.
9// SlaveBegin(): called after Begin(), when on PROOF called only on the
10// slave servers.
11// Process(): called for each event, in this function you decide what
12// to read and fill your histograms.
13// SlaveTerminate: called at the end of the loop on the tree, when on PROOF
14// called only on the slave servers.
15// Terminate(): called at the end of the loop on the tree,
16// a convenient place to draw/fit your histograms.
17//
18// To use this file, try the following session on your Tree T:
19//
20// Root > T->Process("esdClus.C")
21// Root > T->Process("esdClus.C","some options")
22// Root > T->Process("esdClus.C+")
23//
24// Modification log:
25// 05/11/2006 HH Correct for large pads (outer sectors) in amplitude plots
26
27#include "TSystem.h"
28#include <TPDGCode.h>
29#include <TStyle.h>
30#include "TCint.h"
31#include "TH1I.h"
32#include "TTimeStamp.h"
33#include "TProof.h"
34#include "TTree.h"
35#include "TH2F.h"
36#include "TH1F.h"
37
38//
39#include "AliTracker.h"
40#include "AliMagF.h"
41//
42#include "AliESDEvent.h" // new container
43#include "AliESD.h"
44#include "AliESDtrack.h"
45#include "AliESDfriend.h"
46#include "AliESDfriendTrack.h"
47#include "AliTPCseed.h"
48#include "AliTPCclusterMI.h"
49//
50#include "AliComparisonDraw.h"
51#include "AliComparisonSelector.h"
52
53
54
55
56AliComparisonSelector::AliComparisonSelector(TTree *) :
57 TSelector(),
58 //
59 fChain(0),
60 fFileNo(0),
61 fSysWatch(0), // system info
62 fFileWatch(0), // file watch - write the status of the analyzed files
63 fDebugLevel(0),
64 fInfoMC(0),
65 fInfoRC(0),
66 fComp(0)
67{
68 G__SetCatchException(0);
69 //
70 //
71 //if (somthing){
72 fSysWatch = new fstream("syswatch.log", ios_base::out|ios_base::trunc);
73 fFileWatch = new fstream("filewatch.log", ios_base::out|ios_base::trunc);
74 if (gProof) fDebugLevel = gProof->GetLogLevel();
75}
76
77
78void AliComparisonSelector::Begin(TTree * /*tree*/)
79{
80 // The Begin() function is called at the start of the query.
81 // When running with PROOF Begin() is only called on the client.
82 // The tree argument is deprecated (on PROOF 0 is passed).
83
84 TString option = GetOption();
85
86}
87
88void AliComparisonSelector::SlaveBegin(TTree * tree)
89{
90 // The SlaveBegin() function is called after the Begin() function.
91 // When running with PROOF SlaveBegin() is called on each slave server.
92 // The tree argument is deprecated (on PROOF 0 is passed).
93 fChain = tree;
94 fComp = new AliComparisonDraw;
95 Init(tree);
96 fOutput->AddLast(fComp);
97 //
98}
99
100void AliComparisonSelector::Clean(){
101 //
102}
103
104Bool_t AliComparisonSelector::Process(Long64_t entry)
105{
106 // The Process() function is called for each entry in the tree (or possibly
107 // keyed object in the case of PROOF) to be processed. The entry argument
108 // specifies which entry in the currently loaded tree is to be processed.
109 // It can be passed to either AliComparisonSelector::GetEntry() or TBranch::GetEntry()
110 // to read either all or the required parts of the data. When processing
111 // keyed objects with PROOF, the object is already loaded and is available
112 // via the fObject pointer.
113 //
114 // This function should contain the "body" of the analysis. It can contain
115 // simple or elaborate selection criteria, run algorithms on the data
116 // of the event and typically fill histograms.
117 //
118 // The processing can be stopped by calling Abort().
119 //
120 // Use fStatus to set the return value of TTree::Process().
121 //
122 // The return value is currently not used.
123
124 Int_t status = ProcessIn(entry);
125 if (fFileWatch) {
126 (*fFileWatch) << "__" << status ;
127 }
128 return (status==0);
129}
130
131
132
133
134Int_t AliComparisonSelector::ReadEvent(Long64_t entry){
135 //
136 //
137 //
138
139
140 if (!fChain) return -1;
141 if (!fChain->GetTree()) return -1;
142 TTree * tree = fChain->GetTree();
143 if (tree->GetBranch("MC") && tree->GetBranch("RC")){
144 tree->GetBranch("MC")->SetAddress(&fInfoMC);
145 tree->GetBranch("RC")->SetAddress(&fInfoRC);
146 }
147 try {
148 fChain->GetTree()->GetEntry(entry);
149 } catch (std::bad_alloc) {
150 printf("Pica vyjebana pojebany skurveny kokot piciak\n");
151 return -1;
152 }
153 return 0;
154}
155
156
157Int_t AliComparisonSelector::ProcessIn(Long64_t entry)
158{
159 //
160 // User part of proccess method
161 //
162
163 //
164 // USER code to go here
165 //
166 Int_t status = ReadEvent(entry);
167 if (status<0) return status;
168 fComp->Process(fInfoMC, fInfoRC);
169 Clean();
170 return 0;
171}
172
173
174void AliComparisonSelector::SlaveTerminate()
175{
176 // The SlaveTerminate() function is called after all entries or objects
177 // have been processed. When running with PROOF SlaveTerminate() is called
178 // on each slave server.
179 printf ("SlaveTerminate.. \n");
180
181}
182
183void AliComparisonSelector::Terminate()
184{
185 // The Terminate() function is the last function to be called during
186 // a query. It always runs on the client, it can be used to present
187 // the results graphically or save the results to file.
188
189 printf ("Terminate... \n");
190 if (!fOutput) return;
191 TFile file("Output.root","recreate");
192 printf("fOutput contains the following: \n");
193 fOutput->Print();
194 printf("Trying to write the file 'Output.root'... \n");
195 fOutput->Write();
196 file.Close();
197
198
199}
200
201
202
203void AliComparisonSelector::Init(TTree *tree)
204{
205 // The Init() function is called when the selector needs to initialize
206 // a new tree or chain. Typically here the branch addresses and branch
207 // pointers of the tree will be set.
208 // It is normaly not necessary to make changes to the generated
209 // code, but the routine can be extended by the user if needed.
210 // Init() will be called many times when running on PROOF
211 // (once per file to be processed).
212
213 // Set branch addresses and branch pointers
214
215 if (!tree) return;
216 fChain = tree;
217 tree->SetBranchStatus("*",1);
218
219 if (tree->GetBranch("MC") && tree->GetBranch("RC")){
220 tree->GetBranch("MC")->SetAddress(&fInfoMC);
221 tree->GetBranch("RC")->SetAddress(&fInfoRC);
222 }
223}
224
225
226
227Bool_t AliComparisonSelector::Notify()
228{
229 // The Notify() function is called when a new file is opened. This
230 // can be either for a new TTree in a TChain or when when a new TTree
231 // is started when using PROOF. It is normaly not necessary to make changes
232 // to the generated code, but the routine can be extended by the
233 // user if needed. The return value is currently not used.
234
235 ++fFileNo;
236 const char * fname = "UNKNOWN";
237 const char * hname = gSystem->HostName();
238 if (fChain->GetCurrentFile()){
239 fname = fChain->GetCurrentFile()->GetName();
240 }
241
242
243 //
244 Info("Notify",Form("Host %s processing file no %d %s\n",hname,fFileNo,fname));
245
246 //
247 // Print statistic to log file
248 //
249 if (fname) {
250 (*fFileWatch) << endl;
251 (*fFileWatch) << hname <<"\t"
252 << fname <<"\t";
253 }
254 DumpSysInfo(-1);
255
256 return kTRUE;
257}
258
259
260void AliComparisonSelector::DumpSysInfo(Int_t entry){
261 //
262 // dump system info to log file
263 // entry - entry number in the chain
264 //
265 const char * fname = "UNKNOWN";
266 const char * hname = gSystem->HostName();
267 if (fChain->GetCurrentFile()){
268 fname = fChain->GetCurrentFile()->GetName();
269 }
270 //
271 if (fSysWatch){
272 TTimeStamp stamp;
273 CpuInfo_t cpuInfo;
274 MemInfo_t memInfo;
275 ProcInfo_t procInfo;
276
277 gSystem->GetCpuInfo(&cpuInfo, 1000);
278 gSystem->GetMemInfo(&memInfo);
279 gSystem->GetProcInfo(&procInfo);
280
281 (*fSysWatch) << hname <<"\t" // hname - hostname
282 << fname <<"\t" // fname - filename
283 << entry <<"\t" // entry - entry number
284 << stamp.GetSec()<<"\t" // time - time stamp in seconds
285 << memInfo.fMemUsed<<"\t" //
286 << memInfo.fSwapUsed<<"\t" //
287 << procInfo.fMemResident<<"\t" //
288 << procInfo.fMemVirtual<<"\t" //
289 << cpuInfo.fUser <<"\t" //
290 << cpuInfo.fSys <<"\t" //
291 << procInfo.fCpuUser<<"\t" //
292 << procInfo.fCpuSys<<"\t" //
293 << endl;
294 }
295}
296
297
298
299
36f9c31d 300
301
302
303