]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/AliComparisonSelector.cxx
LUTs mapping symnames and original global matrices removed from AliGeomManager, which...
[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
b1fcf19c 54ClassImp(AliComparisonSelector)
36f9c31d 55
56
57AliComparisonSelector::AliComparisonSelector(TTree *) :
58 TSelector(),
59 //
60 fChain(0),
61 fFileNo(0),
62 fSysWatch(0), // system info
63 fFileWatch(0), // file watch - write the status of the analyzed files
64 fDebugLevel(0),
65 fInfoMC(0),
66 fInfoRC(0),
67 fComp(0)
68{
69 G__SetCatchException(0);
70 //
71 //
72 //if (somthing){
73 fSysWatch = new fstream("syswatch.log", ios_base::out|ios_base::trunc);
74 fFileWatch = new fstream("filewatch.log", ios_base::out|ios_base::trunc);
75 if (gProof) fDebugLevel = gProof->GetLogLevel();
76}
77
78
79void AliComparisonSelector::Begin(TTree * /*tree*/)
80{
81 // The Begin() function is called at the start of the query.
82 // When running with PROOF Begin() is only called on the client.
83 // The tree argument is deprecated (on PROOF 0 is passed).
84
85 TString option = GetOption();
86
87}
88
89void AliComparisonSelector::SlaveBegin(TTree * tree)
90{
91 // The SlaveBegin() function is called after the Begin() function.
92 // When running with PROOF SlaveBegin() is called on each slave server.
93 // The tree argument is deprecated (on PROOF 0 is passed).
94 fChain = tree;
95 fComp = new AliComparisonDraw;
96 Init(tree);
97 fOutput->AddLast(fComp);
98 //
99}
100
101void AliComparisonSelector::Clean(){
102 //
103}
104
105Bool_t AliComparisonSelector::Process(Long64_t entry)
106{
107 // The Process() function is called for each entry in the tree (or possibly
108 // keyed object in the case of PROOF) to be processed. The entry argument
109 // specifies which entry in the currently loaded tree is to be processed.
110 // It can be passed to either AliComparisonSelector::GetEntry() or TBranch::GetEntry()
111 // to read either all or the required parts of the data. When processing
112 // keyed objects with PROOF, the object is already loaded and is available
113 // via the fObject pointer.
114 //
115 // This function should contain the "body" of the analysis. It can contain
116 // simple or elaborate selection criteria, run algorithms on the data
117 // of the event and typically fill histograms.
118 //
119 // The processing can be stopped by calling Abort().
120 //
121 // Use fStatus to set the return value of TTree::Process().
122 //
123 // The return value is currently not used.
124
125 Int_t status = ProcessIn(entry);
126 if (fFileWatch) {
127 (*fFileWatch) << "__" << status ;
128 }
129 return (status==0);
130}
131
132
133
134
135Int_t AliComparisonSelector::ReadEvent(Long64_t entry){
136 //
137 //
138 //
139
140
141 if (!fChain) return -1;
142 if (!fChain->GetTree()) return -1;
143 TTree * tree = fChain->GetTree();
144 if (tree->GetBranch("MC") && tree->GetBranch("RC")){
145 tree->GetBranch("MC")->SetAddress(&fInfoMC);
146 tree->GetBranch("RC")->SetAddress(&fInfoRC);
147 }
148 try {
149 fChain->GetTree()->GetEntry(entry);
150 } catch (std::bad_alloc) {
151 printf("Pica vyjebana pojebany skurveny kokot piciak\n");
152 return -1;
153 }
154 return 0;
155}
156
157
158Int_t AliComparisonSelector::ProcessIn(Long64_t entry)
159{
160 //
161 // User part of proccess method
162 //
163
164 //
165 // USER code to go here
166 //
167 Int_t status = ReadEvent(entry);
168 if (status<0) return status;
169 fComp->Process(fInfoMC, fInfoRC);
170 Clean();
171 return 0;
172}
173
174
175void AliComparisonSelector::SlaveTerminate()
176{
177 // The SlaveTerminate() function is called after all entries or objects
178 // have been processed. When running with PROOF SlaveTerminate() is called
179 // on each slave server.
180 printf ("SlaveTerminate.. \n");
181
182}
183
184void AliComparisonSelector::Terminate()
185{
186 // The Terminate() function is the last function to be called during
187 // a query. It always runs on the client, it can be used to present
188 // the results graphically or save the results to file.
189
190 printf ("Terminate... \n");
191 if (!fOutput) return;
192 TFile file("Output.root","recreate");
193 printf("fOutput contains the following: \n");
194 fOutput->Print();
195 printf("Trying to write the file 'Output.root'... \n");
196 fOutput->Write();
197 file.Close();
198
199
200}
201
202
203
204void AliComparisonSelector::Init(TTree *tree)
205{
206 // The Init() function is called when the selector needs to initialize
207 // a new tree or chain. Typically here the branch addresses and branch
208 // pointers of the tree will be set.
209 // It is normaly not necessary to make changes to the generated
210 // code, but the routine can be extended by the user if needed.
211 // Init() will be called many times when running on PROOF
212 // (once per file to be processed).
213
214 // Set branch addresses and branch pointers
215
216 if (!tree) return;
217 fChain = tree;
218 tree->SetBranchStatus("*",1);
219
220 if (tree->GetBranch("MC") && tree->GetBranch("RC")){
221 tree->GetBranch("MC")->SetAddress(&fInfoMC);
222 tree->GetBranch("RC")->SetAddress(&fInfoRC);
223 }
224}
225
226
227
228Bool_t AliComparisonSelector::Notify()
229{
230 // The Notify() function is called when a new file is opened. This
231 // can be either for a new TTree in a TChain or when when a new TTree
232 // is started when using PROOF. It is normaly not necessary to make changes
233 // to the generated code, but the routine can be extended by the
234 // user if needed. The return value is currently not used.
235
236 ++fFileNo;
237 const char * fname = "UNKNOWN";
238 const char * hname = gSystem->HostName();
239 if (fChain->GetCurrentFile()){
240 fname = fChain->GetCurrentFile()->GetName();
241 }
242
243
244 //
245 Info("Notify",Form("Host %s processing file no %d %s\n",hname,fFileNo,fname));
246
247 //
248 // Print statistic to log file
249 //
250 if (fname) {
251 (*fFileWatch) << endl;
252 (*fFileWatch) << hname <<"\t"
253 << fname <<"\t";
254 }
255 DumpSysInfo(-1);
256
257 return kTRUE;
258}
259
260
261void AliComparisonSelector::DumpSysInfo(Int_t entry){
262 //
263 // dump system info to log file
264 // entry - entry number in the chain
265 //
266 const char * fname = "UNKNOWN";
267 const char * hname = gSystem->HostName();
268 if (fChain->GetCurrentFile()){
269 fname = fChain->GetCurrentFile()->GetName();
270 }
271 //
272 if (fSysWatch){
273 TTimeStamp stamp;
274 CpuInfo_t cpuInfo;
275 MemInfo_t memInfo;
276 ProcInfo_t procInfo;
277
278 gSystem->GetCpuInfo(&cpuInfo, 1000);
279 gSystem->GetMemInfo(&memInfo);
280 gSystem->GetProcInfo(&procInfo);
281
282 (*fSysWatch) << hname <<"\t" // hname - hostname
283 << fname <<"\t" // fname - filename
284 << entry <<"\t" // entry - entry number
285 << stamp.GetSec()<<"\t" // time - time stamp in seconds
286 << memInfo.fMemUsed<<"\t" //
287 << memInfo.fSwapUsed<<"\t" //
288 << procInfo.fMemResident<<"\t" //
289 << procInfo.fMemVirtual<<"\t" //
290 << cpuInfo.fUser <<"\t" //
291 << cpuInfo.fSys <<"\t" //
292 << procInfo.fCpuUser<<"\t" //
293 << procInfo.fCpuSys<<"\t" //
294 << endl;
295 }
296}
297
298
299
300
36f9c31d 301
302
303
304