]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - PHOS/AliPHOSGetter.cxx
Default branch name set to Default, consistence with AliDigitizer added: new ctr...
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGetter.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id: */
17
18/* $Log:
19 29.05.2001 Yuri Kharlov:
20 Everywhere reading the treese TTree->GetEvent(i)
21 is replaced by reading the branches TBranch->GetEntry(0)
22*/
23
24//_________________________________________________________________________
25// A singleton. This class should be used in the analysis stage to get
26// reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
27// instead of directly reading them from galice.root file. This container
28// ensures, that one reads Digits, made of these particular digits, RecPoints,
29// made of these particular RecPoints, TrackSegments and RecParticles.
30// This becomes non trivial if there are several identical branches, produced with
31// different set of parameters.
32//
33// An example of how to use (see also class AliPHOSAnalyser):
34// AliPHOSGetter * gime = AliPHOSGetter::GetInstance("galice.root","test") ;
35// for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
36// AliPHOSRecParticle * part = gime->RecParticle(1) ;
37// ................
38// please->GetEvent(event) ; // reads new event from galice.root
39//
40//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
41//*-- Completely redesigned by Dmitri Peressounko March 2001
42//
43//*-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
44//*-- systematic usage of TFolders without changing the interface
45//////////////////////////////////////////////////////////////////////////////
46
47
48// --- ROOT system ---
49
50#include "TFile.h"
51#include "TTree.h"
52#include "TROOT.h"
53#include "TObjString.h"
54#include "TFolder.h"
55
56// --- Standard library ---
57#include <iostream.h>
58
59// --- AliRoot header files ---
60
61#include "AliRun.h"
62#include "AliPHOSGetter.h"
63#include "AliPHOS.h"
64#include "AliPHOSDigitizer.h"
65#include "AliPHOSSDigitizer.h"
66#include "AliPHOSClusterizer.h"
67#include "AliPHOSClusterizerv1.h"
68#include "AliPHOSTrackSegmentMaker.h"
69#include "AliPHOSTrackSegmentMakerv1.h"
70#include "AliPHOSTrackSegment.h"
71#include "AliPHOSPID.h"
72#include "AliPHOSPIDv1.h"
73#include "AliPHOSGeometry.h"
74
75ClassImp(AliPHOSGetter)
76
77 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
78
79//____________________________________________________________________________
80AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle )
81{
82 //Initialize all lists
83
84 fHeaderFile = headerFile ;
85 fSDigitsTitle = branchTitle ;
86 fDigitsTitle = branchTitle ;
87 fRecPointsTitle = branchTitle ;
88 fRecParticlesTitle = branchTitle ;
89 fTrackSegmentsTitle = branchTitle ;
90
91 fPrimaries = new TObjArray(1) ;
92
93 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
94
95 //open headers file
96 TFile * file = (TFile*) gROOT->GetFile(fHeaderFile.Data() ) ;
97
98 if(file == 0){ //if file was not opened yet, read gAlice
99 if(fHeaderFile.Contains("rfio")) // if we read file using HPSS
100 file = TFile::Open(fHeaderFile.Data(),"update") ;
101 else
102 file = new TFile(fHeaderFile.Data(),"update") ;
103
104 if (!file->IsOpen()) {
105 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot open " << fHeaderFile.Data() << endl ;
106 abort() ;
107 }
108
109 gAlice = (AliRun *) file->Get("gAlice") ;
110
111 if (!gAlice) {
112 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
113 abort() ;
114 }
115 }
116 }
117 if ( PHOS()->TreeQA() )
118 ReadTreeQA() ;
119 fDebug="";
120}
121//____________________________________________________________________________
122void AliPHOSGetter::CreateWhiteBoard() const
123{
124 // Posts a few item to the white board (folders)
125
126 // -- the geometry
127 Post(fHeaderFile, "G") ;
128
129 // -- the hits
130 Post(fHeaderFile, "H") ;
131
132}
133
134//____________________________________________________________________________
135AliPHOSGetter * AliPHOSGetter::GetInstance()
136{
137 // Returns the pointer of the unique instance already defined
138
139 AliPHOSGetter * rv = 0 ;
140 if ( fgObjGetter )
141 rv = fgObjGetter ;
142 else
143 cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
144
145 return rv ;
146}
147
148//____________________________________________________________________________
149AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
150 const char* branchTitle)
151{
152 // Creates and returns the pointer of the unique instance
153 // Must be called only when the environment has changed
154
155
156 if ( fgObjGetter ) // delete it if already exists
157 delete fgObjGetter ;
158
159 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
160
161 // Posts a few item to the white board (folders)
162 fgObjGetter->CreateWhiteBoard() ;
163
164 // Get the first event into the arrays posted on the white board
165 // branchTitle = 0, means simulation run and no event yet
166 if (branchTitle)
167 fgObjGetter->Event(0) ;
168
169 return fgObjGetter ;
170
171}
172
173//____________________________________________________________________________
174 const AliPHOS * AliPHOSGetter::PHOS() const
175{
176 // returns the PHOS object
177 return ( (AliPHOS*)gAlice->GetDetector("PHOS") );
178}
179
180//____________________________________________________________________________
181 const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const
182{
183 // retrieves the geometr from the folder
184
185 TString path("YSAlice/WhiteBoard/Geometry/PHOS/") ;
186 path += PHOS()->GetTitle() ;
187 return (AliPHOSGeometry*)gROOT->FindObjectAny(path.Data()) ;
188}
189
190//____________________________________________________________________________
191void AliPHOSGetter::Post(const char * headerFile, const char * opt, const char * name, const Int_t event) const
192{
193 // Adds a new folder for summable digits
194
195 TString foldertitle ;
196 if ( event >= 0 )
197 foldertitle += event ;
198 else
199 foldertitle = "" ;
200
201 TFolder * aliceF = (TFolder*)gROOT->FindObjectAny("YSAlice") ;
202
203 if ( strcmp(opt, "G") == 0 ) { // Geometry
204 // the hierarchy is //YSALICE/WhiteBoard/Geometry/PHOS/
205 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance(PHOS()->GetTitle(),"") ;
206 TFolder * geomF = (TFolder*)aliceF->FindObject("WhiteBoard/Geometry/PHOS") ;
207 if ( !geomF ) {
208 cerr << "ERROR: AliPHOSGetter::Post G -> Folder WhiteBoard/Geometry/PHOS/" << " not found!" << endl;
209 abort() ;
210 }
211 else
212 geomF->Add((TObject*)geom) ;
213
214 } else if ( strcmp(opt, "H") == 0 ) { // Hits
215 // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/Hits
216 TClonesArray * hits = new TClonesArray("AliPHOSHit",1000) ;
217 hits->SetName("Hits") ;
218 TFolder * hitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Hits/PHOS") ;
219 if ( !hitsF ) {
220 cerr << "ERROR: AliPHOSGetter::Post H -> Folder WhiteBoard/Hits/PHOS/" << " not found!" << endl;
221 abort() ;
222 }
223 else
224 hitsF->Add(hits) ;
225
226 } else if ( strcmp(opt, "S") == 0 ) { // summable digits
227 // the hierarchy is //YSALICE/WhiteBoard/SDigits/PHOS/headerFile/sdigitsname
228 // because you can have sdigits from several hit files for mixing
229 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1000) ;
230 TString sdigitsName ;
231 if (name)
232 sdigitsName = name ;
233 else
234 sdigitsName = "SDigits" ;
235 sdigits->SetName( sdigitsName.Data() ) ;
236 TFolder * sdigitsF = (TFolder*)aliceF->FindObject("WhiteBoard/SDigits/PHOS") ;
237 TFolder * sdigitsF2 = 0 ;
238 TString subdir(headerFile) ;
239 if ( !(sdigitsF2=(TFolder*)sdigitsF->FindObject(subdir)) )
240 sdigitsF2 = sdigitsF->AddFolder(subdir, foldertitle);
241 else {
242 if ( sdigitsF2->FindObject( sdigitsName.Data() ) ) {
243 if (fDebug.Contains("S"))
244 cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir << ", " << foldertitle
245 << " already exists!" << endl ;
246 return ;
247 }
248 }
249 if ( !sdigitsF2 ) {
250 cerr << "ERROR: AliPHOSGetter::Post S -> Folder WhiteBoard/SDigits/PHOS/" << subdir << " not created!" << endl;
251 abort() ;
252 }
253 else
254 sdigitsF2->Add(sdigits) ;
255
256 } else if ( strcmp(opt, "Ser") == 0 ) { // sdigizer
257 // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/sdigitsname
258 AliPHOSSDigitizer * sdigitizer = new AliPHOSSDigitizer() ;
259 TString sdigitsName ;
260 if (name)
261 sdigitsName = name ;
262 else
263 sdigitsName = "SDigitizer" ;
264 sdigitizer->SetName( sdigitsName.Data() ) ;
265 TTask * sdigitsF = (TTask*)aliceF->FindObject("tasks/SDigitizer") ;
266 if ( !sdigitsF ) {
267 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task tasks/SDigitizer" << " not found!" << endl;
268 abort() ;
269 }
270 TTask * phos = (TTask*)sdigitsF->GetListOfTasks()->FindObject("PHOS") ;
271 if ( !phos ) {
272 cerr <<"ERROR: AliPHOSGetter::Post Ser -> tasks/SDigitizer/PHOS" << " not found!" << endl;
273 abort() ;
274 } else {
275 AliPHOSSDigitizer * phossd = (AliPHOSSDigitizer*)phos->GetListOfTasks()->FindObject(sdigitsName.Data()) ;
276 if (phossd) {
277 if (fDebug.Contains("Ser"))
278 cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitsName.Data() << " already exists" << endl ;
279 return ;
280 } else
281 phos->Add(sdigitizer) ;
282 }
283
284 } else if ( strcmp(opt, "D") == 0 ) { // digits
285 // the hierarchy is //YSALICE/WhiteBoard/Digits/PHOS/digitsname
286 TClonesArray * digits = new TClonesArray("AliPHOSDigit",20000) ;
287 TString digitsName ;
288 if (name)
289 digitsName = name ;
290 else
291 digitsName = "Digits" ;
292 digits->SetName( digitsName.Data() ) ;
293 TFolder * digitsF = (TFolder*)aliceF->FindObject("WhiteBoard/Digits/PHOS") ;
294 if ( !digitsF ) {
295 cerr << "ERROR: AliPHOSGetter::Post D -> Folder WhiteBoard/Digits/PHOS/" << " not found!" << endl;
296 abort() ;
297 }
298 digitsF->SetTitle(foldertitle) ;
299 if ( digitsF->FindObject( digitsName.Data() ) ) {
300 if (fDebug.Contains("D"))
301 cerr <<"INFO: AliPHOSGetter::Post D -> Object " << digitsName.Data()
302 << " already exists!" << endl ;
303 return ;
304 }
305 else
306 digitsF->Add(digits) ;
307
308 } else if ( strcmp(opt, "Der") == 0 ) { // sdigizer
309 // the hierarchy is //YSALICE/tasks/Digitizer/PHOS/digitsname
310 AliPHOSDigitizer * digitizer = new AliPHOSDigitizer() ;
311 TString digitsName ;
312 if (name)
313 digitsName = name ;
314 else
315 digitsName = "Digitizer" ;
316 digitizer->SetName( digitsName.Data() ) ;
317 TTask * digitsF = (TTask*)aliceF->FindObject("tasks/Digitizer") ;
318 if ( !digitsF ) {
319 cerr << "ERROR: AliPHOSGetter::Post Der -> Task tasks/Digitizer" << " not found!" << endl;
320 abort() ;
321 }
322 TTask * phos = (TTask*)digitsF->GetListOfTasks()->FindObject("PHOS") ;
323 if ( !phos ) {
324 cerr <<"ERROR: AliPHOSGetter::Post Der -> tasks/Digitizer/PHOS" << " not found!" << endl;
325 abort() ;
326 } else {
327 AliPHOSDigitizer * phosd = (AliPHOSDigitizer*)phos->GetListOfTasks()->FindObject(digitsName.Data()) ;
328 if (phosd) {
329 if (fDebug.Contains("Der"))
330 cout << "INFO: AliPHOSGetter::Post Der -> Task " << digitsName.Data() << " already exists" << endl ;
331 return ;
332 } else
333 phos->Add(digitizer) ;
334 }
335
336 } else if ( strcmp(opt, "R") == 0 ) { // RecPoints
337 // the hierarchy is //YSALICE/WhiteBoard/RecPoints/PHOS/emc/recpointsname
338 // //YSALICE/WhiteBoard/RecPoints/PHOS/cpv/recpointsname
339 TObjArray * emcrp = new TObjArray(100) ;
340 TObjArray * cpvrp = new TObjArray(100) ;
341 TString recpointsName ;
342 if (name)
343 recpointsName = name ;
344 else
345 recpointsName = "RecPoints" ;
346 emcrp->SetName( recpointsName.Data() ) ;
347 cpvrp->SetName( recpointsName.Data() ) ;
348 TFolder * emcrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/emc") ;
349 TFolder * cpvrpF = (TFolder*)aliceF->FindObject("WhiteBoard/RecPoints/PHOS/cpv") ;
350 emcrpF->SetTitle(foldertitle) ;
351 cpvrpF->SetTitle(foldertitle) ;
352 if ( !emcrpF || !cpvrpF ) {
353 cerr << "ERROR: AliPHOSGetter::Post R -> Folder WhiteBoard/RecPoints/PHOS/emc(cpv)" << " not found!" << endl;
354 abort() ;
355 }
356 // TString title("PHOS Digits") ;
357 if ( emcrpF->FindObject( recpointsName.Data() ) || cpvrpF->FindObject( recpointsName.Data() ) ) {
358 if (fDebug.Contains("R"))
359 cerr <<"INFO: AliPHOSGetter::Post R -> Object " << recpointsName.Data()
360 << " already exists!" << endl ;
361 return ;
362 }
363 else {
364 emcrpF->Add(emcrp) ;
365 cpvrpF->Add(cpvrp) ;
366 }
367
368 } else if ( strcmp(opt, "Rer") == 0 ) { // clusterizer
369 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recpointsname
370 AliPHOSClusterizer * clusterizer;
371 if ( strstr(name, "clu-v1") != 0 )
372 clusterizer = new AliPHOSClusterizerv1() ;
373 else {
374 cerr << "ERROR: AliPHOSGetter::Post Rer -> " << name << " unknown clusterizer version" << endl ;
375 abort() ;
376 }
377 TString recpointsName ;
378 if (name)
379 recpointsName = name ;
380 else
381 recpointsName = "Clusterizer" ;
382 clusterizer->SetName( recpointsName.Data() ) ;
383 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
384 if ( !reF ) {
385 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task tasks/Reconstructioner" << " not found!" << endl;
386 abort() ;
387 }
388 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
389 if ( !phos ) {
390 cerr <<"ERROR: AliPHOSGetter::Post Rer -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
391 abort() ;
392 } else {
393 AliPHOSClusterizer * phoscl = (AliPHOSClusterizer*)phos->GetListOfTasks()->FindObject(recpointsName.Data()) ;
394 if (phoscl) {
395 if (fDebug.Contains("Rer"))
396 cout << "INFO: AliPHOSGetter::Post Rer -> Task " << recpointsName.Data() << " already exists" << endl ;
397 return ;
398 } else
399 phos->Add(clusterizer) ;
400 }
401
402 } else if ( strcmp(opt, "T") == 0 ) { //TrackSegments
403 // the hierarchy is //YSALICE/WhiteBoard/TrackSegments/PHOS/tracksegmentsname
404
405 TClonesArray * tracksegments = new TClonesArray("AliPHOSTrackSegment", 200) ;
406 TString tracksegmentsName ;
407 if (name)
408 tracksegmentsName = name ;
409 else
410 tracksegmentsName = "TrackSegments" ;
411 tracksegments->SetName( tracksegmentsName.Data() ) ;
412 TFolder * tracksegmentsF = (TFolder*)aliceF->FindObject("WhiteBoard/TrackSegments/PHOS") ;
413 tracksegmentsF->SetTitle(foldertitle) ;
414 if ( !tracksegmentsF) {
415 cerr << "ERROR: AliPHOSGetter::Post T -> Folder WhiteBoard/TrackSegments/PHOS" << " not found!" << endl;
416 abort() ;
417 }
418 if ( tracksegmentsF->FindObject( tracksegmentsName.Data() ) ) {
419 if (fDebug.Contains("T"))
420 cerr <<"INFO: AliPHOSGetter::Post T -> Object " << tracksegmentsName.Data()
421 << " already exists!" << endl ;
422 return ;
423 }
424 else
425 tracksegmentsF->Add(tracksegments) ;
426
427 } else if ( strcmp(opt, "Ter") == 0 ) { // TrackSegmentsMaker
428 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/tracksegmentsname
429 AliPHOSTrackSegmentMaker * tracksegmentmaker ;
430 if ( strstr(name, "tsm-v1") != 0 )
431 tracksegmentmaker = new AliPHOSTrackSegmentMakerv1() ;
432 else {
433 cerr << "ERROR: AliPHOSGetter::Post Ter -> " << name << " unknown track segment maker version" << endl ;
434 abort() ;
435 }
436 TString tracksegmentsName ;
437 if (name)
438 tracksegmentsName = name ;
439 else
440 tracksegmentsName = "TrackSegmentMaker" ;
441 tracksegmentmaker->SetName( tracksegmentsName.Data() ) ;
442 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
443 if ( !reF ) {
444 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task tasks/Reconstructioner" << " not found!" << endl;
445 abort() ;
446 }
447 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
448 if ( !phos ) {
449 cerr <<"ERROR: AliPHOSGetter::Post Ter -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
450 abort() ;
451 } else {
452 AliPHOSTrackSegmentMaker * phosts = (AliPHOSTrackSegmentMaker*)phos->GetListOfTasks()->FindObject(tracksegmentsName.Data()) ;
453 if (phosts) {
454 if (fDebug.Contains("Ter"))
455 cout << "INFO: AliPHOSGetter::Post Ter -> Task " << tracksegmentsName.Data() << " already exists" << endl ;
456 return ;
457 } else
458 phos->Add(tracksegmentmaker) ;
459 }
460
461 } else if ( strcmp(opt, "P") == 0 ) { // RecParticles
462 // the hierarchy is //YSALICE/WhiteBoard/RecParticles/PHOS/recparticlesname
463
464 TClonesArray * recparticles = new TClonesArray("AliPHOSRecParticle", 200) ;
465 TString recparticlesName ;
466 if (name)
467 recparticlesName = name ;
468 else
469 recparticlesName = "RecParticles" ;
470 recparticles->SetName( recparticlesName.Data() ) ;
471 TFolder * recparticlesF = (TFolder*)aliceF->FindObject("WhiteBoard/RecParticles/PHOS") ;
472 recparticlesF->SetTitle(foldertitle) ;
473 if ( !recparticlesF) {
474 cerr << "ERROR: AliPHOSGetter::Post P -> Folder WhiteBoard/RecParticles/PHOS" << " not found!" << endl;
475 abort() ;
476 }
477 if ( recparticlesF->FindObject( recparticlesName.Data() ) ) {
478 if (fDebug.Contains("P"))
479 cerr <<"INFO: AliPHOSGetter::Post P -> Object " << recparticlesName.Data()
480 << " already exists!" << endl ;
481 return ;
482 }
483 else
484 recparticlesF->Add(recparticles) ;
485
486 } else if ( strcmp(opt, "Per") == 0 ) { // PID Maker
487 // the hierarchy is //YSALICE/tasks/Reconstructionner/PHOS/recparticlesname
488 AliPHOSPID * pid ;
489 if ( strstr(name, "pid-v1") != 0 )
490 pid = new AliPHOSPIDv1() ;
491 else {
492 cerr << "ERROR: AliPHOSGetter::Post Per -> " << name << " unknown PID maker version" << endl ;
493 abort() ;
494 }
495 TString recparticlesName ;
496 if (name)
497 recparticlesName = name ;
498 else
499 recparticlesName = "PID" ;
500 pid->SetName( recparticlesName.Data() ) ;
501 TTask * reF = (TTask*)aliceF->FindObject("tasks/Reconstructioner") ;
502 if ( !reF ) {
503 cerr << "ERROR: AliPHOSGetter::Post Per -> Task tasks/Reconstructioner" << " not found!" << endl;
504 abort() ;
505 }
506 TTask * phos = (TTask*)reF->GetListOfTasks()->FindObject("PHOS") ;
507 if ( !phos ) {
508 cerr <<"ERROR: AliPHOSGetter::Post Per -> tasks/Reconstructioner/PHOS" << " not found!" << endl;
509 abort() ;
510 } else {
511 AliPHOSPID * phospid = (AliPHOSPID*)phos->GetListOfTasks()->FindObject(recparticlesName.Data()) ;
512 if (phospid) {
513 if (fDebug.Contains("Per"))
514 cout << "INFO: AliPHOSGetter::Post Per -> Task " << recparticlesName.Data() << " already exists" << endl ;
515 return ;
516 } else
517 phos->Add(pid) ;
518 }
519 }
520 else if ( strcmp(opt, "QA") == 0 ) { // Alarms
521 // the hierarchy is //YSALICE/WhiteBoard/Alarms/PHOS/
522
523 TFolder * alarmsF = new TFolder() ;
524 TString alarmsName ;
525 if (name)
526 alarmsName = name ;
527 else
528 alarmsName = "Alarm with no name" ;
529 alarmsF->SetName( alarmsName.Data() ) ;
530 alarmsF->SetTitle(foldertitle) ;
531 TFolder * qaaF = (TFolder*)aliceF->FindObject("WhiteBoard/QAAlarms") ;
532 if ( !qaaF) {
533 cerr << "ERROR: AliPHOSGetter::Post QA -> Folder WhiteBoard/QAAlarms/" << " not found!" << endl;
534 return ;
535 }
536 if ( qaaF->FindObject( alarmsName.Data() ) )
537 qaaF->RecursiveRemove( qaaF->FindObject( alarmsName.Data() ) ) ;
538
539 qaaF->Add(alarmsF) ;
540
541 }
542}
543
544//____________________________________________________________________________
545const TParticle * AliPHOSGetter::Primary(Int_t index) const
546{
547 // Return primary particle numbered by <index>
548
549 if(index < 0)
550 return 0 ;
551
552 Int_t primaryIndex = index % 10000000 ;
553 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
554
555 if ( primaryList > 0 ) {
556 cout << " Getter does not support currently Mixing of primary " << endl ;
557 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
558 return 0;
559 }
560
561 return gAlice->Particle(primaryIndex) ;
562
563}
564
565//____________________________________________________________________________
566void AliPHOSGetter::ReadTreeD()
567{
568 // Read the digit tree gAlice->TreeD()
569 if(gAlice->TreeD()== 0){
570 cerr << "ERROR: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
571 return ;
572 }
573
574 TObjArray * lob = (TObjArray*)gAlice->TreeD()->GetListOfBranches() ;
575 TIter next(lob) ;
576 TBranch * branch = 0 ;
577 TBranch * digitsbranch = 0 ;
578 TBranch * digitizerbranch = 0 ;
579 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
580
581 while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) {
582 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
583 digitsbranch = branch ;
584 phosfound = kTRUE ;
585 }
586 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
587 digitizerbranch = branch ;
588 digitizerfound = kTRUE ;
589 }
590 }
591
592 if ( !phosfound || !digitizerfound ) {
593 cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name " << fDigitsTitle << endl ;
594 return ;
595 }
596
597
598 // Post the Digits
599 if (EventNumber() == 0)
600 Post(fHeaderFile, "D", fDigitsTitle) ;
601
602 // Post the Digitizer
603 if (EventNumber() == 0)
604 Post(fHeaderFile, "Der", fDigitsTitle) ;
605
606 TClonesArray * digits = Digits(fDigitsTitle) ;
607 digits->Clear() ;
608 digitsbranch ->SetAddress(&digits) ;
609
610 AliPHOSDigitizer * digitizer = Digitizer(fDigitsTitle) ;
611 digitizerbranch->SetAddress(&digitizer) ;
612
613 digitsbranch ->GetEntry(0) ;
614 digitizerbranch->GetEntry(0) ;
615
616}
617
618//____________________________________________________________________________
619void AliPHOSGetter::ReadTreeH()
620{
621 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
622
623 if(gAlice->TreeH()== 0){
624 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
625 return ;
626 }
627
628 TBranch * hitsbranch = (TBranch*)gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS") ;
629 if ( !hitsbranch ) {
630 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
631 } else {
632 TClonesArray * hits = Hits() ;
633 hits->Clear() ;
634 hitsbranch->SetAddress(&hits) ;
635 hitsbranch->GetEntry(0) ;
636 }
637}
638
639//____________________________________________________________________________
640void AliPHOSGetter::ReadTreeQA()
641{
642 // Read the digit tree gAlice->TreeQA()
643 // so far only PHOS knows about this Tree
644
645 if(PHOS()->TreeQA()== 0){
646 cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
647 return ;
648 }
649
650 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
651 if (!qabranch) {
652 cout << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
653 return ;
654 }
655
656 // Post the QA Alarms
657 Post(fHeaderFile, "QA", "PHOS") ;
658 TFolder * alarmsF = Alarms() ;
659 alarmsF->Clear() ;
660 qabranch->SetAddress(&alarmsF) ;
661 qabranch->GetEntry(0) ;
662
663}
664
665//____________________________________________________________________________
666void AliPHOSGetter::ReadTreeR()
667{
668 // Read the reconstrunction tree gAlice->TreeR()
669
670 if(gAlice->TreeR()== 0){
671 cout << "ERROR: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
672 return ;
673 }
674 // RecPoints
675 TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ;
676 TIter next(lob) ;
677 TBranch * branch = 0 ;
678 TBranch * emcbranch = 0 ;
679 TBranch * cpvbranch = 0 ;
680 TBranch * clusterizerbranch = 0 ;
681 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
682
683 while ( (branch = (TBranch*)next()) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) ) {
684 if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
685 emcbranch = branch ;
686 phosemcrpfound = kTRUE ;
687 }
688 else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
689 cpvbranch = branch ;
690 phoscpvrpfound = kTRUE ;
691 }
692 else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), fRecPointsTitle)==0) ) {
693 clusterizerbranch = branch ;
694 clusterizerfound = kTRUE ;
695 }
696 }
697
698 if ( !phosemcrpfound || !phoscpvrpfound || !clusterizerfound ) {
699 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecPoints and/or Clusterizer with name " << fRecPointsTitle << endl ;
700 return ;
701 }
702
703 // Post the RecPoints
704 if (EventNumber() == 0)
705 Post(fHeaderFile, "R", fRecPointsTitle) ;
706
707 // Post the Clusterizer
708 // Need the version first
709 AliPHOSClusterizer * clusterizer = 0 ;
710 clusterizerbranch->SetAddress(&clusterizer) ;
711 clusterizerbranch->GetEntry(0) ;
712 TString clusterizerName(fRecPointsTitle) ;
713 clusterizerName.Append(clusterizer->Version()) ;
714 if (EventNumber() == 0)
715 Post(fHeaderFile, "Rer", clusterizerName) ;
716
717 TObjArray * emcRecPoints = EmcRecPoints(fRecPointsTitle) ;
718 emcRecPoints->Delete() ;
719 emcbranch->SetAddress(&emcRecPoints) ;
720
721 TObjArray * cpvRecPoints = CpvRecPoints(fRecPointsTitle) ;
722 cpvRecPoints->Delete() ;
723 cpvbranch->SetAddress(&cpvRecPoints) ;
724
725 delete clusterizer ;
726 clusterizer = Clusterizer(clusterizerName) ;
727 clusterizerbranch->SetAddress(&clusterizer) ;
728
729 emcbranch ->GetEntry(0) ;
730 cpvbranch ->GetEntry(0) ;
731 clusterizerbranch->GetEntry(0) ;
732
733 // TrackSegments
734 next.Reset() ;
735 TBranch * tsbranch = 0 ;
736 TBranch * tsmakerbranch = 0 ;
737 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
738
739 while ( (branch = (TBranch*)next()) && (!phostsfound || !tsmakerfound) ) {
740 if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
741 tsbranch = branch ;
742 phostsfound = kTRUE ;
743 }
744 else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) ) {
745 tsmakerbranch = branch ;
746 tsmakerfound = kTRUE ;
747 }
748 }
749
750 if ( !phostsfound || !tsmakerfound ) {
751 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name " << fTrackSegmentsTitle << endl ;
752 return ;
753 }
754
755 // Post the TrackSegments
756 if (EventNumber() == 0)
757 Post(fHeaderFile, "T", fTrackSegmentsTitle) ;
758
759 // Post the TrackSegment Maker
760 // Need the version first
761 AliPHOSTrackSegmentMaker * tsmaker = 0 ;
762 tsmakerbranch->SetAddress(&tsmaker) ;
763 tsmakerbranch->GetEntry(0) ;
764 TString tsmakerName(fTrackSegmentsTitle) ;
765 tsmakerName.Append(tsmaker->Version()) ;
766 if (EventNumber() == 0)
767 Post(fHeaderFile, "Ter", tsmakerName) ;
768
769 TClonesArray * tracksegments = TrackSegments(fTrackSegmentsTitle) ;
770 tracksegments->Clear() ;
771 tsbranch->SetAddress(&tracksegments) ;
772
773 delete tsmaker ;
774 tsmaker = TrackSegmentMaker(tsmakerName) ;
775 tsmakerbranch->SetAddress(&tsmaker) ;
776
777 tsmakerbranch ->GetEntry(0) ;
778 tsbranch ->GetEntry(0) ;
779
780 // RecParticles
781 next.Reset() ;
782 TBranch * rpabranch = 0 ;
783 TBranch * pidbranch = 0 ;
784 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
785
786 while ( (branch = (TBranch*)next()) && (!phosrpafound || !pidfound) ) {
787 if ( (strcmp(branch->GetName(), "PHOSRP")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
788 rpabranch = branch ;
789 phosrpafound = kTRUE ;
790 }
791 else if ( (strcmp(branch->GetName(), "AliPHOSPID")==0) && (strcmp(branch->GetTitle(), fRecParticlesTitle)==0) ) {
792 pidbranch = branch ;
793 pidfound = kTRUE ;
794 }
795 }
796
797 if ( !phosrpafound || !pidfound ) {
798 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name " << fRecParticlesTitle << endl ;
799 return ;
800 }
801
802 // Post the RecParticles
803 if (EventNumber() == 0)
804 Post(fHeaderFile, "P", fRecParticlesTitle) ;
805
806 // Post the PID
807 // Need the version first
808 AliPHOSPID * pid = 0 ;
809 pidbranch->SetAddress(&pid) ;
810 pidbranch->GetEntry(0) ;
811 TString pidName(fRecParticlesTitle) ;
812 pidName.Append(pid->Version()) ;
813 if (EventNumber() == 0)
814 Post(fHeaderFile, "Per", pidName) ;
815
816 TClonesArray * recParticles = RecParticles(fRecParticlesTitle) ;
817 recParticles->Clear() ;
818 rpabranch->SetAddress(&recParticles) ;
819
820 delete pid ;
821 pid = PID(pidName) ;
822 pidbranch->SetAddress(&pid) ;
823
824 pidbranch ->GetEntry(0) ;
825 rpabranch ->GetEntry(0) ;
826
827}
828
829//____________________________________________________________________________
830void AliPHOSGetter::ReadTreeS()
831{
832 // Read the summable digits tree gAlice->TreeS()
833
834 if(gAlice->TreeS()== 0){
835 cerr << "ERROR: AliPHOSGetter::ReadTreeS -> Cannot find TreeS " << endl ;
836 return ;
837 }
838
839 TObjArray * lob = (TObjArray*)gAlice->TreeS()->GetListOfBranches() ;
840 TIter next(lob) ;
841 TBranch * branch = 0 ;
842 TBranch * sdigitsbranch = 0 ;
843 TBranch * sdigitizerbranch = 0 ;
844 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
845
846 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
847 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
848 sdigitsbranch = branch ;
849 phosfound = kTRUE ;
850 }
851 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
852 sdigitizerbranch = branch ;
853 sdigitizerfound = kTRUE ;
854 }
855 }
856
857 if ( !phosfound || !sdigitizerfound ) {
858 cout << "WARNING: AliPHOSGetter::ReadTreeS -> Cannot find SDigits and/or SDigitizer with name " << fSDigitsTitle << endl ;
859 return ;
860 }
861
862 // -- the SDigits
863 if (EventNumber() == 0)
864 Post(fHeaderFile, "S", fSDigitsTitle) ;
865
866 // Post the SDigitizer
867 if (EventNumber() == 0)
868 Post(fHeaderFile, "Ser", fSDigitsTitle) ;
869
870 TClonesArray * sdigits = SDigits(fSDigitsTitle) ;
871 sdigits->Clear() ;
872 sdigitsbranch->SetAddress(&sdigits) ;
873
874 AliPHOSSDigitizer * sdigitizer = SDigitizer(fSDigitsTitle) ;
875 sdigitizerbranch->SetAddress(&sdigitizer) ;
876
877 sdigitsbranch->GetEvent(0) ;
878 sdigitizerbranch->GetEvent(0) ;
879
880}
881
882//____________________________________________________________________________
883void AliPHOSGetter::ReadPrimaries()
884{
885 // Reads specific branches of primaries
886
887 fNPrimaries = gAlice->GetNtrack();
888
889 // //Check, is it necessary to open new files
890 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
891 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
892// Int_t input ;
893// for(input = 0; input < filenames->GetEntriesFast(); input++){
894
895// TObjString * filename = (TObjString *) filenames->At(input) ;
896
897// //Test, if this file already open
898// TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
899// if(file == 0)
900// file = new TFile( filename->GetString()) ;
901// file->cd() ;
902
903// // Get Kine Tree from file
904// // char treeName[20];
905// // sprintf(treeName,"TreeK%d",events->At(input));
906// // TTree * treeK = (TTree*)gDirectory->Get(treeName);
907// // if (treeK)
908// // treeK->SetBranchAddress("Particles", &fParticleBuffer);
909// // else
910// // cout << "AliPHOSGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
911
912// // // Create the particle stack
913// // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
914// // // Build the pointer list
915// // if(fParticleMap) { <----
916// // fParticleMap->Clear();
917// // fParticleMap->Expand(treeK->GetEntries());
918// // } else
919// // fParticleMap = new TObjArray(treeK->GetEntries());
920
921// // From gAlice->Particle(i)
922
923
924// // if(!(*fParticleMap)[i]) {
925// // Int_t nentries = fParticles->GetEntries();
926
927// // // algorithmic way of getting entry index
928// // // (primary particles are filled after secondaries)
929// // Int_t entry;
930// // if (i<fHeader.GetNprimary())
931// // entry = i+fHeader.GetNsecondary();
932// // else
933// // entry = i-fHeader.GetNprimary();
934
935// // // only check the algorithmic way and give
936// // // the fatal error if it is wrong
937// // if (entry != fParticleFileMap[i]) {
938// // Fatal("Particle",
939// // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
940// // entry, fParticleFileMap[i]);
941// // }
942
943// // fTreeK->GetEntry(fParticleFileMap[i]);
944// // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
945// // fParticleMap->AddAt((*fParticles)[nentries],i);
946// // }
947// // return (TParticle *) (*fParticleMap)[i];
948
949
950
951// }
952
953
954// //scan over opened files and read corresponding TreeK##
955
956 return ;
957}
958//____________________________________________________________________________
959void AliPHOSGetter::Event(Int_t event)
960{
961 // Reads the content of all Tree's S, D and R
962
963 if ( event > gAlice->TreeE()->GetEntries() ) {
964 cerr << "ERROR: AliPHOSGetter::Event -> There are only " << gAlice->TreeE()->GetEntries() << " events in this file" << endl ;
965 return ;
966 }
967
968 gAlice->GetEvent(event) ;
969 gAlice->SetEvent(event) ;
970
971 ReadTreeH() ;
972 ReadTreeS() ;
973 ReadTreeD() ;
974 ReadTreeR() ;
975 ReadPrimaries() ;
976}
977
978//____________________________________________________________________________
979const TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
980{
981 // get the object named "what" from the folder
982 // folders are named like //YSAlice/WhiteBoard/what/PHOS/name
983
984 if ( file.IsNull() )
985 file = fHeaderFile ;
986 TString path("WhiteBoard/") ;
987 if ( name.IsNull() ) {
988 if ( what.CompareTo("Hits") == 0 ) {
989 path += what ;
990 path += "/PHOS/";
991 path += what ;
992 }
993 else if ( what.CompareTo("SDigits") == 0 ) {
994 path += what ;
995 path += "/PHOS/";
996 path += file ;
997 path += "/" ;
998 path += fSDigitsTitle ;
999 }
1000 else if ( what.CompareTo("Digits") == 0 ){
1001 path += what ;
1002 path += "/PHOS/";
1003 path += fDigitsTitle ;
1004 }
1005 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1006 path += "RecPoints/PHOS/";
1007 path += "emc/" ;
1008 path += fRecPointsTitle ;
1009 }
1010 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1011 path += "RecPoints/PHOS/";
1012 path += "cpv/" ;
1013 path += fRecPointsTitle ;
1014 }
1015 else if ( what.CompareTo("TrackSegments") == 0 ) {
1016 path += "TrackSegments/PHOS/";
1017 path += fTrackSegmentsTitle ;
1018 }
1019 else if ( what.CompareTo("RecParticles") == 0 ) {
1020 path += "RecParticles/PHOS/";
1021 path += fRecParticlesTitle ;
1022 }
1023 else if ( what.CompareTo("Alarms") == 0 ) {
1024 path += "QAAlarms/PHOS";
1025 }
1026 }
1027 else {
1028 if ( what.CompareTo("SDigits") == 0 ) {
1029 path += what ;
1030 path += "/PHOS/";
1031 path += file ;
1032 path += "/" ;
1033 path += name ;
1034 }
1035 else if ( what.CompareTo("Digits") == 0 ) {
1036 path += what ;
1037 path += "/PHOS/";
1038 path += name ;
1039 }
1040 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1041 path += "RecPoints/PHOS/";
1042 path += "emc/" ;
1043 path += name ;
1044 }
1045 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1046 path += "RecPoints/PHOS/";
1047 path += "cpv/" ;
1048 path += name ;
1049 }
1050 else if ( what.CompareTo("TrackSegments") == 0 ) {
1051 path += "TrackSegments/PHOS/";
1052 path += name ;
1053 }
1054 else if ( what.CompareTo("RecParticles") == 0 ) {
1055 path += "RecParticles/PHOS/";
1056 path += name ;
1057 }
1058 else if ( what.CompareTo("Alarms") == 0 ) {
1059 path += "QAAlarms/PHOS/";
1060 path += name ;
1061 }
1062 }
1063 path.Prepend("YSAlice/") ;
1064 TObject * phosO = (TObject*)gROOT->FindObjectAny(path) ;
1065 if (!phosO) {
1066 cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << path << " not found!" << endl ;
1067 abort() ;
1068 }
1069 return phosO ;
1070}
1071
1072//____________________________________________________________________________
1073const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
1074{
1075 // get the TTask named "what" from the folder
1076 // folders are named like //YSAlice/Tasks/what/PHOS/name
1077
1078 TString path("tasks") ;
1079
1080 if ( what.CompareTo("SDigitizer") == 0 )
1081 path += "/SDigitizer" ;
1082 else if ( what.CompareTo("Digitizer") == 0 )
1083 path += "/Digitizer" ;
1084 else if ( what.CompareTo("Clusterizer") == 0 )
1085 path += "/Reconstructioner" ;
1086 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1087 path += "/Reconstructioner" ;
1088 else if ( what.CompareTo("PID") == 0 )
1089 path += "/Reconstructioner" ;
1090 else if ( what.CompareTo("QATasks") == 0 )
1091 path += "/QA" ;
1092
1093 TFolder * aliceF = (TFolder*)gROOT ->FindObjectAny("YSAlice") ;
1094 TTask * aliceT = (TTask*) aliceF->FindObject(path) ;
1095
1096 if (!aliceT) {
1097 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << path << " not found!" << endl ;
1098 abort() ;
1099 }
1100
1101 TTask * phosT = (TTask*) aliceT->GetListOfTasks()->FindObject("PHOS") ;
1102 if (!phosT) {
1103 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << path << "/PHOS not found!" << endl ;
1104 abort() ;
1105 }
1106 TList * l = phosT->GetListOfTasks() ;
1107
1108 if (what.CompareTo("SDigitizer") == 0) {
1109 if ( name.IsNull() )
1110 name = fSDigitsTitle ;
1111 } else if (what.CompareTo("Digitizer") == 0){
1112 if ( name.IsNull() )
1113 name = fDigitsTitle ;
1114 } else if (what.CompareTo("Clusterizer") == 0){
1115 if ( name.IsNull() )
1116 name = fRecPointsTitle ;
1117 }
1118 else if (what.CompareTo("TrackSegmentMaker") == 0){
1119 if ( name.IsNull() )
1120 name = fTrackSegmentsTitle ;
1121 }
1122 else if (what.CompareTo("PID") == 0){
1123 if ( name.IsNull() )
1124 name = fRecParticlesTitle ;
1125 }
1126 else if (what.CompareTo("QATasks") == 0){
1127 if ( name.IsNull() )
1128 return phosT ;
1129 }
1130
1131 TTask * task = (TTask*)l->FindObject(name) ;
1132
1133 if (!task)
1134 cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << path << "/" << name << " not found!" << endl ;
1135
1136 return task ;
1137}