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 //*-- Complitely redisigned 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. gigits, made from them RecPoints, made from them TrackSegments, made from
26 // them RecParticles) are distinguished by the title of created branches. One can
27 // use this title as a comment, see user case below. Thanks to getters, one can set
28 // parameters to reconstruction bricks. The full set of parameters is saved in the
29 // correspoinding branch: e.g. parameters of clusterizer are stored in branch
30 // TreeR::AliPHOSClusterizer with the same title as the branch contaning RecPoints
31 // themself. 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 cheine 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"
66 // --- 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 fIsInitialized = kFALSE ;
96 //____________________________________________________________________________
97 AliPHOSReconstructioner::AliPHOSReconstructioner(const char* headerFile):TTask("AliPHOSReconstructioner","")
101 fHeaderFileName = headerFile ;
104 fSDigitizer = new AliPHOSSDigitizer(fHeaderFileName.Data(),fSDigitsBranch.Data()) ;
108 fDigitizer = new AliPHOSDigitizer(fHeaderFileName.Data(),fDigitsBranch.Data()) ;
113 fClusterizer = new AliPHOSClusterizerv1(fHeaderFileName.Data(),fRecPointBranch.Data()) ;
118 fTSMaker = new AliPHOSTrackSegmentMakerv1(fHeaderFileName.Data(),fTSBranch.Data()) ;
123 fPID = new AliPHOSPIDv1(fHeaderFileName.Data(),fRecPartBranch.Data()) ;
126 fIsInitialized = kTRUE ;
129 //____________________________________________________________________________
130 void AliPHOSReconstructioner::Exec(Option_t *option){
131 //chesk, if the names of branches, which should be made conicide with already
136 gAlice->GetEvent(0) ;
138 if(fSDigitizer->IsActive()&& gAlice->TreeS()){ //Will produce SDigits
140 TBranch * sdigitsBranch = 0;
141 TBranch * sdigitizerBranch = 0;
143 TObjArray * branches = gAlice->TreeS()->GetListOfBranches() ;
145 Bool_t phosNotFound = kTRUE ;
146 Bool_t sdigitizerNotFound = kTRUE ;
148 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
150 sdigitsBranch=(TBranch *) branches->At(ibranch) ;
151 if(( strcmp("PHOS",sdigitsBranch->GetName())==0 ) &&
152 (fSDigitsBranch.CompareTo(sdigitsBranch->GetTitle())== 0 ))
153 phosNotFound = kFALSE ;
155 if(sdigitizerNotFound){
156 sdigitizerBranch = (TBranch *) branches->At(ibranch) ;
157 if(( strcmp(sdigitizerBranch->GetName(),"AliPHOSSDigitizer") == 0) &&
158 (fSDigitsBranch.CompareTo(sdigitizerBranch->GetTitle())== 0 ) )
159 sdigitizerNotFound = kFALSE ;
163 if(!(sdigitizerNotFound && phosNotFound)){
164 cout << "AliPHOSReconstructioner error: "<< endl ;
165 cout << " Branches ''PHOS'' or ''AliPHOSSDigitizer'' with title ``" << fSDigitsBranch.Data() << "''" << endl ;
166 cout << " already exist in TreeS. ROOT does not allow updating/overwriting." << endl ;
167 cout << " Specify another title for branches or use ''StartFrom()'' method" << endl ;
169 //mark all tasks as inactive
172 while((task=(TTask*)next()))
173 task->SetActive(kFALSE) ;
179 if(fDigitizer->IsActive() && gAlice->TreeD()){ //Will produce Digits
180 TBranch * digitsBranch = 0;
181 TBranch * digitizerBranch = 0;
183 TObjArray * branches = gAlice->TreeD()->GetListOfBranches() ;
185 Bool_t phosNotFound = kTRUE ;
186 Bool_t digitizerNotFound = kTRUE ;
188 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
190 digitsBranch=(TBranch *) branches->At(ibranch) ;
191 if(( strcmp("PHOS",digitsBranch->GetName())==0 ) &&
192 (fDigitsBranch.CompareTo(digitsBranch->GetTitle())== 0 ))
193 phosNotFound = kFALSE ;
195 if(digitizerNotFound){
196 digitizerBranch = (TBranch *) branches->At(ibranch) ;
197 if(( strcmp(digitizerBranch->GetName(),"AliPHOSDigitizer") == 0) &&
198 (fDigitsBranch.CompareTo(digitizerBranch->GetTitle())== 0 ) )
199 digitizerNotFound = kFALSE ;
203 if(!(digitizerNotFound && phosNotFound)){
204 cout << "AliPHOSReconstructioner error: "<< endl ;
205 cout << " Branches ''PHOS'' or ''AliPHOSDigitizer'' with title ``" << fDigitsBranch.Data() << "''" << endl ;
206 cout << " already exist in TreeD. ROOT does not allow updating/overwriting." << endl ;
207 cout << " Specify another title for branches or use ''StartFrom()'' method" << endl ;
209 //mark all tasks as inactive
212 while((task=(TTask*)next()))
213 task->SetActive(kFALSE) ;
219 if(fClusterizer->IsActive() && gAlice->TreeR()){ //Will produce RecPoints
220 TBranch * emcBranch = 0;
221 TBranch * cpvBranch = 0;
222 TBranch * clusterizerBranch = 0;
224 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
226 Bool_t emcNotFound = kTRUE ;
227 Bool_t cpvNotFound = kTRUE ;
228 Bool_t clusterizerNotFound = kTRUE ;
230 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
233 emcBranch=(TBranch *) branches->At(ibranch) ;
234 if(fRecPointBranch.CompareTo(emcBranch->GetTitle())==0 )
235 if( strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0)
236 emcNotFound = kFALSE ;
239 cpvBranch=(TBranch *) branches->At(ibranch) ;
240 if(fRecPointBranch.CompareTo(cpvBranch->GetTitle())==0 )
241 if( strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0)
242 cpvNotFound = kFALSE ;
244 if(clusterizerNotFound){
245 clusterizerBranch = (TBranch *) branches->At(ibranch) ;
246 if( fRecPointBranch.CompareTo(clusterizerBranch->GetTitle()) == 0)
247 if( strcmp(clusterizerBranch->GetName(),"AliPHOSClusterizer") == 0)
248 clusterizerNotFound = kFALSE ;
252 if(!(clusterizerNotFound && emcNotFound && cpvNotFound)){
253 cout << "AliPHOSReconstructioner error: "<< endl ;
254 cout << " Branches ''PHOSEmcRP'', ''PHOSCpvRP'' or ''AliPHOSClusterizer'' with title ``"
255 << fRecPointBranch.Data() << "''" << endl ;
256 cout << " already exist in TreeR. ROOT does not allow updating/overwriting." << endl ;
257 cout << " Specify another title for branches or use ''StartFrom()'' method" << endl ;
259 //mark all tasks as inactive
262 while((task=(TTask*)next()))
263 task->SetActive(kFALSE) ;
268 if(fTSMaker->IsActive() && gAlice->TreeR()){ //Produce TrackSegments
270 TBranch * tsMakerBranch = 0;
271 TBranch * tsBranch = 0;
273 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
275 Bool_t tsMakerNotFound = kTRUE ;
276 Bool_t tsNotFound = kTRUE ;
278 for(ibranch = 0;(ibranch <branches->GetEntries())&&(tsMakerNotFound||tsNotFound);ibranch++){
280 tsMakerBranch=(TBranch *) branches->At(ibranch) ;
281 if( fTSBranch.CompareTo(tsMakerBranch->GetTitle())==0 )
282 if( strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0)
283 tsMakerNotFound = kFALSE ;
286 tsBranch=(TBranch *) branches->At(ibranch) ;
287 if( fTSBranch.CompareTo(tsBranch->GetTitle())==0 )
288 if( strcmp(tsBranch->GetName(),"PHOSTS") == 0)
289 tsNotFound = kFALSE ;
293 if(!(tsMakerNotFound &&tsNotFound) ){
294 cout << "AliPHOSReconstructioner error: "<< endl ;
295 cout << " Branches ''PHOSTS'' or ''AliPHOSTrackSegmentMaker'' with title ``"
296 << fTSBranch.Data() << "''" << endl ;
297 cout << " already exist in TreeR. ROOT does not allow updating/overwriting." << endl ;
298 cout << " Specify another title for branches or use ''StartFrom()'' method" << endl ;
300 //mark all tasks as inactive
303 while((task=(TTask*)next()))
304 task->SetActive(kFALSE) ;
311 if(fPID->IsActive() && gAlice->TreeR()){ //Produce RecParticles
312 TBranch * pidBranch = 0;
313 TBranch * rpBranch = 0;
315 TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
317 Bool_t pidNotFound = kTRUE ;
318 Bool_t rpNotFound = kTRUE ;
320 for(ibranch = 0;(ibranch <branches->GetEntries()) && pidNotFound && rpNotFound ;ibranch++){
322 pidBranch=(TBranch *) branches->At(ibranch) ;
323 if( (strcmp(fRecPartBranch,pidBranch->GetTitle())==0 ) &&
324 (strcmp(pidBranch->GetName(),"AliPHOSPID") == 0) )
325 pidNotFound = kFALSE ;
328 rpBranch=(TBranch *) branches->At(ibranch) ;
329 if( (strcmp(fRecPartBranch,rpBranch->GetTitle())==0 ) &&
330 (strcmp(rpBranch->GetName(),"PHOSRP") == 0) )
331 rpNotFound = kFALSE ;
335 if(!pidNotFound || !rpNotFound ){
336 cout << "AliPHOSReconstructioner error: "<< endl ;
337 cout << " Branches ''PHOSRP'' or ''AliPHOSPID'' with title ``"
338 << fRecPartBranch.Data() << "''" << endl ;
339 cout << " already exist in TreeR. ROOT does not allow updating/overwriting." << endl ;
340 cout << " Specify another title for branches." << endl ;
342 //mark all tasks as inactive
345 while((task=(TTask*)next()))
346 task->SetActive(kFALSE) ;
352 //____________________________________________________________________________
353 void AliPHOSReconstructioner::Init()
355 //initiase Reconstructioner if necessary: we can not do this in default constructor
361 fSDigitizer = new AliPHOSSDigitizer(fHeaderFileName.Data(),fSDigitsBranch.Data()) ;
365 fDigitizer = new AliPHOSDigitizer(fHeaderFileName.Data(),fDigitsBranch.Data()) ;
369 fClusterizer = new AliPHOSClusterizerv1(fHeaderFileName.Data(),fRecPointBranch.Data()) ;
373 fTSMaker = new AliPHOSTrackSegmentMakerv1(fHeaderFileName.Data(),fTSBranch.Data()) ;
378 fPID = new AliPHOSPIDv1(fHeaderFileName.Data(),fRecPartBranch.Data()) ;
381 fIsInitialized = kTRUE ;
384 //____________________________________________________________________________
385 AliPHOSReconstructioner::~AliPHOSReconstructioner()
395 delete fClusterizer ;
403 //____________________________________________________________________________
404 void AliPHOSReconstructioner::SetBranchTitle(const char* branch, const char * title){
405 //Diverge correcpoinding branch to the file "title"
407 if(strcmp(branch,"SDigits") == 0){
408 fSDigitizer->SetSDigitsBranch(title) ;
409 fDigitizer->SetSDigitsBranch(title) ;
410 fSDigitsBranch = title ;
414 if(strcmp(branch,"Digits") == 0){
415 fDigitizer->SetDigitsBranch(title) ;
416 fClusterizer->SetDigitsBranch(title) ;
417 fDigitsBranch = title ;
421 if(strcmp(branch,"RecPoints") == 0){
422 fClusterizer->SetRecPointsBranch(title) ;
423 fTSMaker->SetRecPointsBranch(title) ;
424 fRecPointBranch = title ;
428 if(strcmp(branch,"TrackSegments") == 0){
429 fTSMaker->SetTrackSegmentsBranch(title) ;
430 fPID->SetTrackSegmentsBranch(title) ;
435 if(strcmp(branch,"RecParticles") == 0){
436 fPID->SetRecParticlesBranch(title) ;
437 fRecPartBranch = title ;
441 cout << "There is no branch " << branch << "!"<< endl ;
442 cout << "Available branches `SDigits', `Digits', `RecPoints', `TrackSegments' and `RecParticles' " << endl ;
445 //____________________________________________________________________________
446 void AliPHOSReconstructioner::StartFrom(char * module,char* title){
447 // in the next pass of reconstruction (call ExecuteTask()) reconstruction will
448 // start from the module "module", and in the case of nonsero title all
449 // pruduced branches will have title "title". Recognize the following "modules"
450 // "SD" - AliPHOSSDigitizer,
451 // "D" - AliPHOSDigitizer
452 // "C" - AliPHOSClusterizer
453 // "TS" - AliPHOSTrackSegmentMaker
459 char * moduleName = new char[30];
460 if(strstr(module,"SD"))
461 sprintf(moduleName,"AliPHOSSDigitizer") ;
463 if(strstr(module,"D") )
464 sprintf(moduleName,"AliPHOSDigitizer") ;
466 if(strstr(module,"C") || strstr(module,"RecPoint") )
467 sprintf(moduleName,"AliPHOSClusterizer") ;
469 if(strstr(module,"TS") || strstr(module,"Track") )
470 sprintf(moduleName,"AliPHOSTrackSegmentMaker") ;
472 if(strstr(module,"PID") || strstr(module,"Particle") || strstr(module,"RP") )
473 sprintf(moduleName,"AliPHOSPID") ;
475 cout << "Do not know such a module / Rec Object " << endl;
481 Bool_t active = kFALSE ;
482 while((task=(TTask*)next())){
483 if (strcmp(moduleName,task->GetName())==0)
485 task->SetActive(active) ;
486 if(active && title){ // set title to branches
487 switch(strlen(task->GetName()) ) {
488 case 17: // "AliPHOSSDigitizer"
489 fSDigitizer->SetSDigitsBranch(title) ;
490 fDigitizer->SetSDigitsBranch(title) ;
491 fSDigitsBranch = title ;
493 case 16: //"AliPHOSDigitizer"
494 fDigitizer->SetDigitsBranch(title) ;
495 fClusterizer->SetDigitsBranch(title) ;
496 fDigitsBranch = title ;
498 case 18: //"AliPHOSClusterizer"
499 fClusterizer->SetRecPointsBranch(title) ;
500 fTSMaker->SetRecPointsBranch(title) ;
501 fRecPointBranch = title ;
503 case 24: //"AliPHOSTrackSegmentMaker"
504 fTSMaker->SetTrackSegmentsBranch(title) ;
505 fPID->SetTrackSegmentsBranch(title) ;
508 case 10: // "AliPHOSPID"
509 fPID->SetRecParticlesBranch(title) ;
510 fRecPartBranch = title ;
519 //____________________________________________________________________________
520 void AliPHOSReconstructioner::Print(Option_t * option)const {
522 cout << "-----------------AliPHOSReconstructioner---------------" << endl ;
523 cout << " Reconstruction of the header file " <<fHeaderFileName.Data() << endl ;
524 cout << " with the following modules: " << endl ;
526 if(fSDigitizer->IsActive()){
527 cout << " (+) " << fSDigitizer->GetName() << " to branch : " << fSDigitsBranch.Data() << endl ;
530 if(fDigitizer->IsActive()){
531 cout << " (+) " << fDigitizer->GetName() << " to branch : " << fDigitsBranch.Data() << endl ;
535 if(fClusterizer->IsActive()){
536 cout << " (+) " <<fClusterizer->GetName() << " to branch : " <<fRecPointBranch.Data() << endl ;
540 if(fTSMaker->IsActive()){
541 cout << " (+) " << fTSMaker->GetName() << " to branch : " << fTSBranch.Data() << endl ;
546 if(fPID->IsActive()){
547 cout << " (+) " << fPID->GetName() << " to branch : " <<fRecPartBranch.Data() << endl ;