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