removed iostream
[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: */
ffa6d63b 17/* $Log:
d75bea67 18 29.05.2001 Yuri Kharlov:
19 Everywhere reading the treese TTree->GetEvent(i)
20 is replaced by reading the branches TBranch->GetEntry(0)
ffa6d63b 21*/
173558f2 22
05a92d59 23/* $Log:
24 08.2002 Dmitri Peressounko:
05a92d59 25*/
ffa6d63b 26
27//_________________________________________________________________________
28// A singleton. This class should be used in the analysis stage to get
29// reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
30// instead of directly reading them from galice.root file. This container
9859bfc0 31// ensures, that one reads Digits, made of these particular digits, RecPoints,
ffa6d63b 32// made of these particular RecPoints, TrackSegments and RecParticles.
33// This becomes non trivial if there are several identical branches, produced with
d75bea67 34// different set of parameters.
ffa6d63b 35//
36// An example of how to use (see also class AliEMCALAnalyser):
37// AliEMCALGetter * gime = AliEMCALGetter::GetInstance("galice.root","test") ;
d75bea67 38// for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
39// AliEMCALRecParticle * part = gime->RecParticle(1) ;
ffa6d63b 40// ................
41// please->GetEvent(event) ; // reads new event from galice.root
42//
d75bea67 43//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
44//*-- Completely redesigned by Dmitri Peressounko March 2001
45//
46//*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
05a92d59 47//*-- systematic usage of TFolders without changing the interface
48//*-- YS August 2002 : clone PHOS as closely as possible and intoduction
49// of new IO (à la PHOS)
173558f2 50
ffa6d63b 51//////////////////////////////////////////////////////////////////////////////
52
173558f2 53
54
ffa6d63b 55// --- ROOT system ---
173558f2 56
ffa6d63b 57#include "TFile.h"
58#include "TTree.h"
59#include "TROOT.h"
60#include "TObjString.h"
61#include "TFolder.h"
05a92d59 62#include "TParticle.h"
ffa6d63b 63
64// --- Standard library ---
173558f2 65
70479d0e 66#include <Riostream.h>
ffa6d63b 67
68// --- AliRoot header files ---
173558f2 69
ffa6d63b 70#include "AliRun.h"
71#include "AliConfig.h"
72#include "AliEMCALGetter.h"
05a92d59 73#include "AliEMCAL.h"
ffa6d63b 74#include "AliEMCALDigitizer.h"
75#include "AliEMCALSDigitizer.h"
f07cab21 76#include "AliEMCALClusterizerv1.h"
ffa6d63b 77#include "AliEMCALGeometry.h"
78
79ClassImp(AliEMCALGetter)
173558f2 80
ffa6d63b 81 AliEMCALGetter * AliEMCALGetter::fgObjGetter = 0 ;
52ea052c 82 TFile * AliEMCALGetter::fFile = 0 ;
ffa6d63b 83
84//____________________________________________________________________________
173558f2 85
05a92d59 86AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* branchTitle, const Bool_t toSplit)
ffa6d63b 87{
05a92d59 88 // This is the ctor called by GetInstance and the only one that can be used
173558f2 89
05a92d59 90 if ( fHeaderFile.Contains("_") ) {
9859bfc0 91 Fatal("AliEMCALGetter","Invalid file name (_ not allowed) %s",fHeaderFile.Data()) ;
05a92d59 92 }
173558f2 93
05a92d59 94 //Initialize all data
95
96 fFailed = kFALSE ;
97 fDebug = 0 ;
05a92d59 98 fToSplit = toSplit ;
99 fHeaderFile = headerFile ;
ffa6d63b 100
101 fPrimaries = new TObjArray(1) ;
d75bea67 102
9bd3caba 103 fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
104 fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data"));
105 fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
106 fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
107 fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
108 fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
d75bea67 109 //fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
9bd3caba 110 fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
ffa6d63b 111
05a92d59 112 //Set titles to branches and create PHOS specific folders
173558f2 113
05a92d59 114 SetTitle(branchTitle) ;
173558f2 115
ffa6d63b 116 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
173558f2 117
ffa6d63b 118 //open headers file
173558f2 119
4dcdb968 120 fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
173558f2 121
ed215ae7 122 if(!fFile){ //if file was not opened yet, read gAlice
05a92d59 123 fFile = TFile::Open(fHeaderFile.Data(), "update") ;
4dcdb968 124 if (!fFile->IsOpen()) {
9859bfc0 125 Error("AliEMCALGetter","Cannot open %s",fHeaderFile.Data()) ;
28b243ad 126 fFailed = kTRUE ;
127 return ;
ffa6d63b 128 }
12eac0c2 129 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
ffa6d63b 130 }
d75bea67 131 }
173558f2 132
d75bea67 133 if (!gAlice) {
9859bfc0 134 Error("AliEMCALGetter","Cannot find gAlice in %s",fHeaderFile.Data()) ;
28b243ad 135 fFailed = kTRUE ;
136 return ;
d75bea67 137 }
173558f2 138
d75bea67 139 if (!EMCAL()) {
140 if (fDebug)
9859bfc0 141 Info("AliEMCALGetter","Posting EMCAL to Folders") ;
173558f2 142
ba298680 143 if (gAlice->GetDetector("EMCAL")) {
144 AliConfig * conf = AliConfig::Instance() ;
145 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("EMCAL"))) ;
146 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("EMCAL"))) ;
147 }
148 else
9859bfc0 149 Error("AliEMCALGetter"," Detector EMCAL not found");
ffa6d63b 150 }
173558f2 151
d75bea67 152 fDebug=0;
ffa6d63b 153}
05a92d59 154
ffa6d63b 155//____________________________________________________________________________
173558f2 156
ba298680 157AliEMCALGetter::~AliEMCALGetter()
158{
ededcd8c 159 if (fPrimaries) {
160 fPrimaries->Delete() ;
161 delete fPrimaries ;
162 }
d489fb96 163
164 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
165 TCollection * folderslist = emcalF->GetListOfFolders() ;
166 TIter next(folderslist) ;
167 TFolder * folder = 0 ;
173558f2 168
d489fb96 169 while ( (folder = static_cast<TFolder*>(next())) )
170 emcalF->Remove(folder) ;
171
05a92d59 172 if (fFile) {
173 fFile->Close() ;
174 delete fFile ;
175 fFile = 0 ;
176 }
173558f2 177
65549808 178 fgObjGetter = 0 ;
ffa6d63b 179}
180
181//____________________________________________________________________________
173558f2 182
65549808 183void AliEMCALGetter::CloseFile()
184{
05a92d59 185 delete gAlice ;
b134c32f 186 gAlice = 0 ;
65549808 187}
188
189//____________________________________________________________________________
173558f2 190
0c87da39 191const TFolder * AliEMCALGetter::Folder(const TString what) const {
192
193 // returns the EMCAL folder required by what
194 // what = hits, sdigits, digits
195
196 if ( what == "hits" )
197 return dynamic_cast<const TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
198 else if ( what == "sdigits" )
199 return dynamic_cast<const TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
200 else if ( what == "digits" )
9859bfc0 201 return dynamic_cast<const TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
0c87da39 202 else {
9859bfc0 203 Error("GetFolder","%s illegal option (hits, sdigits, digits) ", what.Data()) ;
0c87da39 204 return 0 ;
205 }
206}
05a92d59 207
0c87da39 208//____________________________________________________________________________
173558f2 209
ffa6d63b 210AliEMCALGetter * AliEMCALGetter::GetInstance()
211{
212 // Returns the pointer of the unique instance already defined
173558f2 213
b134c32f 214 if ( fgObjGetter ) {
b134c32f 215 return fgObjGetter ;
216 }
217 else {
b134c32f 218 return 0 ;
219 }
ffa6d63b 220}
221
222//____________________________________________________________________________
173558f2 223
ffa6d63b 224AliEMCALGetter * AliEMCALGetter::GetInstance(const char* headerFile,
05a92d59 225 const char* branchTitle,
226 const Bool_t toSplit)
ffa6d63b 227{
228 // Creates and returns the pointer of the unique instance
229 // Must be called only when the environment has changed
230
05a92d59 231 if(!fgObjGetter){
232 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
233 if(fgObjGetter->fFailed)
234 return 0;
235 else
236 return fgObjGetter ;
237 }
238
239 //First checks, if header file already opened
173558f2 240
05a92d59 241 if(!fgObjGetter->fFile){
242 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
243 if(fgObjGetter->fFailed)
244 return 0;
245 else
246 return fgObjGetter ;
247 }
173558f2 248
05a92d59 249 if(fgObjGetter->fHeaderFile.CompareTo(headerFile)==0){ //Opened the same header file
250 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0)&& //Open the same branch title
251 (toSplit==fgObjGetter->fToSplit)){ //Nothing should be cleaned
52ea052c 252 }
05a92d59 253 else{ //Clean all data and AliEMCAL...zers
254 if(fgObjGetter->fToSplit)
9859bfc0 255 fgObjGetter->CloseSplitFiles() ;
05a92d59 256 fgObjGetter->CleanWhiteBoard() ;
257 fgObjGetter->fToSplit = toSplit ;
258 fgObjGetter->SetTitle(branchTitle) ;
05a92d59 259 }
260 }
261 else{ //Close already opened files, clean memory and open new header file
262 if(gAlice)
263 delete gAlice ;
264 gAlice= 0;
265 if(fgObjGetter->fFile){
266 fgObjGetter->fFile->Close() ;
267 fgObjGetter->fFile=0;
268 }
269 if(fgObjGetter->fToSplit)
270 fgObjGetter->CloseSplitFiles() ;
271 fgObjGetter->CleanWhiteBoard() ;
272 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
05a92d59 273 }
173558f2 274
05a92d59 275 return fgObjGetter ;
173558f2 276
05a92d59 277}
6c58180f 278
05a92d59 279//____________________________________________________________________________
173558f2 280
05a92d59 281const Bool_t AliEMCALGetter::BranchExists(const TString recName) const
282{
283 //Looks in the tree Tree"name" if branch with current name olready exists
173558f2 284
05a92d59 285 TString filename("") ;
286 TString name, dataname, zername;
287 if(recName == "SDigits"){
288 filename=fSDigitsFileName ;
289 name = "TreeS0" ;
290 dataname = "PHOS" ;
291 zername = "AliPHOSSDigitizer" ;
292 }
9859bfc0 293 else if(recName == "Digits"){
294 filename=fDigitsFileName ;
295 name = "TreeD0" ;
296 dataname = "PHOS" ;
297 zername = "AliPHOSDigitizer" ;
298 }
299 else if(recName =="RecPoints"){
05a92d59 300 filename=fRecPointsFileName ;
301 name = "TreeR0" ;
302 dataname = "PHOSEmcRP" ;
303 zername = "AliPHOSClusterizer" ;
9859bfc0 304 }
305 else if(recName == "TrackSegments"){
306 filename=fTrackSegmentsFileName ;
307 name = "TreeR0" ;
308 dataname = "PHOSTS" ;
309 zername = "AliPHOSTrackSegmentMaker" ;
310 }
311 else if(recName == "RecParticles"){
312 filename= fRecParticlesFileName ;
313 name = "TreeR0" ;
314 dataname = "PHOSRP" ;
315 zername = "AliPHOSPID" ;
316 }
317 else
318 return kFALSE ;
173558f2 319
05a92d59 320 TFile * file ;
321 TTree * tree ;
322 if(fToSplit){
323 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
324 if(!file)
325 file = TFile::Open(fSDigitsFileName.Data(),"update");
326 }
327 else
328 file = fFile ;
173558f2 329
05a92d59 330 tree = (TTree *)file->Get(name.Data()) ;
173558f2 331
05a92d59 332 if(!tree )
333 return kFALSE ;
d489fb96 334
05a92d59 335 TObjArray * lob = static_cast<TObjArray*>(tree->GetListOfBranches()) ;
336 TIter next(lob) ;
337 TBranch * branch = 0 ;
338 TString titleName(fBranchTitle);
339 titleName+=":";
173558f2 340
05a92d59 341 while ((branch = (static_cast<TBranch*>(next())))) {
342 TString branchName(branch->GetName() ) ;
343 TString branchTitle(branch->GetTitle() ) ;
344 if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){
9859bfc0 345 Warning("BranchExists", "branch %s with title %s already exits in %s", dataname.Data(), fBranchTitle.Data(), name.Data());
05a92d59 346 return kTRUE ;
347 }
173558f2 348
05a92d59 349 if ( branchName.BeginsWith(zername) && branchTitle.BeginsWith(titleName) ){
9859bfc0 350 Warning("BranchExists","Branch AliEMCAL... with title %s already exits in %s",branch->GetTitle(), name.Data());
05a92d59 351 return kTRUE ;
352 }
353 }
173558f2 354
48f12df6 355 //We can't delete three if gAlice points to it... To be redisigned somehow???!!!
173558f2 356
48f12df6 357 if(!fToSplit){
358 if(name.Contains("TreeS"))
359 if(tree!=gAlice->TreeS())
9859bfc0 360 tree->Delete();
48f12df6 361 if(name.Contains("TreeD"))
362 if(tree!=gAlice->TreeD())
9859bfc0 363 tree->Delete();
48f12df6 364 if(name.Contains("TreeR"))
365 if(tree!=gAlice->TreeR())
9859bfc0 366 tree->Delete();
48f12df6 367 }
173558f2 368
05a92d59 369 return kFALSE ;
05a92d59 370}
371
372//____________________________________________________________________________
173558f2 373
05a92d59 374void AliEMCALGetter::ListBranches(Int_t event) const
375{
05a92d59 376 TBranch * branch = 0 ;
377 if (gAlice->GetEvent(event) == -1)
378 return ;
379
380 TTree * t = gAlice->TreeH() ;
173558f2 381
05a92d59 382 if(t){
9859bfc0 383 Info("ListBranches"," -> ****** Hits : ");
05a92d59 384 TObjArray * lob = t->GetListOfBranches() ;
385 TIter next(lob) ;
173558f2 386
05a92d59 387 while ( (branch = static_cast<TBranch*>(next())) )
9859bfc0 388 Info("ListBranches"," %s", branch->GetName());
173558f2 389
05a92d59 390 } else
9859bfc0 391 Warning("ListBranches"," -> TreeH not found for event %d",event);
173558f2 392
05a92d59 393 t = gAlice->TreeS() ;
173558f2 394
05a92d59 395 if(t){
9859bfc0 396 Info("ListBranches"," -> ****** SDigits : ");
05a92d59 397 TObjArray * lob = t->GetListOfBranches() ;
398 TIter next(lob) ;
173558f2 399
05a92d59 400 while ( (branch = static_cast<TBranch*>(next())) )
9859bfc0 401 Info("ListBranches"," %s %s",branch->GetName(),branch->GetTitle());
05a92d59 402 } else
9859bfc0 403 Warning("ListBranches"," -> TreeS not found for event %d",event);
173558f2 404
05a92d59 405 t = gAlice->TreeD() ;
173558f2 406
05a92d59 407 if(t){
9859bfc0 408 Info("ListBranches"," -> ****** Digits : ");
05a92d59 409 TObjArray * lob = t->GetListOfBranches() ;
410 TIter next(lob) ;
173558f2 411
05a92d59 412 while ( (branch = static_cast<TBranch*>(next())) )
9859bfc0 413 Info(" %s %s", branch->GetName(), branch->GetTitle());
05a92d59 414 } else
9859bfc0 415 Warning("ListBranches"," -> TreeD not found for event %d", event);
173558f2 416
05a92d59 417 t = gAlice->TreeR() ;
173558f2 418
05a92d59 419 if(t){
9859bfc0 420 Info("ListBranches"," -> ****** Recon : ");
05a92d59 421 TObjArray * lob = t->GetListOfBranches() ;
422 TIter next(lob) ;
423 while ( (branch = static_cast<TBranch*>(next())) )
9859bfc0 424 Info(" %s %s", branch->GetName(), branch->GetTitle());
05a92d59 425 } else
9859bfc0 426 Warning("ListBranches"," -> TreeR not found for event %d",event);
ffa6d63b 427}
428
429//____________________________________________________________________________
173558f2 430
05a92d59 431void AliEMCALGetter::NewBranch(TString name, Int_t event)
432{
433 fBranchTitle = fSDigitsTitle = fDigitsTitle = fRecPointsTitle = fTrackSegmentsTitle = fRecParticlesTitle = name ;
434 Event(event) ;
435}
436
437//____________________________________________________________________________
173558f2 438
05a92d59 439Bool_t AliEMCALGetter::NewFile(TString name)
440{
441 fHeaderFile = name ;
442 fFile->Close() ;
443 fFailed = kFALSE;
444
445 fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
173558f2 446
05a92d59 447 if(!fFile) { //if file was not opened yet, read gAlice
448 fFile = TFile::Open(fHeaderFile.Data(),"update") ;
449 if (!fFile->IsOpen()) {
9859bfc0 450 Error("NewFile", " -> Cannot open %s", fHeaderFile.Data());
05a92d59 451 fFailed = kTRUE ;
452 return fFailed ;
453 }
454 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
455 }
173558f2 456
05a92d59 457 if (!gAlice) {
9859bfc0 458 Error("NewFile"," -> Cannot find gAlice in %s", fHeaderFile.Data());
05a92d59 459 fFailed = kTRUE ;
460 return fFailed ;
461 }
462 return fFailed ;
463}
464
465//____________________________________________________________________________
173558f2 466
05a92d59 467const AliEMCAL * AliEMCALGetter::EMCAL()
ffa6d63b 468{
469 // returns the EMCAL object
173558f2 470
05a92d59 471 AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(fModuleFolder->FindObject("EMCAL")) ;
173558f2 472
ffa6d63b 473 if (!emcal)
d75bea67 474 if (fDebug)
9859bfc0 475 Warning("EMCAL"," -> EMCAL module not found in Folders" );
ffa6d63b 476 return emcal ;
477}
478
479//____________________________________________________________________________
173558f2 480
f07cab21 481AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
ffa6d63b 482{
483 AliEMCALGeometry * rv = 0 ;
484 if (EMCAL() )
d75bea67 485 rv = EMCAL()->GetGeometry() ;
ffa6d63b 486 return rv ;
487}
488
489//____________________________________________________________________________
173558f2 490
05a92d59 491const Bool_t AliEMCALGetter::PostPrimaries(void) const
9859bfc0 492{
493 //------- Primaries ----------------------
9bd3caba 494 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
173558f2 495
9bd3caba 496 TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
497 if ( !primariesFolder ) {
498 if (fDebug) {
9859bfc0 499 Warning("PostPrimaries", "-> Folder //%s/Primaries/ not found!", fPrimariesFolder->GetName());
500 Info("PostPrimaries", "-> Adding Folder //%s/Primaries/",fPrimariesFolder->GetName());
9bd3caba 501 }
502 primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
503 }
173558f2 504
9bd3caba 505 TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
506 primaries->SetName("Primaries") ;
507 primariesFolder->Add(primaries) ;
173558f2 508
9bd3caba 509 return kTRUE;
510}
511
512//____________________________________________________________________________
173558f2 513
9bd3caba 514TObject** AliEMCALGetter::PrimariesRef(void) const
9859bfc0 515{
516 //------- Primaries ----------------------
9bd3caba 517 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
173558f2 518
9bd3caba 519 if ( !fPrimariesFolder ) {
9859bfc0 520 Fatal("PrimariesRef", "-> Folder //%s not found!",fPrimariesFolder);
9bd3caba 521 }
173558f2 522
9bd3caba 523 TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
173558f2 524
9bd3caba 525 if ( !primariesFolder ) {
9859bfc0 526 Fatal("PrimariesRef", "-> Folder //%s/Primaries/ not found!",fPrimariesFolder);
9bd3caba 527 }
173558f2 528
9bd3caba 529 TObject * p = primariesFolder->FindObject("Primaries") ;
173558f2 530
9bd3caba 531 if(!p) {
9859bfc0 532 Fatal("PrimariesRef", "-> %s/Primaries not found !",primariesFolder->GetName());
9bd3caba 533 }
173558f2 534
9859bfc0 535 return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
9bd3caba 536}
537
538//____________________________________________________________________________
173558f2 539
05a92d59 540const Bool_t AliEMCALGetter::PostHits(void) const
9859bfc0 541{
542 //------- Hits ----------------------
ffa6d63b 543 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
173558f2 544
ffa6d63b 545 TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
173558f2 546
ffa6d63b 547 if ( !emcalFolder ) {
d75bea67 548 if (fDebug) {
9859bfc0 549 Warning("PostHits", "-> Folder //%s/EMCAL/ not found!", fHitsFolder);
550 Info("PostHits", "-> Adding Folder //%s/EMCAL/",fHitsFolder);
d75bea67 551 }
ffa6d63b 552 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
553 }
173558f2 554
ffa6d63b 555 TClonesArray *hits= new TClonesArray("AliEMCALHit",1000) ;
556 hits->SetName("Hits") ;
557 emcalFolder->Add(hits) ;
173558f2 558
ffa6d63b 559 return kTRUE;
560}
561
562//____________________________________________________________________________
173558f2 563
472319e5 564TObject ** AliEMCALGetter::HitsRef(void) const
9859bfc0 565{
566 //------- Hits ----------------------
ffa6d63b 567 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
173558f2 568
ffa6d63b 569 if ( !fHitsFolder ) {
9859bfc0 570 Error("HitsRef", "-> Folder //%s not found!",fHitsFolder);
ffa6d63b 571 return 0;
572 }
173558f2 573
ffa6d63b 574 TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
575 if ( !emcalFolder ) {
9859bfc0 576 Error("HitsRef", "-> Folder //%s/EMCAL/ not found!",fHitsFolder);
ffa6d63b 577 return 0;
578 }
173558f2 579
ffa6d63b 580 TObject * h = emcalFolder->FindObject("Hits") ;
173558f2 581
ffa6d63b 582 if(!h) {
9859bfc0 583 Error("HitsRef", "-> %s/Hits not found !",emcalFolder->GetName());
ffa6d63b 584 return 0 ;
585 }
586 else
472319e5 587 return emcalFolder->GetListOfFolders()->GetObjectRef(h) ;
ffa6d63b 588}
589
590//____________________________________________________________________________
173558f2 591
05a92d59 592const Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const
9859bfc0 593{
594 //---------- SDigits -------------------------
ffa6d63b 595 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
596 // because you can have sdigits from several hit files for mixing
173558f2 597
ffa6d63b 598 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
173558f2 599
ffa6d63b 600 if ( !emcalFolder ) {
d75bea67 601 if (fDebug) {
9859bfc0 602 Warning("PostSDigits", "-> Folder //%s/EMCAL/ not found!", fSDigitsFolder);
603 Info("PostSDigits", "-> Adding Folder //%s/EMCAL/",fHitsFolder);
d75bea67 604 }
ffa6d63b 605 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
606 }
05a92d59 607
ffa6d63b 608 TString subdir(headerFile) ;
35014875 609 subdir.ReplaceAll("/", "_") ;
ffa6d63b 610 TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ;
611 if ( !emcalSubFolder )
612 emcalSubFolder = emcalFolder->AddFolder(subdir, "");
05a92d59 613
ffa6d63b 614 TObject * sd = emcalSubFolder->FindObject(name);
173558f2 615
05a92d59 616 if ( !sd ) {
d75bea67 617 TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
ffa6d63b 618 sdigits->SetName(name) ;
619 emcalSubFolder->Add(sdigits) ;
620 }
173558f2 621
ffa6d63b 622 return kTRUE;
623}
173558f2 624
ffa6d63b 625//____________________________________________________________________________
173558f2 626
472319e5 627TObject ** AliEMCALGetter::SDigitsRef(const char * name, const char * file) const
9859bfc0 628{
629 //------- SDigits ----------------------
ffa6d63b 630 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
631
632 if ( !fSDigitsFolder ) {
9859bfc0 633 Fatal("SDigitsRef", "-> Folder //%s not found!", fSDigitsFolder);
ffa6d63b 634 }
173558f2 635
ffa6d63b 636 TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
173558f2 637
ffa6d63b 638 if ( !emcalFolder ) {
9859bfc0 639 Fatal("SDigitsRef", "-> Folder //%s/EMCAL/ not found!", fSDigitsFolder);
ffa6d63b 640 }
641
642 TFolder * emcalSubFolder = 0 ;
173558f2 643
ffa6d63b 644 if(file)
645 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
646 else
647 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
173558f2 648
ffa6d63b 649 if(!emcalSubFolder) {
9859bfc0 650 Fatal("SDigitsRef", "-> Folder //Folders/RunMC/Event/Data/EMCAL/%s not found!", file);
ffa6d63b 651 }
652
653 TObject * dis = emcalSubFolder->FindObject(name) ;
173558f2 654
05a92d59 655 if(!dis) {
9859bfc0 656 Fatal("SDigitsRef", "-> object %s not found!", name);
05a92d59 657 }
173558f2 658
9859bfc0 659 return emcalSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
ffa6d63b 660}
661
662//____________________________________________________________________________
173558f2 663
05a92d59 664const Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const
9859bfc0 665{
666 //---------- SDigitizer -------------------------
ffa6d63b 667 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
668
ffa6d63b 669 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
670
671 if ( !sd ) {
9859bfc0 672 Error("PostSDigitizer", "-> Task //%s/SDigitizer not found!",fTasksFolder);
ffa6d63b 673 return kFALSE ;
674 }
173558f2 675
ffa6d63b 676 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 677
ffa6d63b 678 if ( !emcal ) {
d75bea67 679 if (fDebug) {
9859bfc0 680 Warning("PostSDigitizer", "->//%s/SDigitizer/EMCAL/ not found!",fTasksFolder);
681 Info("PostSDigitizer", "-> Adding //%s/SDigitizer/EMCAL/", fTasksFolder);
d75bea67 682 }
ffa6d63b 683 emcal = new TTask("EMCAL", "") ;
684 sd->Add(emcal) ;
685 }
173558f2 686
ffa6d63b 687 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
173558f2 688
ffa6d63b 689 if (emcalsd) {
d75bea67 690 if (fDebug)
9859bfc0 691 Info("PostSDigitizer", "-> Task %s already exists",sdigitizer->GetName());
ffa6d63b 692 emcal->GetListOfTasks()->Remove(emcalsd) ;
693 }
173558f2 694
ffa6d63b 695 emcal->Add(sdigitizer) ;
173558f2 696
ffa6d63b 697 return kTRUE;
ffa6d63b 698}
699
700//____________________________________________________________________________
173558f2 701
472319e5 702TObject ** AliEMCALGetter::SDigitizerRef(const char * name) const
ffa6d63b 703{
ffa6d63b 704 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
173558f2 705
ffa6d63b 706 if ( !sd ) {
9859bfc0 707 Fatal("SDigitizerRef", "-> Task //%s/SDigitizer not found!", fTasksFolder);
ffa6d63b 708 }
709
710 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 711
ffa6d63b 712 if ( !emcal ) {
9859bfc0 713 Fatal("SDigitizerRef", "-> //%s/SDigitizer/EMCAL not found!", fTasksFolder);
ffa6d63b 714 }
715
716 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
717
472319e5 718 return emcal->GetListOfTasks()->GetObjectRef(task) ;
ffa6d63b 719}
720
721//____________________________________________________________________________
173558f2 722
05a92d59 723const Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const
9859bfc0 724{
725 //---------- SDigitizer -------------------------
726 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
173558f2 727
ffa6d63b 728 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
173558f2 729
ffa6d63b 730 if ( !sd ) {
9859bfc0 731 Error("PostSDigitizer", "-> Task //%s/SDigitizer not found!", fTasksFolder);
ffa6d63b 732 return kFALSE ;
733 }
734
735 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 736
ffa6d63b 737 if ( !emcal ) {
d75bea67 738 if (fDebug) {
9859bfc0 739 Warning("PostSDigitizer", "-> //%s/SDigitizer/EMCAL/ not found!", fTasksFolder);
173558f2 740
9859bfc0 741 Info("PostSDigitizer", "-> Adding //%s/SDigitizer/EMCAL", fTasksFolder);
173558f2 742
d75bea67 743 }
ffa6d63b 744 emcal = new TTask("EMCAL", "") ;
745 sd->Add(emcal) ;
746 }
747
748 TString sdname(name) ;
749 sdname.Append(":") ;
750 sdname.Append(file);
54b82aa4 751 sdname.ReplaceAll("/","_") ;
ffa6d63b 752 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname ));
173558f2 753
ffa6d63b 754 if (!emcalsd) {
755 emcalsd = new AliEMCALSDigitizer() ;
173558f2 756
6c58180f 757 //Note, we can not call constructor with parameters: it will call Getter and screw up everething
173558f2 758
ffa6d63b 759 emcalsd->SetName(sdname) ;
760 emcalsd->SetTitle(file) ;
761 emcal->Add(emcalsd) ;
762 }
173558f2 763
ffa6d63b 764 return kTRUE;
ffa6d63b 765}
766
767//____________________________________________________________________________
173558f2 768
05a92d59 769const Bool_t AliEMCALGetter::PostDigits(const char * name) const
9859bfc0 770{
771 //---------- Digits -------------------------
ffa6d63b 772 // the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
773
774 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
775
776 if ( !emcalFolder ) {
d75bea67 777 if (fDebug) {
9859bfc0 778 Warning("PostDigits", "-> Folder //%s/EMCAL/ not found!", fDigitsFolder);
779 Info("PostDigits", "-> Adding Folder //%s/EMCAL/", fDigitsFolder);
d75bea67 780 }
ffa6d63b 781 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
782 }
173558f2 783
ffa6d63b 784 TObject* dig = emcalFolder->FindObject( name ) ;
173558f2 785
ffa6d63b 786 if ( !dig ) {
787 TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
788 digits->SetName(name) ;
789 emcalFolder->Add(digits) ;
790 }
173558f2 791
ffa6d63b 792 return kTRUE;
793}
794
795//____________________________________________________________________________
173558f2 796
472319e5 797TObject ** AliEMCALGetter::DigitsRef(const char * name) const
9859bfc0 798{
799 //------- Digits ----------------------
ffa6d63b 800 // the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
801
802 if ( !fDigitsFolder ) {
9859bfc0 803 Fatal("DigitsRef", "-> Folder //%s not found!", fDigitsFolder);
ffa6d63b 804 }
173558f2 805
ffa6d63b 806 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
173558f2 807
ffa6d63b 808 if ( !emcalFolder ) {
9859bfc0 809 Fatal("DigitsRef", "-> Folder //%s/EMCAL/ not found!", fDigitsFolder);
ffa6d63b 810 }
811
812 TObject * d = emcalFolder->FindObject(name) ;
173558f2 813
05a92d59 814 if(!d) {
9859bfc0 815 Fatal("DigitsRef", "-> object %s not found!", name);
05a92d59 816 }
173558f2 817
9859bfc0 818 return emcalFolder->GetListOfFolders()->GetObjectRef(d) ;
ffa6d63b 819}
820
821//____________________________________________________________________________
173558f2 822
9859bfc0 823const Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const
824{
825 //---------- Digitizer -------------------------
173558f2 826
ffa6d63b 827 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
828
829 if ( !sd ) {
9859bfc0 830 Error("PostDigitizer", "-> Task //%s/Digitizer not found!", fTasksFolder);
ffa6d63b 831 return kFALSE ;
832 }
173558f2 833
ffa6d63b 834 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 835
ffa6d63b 836 if ( !emcal ) {
d75bea67 837 if (fDebug) {
9859bfc0 838 Warning("PostDigitizer", "-> //%s/Digitizer/EMCAL not found!", fTasksFolder);
839 Info("PostDigitizer", "-> Adding //%s/Digitizer/EMCAL", fTasksFolder);
d75bea67 840 }
ffa6d63b 841 emcal = new TTask("EMCAL", "") ;
842 sd->Add(emcal) ;
843 }
844
845 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ;
173558f2 846
ffa6d63b 847 if (emcald) {
848 emcald->Delete() ;
849 emcal->GetListOfTasks()->Remove(emcald) ;
850 }
173558f2 851
ffa6d63b 852 emcal->Add(digitizer) ;
173558f2 853
ffa6d63b 854 return kTRUE;
855}
856
857//____________________________________________________________________________
173558f2 858
05a92d59 859const Bool_t AliEMCALGetter::PostDigitizer(const char * name) const
9859bfc0 860{
861 //---------- Digitizer -------------------------
862 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
173558f2 863
ffa6d63b 864 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
173558f2 865
ffa6d63b 866 if ( !d ) {
173558f2 867
9859bfc0 868 Error("PostDigitizer", "-> Task //%s/Digitizer not found!", fTasksFolder);
ffa6d63b 869 return kFALSE ;
870 }
871
872 TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 873
ffa6d63b 874 if ( !emcal ) {
d75bea67 875 if (fDebug) {
9859bfc0 876 Warning("PostDigitizer", "-> //%s/Digitizer/EMCAL not found!", fTasksFolder);
173558f2 877
9859bfc0 878 Info("PostDigitizer", "-> Adding //%s/Digitizer/EMCAL", fTasksFolder);
d75bea67 879 }
ffa6d63b 880 emcal = new TTask("EMCAL", "") ;
881 d->Add(emcal) ;
882}
883
884 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ;
173558f2 885
ffa6d63b 886 if (!emcald) {
887 emcald = new AliEMCALDigitizer() ;
888 emcald->SetName(fDigitsTitle) ;
889 emcald->SetTitle(fHeaderFile) ;
890 emcal->Add(emcald) ;
891 }
173558f2 892
ffa6d63b 893 return kTRUE;
894}
895
896//____________________________________________________________________________
173558f2 897
472319e5 898TObject ** AliEMCALGetter::DigitizerRef(const char * name) const
ffa6d63b 899{
173558f2 900
ffa6d63b 901 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
173558f2 902
ffa6d63b 903 if ( !sd ) {
9859bfc0 904 Fatal("DigitizerRef", "-> Task //%s/Digitizer not found!", fTasksFolder->GetName());
ffa6d63b 905 }
906
907 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 908
ffa6d63b 909 if ( !emcal ) {
9859bfc0 910 Fatal("DigitizerRef", "-> //%s/Digitizer/EMCAL", fTasksFolder->GetName());
ffa6d63b 911 }
912
913 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
914
472319e5 915 return emcal->GetListOfTasks()->GetObjectRef(task) ;
ffa6d63b 916}
173558f2 917
ffa6d63b 918//____________________________________________________________________________
173558f2 919
05a92d59 920const Bool_t AliEMCALGetter::PostRecPoints(const char * name) const
9859bfc0 921{
922 // -------------- RecPoints -------------------------------------------
f07cab21 923 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
05a92d59 924 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
d75bea67 925
926 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
173558f2 927
d75bea67 928 if ( !emcalFolder ) {
929 if (fDebug) {
9859bfc0 930 Warning("PostRecPoints", "-> Folder //%s/EMCAL/ not found!", fRecoFolder);
931 Info("PostRecPoints", "-> Adding Folder //%s/EMCAL/", fRecoFolder);
d75bea67 932 }
933 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
934 }
173558f2 935
f07cab21 936 // Tower RecPoints
173558f2 937
f07cab21 938 TFolder * emcalRPoTowerFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TowerRecPoints")) ;
173558f2 939
f07cab21 940 if ( !emcalRPoTowerFolder ) {
d75bea67 941 if (fDebug) {
173558f2 942
9859bfc0 943 Warning("PostRecPoints", "-> Folder //%s/EMCAL/TowerRecPoints/ not found!", fRecoFolder);
944 Info("PostRecPoints", "-> Adding Folder //%s/EMCAL/TowerRecPoints not found!", fRecoFolder);
d75bea67 945 }
f07cab21 946 emcalRPoTowerFolder = emcalFolder->AddFolder("TowerRecPoints", "Tower RecPoints from EMCAL") ;
d75bea67 947 }
173558f2 948
d75bea67 949 TObject * erp = emcalFolder->FindObject( name ) ;
173558f2 950
d75bea67 951 if ( !erp ) {
f07cab21 952 TObjArray * towerrp = new TObjArray(100) ;
953 towerrp->SetName(name) ;
954 emcalRPoTowerFolder->Add(towerrp) ;
d75bea67 955 }
956
f07cab21 957 // Pre Shower RecPoints
173558f2 958
05a92d59 959 TFolder * emcalRPoPreShoFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("PreShowerRecPoints")) ;
173558f2 960
f07cab21 961 if ( !emcalRPoPreShoFolder ) {
d75bea67 962 if (fDebug) {
9859bfc0 963 Warning("PostRecPoints", "-> Folder //%s/EMCAL/PreShowerRecPoints/ not found!", fRecoFolder);
964 Info("PostRecPoints", "-> Adding Folder //%s/EMCAL/PreShowerRecPoints/", fRecoFolder);
d75bea67 965 }
05a92d59 966 emcalRPoPreShoFolder = emcalFolder->AddFolder("PreShowerRecPoints", "PreSho RecPoints from EMCAL") ;
d75bea67 967 }
173558f2 968
f07cab21 969 TObject * crp = emcalRPoPreShoFolder->FindObject( name ) ;
173558f2 970
d75bea67 971 if ( !crp ) {
f07cab21 972 TObjArray * preshorp = new TObjArray(100) ;
973 preshorp->SetName(name) ;
974 emcalRPoPreShoFolder->Add(preshorp) ;
d75bea67 975 }
173558f2 976
d75bea67 977 return kTRUE;
978}
979
980//____________________________________________________________________________
173558f2 981
f07cab21 982TObject ** AliEMCALGetter::TowerRecPointsRef(const char * name) const
9859bfc0 983{
984 // -------------- RecPoints -------------------------------------------
f07cab21 985 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
173558f2 986
d75bea67 987 if ( !fRecoFolder ) {
9859bfc0 988 Fatal("TowerRecPointsRef", "-> Folder //%s not found!", fRecoFolder);
d75bea67 989 }
990
f07cab21 991 TFolder * towerFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
173558f2 992
f07cab21 993 if ( !towerFolder ) {
9859bfc0 994 Fatal("TowerRecPointsRef", "-> Folder //%s/EMCAL/TowerRecPoints/ not found!", fRecoFolder);
d75bea67 995 }
996
f07cab21 997 TObject * trp = towerFolder->FindObject(name ) ;
173558f2 998
f07cab21 999 if ( !trp ) {
9859bfc0 1000 Fatal("TowerRecPointsRef", "-> Object %s not found!", name);
d75bea67 1001 }
173558f2 1002
f07cab21 1003 return towerFolder->GetListOfFolders()->GetObjectRef(trp) ;
d75bea67 1004}
1005
1006//____________________________________________________________________________
173558f2 1007
05a92d59 1008TObject ** AliEMCALGetter::PreShowerRecPointsRef(const char * name) const
9859bfc0 1009{
1010 // -------------- RecPoints -------------------------------------------
05a92d59 1011 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
173558f2 1012
d75bea67 1013 if ( !fRecoFolder ) {
9859bfc0 1014 Fatal("PreShowerRecPointsRef", "-> Folder //%s not found!", fRecoFolder);
d75bea67 1015 }
1016
05a92d59 1017 TFolder * preshoFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
173558f2 1018
f07cab21 1019 if ( !preshoFolder ) {
9859bfc0 1020 Fatal("PreShowerRecPointsRef", "-> Folder //%s/EMCAL/PreShowerRecPoints/", fRecoFolder);
d75bea67 1021 }
1022
173558f2 1023
1024
f07cab21 1025 TObject * prp = preshoFolder->FindObject(name ) ;
173558f2 1026
f07cab21 1027 if ( !prp ) {
9859bfc0 1028 Fatal("PreShowerRecPointsRef", "-> Object %s not found!", name);
d75bea67 1029 }
173558f2 1030
f07cab21 1031 return preshoFolder->GetListOfFolders()->GetObjectRef(prp) ;
d75bea67 1032}
1033
1034//____________________________________________________________________________
173558f2 1035
05a92d59 1036const Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizer * clu) const
9859bfc0 1037{
1038 // ------------------ AliEMCALClusterizer ------------------------
d75bea67 1039 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1040
1041 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1042
1043 if ( !tasks ) {
9859bfc0 1044 Error("PostClusterizer", "-> Task //%s/Reconstructioner not found!", fTasksFolder);
d75bea67 1045 return kFALSE ;
1046 }
173558f2 1047
d75bea67 1048 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 1049
d75bea67 1050 if ( !emcal ) {
1051 if (fDebug) {
9859bfc0 1052 Warning("PostClusterizer", "-> //%s/ReconstructionerEMCAL not found!", fTasksFolder);
1053 Info("PostClusterizer", "-> Adding //%s/Reconstructioner/EMCAL", fTasksFolder);
d75bea67 1054 }
1055 emcal = new TTask("EMCAL", "") ;
1056 tasks->Add(emcal) ;
1057 }
1058
ea4de7a2 1059 AliEMCALClusterizerv1 * emcalcl = dynamic_cast<AliEMCALClusterizerv1*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ;
173558f2 1060
d75bea67 1061 if (emcalcl) {
1062 if (fDebug)
9859bfc0 1063 Info("PostClusterizer", "-> Task %s already exists", clu->GetName());
d75bea67 1064 emcalcl->Delete() ;
1065 emcal->GetListOfTasks()->Remove(emcalcl) ;
1066 }
1067 emcal->Add(clu) ;
173558f2 1068
d75bea67 1069 return kTRUE;
1070}
1071
1072//____________________________________________________________________________
173558f2 1073
472319e5 1074TObject ** AliEMCALGetter::ClusterizerRef(const char * name) const
9859bfc0 1075{
1076 // ------------------ AliEMCALClusterizer ------------------------
173558f2 1077
d75bea67 1078 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1079
1080 if ( !tasks ) {
9859bfc0 1081 Fatal("ClusterizerRef", "-> Task //%s/Reconstructioner not found!", fTasksFolder->GetName());
d75bea67 1082 }
173558f2 1083
d75bea67 1084 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 1085
d75bea67 1086 if ( !emcal ) {
9859bfc0 1087 Fatal("ClusterizerRef", "-> //%s/Reconstructioner/EMCAL", fTasksFolder->GetName());
d75bea67 1088 }
1089
1090 TList * l = emcal->GetListOfTasks() ;
1091 TIter it(l) ;
1092 TTask * task ;
1093 TTask * clu = 0 ;
1094 TString cluname(name) ;
1095 cluname+=":clu-" ;
173558f2 1096
d75bea67 1097 while((task = static_cast<TTask *>(it.Next()) )){
1098 TString taskname(task->GetName()) ;
1099 if(taskname.BeginsWith(cluname)){
1100 clu = task ;
1101 break ;
1102 }
1103 }
1104
9859bfc0 1105 if(!clu) {
1106 Fatal("ClusterizerRef", "-> task %s not found!", task->GetName());
52ea052c 1107 }
173558f2 1108
9859bfc0 1109 return l->GetObjectRef(clu) ;
d75bea67 1110}
1111
1112//____________________________________________________________________________
173558f2 1113
05a92d59 1114const Bool_t AliEMCALGetter::PostClusterizer(const char * name) const
9859bfc0 1115{
1116 // ------------------ AliEMCALClusterizer ------------------------
d75bea67 1117 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1118
173558f2 1119
d75bea67 1120 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1121
1122 if ( !tasks ) {
9859bfc0 1123 Error("PostClusterizer", "-> Task //%s/Reconstructioner not found!", fTasksFolder->GetName());
d75bea67 1124 return kFALSE ;
1125 }
173558f2 1126
d75bea67 1127 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 1128
d75bea67 1129 if ( !emcal ) {
1130 if (fDebug) {
9859bfc0 1131 Warning("PostClusterizer", "-> //%s/Reconstructioner/EMCAL not found!", fTasksFolder);
1132 Info("PostClusterizer", "-> Adding //%s/Reconstructioner/EMCAL", fTasksFolder);
d75bea67 1133 }
1134 emcal = new TTask("EMCAL", "") ;
1135 tasks->Add(emcal) ;
1136 }
1137
b134c32f 1138 TList * l = emcal->GetListOfTasks() ;
1139 TIter it(l) ;
d75bea67 1140 TString clun(name) ;
b134c32f 1141 clun+=":clu" ;
1142 TTask * task ;
173558f2 1143
b134c32f 1144 while((task = static_cast<TTask *>(it.Next()) )){
1145 TString taskname(task->GetName()) ;
173558f2 1146
b134c32f 1147 if(taskname.BeginsWith(clun))
1148 return kTRUE ;
1149 }
1150
1151 AliEMCALClusterizerv1 * emcalcl = new AliEMCALClusterizerv1() ;
173558f2 1152
05a92d59 1153 clun+="-v1" ;
1154 emcalcl->SetName(clun) ;
1155 emcalcl->SetTitle(fHeaderFile) ;
d75bea67 1156 emcal->Add(emcalcl) ;
173558f2 1157
d75bea67 1158 return kTRUE;
d75bea67 1159}
1160
05a92d59 1161//____________________________________________________________________________
173558f2 1162
05a92d59 1163TTree * AliEMCALGetter::TreeK(TString filename)
1164{
05a92d59 1165 // returns TreeK from file filename
1166 // usefull in case of split file
1167
1168 if ( filename.IsNull() )
1169 filename = fHeaderFile ;
1170
1171 TFile * file = 0 ;
173558f2 1172
05a92d59 1173 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
173558f2 1174
5b5d8342 1175 if (!file) { // file not yet open
5b5d8342 1176 file = TFile::Open(filename.Data(), "read") ;
05a92d59 1177 }
173558f2 1178
05a92d59 1179 TString treeName("TreeK") ;
1180 treeName += EventNumber() ;
1181 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
173558f2 1182
05a92d59 1183 if (!tree && fDebug)
9859bfc0 1184 Warning("TreeK", "-> %s not found in %s", treeName.Data(),filename.Data());
173558f2 1185
05a92d59 1186 return tree ;
1187}
1188
1189//____________________________________________________________________________
173558f2 1190
05a92d59 1191TTree * AliEMCALGetter::TreeH(TString filename)
1192{
05a92d59 1193 // returns TreeH from file filename
1194 // usefull in case of split file
1195
1196 if ( filename.IsNull() )
1197 filename = fHeaderFile ;
1198
1199 TFile * file = 0 ;
1200 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
173558f2 1201
05a92d59 1202 if (!file) { // file not open yet
1203 file = TFile::Open(filename.Data(), "read") ;
1204 }
173558f2 1205
05a92d59 1206 TString treeName("TreeH") ;
1207 treeName += EventNumber() ;
1208 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
173558f2 1209
05a92d59 1210 if (!tree && fDebug)
9859bfc0 1211 Warning("TreeH", "-> %s not found in %s", treeName.Data(), filename.Data());
05a92d59 1212 return tree ;
1213}
1214
1215//____________________________________________________________________________
173558f2 1216
05a92d59 1217TTree * AliEMCALGetter::TreeS(TString filename)
1218{
05a92d59 1219 // returns TreeS from file filename
1220 // usefull in case of split file
1221
1222 if ( filename.IsNull() )
1223 filename = fHeaderFile ;
1224
1225 TFile * file = 0 ;
1226 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
173558f2 1227
05a92d59 1228 if (!file) { // file not open yet
1229 file = TFile::Open(filename.Data(), "read") ;
1230 }
173558f2 1231
05a92d59 1232 TString treeName("TreeS") ;
1233 treeName += EventNumber() ;
1234 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
173558f2 1235
05a92d59 1236 if (!tree && fDebug)
9859bfc0 1237 Warning("TreeS", "-> %s not found in %s", treeName.Data(), filename.Data());
05a92d59 1238 return tree ;
1239}
1240
1241//____________________________________________________________________________
173558f2 1242
05a92d59 1243TTree * AliEMCALGetter::TreeD(TString filename)
1244{
05a92d59 1245 // returns TreeD from file filename
1246 // usefull in case of split file
1247
1248 if ( filename.IsNull() )
1249 filename = fHeaderFile ;
1250
1251 TFile * file = 0 ;
1252 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
173558f2 1253
05a92d59 1254 if (!file) { // file not open yet
1255 file = TFile::Open(filename.Data(), "read") ;
1256 }
173558f2 1257
05a92d59 1258 TString treeName("TreeD") ;
1259 treeName += EventNumber() ;
1260 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
173558f2 1261
05a92d59 1262 if (!tree && fDebug)
9859bfc0 1263 Warning("TreeD", "-> %s not found in %s", treeName.Data(), filename.Data());
05a92d59 1264 return tree ;
1265}
1266
d75bea67 1267//____________________________________________________________________________
173558f2 1268
ffa6d63b 1269const TParticle * AliEMCALGetter::Primary(Int_t index) const
1270{
1271 // Return primary particle numbered by <index>
173558f2 1272
ffa6d63b 1273 if(index < 0)
1274 return 0 ;
173558f2 1275
9bd3caba 1276 TParticle * p = 0 ;
5b5d8342 1277 p = gAlice->Particle(index) ;
9bd3caba 1278
1279 return p ;
ffa6d63b 1280}
1281
1282//____________________________________________________________________________
173558f2 1283
05a92d59 1284const TParticle * AliEMCALGetter::Secondary(TParticle* p, Int_t index) const
ffa6d63b 1285{
05a92d59 1286 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1287
1288 if(index <= 0)
1289 return 0 ;
1290 if(index > 2)
1291 return 0 ;
1292
1293 if(p) {
9859bfc0 1294 Int_t daughterIndex = p->GetDaughter(index-1) ;
1295 return gAlice->Particle(daughterIndex) ;
05a92d59 1296 }
1297 else
1298 return 0 ;
1299}
9bd3caba 1300
05a92d59 1301//____________________________________________________________________________
173558f2 1302
05a92d59 1303Int_t AliEMCALGetter::ReadTreeD(const Int_t event)
1304{
1305 // Read the digit tree gAlice->TreeD()
173558f2 1306
05a92d59 1307 TTree * treeD ;
1308 if(fToSplit){
1309 TFile * file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName));
1310 if(!file)
1311 file = TFile::Open(fDigitsFileName) ;
173558f2 1312
05a92d59 1313 // Get Digits Tree header from file
173558f2 1314
05a92d59 1315 TString treeName("TreeD") ;
1316 treeName += event ;
1317 treeD = dynamic_cast<TTree*>(file->Get(treeName.Data()));
173558f2 1318
05a92d59 1319 if(!treeD){ // TreeD not found in header file
1320 if (fDebug)
9859bfc0 1321 Warning("ReadTreeD", "-> Cannot find TreeD in %s", fDigitsFileName.Data());
05a92d59 1322 return 1;
1323 }
9bd3caba 1324 }
05a92d59 1325 else
1326 treeD = gAlice->TreeD() ;
173558f2 1327
05a92d59 1328 TObjArray * lob = static_cast<TObjArray*>(treeD->GetListOfBranches()) ;
ffa6d63b 1329 TIter next(lob) ;
1330 TBranch * branch = 0 ;
1331 TBranch * digitsbranch = 0 ;
1332 TBranch * digitizerbranch = 0 ;
173558f2 1333
ffa6d63b 1334 Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
173558f2 1335
ffa6d63b 1336 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
1337 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1338 digitsbranch = branch ;
1339 emcalfound = kTRUE ;
1340 }
1341 else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1342 digitizerbranch = branch ;
1343 digitizerfound = kTRUE ;
1344 }
1345 }
1346
1347 if ( !emcalfound || !digitizerfound ) {
d75bea67 1348 if (fDebug)
9859bfc0 1349 Warning("ReadTreeD", "-> Cannot find Digits and/or Digitizer with name %s", fDigitsTitle.Data());
05a92d59 1350 return 2;
ffa6d63b 1351 }
173558f2 1352
ffa6d63b 1353 //read digits
173558f2 1354
ffa6d63b 1355 if(!Digits(fDigitsTitle) )
1356 PostDigits(fDigitsTitle);
1357 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1358 digitsbranch->GetEntry(0) ;
173558f2 1359
ffa6d63b 1360 // read the Digitizer
173558f2 1361
05a92d59 1362 RemoveTask("D", fDigitsTitle) ; // I do not understand why I need that
ffa6d63b 1363 if(!Digitizer(fDigitsTitle))
1364 PostDigitizer(fDigitsTitle) ;
92f521a9 1365 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1366 digitizerbranch->GetEntry(0) ;
173558f2 1367
9859bfc0 1368 lob->Delete();
173558f2 1369
05a92d59 1370 if(gAlice->TreeD()!=treeD)
1371 treeD->Delete();
173558f2 1372
05a92d59 1373 return 0 ;
ffa6d63b 1374}
1375
1376//____________________________________________________________________________
173558f2 1377
05a92d59 1378Int_t AliEMCALGetter::ReadTreeH()
ffa6d63b 1379{
1380 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1381
9bd3caba 1382 TTree * treeH = gAlice->TreeH() ;
173558f2 1383
9bd3caba 1384 if(!treeH) {// TreeH not found in header file
9bd3caba 1385 if (fDebug)
9859bfc0 1386 Warning("ReadTreeH", "-> Cannot find TreeH in %s", fHeaderFile.Data());
173558f2 1387
05a92d59 1388 TString searchFileName("EMCAL.HITS") ;
1389 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
1390 searchFileName+="." ;
1391 searchFileName += fBranchTitle ;
1392 }
173558f2 1393
05a92d59 1394 searchFileName+=".root" ;
173558f2 1395
05a92d59 1396 if ( (treeH = TreeH(searchFileName)) ) { //found TreeH in the file which contains the hits
9bd3caba 1397 if (fDebug)
9859bfc0 1398 Info("ReadTreeH", "-> TreeH found in %s", searchFileName.Data());
9bd3caba 1399 } else {
9859bfc0 1400 Error("ReadTreeH", "-> TreeH not found ");
05a92d59 1401 return 1;
9bd3caba 1402 }
05a92d59 1403 }
173558f2 1404
ffa6d63b 1405 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
173558f2 1406
ffa6d63b 1407 if ( !hitsbranch ) {
d75bea67 1408 if (fDebug)
9859bfc0 1409 Warning("ReadTreeH", "-> Cannot find branch EMCAL");
05a92d59 1410 return 2;
ffa6d63b 1411 }
173558f2 1412
ffa6d63b 1413 if(!Hits())
1414 PostHits() ;
173558f2 1415
472319e5 1416 if (hitsbranch->GetEntries() > 1 ) {
05a92d59 1417 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
472319e5 1418 TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000) ;
1419 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1420 hitsbranch->SetAddress(&tempo) ;
173558f2 1421
472319e5 1422 Int_t index = 0 ;
1423 Int_t i = 0 ;
173558f2 1424
472319e5 1425 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1426 hitsbranch->GetEntry(i) ;
1427 Int_t j = 0 ;
1428 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
9859bfc0 1429 const AliEMCALHit * hit = static_cast<const AliEMCALHit *>(tempo->At(j)) ;
1430 new((*hits)[index]) AliEMCALHit( *hit ) ;
1431 index++ ;
472319e5 1432 }
1433 }
1434 delete tempo ;
1435 }
1436 else {
9859bfc0 1437 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1438 hitsbranch->SetAddress(HitsRef()) ;
1439 hitsbranch->GetEntry(0) ;
472319e5 1440 }
05a92d59 1441 return 0 ;
ffa6d63b 1442}
1443
1444//____________________________________________________________________________
173558f2 1445
d36f79cd 1446void AliEMCALGetter::Track(const Int_t itrack)
ffa6d63b 1447{
1448 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
ffa6d63b 1449 if(gAlice->TreeH()== 0){
9859bfc0 1450 Error("ReadTreeH", "-> Cannot read TreeH ");
ffa6d63b 1451 return ;
1452 }
173558f2 1453
ffa6d63b 1454 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
173558f2 1455
ffa6d63b 1456 if ( !hitsbranch ) {
d75bea67 1457 if (fDebug)
9859bfc0 1458 Warning("ReadTreeH", "-> Cannot find branch EMCAL");
ffa6d63b 1459 return ;
1460 }
173558f2 1461
ffa6d63b 1462 if(!Hits())
1463 PostHits() ;
05a92d59 1464
1465 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
ffa6d63b 1466 hitsbranch->SetAddress(HitsRef()) ;
1467 hitsbranch->GetEntry(itrack) ;
ffa6d63b 1468}
9bd3caba 1469
9bd3caba 1470//____________________________________________________________________________
173558f2 1471
05a92d59 1472void AliEMCALGetter::ReadTreeQA()
9bd3caba 1473{
05a92d59 1474 if (fDebug)
9859bfc0 1475 Warning("ReadTreeQA", "-> %s not implemented", ClassName());
05a92d59 1476}
173558f2 1477
f07cab21 1478
173558f2 1479
d75bea67 1480//____________________________________________________________________________
173558f2 1481
05a92d59 1482Int_t AliEMCALGetter::ReadTreeR(const Int_t event)
173558f2 1483
d75bea67 1484{
05a92d59 1485 // Read the reconstrunction tree gAlice->TreeR()
1486 // A particularity has been introduced here :
1487 // if gime->Event(ievent,"R") is called branches with the current title are read, the current title
1488 // being for example give in AliPHOSPID(fileName, title)
1489 // if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
1490 // This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
1491 // from a given set of TrackSegments (with a given name)
1492 // This is why any is NOT used to read the branch of RecParticles
1493 // any migh have become obsolete : to be checked
1494 // See AliEMCALPIDv1
1495
9859bfc0 1496 TTree * treeR ;
173558f2 1497
05a92d59 1498 if(fToSplit){
1499 TFile * file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName));
1500 if(!file)
1501 file = TFile::Open(fRecPointsFileName) ;
173558f2 1502
05a92d59 1503 // Get Digits Tree header from file
173558f2 1504
05a92d59 1505 TString treeName("TreeR") ;
1506 treeName += event ;
1507 treeR = dynamic_cast<TTree*>(file->Get(treeName.Data()));
173558f2 1508
05a92d59 1509 if(!treeR){ // TreeR not found in header file
1510 if (fDebug)
9859bfc0 1511 Warning("ReadTreeD", "-> Cannot find TreeR in %s", fRecPointsFileName.Data());
05a92d59 1512 return 1;
1513 }
d75bea67 1514 }
05a92d59 1515 else
1516 treeR = gAlice->TreeR() ;
173558f2 1517
d75bea67 1518 // RecPoints
173558f2 1519
05a92d59 1520 TObjArray * lob = static_cast<TObjArray*>(treeR->GetListOfBranches()) ;
d75bea67 1521 TIter next(lob) ;
1522 TBranch * branch = 0 ;
f07cab21 1523 TBranch * towerbranch = 0 ;
05a92d59 1524 TBranch * preshowerbranch = 0 ;
d75bea67 1525 TBranch * clusterizerbranch = 0 ;
173558f2 1526
05a92d59 1527 Bool_t emcalTowerRPfound = kFALSE, emcalPreShoRPfound = kFALSE, clusterizerfound = kFALSE ;
1528
05a92d59 1529 while ( (branch = static_cast<TBranch*>(next())) && (!emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) ) {
1530 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 ) {
f07cab21 1531 if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
9859bfc0 1532 towerbranch = branch ;
1533 emcalTowerRPfound = kTRUE ;
d75bea67 1534 }
f07cab21 1535 else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
9859bfc0 1536 preshowerbranch = branch ;
1537 emcalPreShoRPfound = kTRUE ;
d75bea67 1538 }
1539 else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
9859bfc0 1540 clusterizerbranch = branch ;
1541 clusterizerfound = kTRUE ;
d75bea67 1542 }
1543 }
05a92d59 1544 }
d75bea67 1545
05a92d59 1546 if ( !emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) {
d75bea67 1547 if (fDebug)
9859bfc0 1548 Warning("ReadTreeR", "-> Cannot find RecPoints and/or Clusterizer with name %s", fRecPointsTitle.Data());
1549 }
1550 else {
05a92d59 1551 if(!TowerRecPoints(fRecPointsTitle) )
1552 PostRecPoints(fRecPointsTitle) ;
05a92d59 1553 towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
1554 towerbranch->GetEntry(0) ;
1555
1556 preshowerbranch->SetAddress(PreShowerRecPointsRef(fRecPointsTitle)) ;
1557 preshowerbranch->GetEntry(0) ;
173558f2 1558
05a92d59 1559 if(!Clusterizer(fRecPointsTitle) )
1560 PostClusterizer(fRecPointsTitle) ;
173558f2 1561
05a92d59 1562 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1563 clusterizerbranch->GetEntry(0) ;
1564 }
173558f2 1565
05a92d59 1566 if(gAlice->TreeR()!=treeR)
1567 treeR->Delete();
1568 return 0 ;
d75bea67 1569}
f07cab21 1570
d75bea67 1571//____________________________________________________________________________
173558f2 1572
9859bfc0 1573Int_t AliEMCALGetter::ReadTreeS(const Int_t event)
ffa6d63b 1574{
05a92d59 1575 // Reads the SDigits treeS from all files
1576 // Files, which should be opened are listed in emcalF
1577 // So, first get list of files
173558f2 1578
ffa6d63b 1579 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
173558f2 1580
ffa6d63b 1581 if (!emcalF)
1582 emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
173558f2 1583
ffa6d63b 1584 TCollection * folderslist = emcalF->GetListOfFolders() ;
173558f2 1585
05a92d59 1586 // Now iterate over the list of files and read TreeS into Whiteboard
173558f2 1587
ffa6d63b 1588 TIter next(folderslist) ;
1589 TFolder * folder = 0 ;
1590 TFile * file;
1591 TTree * treeS = 0;
173558f2 1592
ffa6d63b 1593 while ( (folder = static_cast<TFolder*>(next())) ) {
05a92d59 1594 TString fileName("") ;
1595 if(fToSplit)
1596 fileName = folder->GetTitle() ;
1597 else
1598 fileName = folder->GetName() ;
173558f2 1599
05a92d59 1600 fileName.ReplaceAll("_","/") ;
1601 file = static_cast<TFile*>(gROOT->GetFile(fileName));
173558f2 1602
05a92d59 1603 if(!file)
1604 file = TFile::Open(fileName) ;
173558f2 1605
05a92d59 1606 // Get SDigits Tree header from file
173558f2 1607
05a92d59 1608 TString treeName("TreeS") ;
1609 treeName += event ;
1610 treeS = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1611
1612 if(!treeS){ // TreeS not found in header file
1613 if (fDebug)
9859bfc0 1614 Warning("ReadTreeS", "-> Cannot find TreeS in %s", fileName.Data());
05a92d59 1615 return 1;
1616 }
173558f2 1617
05a92d59 1618 //set address of the SDigits and SDigitizer
173558f2 1619
05a92d59 1620 TBranch * sdigitsBranch = 0;
1621 TBranch * sdigitizerBranch = 0;
1622 TBranch * branch = 0 ;
1623 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1624 TIter next(lob) ;
173558f2 1625
05a92d59 1626 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1627
1628 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
1629 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
9859bfc0 1630 emcalfound = kTRUE ;
1631 sdigitsBranch = branch ;
05a92d59 1632 }
05a92d59 1633 else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) &&
9859bfc0 1634 (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1635 sdigitizerfound = kTRUE ;
1636 sdigitizerBranch = branch ;
05a92d59 1637 }
ffa6d63b 1638 }
05a92d59 1639 if ( !emcalfound || !sdigitizerfound ) {
1640 if (fDebug)
9859bfc0 1641 Warning("ReadSDigits", "-> Digits and/or Digitizer branch with name %s not found", GetName());
05a92d59 1642 return 2;
1643 }
173558f2 1644
05a92d59 1645 if ( !folder->FindObject(fSDigitsTitle) )
1646 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1647
1648 ((TClonesArray*) (*SDigitsRef(fSDigitsTitle,folder->GetName())))->Clear() ;
173558f2 1649
05a92d59 1650 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1651 sdigitsBranch->GetEntry(0) ;
173558f2 1652
05a92d59 1653 TString sdname(fSDigitsTitle) ;
1654 sdname+=":" ;
1655 sdname+=folder->GetName() ;
173558f2 1656
05a92d59 1657 if(!SDigitizer(sdname) )
1658 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
173558f2 1659
05a92d59 1660 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1661 sdigitizerBranch->GetEntry(0) ;
173558f2 1662
05a92d59 1663 if(gAlice->TreeS()!=treeS)
1664 treeS->Delete();
1665 }
1666 return 0 ;
ffa6d63b 1667}
9bd3caba 1668
ffa6d63b 1669//____________________________________________________________________________
173558f2 1670
ffa6d63b 1671void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
9859bfc0 1672{
1673 // Read the summable digits fron treeS()
173558f2 1674
ffa6d63b 1675 TString filename("mergefile") ;
1676 filename+= input ;
1677
1678 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1679 if ( !emcalFolder ) {
9859bfc0 1680 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
ffa6d63b 1681 }
173558f2 1682
ffa6d63b 1683 TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
173558f2 1684
ffa6d63b 1685 //set address of the SDigits and SDigitizer
173558f2 1686
ffa6d63b 1687 TBranch * sdigitsBranch = 0;
1688 TBranch * sdigitizerBranch = 0;
1689 TBranch * branch = 0 ;
1690 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1691 TIter next(lob) ;
173558f2 1692
ffa6d63b 1693 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
173558f2 1694
ffa6d63b 1695 while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
1696 if ( strcmp(branch->GetName(), "EMCAL")==0) {
1697 emcalfound = kTRUE ;
1698 sdigitsBranch = branch ;
1699 }
ffa6d63b 1700 else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
1701 sdigitizerfound = kTRUE ;
1702 sdigitizerBranch = branch ;
1703 }
1704 }
173558f2 1705
ffa6d63b 1706 if ( !emcalfound || !sdigitizerfound ) {
d75bea67 1707 if (fDebug)
9859bfc0 1708 Warning("ReadTreeS", "-> Digits and/or Digitizer branch not found");
ffa6d63b 1709 return ;
1710 }
173558f2 1711
ffa6d63b 1712 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1713 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1714
1715 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
d75bea67 1716 sdigitsBranch->GetEntry(0) ;
173558f2 1717
ffa6d63b 1718 TString sdname(sdigitsBranch->GetTitle()) ;
1719 sdname+=":" ;
1720 sdname+=filename ;
05a92d59 1721
ffa6d63b 1722 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1723 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
173558f2 1724
ffa6d63b 1725 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
ffa6d63b 1726 sdigitizerBranch->GetEntry(0) ;
173558f2 1727
05a92d59 1728 if(gAlice->TreeS()!=treeS)
1729 treeS->Delete();
ffa6d63b 1730}
1731
ffa6d63b 1732//____________________________________________________________________________
173558f2 1733
ffa6d63b 1734void AliEMCALGetter::ReadPrimaries()
1735{
173558f2 1736
ffa6d63b 1737 // Reads specific branches of primaries
173558f2 1738
9bd3caba 1739 TClonesArray * ar = 0 ;
173558f2 1740
9bd3caba 1741 if(! (ar = Primaries()) ) {
1742 PostPrimaries() ;
1743 ar = Primaries() ;
1744 }
173558f2 1745
9bd3caba 1746 ar->Delete() ;
173558f2 1747
9bd3caba 1748 if (TreeK(fHeaderFile)) { // treeK found in header file
1749 if (fDebug)
9859bfc0 1750 Info("ReadPrimaries", "-> TreeK found in %s", fHeaderFile.Data());
9bd3caba 1751 fNPrimaries = gAlice->GetNtrack() ;
9859bfc0 1752 }
1753 else { // treeK not found in header file
1754 Error("ReadPrimaries", "-> TreeK not found ");
05a92d59 1755 return ;
9bd3caba 1756 }
173558f2 1757
9bd3caba 1758 Int_t index = 0 ;
173558f2 1759
9bd3caba 1760 for (index = 0 ; index < fNPrimaries; index++) {
1761 new ((*ar)[index]) TParticle(*(Primary(index)));
1762 }
ffa6d63b 1763}
9bd3caba 1764
ffa6d63b 1765//____________________________________________________________________________
173558f2 1766
ffa6d63b 1767void AliEMCALGetter::Event(const Int_t event, const char* opt)
1768{
1769 // Reads the content of all Tree's S, D and R
173558f2 1770
ffa6d63b 1771 if (event >= gAlice->TreeE()->GetEntries() ) {
9859bfc0 1772 Error("Event", "-> %d not found in TreeE!", event);
ffa6d63b 1773 return ;
1774 }
ffa6d63b 1775
05a92d59 1776 Bool_t any = kFALSE ;
173558f2 1777
05a92d59 1778 if (strstr(opt,"A") ) // do not check the title of the branches
1779 any = kTRUE;
1780
1781 gAlice->GetEvent(event) ;
1782
9bd3caba 1783 if( strstr(opt,"R") )
05a92d59 1784 ReadTreeR(event) ;
ffa6d63b 1785
1786 if( strstr(opt,"D") )
05a92d59 1787 ReadTreeD(event) ;
ffa6d63b 1788
9bd3caba 1789 if(strstr(opt,"S") )
1790 ReadTreeS(event) ;
1791
1792 if(strstr(opt,"H") )
1793 ReadTreeH() ;
173558f2 1794
05a92d59 1795 if( strstr(opt,"Q") )
1796 ReadTreeQA() ;
173558f2 1797
5b5d8342 1798 if( strstr(opt,"P") )
9bd3caba 1799 ReadPrimaries() ;
ffa6d63b 1800}
1801
1802//____________________________________________________________________________
173558f2 1803
472319e5 1804TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
ffa6d63b 1805{
1806 // get the object named "what" from the folder
1807 // folders are named like //Folders
1808
1809 if ( file.IsNull() )
1810 file = fHeaderFile ;
1811
1812 TFolder * folder = 0 ;
1813 TObject * emcalO = 0 ;
1814
05a92d59 1815 if ( what.CompareTo("Primaries") == 0 ) {
1816 folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
1817 if (folder)
1818 emcalO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
1819 else
1820 return 0 ;
1821 }
1822 else if ( what.CompareTo("Hits") == 0 ) {
ffa6d63b 1823 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
1824 if (folder)
1825 emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1826 }
1827 else if ( what.CompareTo("SDigits") == 0 ) {
4e5c8d4c 1828 file.ReplaceAll("/","_") ;
ffa6d63b 1829 TString path = "EMCAL/" + file ;
1830 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1831 if (folder) {
d75bea67 1832 if (name.IsNull())
9859bfc0 1833 name = fSDigitsTitle ;
ffa6d63b 1834 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1835 }
1836 }
1837 else if ( what.CompareTo("Digits") == 0 ){
1838 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
1839 if (folder) {
1840 if (name.IsNull())
9859bfc0 1841 name = fDigitsTitle ;
ffa6d63b 1842 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1843 }
1844 }
f07cab21 1845 else if ( what.CompareTo("TowerRecPoints") == 0 ) {
1846 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
d75bea67 1847 if (folder) {
1848 if (name.IsNull())
9859bfc0 1849 name = fRecPointsTitle ;
d75bea67 1850 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1851 }
1852 }
05a92d59 1853 else if ( what.CompareTo("PreShowerRecPoints") == 0 ) {
1854 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
d75bea67 1855 if (folder) {
1856 if (name.IsNull())
9859bfc0 1857 name = fRecPointsTitle ;
d75bea67 1858 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1859 }
1860 }
173558f2 1861
ffa6d63b 1862 if (!emcalO) {
d75bea67 1863 if(fDebug)
9859bfc0 1864 Warning("ReturnO", "-> Object %s not found in %s", what.Data(), folder->GetName());
ffa6d63b 1865 return 0 ;
1866 }
05a92d59 1867
ffa6d63b 1868 return emcalO ;
1869}
173558f2 1870
ffa6d63b 1871//____________________________________________________________________________
173558f2 1872
ffa6d63b 1873const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
1874{
1875 // get the TTask named "what" from the folder
1876 // folders are named like //Folders/Tasks/what/EMCAL/name
1877
1878 TString search(what) ;
f07cab21 1879 if ( what.CompareTo("Clusterizer") == 0 )
d75bea67 1880 search = "Reconstructioner" ;
1881 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1882 search = "Reconstructioner" ;
1883 else if ( what.CompareTo("PID") == 0 )
1884 search = "Reconstructioner" ;
1885 else if ( what.CompareTo("QATasks") == 0 )
1886 search = "QA" ;
f07cab21 1887
ffa6d63b 1888 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1889
1890 if (!tasks) {
9859bfc0 1891 Error("AliReturnT", "-> Task %s not found!", what.Data());
ffa6d63b 1892 return 0 ;
1893 }
1894
1895 TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 1896
ffa6d63b 1897 if (!emcalT) {
9859bfc0 1898 Error("ReturnT", "-> Task %s/EMCAL not found!", what.Data());
ffa6d63b 1899 return 0 ;
1900 }
173558f2 1901
ffa6d63b 1902 TList * list = emcalT->GetListOfTasks() ;
173558f2 1903
ffa6d63b 1904 if (what.CompareTo("SDigitizer") == 0) {
1905 if ( name.IsNull() )
1906 name = fSDigitsTitle ;
9859bfc0 1907 }
1908 else if (what.CompareTo("Digitizer") == 0){
ffa6d63b 1909 if ( name.IsNull() )
1910 name = fDigitsTitle ;
9859bfc0 1911 }
1912 else if (what.CompareTo("Clusterizer") == 0){
d75bea67 1913 if ( name.IsNull() )
1914 name = fRecPointsTitle ;
1915 name.Append(":clu") ;
1916 }
173558f2 1917
ffa6d63b 1918 TIter it(list) ;
1919 TTask * task = 0 ;
173558f2 1920
ffa6d63b 1921 while((task = static_cast<TTask *>(it.Next()) )){
1922 TString taskname(task->GetName()) ;
54b82aa4 1923 if(taskname.BeginsWith(name)){
1924 return task ;}
ffa6d63b 1925 }
173558f2 1926
d75bea67 1927 if(fDebug)
9859bfc0 1928 Warning("ReturnT", "-> Task %s/%s not found!", search.Data(), name.Data());
ffa6d63b 1929 return 0 ;
1930}
65549808 1931
65549808 1932//____________________________________________________________________________
173558f2 1933
65549808 1934void AliEMCALGetter::RemoveTask(TString opt, TString name) const
173558f2 1935
65549808 1936{
1937 // remove a task from the folder
9bd3caba 1938 // path is fTasksFolder/SDigitizer/EMCAL/name
65549808 1939
1940 TTask * task = 0 ;
1941 TTask * emcal = 0 ;
1942 TList * lofTasks = 0 ;
1943
b134c32f 1944 if (opt == "S") { // SDigitizer
65549808 1945 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
1946 if (!task)
1947 return ;
05a92d59 1948 }
b134c32f 1949 else if (opt == "D") { // Digitizer
65549808 1950 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
1951 if (!task)
1952 return ;
1953 }
b134c32f 1954 else if (opt == "C") { // Clusterizer
1955 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1956 if (!task)
1957 return ;
1958 }
65549808 1959 else {
9859bfc0 1960 Warning("RemoveTask", "-> Unknown option %s");
65549808 1961 return ;
05a92d59 1962 }
173558f2 1963
65549808 1964 emcal = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
173558f2 1965
65549808 1966 if (!emcal)
1967 return ;
173558f2 1968
65549808 1969 lofTasks = emcal->GetListOfTasks() ;
173558f2 1970
65549808 1971 if (!lofTasks)
1972 return ;
173558f2 1973
65549808 1974 TObject * obj = lofTasks->FindObject(name) ;
1975 if (obj)
173558f2 1976
65549808 1977 lofTasks->Remove(obj) ;
1978}
173558f2 1979
65549808 1980//____________________________________________________________________________
173558f2 1981
65549808 1982void AliEMCALGetter::RemoveObjects(TString opt, TString name) const
1983{
1984 // remove SDigits from the folder
1985 // path is fSDigitsFolder/fHeaderFileName/name
1986
1987 TFolder * emcal = 0 ;
1988 TFolder * emcalmain = 0 ;
1989
b134c32f 1990 if (opt == "H") { // Hits
65549808 1991 emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
1992 if (!emcal)
1993 return ;
1994 name = "Hits" ;
1995 }
b134c32f 1996 else if ( opt == "S") { // SDigits
65549808 1997 emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1998 if (!emcalmain)
1999 return ;
2000 emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2001 if (!emcal)
2002 return ;
2003 }
b134c32f 2004 else if (opt == "D") { // Digits
65549808 2005 emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2006 if (!emcal)
2007 return ;
2008 }
b134c32f 2009 else if (opt == "RT") { // Tower RecPoints
2010 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2011 if (!emcal)
2012 return ;
2013 }
b134c32f 2014 else if (opt == "RP") { // Preshower RecPoints
05a92d59 2015 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2016 if (!emcal)
2017 return ;
2018 }
05a92d59 2019 else if (opt == "T") { // TrackSegments
2020 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
b134c32f 2021 if (!emcal)
2022 return ;
2023 }
05a92d59 2024 else if (opt == "P") { // RecParticles
2025 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2026 if (!emcal)
2027 return ;
2028 }
65549808 2029 else {
9859bfc0 2030 Warning("RemoveObjects", "-> Unknown option %s", opt.Data());
65549808 2031 return ;
2032 }
173558f2 2033
65549808 2034 TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject(name)) ;
173558f2 2035
65549808 2036 if (ar) {
2037 emcal->Remove(ar) ;
2038 ar->Delete() ;
2039 delete ar ;
2040 }
2041
2042 if (opt == "S")
2043 emcalmain->Remove(emcal) ;
65549808 2044}
2045
2046//____________________________________________________________________________
173558f2 2047
65549808 2048void AliEMCALGetter::RemoveSDigits() const
2049{
2050 TFolder * emcal= dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
173558f2 2051
65549808 2052 if (!emcal)
2053 return ;
173558f2 2054
65549808 2055 emcal->SetOwner() ;
2056 emcal->Clear() ;
2057}
05a92d59 2058
2059//____________________________________________________________________________
173558f2 2060
05a92d59 2061void AliEMCALGetter::CleanWhiteBoard(void){
2062
2063 TFolder * emcalmain = 0 ;
2064 TFolder * emcal ;
2065 TObjArray * ar ;
2066 TList * lofTasks = 0 ;
2067 TTask * task = 0 ;
2068 TTask * emcalt = 0 ;
173558f2 2069
05a92d59 2070 // Hits
173558f2 2071
05a92d59 2072 emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
173558f2 2073
05a92d59 2074 if (emcal){
2075 TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject("Hits")) ;
2076 if (ar) {
2077 emcal->Remove(ar) ;
2078 ar->Delete() ;
2079 delete ar ;
2080 }
2081 }
173558f2 2082
05a92d59 2083 // SDigits
173558f2 2084
05a92d59 2085 emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
173558f2 2086
05a92d59 2087 if (emcalmain){
2088 emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2089 if (emcal) {
2090 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fSDigitsTitle)) ;
2091 if (ar) {
9859bfc0 2092 emcal->Remove(ar) ;
2093 ar->Delete() ;
2094 delete ar ;
05a92d59 2095 }
2096 }
2097 emcalmain->Remove(emcal) ;
2098 }
2099
05a92d59 2100 // Digits
173558f2 2101
05a92d59 2102 emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
173558f2 2103
05a92d59 2104 if (emcal){
2105 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fDigitsTitle)) ;
2106 if (ar) {
2107 emcal->Remove(ar) ;
2108 ar->Delete() ;
2109 delete ar ;
2110 }
2111 }
2112
05a92d59 2113 // TowerRecPoints
173558f2 2114
05a92d59 2115 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
173558f2 2116
05a92d59 2117 if (emcal){
2118 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
2119 if (ar) {
2120 emcal->Remove(ar) ;
2121 ar->Delete() ;
2122 delete ar ;
2123 }
2124 }
2125
05a92d59 2126 // PreShowerRecPoints
173558f2 2127
05a92d59 2128 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
173558f2 2129
05a92d59 2130 if (emcal){
2131 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
2132 if (ar) {
2133 emcal->Remove(ar) ;
2134 ar->Delete() ;
2135 delete ar ;
2136 }
2137 }
2138
05a92d59 2139 // TrackSegments
173558f2 2140
05a92d59 2141 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
173558f2 2142
05a92d59 2143 if (emcal) {
2144 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fTrackSegmentsTitle)) ;
2145 if (ar) {
2146 emcal->Remove(ar) ;
2147 ar->Delete() ;
2148 delete ar ;
2149 }
2150 }
173558f2 2151
05a92d59 2152 // RecParticles
173558f2 2153
05a92d59 2154 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
173558f2 2155
05a92d59 2156 if (emcal){
2157 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecParticlesTitle)) ;
2158 if (ar) {
2159 emcal->Remove(ar) ;
2160 ar->Delete() ;
2161 delete ar ;
2162 }
2163 }
2164
05a92d59 2165 //---- Now Tasks -----------
2166
2167 TObject * obj ;
2168 TString sdname(fSDigitsTitle);
173558f2 2169
05a92d59 2170 // Digitizer
173558f2 2171
05a92d59 2172 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
173558f2 2173
05a92d59 2174 if (task){
2175 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2176 if (emcalt){
2177 lofTasks = emcalt->GetListOfTasks() ;
2178 if (lofTasks){
9859bfc0 2179 obj = lofTasks->FindObject(sdname.Data()) ;
2180 if (obj)
2181 lofTasks->Remove(obj) ;
05a92d59 2182 }
2183 }
2184 }
173558f2 2185
05a92d59 2186 sdname.Append(":") ;
173558f2 2187
05a92d59 2188 // Clusterizer, TrackSegmentMaker, PID
173558f2 2189
05a92d59 2190 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
173558f2 2191
05a92d59 2192 if (task){
2193 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2194 if (emcalt){
2195 lofTasks = emcalt->GetListOfTasks() ;
2196 TIter next(lofTasks);
2197 while((obj=next())){
9859bfc0 2198 TString oname(obj->GetName()) ;
2199 if (oname.BeginsWith(sdname)){
2200 lofTasks->Remove(obj) ;
2201 }
05a92d59 2202 }
2203 }
2204 }
2205
05a92d59 2206 // SDigitizer
173558f2 2207
05a92d59 2208 sdname.Append(fHeaderFile) ;
2209 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
173558f2 2210
05a92d59 2211 if (task) {
2212 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2213 if (emcalt){
2214 lofTasks = emcalt->GetListOfTasks() ;
2215 if (lofTasks){
9859bfc0 2216 obj = lofTasks->FindObject(sdname.Data()) ;
2217 if (obj)
2218 lofTasks->Remove(obj) ;
05a92d59 2219 }
2220 }
2221 }
05a92d59 2222}
173558f2 2223
05a92d59 2224//____________________________________________________________________________
173558f2 2225
05a92d59 2226void AliEMCALGetter::SetTitle(const char * branchTitle )
173558f2 2227
05a92d59 2228{
2229 fBranchTitle = branchTitle ;
2230 fSDigitsTitle = branchTitle ;
2231 fDigitsTitle = branchTitle ;
2232 fRecPointsTitle = branchTitle ;
2233 fRecParticlesTitle = branchTitle ;
2234 fTrackSegmentsTitle = branchTitle ;
173558f2 2235
05a92d59 2236 if(fToSplit){
173558f2 2237
05a92d59 2238 //First - extract full path if necessary
173558f2 2239
05a92d59 2240 TString sFileName(fHeaderFile) ;
2241 Ssiz_t islash = sFileName.Last('/') ;
173558f2 2242
05a92d59 2243 if(islash<sFileName.Length())
2244 sFileName.Remove(islash+1,sFileName.Length()) ;
2245 else
2246 sFileName="" ;
173558f2 2247
05a92d59 2248 //Now construct file names
173558f2 2249
05a92d59 2250 fSDigitsFileName = sFileName ;
2251 fDigitsFileName = sFileName ;
2252 fRecPointsFileName = sFileName ;
2253 fRecParticlesFileName = sFileName ;
2254 fTrackSegmentsFileName = sFileName ;
2255 fSDigitsFileName += "EMCAL.SDigits." ;
2256 fDigitsFileName += "EMCAL.Digits." ;
2257 fRecPointsFileName += "EMCAL.RecData." ;
2258 fTrackSegmentsFileName+= "EMCAL.RecData." ;
2259 fRecParticlesFileName += "EMCAL.RecData." ;
173558f2 2260
05a92d59 2261 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
2262 fSDigitsFileName += fBranchTitle ;
2263 fSDigitsFileName += "." ;
2264 fDigitsFileName += fBranchTitle ;
2265 fDigitsFileName += "." ;
2266 fRecPointsFileName += fBranchTitle ;
2267 fRecPointsFileName += "." ;
2268 fRecParticlesFileName += fBranchTitle ;
2269 fRecParticlesFileName += "." ;
2270 fTrackSegmentsFileName+= fBranchTitle ;
2271 fTrackSegmentsFileName+= "." ;
2272 }
173558f2 2273
05a92d59 2274 fSDigitsFileName += "root" ;
2275 fDigitsFileName += "root" ;
2276 fRecPointsFileName += "root" ;
2277 fRecParticlesFileName += "root" ;
2278 fTrackSegmentsFileName+= "root" ;
9859bfc0 2279 }
2280 else{
05a92d59 2281 fSDigitsFileName = "" ;
2282 fDigitsFileName = "" ;
2283 fRecPointsFileName = "" ;
2284 fRecParticlesFileName = "" ;
2285 fTrackSegmentsFileName = "" ;
2286 }
173558f2 2287
05a92d59 2288 TFolder * emcalFolder ;
2289 emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
173558f2 2290
05a92d59 2291 if ( !emcalFolder )
2292 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
2293
2294 emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
173558f2 2295
05a92d59 2296 if ( !emcalFolder )
2297 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
173558f2 2298
05a92d59 2299 //Make folder for SDigits
173558f2 2300
05a92d59 2301 TString subdir(fHeaderFile) ;
2302 subdir.ReplaceAll("/","_") ;
173558f2 2303
05a92d59 2304 emcalFolder->AddFolder(subdir, fSDigitsFileName.Data());
05a92d59 2305 emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
173558f2 2306
05a92d59 2307 if ( !emcalFolder )
2308 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
2309
2310 emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
173558f2 2311
05a92d59 2312 if ( !emcalFolder )
2313 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
05a92d59 2314}
173558f2 2315
05a92d59 2316//____________________________________________________________________________
173558f2 2317
05a92d59 2318void AliEMCALGetter::CloseSplitFiles(void){
173558f2 2319
05a92d59 2320 TFile * file ;
2321 file = static_cast<TFile*>(gROOT->GetFile(fSDigitsFileName.Data() ) ) ;
173558f2 2322
05a92d59 2323 if(file)
2324 file->Close() ;
173558f2 2325
05a92d59 2326 file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName.Data() ) ) ;
173558f2 2327
05a92d59 2328 if(file)
2329 file->Close() ;
173558f2 2330
05a92d59 2331 file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName.Data() ) ) ;
173558f2 2332
05a92d59 2333 if(file)
2334 file->Close() ;
173558f2 2335
05a92d59 2336 file = static_cast<TFile*>(gROOT->GetFile(fTrackSegmentsFileName.Data() ) ) ;
173558f2 2337
05a92d59 2338 if(file)
2339 file->Close() ;
173558f2 2340
05a92d59 2341 file = static_cast<TFile*>(gROOT->GetFile(fRecParticlesFileName.Data() ) ) ;
173558f2 2342
05a92d59 2343 if(file)
2344 file->Close() ;
9859bfc0 2345}
2346
2347
05a92d59 2348
173558f2 2349
2350
173558f2 2351