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