1. Added time
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGetter.cxx
CommitLineData
ffa6d63b 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:
d75bea67 19 29.05.2001 Yuri Kharlov:
20 Everywhere reading the treese TTree->GetEvent(i)
21 is replaced by reading the branches TBranch->GetEntry(0)
ffa6d63b 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
d75bea67 31// different set of parameters.
ffa6d63b 32//
33// An example of how to use (see also class AliEMCALAnalyser):
34// AliEMCALGetter * gime = AliEMCALGetter::GetInstance("galice.root","test") ;
d75bea67 35// for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
36// AliEMCALRecParticle * part = gime->RecParticle(1) ;
ffa6d63b 37// ................
38// please->GetEvent(event) ; // reads new event from galice.root
39//
d75bea67 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 AliEMCALIndexToObject and make
44//*-- systematic usage of TFolders without changing the interface
ffa6d63b 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 "AliConfig.h"
63#include "AliEMCALGetter.h"
64#include "AliEMCALv1.h"
65#include "AliEMCALDigitizer.h"
66#include "AliEMCALSDigitizer.h"
d75bea67 67//#include "AliEMCALClusterizer.h"
68//#include "AliEMCALClusterizerv1.h"
69//#include "AliEMCALTrackSegmentMaker.h"
70//#include "AliEMCALTrackSegmentMakerv1.h"
71//#include "AliEMCALTrackSegment.h"
72//#include "AliEMCALPID.h"
73//#include "AliEMCALPIDv1.h"
ffa6d63b 74#include "AliEMCALGeometry.h"
75
76ClassImp(AliEMCALGetter)
77
78 AliEMCALGetter * AliEMCALGetter::fgObjGetter = 0 ;
79
80//____________________________________________________________________________
81AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* branchTitle )
82{
83 //Initialize all lists
84
85 fHeaderFile = headerFile ;
86 fBranchTitle = branchTitle ;
87 fSDigitsTitle = branchTitle ;
88 fDigitsTitle = branchTitle ;
d75bea67 89 //fRecPointsTitle = branchTitle ;
90 //fRecParticlesTitle = branchTitle ;
91 //fTrackSegmentsTitle = branchTitle ;
ffa6d63b 92
93 fPrimaries = new TObjArray(1) ;
d75bea67 94
95 fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
ffa6d63b 96 fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
97 fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
98 fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
d75bea67 99 //fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
100 //fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
ffa6d63b 101 fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
102
103 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
104
105 //open headers file
106 TFile * file = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
107
108 if(file == 0){ //if file was not opened yet, read gAlice
109 if(fHeaderFile.Contains("rfio")) // if we read file using HPSS
110 file = TFile::Open(fHeaderFile.Data(),"update") ;
111 else
112 file = new TFile(fHeaderFile.Data(),"update") ;
113
114 if (!file->IsOpen()) {
115 cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot open " << fHeaderFile.Data() << endl ;
116 abort() ;
117 }
118
119 gAlice = static_cast<AliRun *>(file->Get("gAlice")) ;
ffa6d63b 120 }
d75bea67 121 }
ffa6d63b 122
d75bea67 123 if (!gAlice) {
124 cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
125 abort() ;
126 }
127 if (!EMCAL()) {
128 if (fDebug)
129 cout << "INFO: AliEMCALGetter -> Posting EMCAL to Folders" << endl ;
130 AliConfig * conf = AliConfig::Instance() ;
131 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("EMCAL"))) ;
132 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("EMCAL"))) ;
ffa6d63b 133 }
d75bea67 134
135 fDebug=0;
ffa6d63b 136}
137//____________________________________________________________________________
138AliEMCALGetter::~AliEMCALGetter(){
139
140}
141
142//____________________________________________________________________________
143void AliEMCALGetter::CreateWhiteBoard() const
144{
145
146}
147
148//____________________________________________________________________________
149AliEMCALGetter * AliEMCALGetter::GetInstance()
150{
151 // Returns the pointer of the unique instance already defined
152
153 AliEMCALGetter * rv = 0 ;
154 if ( fgObjGetter )
155 rv = fgObjGetter ;
156 else
157 cout << "AliEMCALGetter::GetInstance ERROR: not yet initialized" << endl ;
158
159 return rv ;
160}
161
162//____________________________________________________________________________
163AliEMCALGetter * AliEMCALGetter::GetInstance(const char* headerFile,
164 const char* branchTitle)
165{
166 // Creates and returns the pointer of the unique instance
167 // Must be called only when the environment has changed
168
169 if ( fgObjGetter )
170 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0) &&
171 (fgObjGetter->fHeaderFile.CompareTo(headerFile)==0))
172 return fgObjGetter ;
173 else
174 fgObjGetter->~AliEMCALGetter() ; // delete it if already exists another version
175
176 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle) ;
177
178 // Posts a few item to the white board (folders)
179 // fgObjGetter->CreateWhiteBoard() ;
180
181 return fgObjGetter ;
182
183}
184
185//____________________________________________________________________________
d75bea67 186const AliEMCALv1 * AliEMCALGetter::EMCAL()
ffa6d63b 187{
188 // returns the EMCAL object
d75bea67 189 AliEMCALv1 * emcal = dynamic_cast<AliEMCALv1*>(fModuleFolder->FindObject("EMCAL")) ;
ffa6d63b 190 if (!emcal)
d75bea67 191 if (fDebug)
ffa6d63b 192 cout << "WARNING: AliEMCALGetter::EMCAL -> EMCAL module not found in Folders" << endl ;
193 return emcal ;
194}
195
196//____________________________________________________________________________
197const AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
198{
199 AliEMCALGeometry * rv = 0 ;
200 if (EMCAL() )
d75bea67 201 rv = EMCAL()->GetGeometry() ;
ffa6d63b 202 return rv ;
203}
204
205//____________________________________________________________________________
206Bool_t AliEMCALGetter::PostHits(void) const
207{ //------- Hits ----------------------
208
209 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
210
211 TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
212 if ( !emcalFolder ) {
d75bea67 213 if (fDebug) {
ffa6d63b 214 cout << "WARNING: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
215 cout << "INFO: AliEMCALGetter::Post H -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
d75bea67 216 }
ffa6d63b 217 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
218 }
219 TClonesArray *hits= new TClonesArray("AliEMCALHit",1000) ;
220 hits->SetName("Hits") ;
221 emcalFolder->Add(hits) ;
222
223 return kTRUE;
224}
225
226//____________________________________________________________________________
227void * AliEMCALGetter::HitsRef(void) const
228{ //------- Hits ----------------------
229
230
231 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
232 if ( !fHitsFolder ) {
233 cerr << "ERROR: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
234 return 0;
235 }
236
237 TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
238 if ( !emcalFolder ) {
239 cerr << "ERROR: AliEMCALGetter::Post HRef -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
240 return 0;
241 }
242
243 TObject * h = emcalFolder->FindObject("Hits") ;
244 if(!h) {
245 cerr << "ERROR: AliEMCALGetter::HRef -> " << emcalFolder->GetName() << "/Hits not found !" << endl ;
246 return 0 ;
247 }
248 else
249 return static_cast<void *>(emcalFolder->GetListOfFolders()->GetObjectRef(h)) ;
250}
251
252//____________________________________________________________________________
253Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const
254{ //---------- SDigits -------------------------
255
256
257 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
258 // because you can have sdigits from several hit files for mixing
259
260 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
261 if ( !emcalFolder ) {
d75bea67 262 if (fDebug) {
ffa6d63b 263 cout << "WARNING: AliEMCALGetter::Post S -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
264 cout << "INFO: AliEMCALGetter::Post S -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
d75bea67 265 }
ffa6d63b 266 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
267 }
268 TString subdir(headerFile) ;
269 TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ;
270 if ( !emcalSubFolder )
271 emcalSubFolder = emcalFolder->AddFolder(subdir, "");
272
273 TObject * sd = emcalSubFolder->FindObject(name);
274 if ( sd ) {
d75bea67 275 if (fDebug)
ffa6d63b 276 cerr <<"INFO: AliEMCALGetter::Post S -> Folder " << subdir
277 << " already exists!" << endl ;
278 }else{
d75bea67 279 TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
ffa6d63b 280 sdigits->SetName(name) ;
281 emcalSubFolder->Add(sdigits) ;
282 }
283
284 return kTRUE;
285}
286//____________________________________________________________________________
287void * AliEMCALGetter::SDigitsRef(const char * name, const char * file) const
288{ //------- SDigits ----------------------
289
290 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
291
292 if ( !fSDigitsFolder ) {
293 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
294 return 0;
295 }
296
297 TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
298 if ( !emcalFolder ) {
299 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
300 return 0;
301 }
302
303 TFolder * emcalSubFolder = 0 ;
304 if(file)
305 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
306 else
307 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
308
309 if(!emcalSubFolder) {
310 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/EMCAL/" << file << "not found!" << endl;
311 return 0;
312 }
313
314 TObject * dis = emcalSubFolder->FindObject(name) ;
315 if(!dis)
316 return 0 ;
317 else
318 return static_cast<void *>(emcalSubFolder->GetListOfFolders()->GetObjectRef(dis)) ;
319
320}
321
322//____________________________________________________________________________
323Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const
324{ //---------- SDigitizer -------------------------
325
326 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
327
328
329 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
330
331 if ( !sd ) {
332 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
333 return kFALSE ;
334 }
335 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
336 if ( !emcal ) {
d75bea67 337 if (fDebug) {
ffa6d63b 338 cout <<"WARNING: AliEMCALGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
339 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL/" << endl;
d75bea67 340 }
ffa6d63b 341 emcal = new TTask("EMCAL", "") ;
342 sd->Add(emcal) ;
343 }
344 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
345 if (emcalsd) {
d75bea67 346 if (fDebug)
ffa6d63b 347 cout << "INFO: AliEMCALGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
348 emcal->GetListOfTasks()->Remove(emcalsd) ;
349 }
350 emcal->Add(sdigitizer) ;
351 return kTRUE;
352
353}
354
355//____________________________________________________________________________
356void * AliEMCALGetter::SDigitizerRef(const char * name) const
357{
358
359 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
360 if ( !sd ) {
361 cerr << "ERROR: AliEMCALGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
362 abort();
363 }
364
365 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
366 if ( !emcal ) {
367 cerr <<"ERROR: AliEMCALGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/EMCAL not found!" << endl;
368 abort();
369 }
370
371 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
372
373 return static_cast<void *>(emcal->GetListOfTasks()->GetObjectRef(task)) ;
374
375}
376
377//____________________________________________________________________________
378Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const
379{ //---------- SDigitizer -------------------------
380
381 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
382
383
384 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
385 if ( !sd ) {
386 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
387 return kFALSE ;
388 }
389
390 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
391 if ( !emcal ) {
d75bea67 392 if (fDebug) {
ffa6d63b 393 cout <<"WARNING: AliEMCALGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
394 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL" << endl;
d75bea67 395 }
ffa6d63b 396 emcal = new TTask("EMCAL", "") ;
397 sd->Add(emcal) ;
398 }
399
400 TString sdname(name) ;
401 sdname.Append(":") ;
402 sdname.Append(file);
403 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname ));
404 if (!emcalsd) {
405 emcalsd = new AliEMCALSDigitizer() ;
406 //Note, we can not call constructor with parameters: it will call Getter and scrud up everething
407 emcalsd->SetName(sdname) ;
408 emcalsd->SetTitle(file) ;
409 emcal->Add(emcalsd) ;
410 }
411 return kTRUE;
412
413}
414
415//____________________________________________________________________________
416Bool_t AliEMCALGetter::PostDigits(const char * name) const
417{ //---------- Digits -------------------------
418
419 // the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
420
421 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
422
423 if ( !emcalFolder ) {
d75bea67 424 if (fDebug) {
ffa6d63b 425 cout << "WARNING: AliEMCALGetter::Post D -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
426 cout << "INFO: AliEMCALGetter::Post D -> Adding Folder //" << fDigitsFolder << "/EMCAL/" << endl;
d75bea67 427 }
ffa6d63b 428 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
429 }
430
431 TObject* dig = emcalFolder->FindObject( name ) ;
432 if ( !dig ) {
433 TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
434 digits->SetName(name) ;
435 emcalFolder->Add(digits) ;
436 }
437 return kTRUE;
438}
439
440//____________________________________________________________________________
441void * AliEMCALGetter::DigitsRef(const char * name) const
442{ //------- Digits ----------------------
443
444 // the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
445
446 if ( !fDigitsFolder ) {
447 cerr << "ERROR: AliEMCALGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
448 return 0;
449 }
450
451 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
452 if ( !emcalFolder ) {
453 cerr << "ERROR: AliEMCALGetter::DRef -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
454 return 0;
455 }
456
457 TObject * d = emcalFolder->FindObject(name) ;
458 if(!d)
459 return 0 ;
460 else
461 return static_cast<void *>(emcalFolder->GetListOfFolders()->GetObjectRef(d)) ;
462
463}
464
465//____________________________________________________________________________
466Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const
467{ //---------- Digitizer -------------------------
468
469 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
470
471 if ( !sd ) {
472 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
473 return kFALSE ;
474 }
475 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
476 if ( !emcal ) {
d75bea67 477 if (fDebug) {
ffa6d63b 478 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
479 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
d75bea67 480 }
ffa6d63b 481 emcal = new TTask("EMCAL", "") ;
482 sd->Add(emcal) ;
483 }
484
485 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ;
486 if (emcald) {
487 emcald->Delete() ;
488 emcal->GetListOfTasks()->Remove(emcald) ;
489 }
490 emcal->Add(digitizer) ;
491 return kTRUE;
492}
493
494//____________________________________________________________________________
495Bool_t AliEMCALGetter::PostDigitizer(const char * name) const
496{ //---------- Digitizer -------------------------
497
498 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
499
500 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
501 if ( !d ) {
502 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
503 return kFALSE ;
504 }
505
506 TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ;
507 if ( !emcal ) {
d75bea67 508 if (fDebug) {
ffa6d63b 509 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
510 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
d75bea67 511 }
ffa6d63b 512 emcal = new TTask("EMCAL", "") ;
513 d->Add(emcal) ;
514}
515
516 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ;
517 if (!emcald) {
518 emcald = new AliEMCALDigitizer() ;
519 emcald->SetName(fDigitsTitle) ;
520 emcald->SetTitle(fHeaderFile) ;
521 emcal->Add(emcald) ;
522 }
523 return kTRUE;
524}
525
526//____________________________________________________________________________
527void * AliEMCALGetter::DigitizerRef(const char * name) const
528{
529 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
530 if ( !sd ) {
531 cerr << "ERROR: AliEMCALGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
532 abort();
533 }
534
535 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
536 if ( !emcal ) {
537 cerr <<"ERROR: AliEMCALGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
538 abort();
539 }
540
541 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
542
543 return static_cast<void *>(emcal->GetListOfTasks()->GetObjectRef(task)) ;
544
545}
546
d75bea67 547//____________________________________________________________________________
548/*
549Bool_t AliEMCALGetter::PostRecPoints(const char * name) const
550{ // -------------- RecPoints -------------------------------------------
551
552 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/EMCARecPoints/name
553 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/CPVRecPoints/name
554
555 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
556
557 if ( !emcalFolder ) {
558 if (fDebug) {
559 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
560 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
561 }
562 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
563 }
564
565 // EMCA RecPoints
566 TFolder * emcalRPoEMCAFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("EMCARecPoints")) ;
567 if ( !emcalRPoEMCAFolder ) {
568 if (fDebug) {
569 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/EMCARecPoints/ not found!" << endl;
570 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/EMCARecPoints not found!" << endl;
571 }
572 emcalRPoEMCAFolder = emcalFolder->AddFolder("EMCARecPoints", "EMCA RecPoints from EMCAL") ;
573 }
574
575 TObject * erp = emcalFolder->FindObject( name ) ;
576 if ( !erp ) {
577 TObjArray * emcrp = new TObjArray(100) ;
578 emcrp->SetName(name) ;
579 emcalRPoEMCAFolder->Add(emcrp) ;
580 }
581
582 // CPV RecPoints
583 TFolder * emcalRPoCPVFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("CPVRecPoints")) ;
584 if ( !emcalRPoCPVFolder ) {
585 if (fDebug) {
586 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/CPVRecPoints/ not found!" << endl;
587 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/CPVRecPoints/" << endl;
588 }
589 emcalRPoCPVFolder = emcalFolder->AddFolder("CPVRecPoints", "CPV RecPoints from EMCAL") ;
590 }
591
592 TObject * crp = emcalRPoCPVFolder->FindObject( name ) ;
593 if ( !crp ) {
594 TObjArray * cpvrp = new TObjArray(100) ;
595 cpvrp->SetName(name) ;
596 emcalRPoCPVFolder->Add(cpvrp) ;
597 }
598 return kTRUE;
599}
600
601//____________________________________________________________________________
602void * AliEMCALGetter::EmcRecPointsRef(const char * name) const
603{ // -------------- RecPoints -------------------------------------------
604
605 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/EMCARecPoints/name
606
607 if ( !fRecoFolder ) {
608 cerr << "ERROR: AliEMCALGetter::EmcRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
609 return 0 ;
610 }
611
612 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/EMCARecPoints")) ;
613 if ( !emcalFolder ) {
614 cerr << "ERROR: AliEMCALGetter::EmcRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/EMCARecPoints/ not found!" << endl;
615 return 0;
616 }
617
618
619 TObject * erp = emcalFolder->FindObject(name ) ;
620 if ( !erp ) {
621 return 0 ;
622 }
623 return static_cast<void *>(emcalFolder->GetListOfFolders()->GetObjectRef(erp)) ;
624
625}
626
627//____________________________________________________________________________
628void * AliEMCALGetter::CpvRecPointsRef(const char * name) const
629{ // -------------- RecPoints -------------------------------------------
630
631 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/CPVRecPoints/name
632
633 if ( !fRecoFolder ) {
634 cerr << "ERROR: AliEMCALGetter::EmcRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
635 return 0 ;
636 }
637
638 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/CPVRecPoints")) ;
639 if ( !emcalFolder ) {
640 cerr << "ERROR: AliEMCALGetter::CpvRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/CPVRecPoints/" << endl;
641 return 0;
642 }
643
644 TObject * crp = emcalFolder->FindObject(name ) ;
645 if ( !crp ) {
646 return 0 ;
647 }
648 return static_cast<void *>(emcalFolder->GetListOfFolders()->GetObjectRef(crp)) ;
649
650}
651
652//____________________________________________________________________________
653Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizer * clu) const
654{ // ------------------ AliEMCALClusterizer ------------------------
655
656 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
657
658 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
659
660 if ( !tasks ) {
661 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
662 return kFALSE ;
663 }
664
665 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
666 if ( !emcal ) {
667 if (fDebug) {
668 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
669 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
670 }
671 emcal = new TTask("EMCAL", "") ;
672 tasks->Add(emcal) ;
673 }
674
675 AliEMCALClusterizer * emcalcl = dynamic_cast<AliEMCALClusterizer*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ;
676 if (emcalcl) {
677 if (fDebug)
678 cout << "INFO: AliEMCALGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
679 emcalcl->Delete() ;
680 emcal->GetListOfTasks()->Remove(emcalcl) ;
681 }
682 emcal->Add(clu) ;
683 return kTRUE;
684}
685
686//____________________________________________________________________________
687void * AliEMCALGetter::ClusterizerRef(const char * name) const
688{ // ------------------ AliEMCALClusterizer ------------------------
689
690 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
691
692 if ( !tasks ) {
693 cerr << "ERROR: AliEMCALGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
694 return kFALSE ;
695 }
696
697 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
698 if ( !emcal ) {
699 cerr <<"WARNING: AliEMCALGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
700 return 0 ;
701 }
702
703 TList * l = emcal->GetListOfTasks() ;
704 TIter it(l) ;
705 TTask * task ;
706 TTask * clu = 0 ;
707 TString cluname(name) ;
708 cluname+=":clu-" ;
709 while((task = static_cast<TTask *>(it.Next()) )){
710 TString taskname(task->GetName()) ;
711 if(taskname.BeginsWith(cluname)){
712 clu = task ;
713 break ;
714 }
715 }
716
717 if(clu)
718 return static_cast<void *>(l->GetObjectRef(clu)) ;
719 else
720 return 0 ;
721}
722
723//____________________________________________________________________________
724Bool_t AliEMCALGetter::PostClusterizer(const char * name) const
725{ // ------------------ AliEMCALClusterizer ------------------------
726
727 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
728
729 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
730
731 if ( !tasks ) {
732 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
733 return kFALSE ;
734 }
735
736 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
737 if ( !emcal ) {
738 if (fDebug) {
739 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
740 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
741 }
742 emcal = new TTask("EMCAL", "") ;
743 tasks->Add(emcal) ;
744 }
745
746 AliEMCALClusterizer * emcalcl = new AliEMCALClusterizerv1() ;
747 TString clun(name) ;
748 clun+=":clu-v1" ;
749 emcalcl->SetName(clun) ;
750 emcal->Add(emcalcl) ;
751 return kTRUE;
752
753}
754
755//____________________________________________________________________________
756Bool_t AliEMCALGetter::PostTrackSegments(const char * name) const
757{ // ---------------TrackSegments -----------------------------------
758
759 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
760
761 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
762
763 if ( !emcalFolder ) {
764 if (fDebug) {
765 cout << "WARNING: AliEMCALGetter::Post TS -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
766 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL" << endl;
767 }
768 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
769 }
770
771 TFolder * emcalTSFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TrackSegments")) ;
772 if ( !emcalTSFolder ) {
773 if (fDebug) {
774 cout << "WARNING: AliEMCALGetter::Post TS -> Folder//" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
775 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL/TrackSegments/" << endl;
776 }
777 emcalTSFolder = emcalFolder->AddFolder("TrackSegments", "TrackSegments from EMCAL") ;
778 }
779
780 TObject * tss = emcalTSFolder->FindObject( name ) ;
781 if (!tss) {
782 TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ;
783 ts->SetName(name) ;
784 emcalTSFolder->Add(ts) ;
785 }
786 return kTRUE;
787}
788
789//____________________________________________________________________________
790void * AliEMCALGetter::TrackSegmentsRef(const char * name) const
791{ // ---------------TrackSegments -----------------------------------
792
793 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
794
795 if ( !fRecoFolder ) {
796 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "not found!" << endl;
797 return 0 ;
798 }
799
800 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
801 if ( !emcalFolder ) {
802 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
803 return 0;
804 }
805
806 TObject * tss = emcalFolder->FindObject(name) ;
807 if (!tss) {
808 return 0 ;
809 }
810 return static_cast<void *>(emcalFolder->GetListOfFolders()->GetObjectRef(tss)) ;
811}
812
813//____________________________________________________________________________
814Bool_t AliEMCALGetter::PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsmaker) const
815{ //------------Track Segment Maker ------------------------------
816
817 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
818
819 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
820
821 if ( !tasks ) {
822 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
823 return kFALSE ;
824 }
825
826 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
827 if ( !emcal ) {
828 if (fDebug) {
829 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
830 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
831 }
832 emcal = new TTask("EMCAL", "") ;
833 tasks->Add(emcal) ;
834 }
835
836 AliEMCALTrackSegmentMaker * emcalts =
837 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
838 if (emcalts) {
839 emcalts->Delete() ;
840 emcal->GetListOfTasks()->Remove(emcalts) ;
841 }
842 emcal->Add(tsmaker) ;
843 return kTRUE;
844
845}
846//____________________________________________________________________________
847Bool_t AliEMCALGetter::PostTrackSegmentMaker(const char * name) const
848{ //------------Track Segment Maker ------------------------------
849
850 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
851
852
853 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
854
855 if ( !tasks ) {
856 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
857 return kFALSE ;
858 }
859
860 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
861 if ( !emcal ) {
862 if (fDebug) {
863 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
864 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
865 }
866 emcal = new TTask("EMCAL", "") ;
867 tasks->Add(emcal) ;
868 }
869
870 AliEMCALTrackSegmentMaker * emcalts =
871 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(name)) ;
872 if (!emcalts) {
873 emcalts = new AliEMCALTrackSegmentMakerv1() ;
874 TString tsn(name);
875 tsn+=":tsm-v1" ;
876 emcalts->SetName(tsn) ;
877 emcal->Add(emcalts) ;
878 }
879 return kTRUE;
880
881}
882
883//____________________________________________________________________________
884void * AliEMCALGetter::TSMakerRef(const char * name) const
885{ //------------Track Segment Maker ------------------------------
886
887 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
888
889 if ( !tasks ) {
890 cerr << "ERROR: AliEMCALGetter::Post TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
891 return kFALSE ;
892 }
893
894 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
895 if ( !emcal ) {
896 cerr <<"WARNING: AliEMCALGetter::Post TerRef -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
897 return 0 ;
898 }
899
900 TList * l = emcal->GetListOfTasks() ;
901 TIter it(l) ;
902 TTask * task ;
903 TTask * tsm = 0 ;
904 TString tsmname(name) ;
905 tsmname+=":tsm-" ;
906 while((task = static_cast<TTask *>(it.Next()) )){
907 TString taskname(task->GetName()) ;
908 if(taskname.BeginsWith(tsmname)){
909 tsm = task ;
910 break ;
911 }
912 }
913
914 if(tsm)
915 return static_cast<void *>(l->GetObjectRef(tsm)) ;
916 else
917 return 0 ;
918
919}
920
921//____________________________________________________________________________
922Bool_t AliEMCALGetter::PostRecParticles(const char * name) const
923{ // -------------------- RecParticles ------------------------
924
925 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
926
927 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
928
929 if ( !emcalFolder ) {
930 if (fDebug) {
931 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
932 cout << "INFO: AliEMCALGetter::Post Rpa -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
933 }
934 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
935 }
936
937 TFolder * emcalRPaFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("RecParticles")) ;
938 if ( !emcalRPaFolder ) {
939 if (fDebug) {
940 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
941 cout << "INFO: AliEMCALGetter::Post RPa -> Adding Folder //" << fRecoFolder << "/EMCAL/RecParticles/" << endl;
942 }
943 emcalRPaFolder = emcalFolder->AddFolder("RecParticles", "RecParticles from EMCAL") ;
944 }
945
946 TObject * rps = emcalRPaFolder->FindObject( name ) ;
947 if ( !rps ) {
948 TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ;
949 rp->SetName(name) ;
950 emcalRPaFolder->Add(rp) ;
951 }
952 return kTRUE;
953}
954
955//____________________________________________________________________________
956void * AliEMCALGetter::RecParticlesRef(const char * name) const
957{ // ---------------TrackSegments -----------------------------------
958
959 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
960
961 if ( !fRecoFolder ) {
962 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder//" << fRecoFolder << " not found!" << endl;
963 return 0 ;
964 }
965
966 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
967 if ( !emcalFolder ) {
968 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
969 return 0;
970 }
971
972 TObject * tss = emcalFolder->FindObject(name ) ;
973 if (!tss) {
974 return 0 ;
975 }
976 return static_cast<void *>(emcalFolder->GetListOfFolders()->GetObjectRef(tss)) ;
977}
978
979//____________________________________________________________________________
980Bool_t AliEMCALGetter::PostPID(AliEMCALPID * pid) const
981{ // ------------AliEMCAL PID -----------------------------
982
983 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
984
985 if ( !tasks ) {
986 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
987 return kFALSE ;
988 }
989
990 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
991 if ( !emcal ) {
992 if (fDebug) {
993 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
994 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
995 }
996 emcal = new TTask("EMCAL", "") ;
997 tasks->Add(emcal) ;
998 }
999
1000 AliEMCALPID * emcalpid = dynamic_cast<AliEMCALPID*>(emcal->GetListOfTasks()->FindObject(pid->GetName())) ;
1001 if (emcalpid) {
1002 if (fDebug)
1003 cout << "INFO: AliEMCALGetter::Post Per -> Task " << pid->GetName()
1004 << " already exists" << endl ;
1005 emcal->GetListOfTasks()->Remove(emcalpid) ;
1006 }
1007
1008 emcal->Add(pid) ;
1009 return kTRUE;
1010}
1011
1012//____________________________________________________________________________
1013Bool_t AliEMCALGetter::PostPID(const char * name) const
1014{
1015 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1016
1017 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1018
1019 if ( !tasks ) {
1020 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1021 return kFALSE ;
1022 }
1023
1024 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1025 if ( !emcal ) {
1026 if (fDebug) {
1027 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1028 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1029 }
1030 emcal = new TTask("EMCAL", "") ;
1031 tasks->Add(emcal) ;
1032 }
1033
1034 TList * l = emcal->GetListOfTasks() ;
1035 TIter it(l) ;
1036 TString pidname(name) ;
1037 pidname+=":pid" ;
1038 TTask * task ;
1039 while((task = static_cast<TTask *>(it.Next()) )){
1040 TString taskname(task->GetName()) ;
1041 if(taskname.BeginsWith(pidname))
1042 return kTRUE ;
1043 }
1044
1045 AliEMCALPIDv1 * emcalpid = new AliEMCALPIDv1() ;
1046 pidname+="-v1" ;
1047 emcalpid->SetName(pidname) ;
1048 emcal->Add(emcalpid) ;
1049
1050 return kTRUE;
1051}
1052
1053//____________________________________________________________________________
1054void * AliEMCALGetter::PIDRef(const char * name) const
1055{ //------------PID ------------------------------
1056
1057 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1058
1059 if ( !tasks ) {
1060 cerr << "ERROR: AliEMCALGetter::Post PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1061 return kFALSE ;
1062 }
1063
1064 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1065 if ( !emcal ) {
1066 cerr <<"WARNING: AliEMCALGetter::Post PerRef -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
1067 return 0 ;
1068 }
1069
1070 TList * l = emcal->GetListOfTasks() ;
1071 TIter it(l) ;
1072 TTask * task ;
1073 TTask * pid = 0 ;
1074 TString pidname(name) ;
1075 pidname+=":pid-" ;
1076 while((task = static_cast<TTask *>(it.Next()) )){
1077 TString taskname(task->GetName()) ;
1078 if(taskname.BeginsWith(pidname)){
1079 pid = task ;
1080 break ;
1081 }
1082 }
1083
1084 if(pid)
1085 return static_cast<void *>(l->GetObjectRef(pid)) ;
1086 else
1087 return 0 ;
1088
1089}
1090
1091//____________________________________________________________________________
1092Bool_t AliEMCALGetter::PostQA(void) const
1093{ // ------------------ QA ---------------------------------
1094
1095 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL/alarmsName
1096
1097 TFolder * emcalFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("EMCAL")) ;
1098 if ( !emcalFolder ) {
1099 if (fDebug) {
1100 cout << "WARNING: AliEMCALGetter::Post Q -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1101 cout << "INFO: AliEMCALGetter::Post Q -> Adding Folder //" << fQAFolder << "/EMCAL/" << endl;
1102 }
1103 emcalFolder = fQAFolder->AddFolder("EMCAL", "QA from EMCAL") ;
1104 }
1105
1106 return kTRUE;
1107}
1108
1109//____________________________________________________________________________
1110void * AliEMCALGetter::AlarmsRef(void) const
1111{ //------- Alarms ----------------------
1112
1113
1114 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL
1115 if ( !fQAFolder ) {
1116 cerr << "ERROR: AliEMCALGetter::Post QRef -> Folder //" << fQAFolder << " not found!" << endl;
1117 return 0;
1118 }
1119
1120 TFolder * emcalFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1121 if ( !emcalFolder ) {
1122 cerr << "ERROR: AliEMCALGetter::Post QRef -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1123 return 0;
1124 }
1125
1126 return static_cast<void *>(fQAFolder->GetListOfFolders()->GetObjectRef(emcalFolder)) ;
1127}
1128*/
ffa6d63b 1129//____________________________________________________________________________
1130const TParticle * AliEMCALGetter::Primary(Int_t index) const
1131{
1132 // Return primary particle numbered by <index>
1133
1134 if(index < 0)
1135 return 0 ;
1136
1137 Int_t primaryIndex = index % 10000000 ;
1138 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
1139
1140 if ( primaryList > 0 ) {
d75bea67 1141 if (fDebug) {
ffa6d63b 1142 cout << " Getter does not support currently Mixing of primary " << endl ;
1143 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
d75bea67 1144 }
ffa6d63b 1145 return 0;
1146 }
1147
1148 return gAlice->Particle(primaryIndex) ;
1149
1150}
1151
1152//____________________________________________________________________________
1153void AliEMCALGetter::ReadTreeD()
1154{
1155 // Read the digit tree gAlice->TreeD()
1156 if(gAlice->TreeD()== 0){
1157 cerr << "ERROR: AliEMCALGetter::ReadTreeD: can not read TreeD " << endl ;
1158 return ;
1159 }
d75bea67 1160
ffa6d63b 1161 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
1162 TIter next(lob) ;
1163 TBranch * branch = 0 ;
1164 TBranch * digitsbranch = 0 ;
1165 TBranch * digitizerbranch = 0 ;
1166 Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
1167
1168 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
1169 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1170 digitsbranch = branch ;
1171 emcalfound = kTRUE ;
1172 }
1173 else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1174 digitizerbranch = branch ;
1175 digitizerfound = kTRUE ;
1176 }
1177 }
1178
1179 if ( !emcalfound || !digitizerfound ) {
d75bea67 1180 if (fDebug)
ffa6d63b 1181 cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1182 << fDigitsTitle << endl ;
1183 return ;
1184 }
1185
1186 //read digits
1187 if(!Digits(fDigitsTitle) )
1188 PostDigits(fDigitsTitle);
1189 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1190 digitsbranch->GetEntry(0) ;
1191
1192
1193 // read the Digitizer
1194 if(!Digitizer(fDigitsTitle))
1195 PostDigitizer(fDigitsTitle) ;
1196 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1197 digitizerbranch->GetEntry(0) ;
1198
1199
1200}
1201
1202//____________________________________________________________________________
1203void AliEMCALGetter::ReadTreeH()
1204{
1205 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1206
1207 if(gAlice->TreeH()== 0){
1208 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1209 return ;
1210 }
1211
1212 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
1213 if ( !hitsbranch ) {
d75bea67 1214 if (fDebug)
ffa6d63b 1215 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1216 return ;
1217 }
1218 if(!Hits())
1219 PostHits() ;
1220
1221 hitsbranch->SetAddress(HitsRef()) ;
1222
1223 hitsbranch->GetEntry(0) ;
1224
1225}
1226
1227//____________________________________________________________________________
1228void AliEMCALGetter::Track(Int_t itrack)
1229{
1230 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1231
1232 if(gAlice->TreeH()== 0){
1233 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1234 return ;
1235 }
1236
1237 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
1238 if ( !hitsbranch ) {
d75bea67 1239 if (fDebug)
ffa6d63b 1240 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1241 return ;
1242 }
1243 if(!Hits())
1244 PostHits() ;
1245 hitsbranch->SetAddress(HitsRef()) ;
1246 hitsbranch->GetEntry(itrack) ;
1247
1248
1249}
1250//____________________________________________________________________________
d75bea67 1251/*void AliEMCALGetter::ReadTreeQA()
1252{
1253 // Read the digit tree gAlice->TreeQA()
1254 // so far only EMCAL knows about this Tree
1255
1256 if(EMCAL()->TreeQA()== 0){
1257 cerr << "ERROR: AliEMCALGetter::ReadTreeQA: can not read TreeQA " << endl ;
1258 return ;
1259 }
1260
1261 TBranch * qabranch = EMCAL()->TreeQA()->GetBranch("EMCAL") ;
1262 if (!qabranch) {
1263 if (fDebug)
1264 cout << "WARNING: AliEMCALGetter::ReadTreeQA -> Cannot find QA Alarms for EMCAL" << endl ;
1265 return ;
1266 }
1267
1268 if(!Alarms())
1269 PostQA() ;
1270
1271 qabranch->SetAddress(AlarmsRef()) ;
1272
1273 qabranch->GetEntry(0) ;
1274
1275// PostQA("EMCAL") ;
1276// TFolder * alarmsF = Alarms() ;
1277// alarmsF->Clear() ;
1278// qabranch->SetAddress(&alarmsF) ;
1279// qabranch->GetEntry(0) ;
1280
1281}
1282
1283//____________________________________________________________________________
1284void AliEMCALGetter::ReadTreeR()
1285{
1286 // Read the reconstrunction tree gAlice->TreeR()
1287
1288 if(gAlice->TreeR()== 0){
1289 cerr << "ERROR: AliEMCALGetter::ReadTreeR: can not read TreeR " << endl ;
1290 return ;
1291 }
1292
1293 // RecPoints
1294 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
1295 TIter next(lob) ;
1296 TBranch * branch = 0 ;
1297 TBranch * emcbranch = 0 ;
1298 TBranch * cpvbranch = 0 ;
1299 TBranch * clusterizerbranch = 0 ;
1300 Bool_t emcalemcrpfound = kFALSE, emcalcpvrpfound = kFALSE, clusterizerfound = kFALSE ;
1301
1302 while ( (branch = static_cast<TBranch*>(next())) && (!emcalemcrpfound || !emcalcpvrpfound || !clusterizerfound) )
1303 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0) {
1304 if ( strcmp(branch->GetName(), "EMCALEmcRP")==0) {
1305 emcbranch = branch ;
1306 emcalemcrpfound = kTRUE ;
1307 }
1308 else if ( strcmp(branch->GetName(), "EMCALCpvRP")==0) {
1309 cpvbranch = branch ;
1310 emcalcpvrpfound = kTRUE ;
1311 }
1312 else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
1313 clusterizerbranch = branch ;
1314 clusterizerfound = kTRUE ;
1315 }
1316 }
1317
1318 if ( !emcalemcrpfound ) {
1319 if (fDebug)
1320 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find EmcRecPoints with title "
1321 << fRecPointsTitle << endl ;
1322 return ;
1323 }
1324 if ( !emcalcpvrpfound ) {
1325 if (fDebug)
1326 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find CpvRecPoints with title "
1327 << fRecPointsTitle << endl ;
1328 return ;
1329 }
1330 if ( !clusterizerfound ) {
1331 if (fDebug)
1332 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Can not find Clusterizer with title "
1333 << fRecPointsTitle << endl ;
1334 return ;
1335 }
1336
1337 // Read and Post the RecPoints
1338 if(!EmcRecPoints(fRecPointsTitle) )
1339 PostRecPoints(fRecPointsTitle) ;
1340 emcbranch->SetAddress(EmcRecPointsRef(fRecPointsTitle)) ;
1341 emcbranch->GetEntry(0) ;
1342
1343 cpvbranch->SetAddress(CpvRecPointsRef(fRecPointsTitle)) ;
1344 cpvbranch->GetEntry(0) ;
1345
1346 if(!Clusterizer(fRecPointsTitle) )
1347 PostClusterizer(fRecPointsTitle) ;
1348 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1349 clusterizerbranch->GetEntry(0) ;
1350
1351
1352 //------------------- TrackSegments ---------------------
1353 next.Reset() ;
1354 TBranch * tsbranch = 0 ;
1355 TBranch * tsmakerbranch = 0 ;
1356 Bool_t emcaltsfound = kFALSE, tsmakerfound = kFALSE ;
1357
1358 while ( (branch = static_cast<TBranch*>(next())) && (!emcaltsfound || !tsmakerfound) )
1359 if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) {
1360 if ( strcmp(branch->GetName(), "EMCALTS")==0){
1361 tsbranch = branch ;
1362 emcaltsfound = kTRUE ;
1363 }
1364 else if(strcmp(branch->GetName(), "AliEMCALTrackSegmentMaker")==0) {
1365 tsmakerbranch = branch ;
1366 tsmakerfound = kTRUE ;
1367 }
1368 }
1369
1370 if ( !emcaltsfound || !tsmakerfound ) {
1371 if (fDebug)
1372 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1373 << fTrackSegmentsTitle << endl ;
1374 return ;
1375 }
1376
1377 // Read and Post the TrackSegments
1378 if(!TrackSegments(fTrackSegmentsTitle))
1379 PostTrackSegments(fTrackSegmentsTitle) ;
1380 tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1381 tsbranch->GetEntry(0) ;
1382
1383 // Read and Post the TrackSegment Maker
1384 if(!TrackSegmentMaker(fTrackSegmentsTitle))
1385 PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1386 tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1387 tsmakerbranch->GetEntry(0) ;
1388
1389
1390 //------------ RecParticles ----------------------------
1391 next.Reset() ;
1392 TBranch * rpabranch = 0 ;
1393 TBranch * pidbranch = 0 ;
1394 Bool_t emcalrpafound = kFALSE, pidfound = kFALSE ;
1395
1396 while ( (branch = static_cast<TBranch*>(next())) && (!emcalrpafound || !pidfound) )
1397 if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1398 if ( strcmp(branch->GetName(), "EMCALRP")==0) {
1399 rpabranch = branch ;
1400 emcalrpafound = kTRUE ;
1401 }
1402 else if (strcmp(branch->GetName(), "AliEMCALPID")==0) {
1403 pidbranch = branch ;
1404 pidfound = kTRUE ;
1405 }
1406 }
1407
1408 if ( !emcalrpafound || !pidfound ) {
1409 if (fDebug)
1410 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1411 << fRecParticlesTitle << endl ;
1412 return ;
1413 }
1414
1415 // Read and Post the RecParticles
1416 if(!RecParticles(fRecParticlesTitle))
1417 PostRecParticles(fRecParticlesTitle) ;
1418 rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1419 rpabranch->GetEntry(0) ;
1420
1421 // Read and Post the PID
1422 if(!PID(fRecParticlesTitle))
1423 PostPID(fRecParticlesTitle) ;
1424 pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
1425 pidbranch->GetEntry(0) ;
1426
1427
1428}
1429*/
1430//____________________________________________________________________________
ffa6d63b 1431void AliEMCALGetter::ReadTreeS(Int_t event)
1432{
1433 // Read the summable digits tree gAlice->TreeS()
1434
1435 // loop over all opened files and read their SDigits to the White Board
1436 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
1437 if (!emcalF)
1438 emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1439 TCollection * folderslist = emcalF->GetListOfFolders() ;
1440
1441 //Add current file to list if it is not there yet
1442 if ( (fHeaderFile != "aliroot") && ( !folderslist->Contains(fHeaderFile) ) ){
1443 emcalF->AddFolder(fHeaderFile, "");
1444 }
1445
1446 TIter next(folderslist) ;
1447 TFolder * folder = 0 ;
1448 TFile * file;
1449 TTree * treeS = 0;
1450 while ( (folder = static_cast<TFolder*>(next())) ) {
1451 if(fHeaderFile.CompareTo(folder->GetName()) == 0 )
d75bea67 1452 treeS=gAlice->TreeS() ;
ffa6d63b 1453 else{
d75bea67 1454 file = static_cast<TFile*>(gROOT->GetFile(folder->GetName()));
ffa6d63b 1455 file->cd() ;
1456
1457 // Get SDigits Tree header from file
1458 TString treeName("TreeS") ;
1459 treeName += event ;
1460 treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
1461 }
1462 if(treeS==0){
1463 cerr << "ERROR: AliEMCALGetter::ReadTreeS There is no SDigit Tree" << endl;
1464 return ;
1465 }
1466
1467 //set address of the SDigits and SDigitizer
1468 TBranch * sdigitsBranch = 0;
1469 TBranch * sdigitizerBranch = 0;
1470 TBranch * branch = 0 ;
1471 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1472 TIter next(lob) ;
1473 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1474
1475 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
d75bea67 1476 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
ffa6d63b 1477 emcalfound = kTRUE ;
1478 sdigitsBranch = branch ;
d75bea67 1479 }
ffa6d63b 1480
1481 else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1482 sdigitizerfound = kTRUE ;
1483 sdigitizerBranch = branch ;
ffa6d63b 1484 }
1485 }
1486 if ( !emcalfound || !sdigitizerfound ) {
d75bea67 1487 if (fDebug)
ffa6d63b 1488 cout << "WARNING: AliEMCALDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName()
1489 << " not found" << endl ;
1490 return ;
1491 }
1492
1493 if ( !folder->FindObject(fSDigitsTitle) )
d75bea67 1494 PostSDigits(fSDigitsTitle,folder->GetName()) ;
ffa6d63b 1495 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
ffa6d63b 1496 sdigitsBranch->GetEntry(0) ;
1497
1498 TString sdname(fSDigitsTitle) ;
ffa6d63b 1499 sdname+=":" ;
1500 sdname+=folder->GetName() ;
1501 if(!SDigitizer(sdname) )
1502 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1503 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1504 sdigitizerBranch->GetEntry(0) ;
1505
1506 }
1507
1508 // After SDigits have been read from all files, return to the first one
1509
1510 next.Reset();
1511 folder = static_cast<TFolder*>(next());
1512 if(folder){
1513 file = static_cast<TFile*>(gROOT->GetFile(folder->GetName()));
1514 file ->cd() ;
1515 }
1516
1517}
1518//____________________________________________________________________________
1519void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
1520{ // Read the summable digits fron treeS()
1521
1522
1523 TString filename("mergefile") ;
1524 filename+= input ;
1525
1526 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1527 if ( !emcalFolder ) {
1528 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1529 }
1530 TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
1531 //set address of the SDigits and SDigitizer
1532 TBranch * sdigitsBranch = 0;
1533 TBranch * sdigitizerBranch = 0;
1534 TBranch * branch = 0 ;
1535 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1536 TIter next(lob) ;
1537 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1538
1539 while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
1540 if ( strcmp(branch->GetName(), "EMCAL")==0) {
1541 emcalfound = kTRUE ;
1542 sdigitsBranch = branch ;
1543 }
1544
1545 else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
1546 sdigitizerfound = kTRUE ;
1547 sdigitizerBranch = branch ;
1548 }
1549 }
1550 if ( !emcalfound || !sdigitizerfound ) {
d75bea67 1551 if (fDebug)
ffa6d63b 1552 cout << "WARNING: AliEMCALGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
1553 return ;
1554 }
1555
1556 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1557 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1558
1559 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
d75bea67 1560 sdigitsBranch->GetEntry(0) ;
ffa6d63b 1561
1562 TString sdname(sdigitsBranch->GetTitle()) ;
1563 sdname+=":" ;
1564 sdname+=filename ;
1565 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1566 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
d75bea67 1567
ffa6d63b 1568 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
ffa6d63b 1569 sdigitizerBranch->GetEntry(0) ;
1570
1571}
1572
1573
1574//____________________________________________________________________________
1575void AliEMCALGetter::ReadPrimaries()
1576{
1577 // Reads specific branches of primaries
1578
1579 fNPrimaries = gAlice->GetNtrack();
1580
1581 // //Check, is it necessary to open new files
1582 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
1583 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
1584// Int_t input ;
1585// for(input = 0; input < filenames->GetEntriesFast(); input++){
1586
1587// TObjString * filename = (TObjString *) filenames->At(input) ;
1588
1589// //Test, if this file already open
1590// TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
1591// if(file == 0)
1592// file = new TFile( filename->GetString()) ;
1593// file->cd() ;
1594
1595// // Get Kine Tree from file
1596// // char treeName[20];
1597// // sprintf(treeName,"TreeK%d",events->At(input));
1598// // TTree * treeK = (TTree*)gDirectory->Get(treeName);
1599// // if (treeK)
1600// // treeK->SetBranchAddress("Particles", &fParticleBuffer);
1601// // else
1602// // cout << "AliEMCALGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
1603
1604// // // Create the particle stack
1605// // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
1606// // // Build the pointer list
1607// // if(fParticleMap) { <----
1608// // fParticleMap->Clear();
1609// // fParticleMap->Expand(treeK->GetEntries());
1610// // } else
1611// // fParticleMap = new TObjArray(treeK->GetEntries());
1612
1613// // From gAlice->Particle(i)
1614
1615
1616// // if(!(*fParticleMap)[i]) {
1617// // Int_t nentries = fParticles->GetEntries();
1618
1619// // // algorithmic way of getting entry index
1620// // // (primary particles are filled after secondaries)
1621// // Int_t entry;
1622// // if (i<fHeader.GetNprimary())
1623// // entry = i+fHeader.GetNsecondary();
1624// // else
1625// // entry = i-fHeader.GetNprimary();
1626
1627// // // only check the algorithmic way and give
1628// // // the fatal error if it is wrong
1629// // if (entry != fParticleFileMap[i]) {
1630// // Fatal("Particle",
1631// // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
1632// // entry, fParticleFileMap[i]);
1633// // }
1634
1635// // fTreeK->GetEntry(fParticleFileMap[i]);
1636// // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
1637// // fParticleMap->AddAt((*fParticles)[nentries],i);
1638// // }
1639// // return (TParticle *) (*fParticleMap)[i];
1640
1641
1642
1643// }
1644
1645
1646// //scan over opened files and read corresponding TreeK##
1647
1648 return ;
1649}
1650//____________________________________________________________________________
1651void AliEMCALGetter::Event(const Int_t event, const char* opt)
1652{
1653 // Reads the content of all Tree's S, D and R
1654
1655 if (event >= gAlice->TreeE()->GetEntries() ) {
1656 cerr << "ERROR: AliEMCALGetter::Event -> " << event << " not found in TreeE!" << endl ;
1657 return ;
1658 }
1659 gAlice->GetEvent(event) ;
1660
1661 if(strstr(opt,"H") )
d75bea67 1662 ReadTreeH() ;
ffa6d63b 1663
1664 if(strstr(opt,"S") )
d75bea67 1665 ReadTreeS(event) ;
ffa6d63b 1666
1667 if( strstr(opt,"D") )
1668 ReadTreeD() ;
1669
d75bea67 1670 // if( strstr(opt,"R") )
1671 // ReadTreeR() ;
ffa6d63b 1672
d75bea67 1673 // if( strstr(opt,"Q") )
1674 // ReadTreeQA() ;
ffa6d63b 1675
d75bea67 1676 // if( strstr(opt,"P") || (strcmp(opt,"")==0) )
1677 // ReadPrimaries() ;
ffa6d63b 1678
1679}
1680
1681//____________________________________________________________________________
1682const TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
1683{
1684 // get the object named "what" from the folder
1685 // folders are named like //Folders
1686
1687 if ( file.IsNull() )
1688 file = fHeaderFile ;
1689
1690 TFolder * folder = 0 ;
1691 TObject * emcalO = 0 ;
1692
1693 // if ( name.IsNull() ) {
1694 if ( what.CompareTo("Hits") == 0 ) {
1695 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
1696 if (folder)
1697 emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1698 }
1699 else if ( what.CompareTo("SDigits") == 0 ) {
1700 TString path = "EMCAL/" + file ;
1701 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1702 if (folder) {
d75bea67 1703 if (name.IsNull())
ffa6d63b 1704 name = fSDigitsTitle ;
1705 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1706 }
1707 }
1708 else if ( what.CompareTo("Digits") == 0 ){
1709 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
1710 if (folder) {
1711 if (name.IsNull())
1712 name = fDigitsTitle ;
1713 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1714 }
1715 }
d75bea67 1716/* else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1717 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/EMCARecPoints")) ;
1718 if (folder) {
1719 if (name.IsNull())
1720 name = fRecPointsTitle ;
1721 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1722 }
1723 }
1724 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1725 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/CPVRecPoints")) ;
1726 if (folder) {
1727 if (name.IsNull())
1728 name = fRecPointsTitle ;
1729 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1730 }
1731 }
1732 else if ( what.CompareTo("TrackSegments") == 0 ) {
1733 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
1734 if (folder) {
1735 if (name.IsNull())
1736 name = fTrackSegmentsTitle ;
1737 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1738 }
1739 }
1740 else if ( what.CompareTo("RecParticles") == 0 ) {
1741 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
1742 if (folder) {
1743 if (name.IsNull())
1744 name = fRecParticlesTitle ;
1745 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1746 }
1747 }
1748 else if ( what.CompareTo("Alarms") == 0 ){
1749 if (name.IsNull() )
1750 emcalO = dynamic_cast<TObject *>(fQAFolder->FindObject("EMCAL")) ;
1751 else {
1752 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1753 if (!folder)
1754 emcalO = 0 ;
1755 else
1756 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1757 }
1758 }
1759*/
ffa6d63b 1760 if (!emcalO) {
d75bea67 1761 if(fDebug)
ffa6d63b 1762 cerr << "ERROR : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
1763 return 0 ;
1764 }
1765 return emcalO ;
1766}
1767
1768//____________________________________________________________________________
1769const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
1770{
1771 // get the TTask named "what" from the folder
1772 // folders are named like //Folders/Tasks/what/EMCAL/name
1773
1774 TString search(what) ;
d75bea67 1775/* if ( what.CompareTo("Clusterizer") == 0 )
1776 search = "Reconstructioner" ;
1777 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1778 search = "Reconstructioner" ;
1779 else if ( what.CompareTo("PID") == 0 )
1780 search = "Reconstructioner" ;
1781 else if ( what.CompareTo("QATasks") == 0 )
1782 search = "QA" ;
1783*/
ffa6d63b 1784 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1785
1786 if (!tasks) {
1787 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << " not found!" << endl ;
1788 return 0 ;
1789 }
1790
1791 TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1792 if (!emcalT) {
1793 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << "/EMCAL not found!" << endl ;
1794 return 0 ;
1795 }
1796
1797 TList * list = emcalT->GetListOfTasks() ;
1798
1799 if (what.CompareTo("SDigitizer") == 0) {
1800 if ( name.IsNull() )
1801 name = fSDigitsTitle ;
1802 } else if (what.CompareTo("Digitizer") == 0){
1803 if ( name.IsNull() )
1804 name = fDigitsTitle ;
d75bea67 1805 } /*else if (what.CompareTo("Clusterizer") == 0){
1806 if ( name.IsNull() )
1807 name = fRecPointsTitle ;
1808 name.Append(":clu") ;
1809 }
1810 else if (what.CompareTo("TrackSegmentMaker") == 0){
1811 if ( name.IsNull() )
1812 name = fTrackSegmentsTitle ;
1813 name.Append(":tsm") ;
ffa6d63b 1814 }
d75bea67 1815 else if (what.CompareTo("PID") == 0){
1816 if ( name.IsNull() )
1817 name = fRecParticlesTitle ;
1818 name.Append(":pid") ;
1819 }
1820 else if (what.CompareTo("QATasks") == 0){
1821 if ( name.IsNull() )
1822 return emcalT ;
1823 }*/
ffa6d63b 1824
1825 TIter it(list) ;
1826 TTask * task = 0 ;
1827 while((task = static_cast<TTask *>(it.Next()) )){
1828 TString taskname(task->GetName()) ;
1829 if(taskname.BeginsWith(name))
1830 return task ;
1831 }
1832
d75bea67 1833 if(fDebug)
ffa6d63b 1834 cout << "WARNING: AliEMCALGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;
1835 return 0 ;
1836}