1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
20 //*-- Author: Gines Martinez & Yves Schutz (SUBATECH)
21 //*-- Compleetely redesigned by Dmitri Peressounko (SUBATECH & RRC KI) March 2001
22 /////////////////////////////////////////////////////////////////////////////////////
23 // Wrapping class for reconstruction. Allows to produce reconstruction from
24 // different steps: from previously produced hits,sdigits, etc. Each new reconstruction
25 // flow (e.g. digits, made from them RecPoints, subsequently made TrackSegments,
26 // subsequently made RecParticles) are distinguished by the title of created branches. One can
27 // use this title as a comment, see use case below.
28 // Thanks to getters, one can set
29 // parameters to reconstruction briks. The full set of parameters is saved in the
30 // corresponding branch: e.g. parameters of clusterizer are stored in branch
31 // TreeR::AliPHOSClusterizer with the same title as the branch containing the RecPoints. // TTree does not support overwriting, therefore one can not produce several
32 // branches with the same names and titles - use different titles.
36 // root [0] AliPHOSReconstructioner * r = new AliPHOSReconstructioner("galice.root")
37 // // Set the header file
38 // root [1] r->ExecuteTask()
39 // // Make full chain of reconstruction
41 // // One can specify the title for each branch
42 // root [2] r->SetBranchFileName("RecPoints","RecPoints1") ;
44 // // One can change parameters of reconstruction algorithms
45 // root [3] r->GetClusterizer()->SetEmcLocalMaxCut(0.02)
47 // // One can specify the starting point of the reconstruction and title of all
48 // // branches produced in this pass
49 // root [4] r->StartFrom("AliPHOSClusterizer","Local max cut 0.02")
50 // // means that will use already generated Digits and produce only RecPoints,
51 // // TS and RecParticles
53 // // And finally one can call ExecuteTask() with the following options
54 // root [5] r->ExecuteTask("debug all timing")
55 // // deb - prints the numbers of produced SDigits, Digits etc.
56 // // deb all - prints in addition list of made SDigits, digits etc.
57 // // timing - prints benchmarking results
58 ///////////////////////////////////////////////////////////////////////////////////////////////////
60 // --- ROOT system ---
62 #include "TClonesArray.h"
67 // --- Standard library ---
69 // --- AliRoot header files ---
71 #include "AliPHOSReconstructioner.h"
72 #include "AliPHOSClusterizerv1.h"
73 #include "AliPHOSDigitizer.h"
74 #include "AliPHOSSDigitizer.h"
75 #include "AliPHOSTrackSegmentMakerv1.h"
76 #include "AliPHOSPIDv1.h"
77 #include "AliPHOSFastRecParticle.h"
78 #include "AliPHOSCpvRecPoint.h"
80 ClassImp(AliPHOSReconstructioner)
82 //____________________________________________________________________________
83 AliPHOSReconstructioner::AliPHOSReconstructioner():TTask("AliPHOSReconstructioner","")
92 fHeaderFileName = "galice.root" ;
94 fIsInitialized = kFALSE ;
98 //____________________________________________________________________________
99 AliPHOSReconstructioner::AliPHOSReconstructioner(const char* headerFile,const char * branchName,Bool_t toSplit):
100 TTask("AliPHOSReconstructioner","")
104 fHeaderFileName = headerFile ;
106 fSDigitsBranch= branchName;
107 fSDigitizer = new AliPHOSSDigitizer(fHeaderFileName.Data(),fSDigitsBranch.Data(),toSplit) ;
110 fDigitsBranch=branchName ;
111 fDigitizer = new AliPHOSDigitizer(fHeaderFileName.Data(),fDigitsBranch.Data(),toSplit) ;
115 fRecPointBranch=branchName ;
116 fClusterizer = new AliPHOSClusterizerv1(fHeaderFileName.Data(),fRecPointBranch.Data(),toSplit) ;
120 fTSBranch=branchName ;
121 fTSMaker = new AliPHOSTrackSegmentMakerv1(fHeaderFileName.Data(),fTSBranch.Data(),toSplit) ;
125 fRecPartBranch=branchName ;
126 fPID = new AliPHOSPIDv1(fHeaderFileName.Data(),fRecPartBranch.Data(),toSplit) ;
129 fIsInitialized = kTRUE ;
132 //____________________________________________________________________________
133 void AliPHOSReconstructioner::Exec(Option_t *option)
135 //chesk, if the names of branches, which should be made conicide with already
140 TString message(" ") ;
141 // gAlice->GetEvent(0) ;
143 // if(fSDigitizer->IsActive()&& gAlice->TreeS()){ //Will produce SDigits
144 // TBranch * sdigitsBranch = 0;
145 // TBranch * sdigitizerBranch = 0;
147 // TObjArray * branches = gAlice->TreeS()->GetListOfBranches() ;
149 // Bool_t phosNotFound = kTRUE ;
150 // Bool_t sdigitizerNotFound = kTRUE ;
152 // for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
154 // sdigitsBranch=(TBranch *) branches->At(ibranch) ;
155 // if(( strcmp("PHOS",sdigitsBranch->GetName())==0 ) &&
156 // (fSDigitsBranch.CompareTo(sdigitsBranch->GetTitle())== 0 ))
157 // phosNotFound = kFALSE ;
159 // if(sdigitizerNotFound){
160 // sdigitizerBranch = (TBranch *) branches->At(ibranch) ;
161 // if(( strcmp(sdigitizerBranch->GetName(),"AliPHOSSDigitizer") == 0) &&
162 // (fSDigitsBranch.CompareTo(sdigitizerBranch->GetTitle())== 0 ) )
163 // sdigitizerNotFound = kFALSE ;
167 // if(!(sdigitizerNotFound && phosNotFound)){
168 // message = " Branches PHOS or AliPHOSSDigitizer with title %s\n" ;
169 // message += " already exist in TreeS. ROOT does not allow updating/overwriting.\n" ;
170 // message += " Specify another title for branches or use StartFrom() method\n" ;
171 // Error("Exec", message.Data(), fSDigitsBranch.Data() ) ;
172 // //mark all tasks as inactive
173 // TIter next(fTasks);
175 // while((task=(TTask*)next()))
176 // task->SetActive(kFALSE) ;
182 // if(fDigitizer->IsActive() && gAlice->TreeD()){ //Will produce Digits
183 // TBranch * digitsBranch = 0;
184 // TBranch * digitizerBranch = 0;
186 // TObjArray * branches = gAlice->TreeD()->GetListOfBranches() ;
188 // Bool_t phosNotFound = kTRUE ;
189 // Bool_t digitizerNotFound = kTRUE ;
191 // for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
193 // digitsBranch=(TBranch *) branches->At(ibranch) ;
194 // if(( strcmp("PHOS",digitsBranch->GetName())==0 ) &&
195 // (fDigitsBranch.CompareTo(digitsBranch->GetTitle())== 0 ))
196 // phosNotFound = kFALSE ;
198 // if(digitizerNotFound){
199 // digitizerBranch = (TBranch *) branches->At(ibranch) ;
200 // if(( strcmp(digitizerBranch->GetName(),"AliPHOSDigitizer") == 0) &&
201 // (fDigitsBranch.CompareTo(digitizerBranch->GetTitle())== 0 ) )
202 // digitizerNotFound = kFALSE ;
206 // if(!(digitizerNotFound && phosNotFound)){
207 // message = " Branches PHOS or AliPHOSDigitizer with title %s\n" ;
208 // message += " already exist in TreeD. ROOT does not allow updating/overwriting.\n" ;
209 // message += " Specify another title for branches or use StartFrom() method" ;
210 // Error("Exec", message>Data(), fDigitsBranch.Data() ) ;
211 // //mark all tasks as inactive
212 // TIter next(fTasks);
214 // while((task=(TTask*)next()))
215 // task->SetActive(kFALSE) ;
221 // if(fClusterizer->IsActive() && gAlice->TreeR()){ //Will produce RecPoints
222 // TBranch * emcBranch = 0;
223 // TBranch * cpvBranch = 0;
224 // TBranch * clusterizerBranch = 0;
226 // TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
228 // Bool_t emcNotFound = kTRUE ;
229 // Bool_t cpvNotFound = kTRUE ;
230 // Bool_t clusterizerNotFound = kTRUE ;
232 // for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
235 // emcBranch=(TBranch *) branches->At(ibranch) ;
236 // if(fRecPointBranch.CompareTo(emcBranch->GetTitle())==0 )
237 // if( strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0)
238 // emcNotFound = kFALSE ;
241 // cpvBranch=(TBranch *) branches->At(ibranch) ;
242 // if(fRecPointBranch.CompareTo(cpvBranch->GetTitle())==0 )
243 // if( strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0)
244 // cpvNotFound = kFALSE ;
246 // if(clusterizerNotFound){
247 // clusterizerBranch = (TBranch *) branches->At(ibranch) ;
248 // if( fRecPointBranch.CompareTo(clusterizerBranch->GetTitle()) == 0)
249 // if( strcmp(clusterizerBranch->GetName(),"AliPHOSClusterizer") == 0)
250 // clusterizerNotFound = kFALSE ;
254 // if(!(clusterizerNotFound && emcNotFound && cpvNotFound)){
255 // message = " Branches PHOSEmcRP, PHOSCpvRP or AliPHOSClusterizer with title %s\n" ;
256 // message += " already exist in TreeR. ROOT does not allow updating/overwriting.\n" ;
257 // message += " Specify another title for branches or use StartFrom() method\n" ;
258 // Error("Exec", message.Data(),fRecPointBranch.Data() ) ;
259 // //mark all tasks as inactive
260 // TIter next(fTasks);
262 // while((task=(TTask*)next()))
263 // task->SetActive(kFALSE) ;
268 // if(fTSMaker->IsActive() && gAlice->TreeR()){ //Produce TrackSegments
269 // TBranch * tsMakerBranch = 0;
270 // TBranch * tsBranch = 0;
272 // TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
274 // Bool_t tsMakerNotFound = kTRUE ;
275 // Bool_t tsNotFound = kTRUE ;
277 // for(ibranch = 0;(ibranch <branches->GetEntries())&&(tsMakerNotFound||tsNotFound);ibranch++){
278 // if(tsMakerNotFound){
279 // tsMakerBranch=(TBranch *) branches->At(ibranch) ;
280 // if( fTSBranch.CompareTo(tsMakerBranch->GetTitle())==0 )
281 // if( strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0)
282 // tsMakerNotFound = kFALSE ;
285 // tsBranch=(TBranch *) branches->At(ibranch) ;
286 // if( fTSBranch.CompareTo(tsBranch->GetTitle())==0 )
287 // if( strcmp(tsBranch->GetName(),"PHOSTS") == 0)
288 // tsNotFound = kFALSE ;
292 // if(!(tsMakerNotFound &&tsNotFound) ){
293 // message = " Branches PHOSTS or AliPHOSTrackSegmentMaker with title %s\n" ;
294 // message += " already exist in TreeR. ROOT does not allow updating/overwriting.\n" ;
295 // message += " Specify another title for branches or use StartFrom() method\n" ;
296 // Error("Exec", message.Data(),fTSBranch.Data() ) ;
297 // //mark all tasks as inactive
298 // TIter next(fTasks);
300 // while((task=(TTask*)next()))
301 // task->SetActive(kFALSE) ;
308 // if(fPID->IsActive() && gAlice->TreeR()){ //Produce RecParticles
309 // TBranch * pidBranch = 0;
310 // TBranch * rpBranch = 0;
312 // TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
314 // Bool_t pidNotFound = kTRUE ;
315 // Bool_t rpNotFound = kTRUE ;
317 // for(ibranch = 0;(ibranch <branches->GetEntries()) && pidNotFound && rpNotFound ;ibranch++){
319 // pidBranch=(TBranch *) branches->At(ibranch) ;
320 // if( (strcmp(fRecPartBranch,pidBranch->GetTitle())==0 ) &&
321 // (strcmp(pidBranch->GetName(),"AliPHOSPID") == 0) )
322 // pidNotFound = kFALSE ;
325 // rpBranch=(TBranch *) branches->At(ibranch) ;
326 // if( (strcmp(fRecPartBranch,rpBranch->GetTitle())==0 ) &&
327 // (strcmp(rpBranch->GetName(),"PHOSRP") == 0) )
328 // rpNotFound = kFALSE ;
332 // if(!pidNotFound || !rpNotFound ){
333 // message = " Branches PHOSRP or AliPHOSPID with title %s\n" ;
334 // message += " already exist in TreeR. ROOT does not allow updating/overwriting.\n" ;
335 // message += " Specify another title for branches.\n" ;
336 // Error("Exec", message.Data(), fRecPartBranch.Data() ) ;
337 // //mark all tasks as inactive
338 // TIter next(fTasks);
340 // while((task=(TTask*)next()))
341 // task->SetActive(kFALSE) ;
347 //____________________________________________________________________________
348 void AliPHOSReconstructioner::Init()
350 // initiliaze Reconstructioner if necessary: we can not do this in default constructor
355 fSDigitsBranch="Default" ;
356 fSDigitizer = new AliPHOSSDigitizer(fHeaderFileName.Data(),fSDigitsBranch.Data(),fToSplit) ;
359 fDigitsBranch="Default" ;
360 fDigitizer = new AliPHOSDigitizer(fHeaderFileName.Data(),fDigitsBranch.Data(),fToSplit) ;
363 fRecPointBranch="Default" ;
364 fClusterizer = new AliPHOSClusterizerv1(fHeaderFileName.Data(),fRecPointBranch.Data(),fToSplit) ;
367 fTSBranch="Default" ;
368 fTSMaker = new AliPHOSTrackSegmentMakerv1(fHeaderFileName.Data(),fTSBranch.Data(),fToSplit) ;
372 fRecPartBranch="Default" ;
373 fPID = new AliPHOSPIDv1(fHeaderFileName.Data(),fRecPartBranch.Data(),fToSplit) ;
376 fIsInitialized = kTRUE ;
379 //____________________________________________________________________________
380 AliPHOSReconstructioner::~AliPHOSReconstructioner()
382 // Delete data members if any
385 // delete fSDigitizer ;
388 // delete fDigitizer ;
391 // delete fClusterizer ;
399 // TFile * file = (TFile*) gROOT->GetFile(fHeaderFileName.Data()) ;
404 // printf("File %s is closed\n",fHeaderFileName.Data());
408 // //____________________________________________________________________________
409 // void AliPHOSReconstructioner::SetBranchTitle(const char* branch, const char * title)
411 // //Diverge correcpoinding branch to the file "title"
413 // if(strcmp(branch,"SDigits") == 0){
414 // fSDigitizer->SetSDigitsBranch(title) ;
415 // fDigitizer->SetSDigitsBranch(title) ;
416 // fSDigitsBranch = title ;
420 // if(strcmp(branch,"Digits") == 0){
421 // fDigitizer->SetName(title) ;
422 // fClusterizer->SetName(title) ;
423 // fDigitsBranch = title ;
427 // if(strcmp(branch,"RecPoints") == 0){
428 // fClusterizer->SetRecPointsBranch(title) ;
429 // fTSMaker->SetRecPointsBranch(title) ;
430 // fRecPointBranch = title ;
434 // if(strcmp(branch,"TrackSegments") == 0){
435 // fTSMaker->SetTrackSegmentsBranch(title) ;
436 // fPID->SetTrackSegmentsBranch(title) ;
437 // fTSBranch = title ;
441 // if(strcmp(branch,"RecParticles") == 0){
442 // fPID->SetRecParticlesBranch(title) ;
443 // fRecPartBranch = title ;
449 // message = "There is no branch %s !\n" ;
450 // message += "Available branches `SDigits', `Digits', `RecPoints', `TrackSegments' and `RecParticles'\n" ;
451 // Warning("SetBranchTitle", message.Data(), branch ) ;
453 // //____________________________________________________________________________
454 // void AliPHOSReconstructioner::StartFrom(char * module,char* title)
456 // // in the next pass of reconstruction (call ExecuteTask()) reconstruction will
457 // // start from the module "module", and in the case of non zero title all
458 // // pruduced branches will have title "title". The following "modules" are recognized
459 // // "SD" - AliPHOSSDigitizer,
460 // // "D" - AliPHOSDigitizer
461 // // "C" - AliPHOSClusterizer
462 // // "TS" - AliPHOSTrackSegmentMaker
463 // // "RP" - AliPHOSPID
465 // if(!fIsInitialized)
468 // char * moduleName = new char[30];
469 // if(strstr(module,"SD"))
470 // sprintf(moduleName,"AliPHOSSDigitizer") ;
472 // if(strstr(module,"D") )
473 // sprintf(moduleName,"AliPHOSDigitizer") ;
475 // if(strstr(module,"C") || strstr(module,"RecPoint") )
476 // sprintf(moduleName,"AliPHOSClusterizer") ;
478 // if(strstr(module,"TS") || strstr(module,"Track") )
479 // sprintf(moduleName,"AliPHOSTrackSegmentMaker") ;
481 // if(strstr(module,"PID") || strstr(module,"Particle") || strstr(module,"RP") )
482 // sprintf(moduleName,"AliPHOSPID") ;
484 // Warning("StartFrom", "Do not know such a module / Rec Object ") ;
488 // TIter next(fTasks);
490 // Bool_t active = kFALSE ;
491 // while((task=(TTask*)next())){
492 // if (strcmp(moduleName,task->GetName())==0)
494 // task->SetActive(active) ;
495 // if(active && title){ // set title to branches
496 // switch(strlen(task->GetName()) ) {
497 // case 17: // "AliPHOSSDigitizer"
498 // fSDigitizer->SetSDigitsBranch(title) ;
499 // fDigitizer->SetSDigitsBranch(title) ;
500 // fSDigitsBranch = title ;
502 // case 16: //"AliPHOSDigitizer"
503 // fDigitizer->SetName(title) ;
504 // fClusterizer->SetName(title) ;
505 // fDigitsBranch = title ;
507 // case 18: //"AliPHOSClusterizer"
508 // fClusterizer->SetRecPointsBranch(title) ;
509 // fTSMaker->SetRecPointsBranch(title) ;
510 // fRecPointBranch = title ;
512 // case 24: //"AliPHOSTrackSegmentMaker"
513 // fTSMaker->SetTrackSegmentsBranch(title) ;
514 // fPID->SetTrackSegmentsBranch(title) ;
515 // fTSBranch = title ;
517 // case 10: // "AliPHOSPID"
518 // fPID->SetRecParticlesBranch(title) ;
519 // fRecPartBranch = title ;
526 // delete [] moduleName;
528 //____________________________________________________________________________
530 void AliPHOSReconstructioner::Print(Option_t * option)const {
531 // Print reconstructioner data
534 message = "-----------------AliPHOSReconstructioner---------------\n" ;
535 message += " Reconstruction of the header file %s\n" ;
536 message += " with the following modules:\n" ;
538 if(fSDigitizer->IsActive()){
539 message += " (+) %s to branch %s\n" ;
541 if(fDigitizer->IsActive()){
542 message += " (+) %s to branch %s\n" ;
545 if(fClusterizer->IsActive()){
546 message += " (+) %s to branch %s\n" ;
549 if(fTSMaker->IsActive()){
550 message += " (+) %s to branch %s\n" ;
553 if(fPID->IsActive()){
554 message += " (+) %s to branch %s\n" ;
556 Info("Print", message.Data(),
557 fHeaderFileName.Data(),
558 fSDigitizer->GetName(), fSDigitsBranch.Data(),
559 fDigitizer->GetName(), fDigitsBranch.Data() ,
560 fClusterizer->GetName(), fRecPointBranch.Data(),
561 fTSMaker->GetName(), fTSBranch.Data() ,
562 fPID->GetName(), fRecPartBranch.Data() ) ;