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 // --- Standard library ---
64 // --- AliRoot header files ---
65 #include "AliPHOSReconstructioner.h"
66 #include "AliPHOSClusterizerv1.h"
67 #include "AliPHOSDigitizer.h"
68 #include "AliPHOSSDigitizer.h"
69 #include "AliPHOSTrackSegmentMakerv1.h"
70 #include "AliPHOSPIDv1.h"
73 ClassImp(AliPHOSReconstructioner)
75 //____________________________________________________________________________
76 AliPHOSReconstructioner::AliPHOSReconstructioner():TTask("AliPHOSReconstructioner","")
85 fHeaderFileName = "galice.root" ;
87 fIsInitialized = kFALSE ;
91 //____________________________________________________________________________
92 AliPHOSReconstructioner::AliPHOSReconstructioner(const char* headerFile,const char * branchName,Bool_t toSplit):
93 TTask("AliPHOSReconstructioner","")
97 fHeaderFileName = headerFile ;
99 fSDigitsBranch= branchName;
100 fSDigitizer = new AliPHOSSDigitizer(fHeaderFileName.Data(),fSDigitsBranch.Data(),toSplit) ;
103 fDigitsBranch=branchName ;
104 fDigitizer = new AliPHOSDigitizer(fHeaderFileName.Data(),fDigitsBranch.Data(),toSplit) ;
108 fRecPointBranch=branchName ;
109 fClusterizer = new AliPHOSClusterizerv1(fHeaderFileName.Data(),fRecPointBranch.Data(),toSplit) ;
113 fTSBranch=branchName ;
114 fTSMaker = new AliPHOSTrackSegmentMakerv1(fHeaderFileName.Data(),fTSBranch.Data(),toSplit) ;
118 fRecPartBranch=branchName ;
119 fPID = new AliPHOSPIDv1(fHeaderFileName.Data(),fRecPartBranch.Data(),toSplit) ;
122 fIsInitialized = kTRUE ;
125 //____________________________________________________________________________
126 void AliPHOSReconstructioner::Exec(Option_t *option)
128 //chesk, if the names of branches, which should be made conicide with already
133 TString message(" ") ;
134 // gAlice->GetEvent(0) ;
136 // if(fSDigitizer->IsActive()&& gAlice->TreeS()){ //Will produce SDigits
137 // TBranch * sdigitsBranch = 0;
138 // TBranch * sdigitizerBranch = 0;
140 // TObjArray * branches = gAlice->TreeS()->GetListOfBranches() ;
142 // Bool_t phosNotFound = kTRUE ;
143 // Bool_t sdigitizerNotFound = kTRUE ;
145 // for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
147 // sdigitsBranch=(TBranch *) branches->At(ibranch) ;
148 // if(( strcmp("PHOS",sdigitsBranch->GetName())==0 ) &&
149 // (fSDigitsBranch.CompareTo(sdigitsBranch->GetTitle())== 0 ))
150 // phosNotFound = kFALSE ;
152 // if(sdigitizerNotFound){
153 // sdigitizerBranch = (TBranch *) branches->At(ibranch) ;
154 // if(( strcmp(sdigitizerBranch->GetName(),"AliPHOSSDigitizer") == 0) &&
155 // (fSDigitsBranch.CompareTo(sdigitizerBranch->GetTitle())== 0 ) )
156 // sdigitizerNotFound = kFALSE ;
160 // if(!(sdigitizerNotFound && phosNotFound)){
161 // message = " Branches PHOS or AliPHOSSDigitizer with title %s\n" ;
162 // message += " already exist in TreeS. ROOT does not allow updating/overwriting.\n" ;
163 // message += " Specify another title for branches or use StartFrom() method\n" ;
164 // Error("Exec", message.Data(), fSDigitsBranch.Data() ) ;
165 // //mark all tasks as inactive
166 // TIter next(fTasks);
168 // while((task=(TTask*)next()))
169 // task->SetActive(kFALSE) ;
175 // if(fDigitizer->IsActive() && gAlice->TreeD()){ //Will produce Digits
176 // TBranch * digitsBranch = 0;
177 // TBranch * digitizerBranch = 0;
179 // TObjArray * branches = gAlice->TreeD()->GetListOfBranches() ;
181 // Bool_t phosNotFound = kTRUE ;
182 // Bool_t digitizerNotFound = kTRUE ;
184 // for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
186 // digitsBranch=(TBranch *) branches->At(ibranch) ;
187 // if(( strcmp("PHOS",digitsBranch->GetName())==0 ) &&
188 // (fDigitsBranch.CompareTo(digitsBranch->GetTitle())== 0 ))
189 // phosNotFound = kFALSE ;
191 // if(digitizerNotFound){
192 // digitizerBranch = (TBranch *) branches->At(ibranch) ;
193 // if(( strcmp(digitizerBranch->GetName(),"AliPHOSDigitizer") == 0) &&
194 // (fDigitsBranch.CompareTo(digitizerBranch->GetTitle())== 0 ) )
195 // digitizerNotFound = kFALSE ;
199 // if(!(digitizerNotFound && phosNotFound)){
200 // message = " Branches PHOS or AliPHOSDigitizer with title %s\n" ;
201 // message += " already exist in TreeD. ROOT does not allow updating/overwriting.\n" ;
202 // message += " Specify another title for branches or use StartFrom() method" ;
203 // Error("Exec", message>Data(), fDigitsBranch.Data() ) ;
204 // //mark all tasks as inactive
205 // TIter next(fTasks);
207 // while((task=(TTask*)next()))
208 // task->SetActive(kFALSE) ;
214 // if(fClusterizer->IsActive() && gAlice->TreeR()){ //Will produce RecPoints
215 // TBranch * emcBranch = 0;
216 // TBranch * cpvBranch = 0;
217 // TBranch * clusterizerBranch = 0;
219 // TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
221 // Bool_t emcNotFound = kTRUE ;
222 // Bool_t cpvNotFound = kTRUE ;
223 // Bool_t clusterizerNotFound = kTRUE ;
225 // for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
228 // emcBranch=(TBranch *) branches->At(ibranch) ;
229 // if(fRecPointBranch.CompareTo(emcBranch->GetTitle())==0 )
230 // if( strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0)
231 // emcNotFound = kFALSE ;
234 // cpvBranch=(TBranch *) branches->At(ibranch) ;
235 // if(fRecPointBranch.CompareTo(cpvBranch->GetTitle())==0 )
236 // if( strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0)
237 // cpvNotFound = kFALSE ;
239 // if(clusterizerNotFound){
240 // clusterizerBranch = (TBranch *) branches->At(ibranch) ;
241 // if( fRecPointBranch.CompareTo(clusterizerBranch->GetTitle()) == 0)
242 // if( strcmp(clusterizerBranch->GetName(),"AliPHOSClusterizer") == 0)
243 // clusterizerNotFound = kFALSE ;
247 // if(!(clusterizerNotFound && emcNotFound && cpvNotFound)){
248 // message = " Branches PHOSEmcRP, PHOSCpvRP or AliPHOSClusterizer with title %s\n" ;
249 // message += " already exist in TreeR. ROOT does not allow updating/overwriting.\n" ;
250 // message += " Specify another title for branches or use StartFrom() method\n" ;
251 // Error("Exec", message.Data(),fRecPointBranch.Data() ) ;
252 // //mark all tasks as inactive
253 // TIter next(fTasks);
255 // while((task=(TTask*)next()))
256 // task->SetActive(kFALSE) ;
261 // if(fTSMaker->IsActive() && gAlice->TreeR()){ //Produce TrackSegments
262 // TBranch * tsMakerBranch = 0;
263 // TBranch * tsBranch = 0;
265 // TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
267 // Bool_t tsMakerNotFound = kTRUE ;
268 // Bool_t tsNotFound = kTRUE ;
270 // for(ibranch = 0;(ibranch <branches->GetEntries())&&(tsMakerNotFound||tsNotFound);ibranch++){
271 // if(tsMakerNotFound){
272 // tsMakerBranch=(TBranch *) branches->At(ibranch) ;
273 // if( fTSBranch.CompareTo(tsMakerBranch->GetTitle())==0 )
274 // if( strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0)
275 // tsMakerNotFound = kFALSE ;
278 // tsBranch=(TBranch *) branches->At(ibranch) ;
279 // if( fTSBranch.CompareTo(tsBranch->GetTitle())==0 )
280 // if( strcmp(tsBranch->GetName(),"PHOSTS") == 0)
281 // tsNotFound = kFALSE ;
285 // if(!(tsMakerNotFound &&tsNotFound) ){
286 // message = " Branches PHOSTS or AliPHOSTrackSegmentMaker with title %s\n" ;
287 // message += " already exist in TreeR. ROOT does not allow updating/overwriting.\n" ;
288 // message += " Specify another title for branches or use StartFrom() method\n" ;
289 // Error("Exec", message.Data(),fTSBranch.Data() ) ;
290 // //mark all tasks as inactive
291 // TIter next(fTasks);
293 // while((task=(TTask*)next()))
294 // task->SetActive(kFALSE) ;
301 // if(fPID->IsActive() && gAlice->TreeR()){ //Produce RecParticles
302 // TBranch * pidBranch = 0;
303 // TBranch * rpBranch = 0;
305 // TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ;
307 // Bool_t pidNotFound = kTRUE ;
308 // Bool_t rpNotFound = kTRUE ;
310 // for(ibranch = 0;(ibranch <branches->GetEntries()) && pidNotFound && rpNotFound ;ibranch++){
312 // pidBranch=(TBranch *) branches->At(ibranch) ;
313 // if( (strcmp(fRecPartBranch,pidBranch->GetTitle())==0 ) &&
314 // (strcmp(pidBranch->GetName(),"AliPHOSPID") == 0) )
315 // pidNotFound = kFALSE ;
318 // rpBranch=(TBranch *) branches->At(ibranch) ;
319 // if( (strcmp(fRecPartBranch,rpBranch->GetTitle())==0 ) &&
320 // (strcmp(rpBranch->GetName(),"PHOSRP") == 0) )
321 // rpNotFound = kFALSE ;
325 // if(!pidNotFound || !rpNotFound ){
326 // message = " Branches PHOSRP or AliPHOSPID with title %s\n" ;
327 // message += " already exist in TreeR. ROOT does not allow updating/overwriting.\n" ;
328 // message += " Specify another title for branches.\n" ;
329 // Error("Exec", message.Data(), fRecPartBranch.Data() ) ;
330 // //mark all tasks as inactive
331 // TIter next(fTasks);
333 // while((task=(TTask*)next()))
334 // task->SetActive(kFALSE) ;
340 //____________________________________________________________________________
341 void AliPHOSReconstructioner::Init()
343 // initiliaze Reconstructioner if necessary: we can not do this in default constructor
348 fSDigitsBranch="Default" ;
349 fSDigitizer = new AliPHOSSDigitizer(fHeaderFileName.Data(),fSDigitsBranch.Data(),fToSplit) ;
352 fDigitsBranch="Default" ;
353 fDigitizer = new AliPHOSDigitizer(fHeaderFileName.Data(),fDigitsBranch.Data(),fToSplit) ;
356 fRecPointBranch="Default" ;
357 fClusterizer = new AliPHOSClusterizerv1(fHeaderFileName.Data(),fRecPointBranch.Data(),fToSplit) ;
360 fTSBranch="Default" ;
361 fTSMaker = new AliPHOSTrackSegmentMakerv1(fHeaderFileName.Data(),fTSBranch.Data(),fToSplit) ;
365 fRecPartBranch="Default" ;
366 fPID = new AliPHOSPIDv1(fHeaderFileName.Data(),fRecPartBranch.Data(),fToSplit) ;
369 fIsInitialized = kTRUE ;
372 //____________________________________________________________________________
373 AliPHOSReconstructioner::~AliPHOSReconstructioner()
375 // Delete data members if any
378 // delete fSDigitizer ;
381 // delete fDigitizer ;
384 // delete fClusterizer ;
392 // TFile * file = (TFile*) gROOT->GetFile(fHeaderFileName.Data()) ;
397 // printf("File %s is closed\n",fHeaderFileName.Data());
401 // //____________________________________________________________________________
402 // void AliPHOSReconstructioner::SetBranchTitle(const char* branch, const char * title)
404 // //Diverge correcpoinding branch to the file "title"
406 // if(strcmp(branch,"SDigits") == 0){
407 // fSDigitizer->SetSDigitsBranch(title) ;
408 // fDigitizer->SetSDigitsBranch(title) ;
409 // fSDigitsBranch = title ;
413 // if(strcmp(branch,"Digits") == 0){
414 // fDigitizer->SetName(title) ;
415 // fClusterizer->SetName(title) ;
416 // fDigitsBranch = title ;
420 // if(strcmp(branch,"RecPoints") == 0){
421 // fClusterizer->SetRecPointsBranch(title) ;
422 // fTSMaker->SetRecPointsBranch(title) ;
423 // fRecPointBranch = title ;
427 // if(strcmp(branch,"TrackSegments") == 0){
428 // fTSMaker->SetTrackSegmentsBranch(title) ;
429 // fPID->SetTrackSegmentsBranch(title) ;
430 // fTSBranch = title ;
434 // if(strcmp(branch,"RecParticles") == 0){
435 // fPID->SetRecParticlesBranch(title) ;
436 // fRecPartBranch = title ;
442 // message = "There is no branch %s !\n" ;
443 // message += "Available branches `SDigits', `Digits', `RecPoints', `TrackSegments' and `RecParticles'\n" ;
444 // Warning("SetBranchTitle", message.Data(), branch ) ;
446 // //____________________________________________________________________________
447 // void AliPHOSReconstructioner::StartFrom(char * module,char* title)
449 // // in the next pass of reconstruction (call ExecuteTask()) reconstruction will
450 // // start from the module "module", and in the case of non zero title all
451 // // pruduced branches will have title "title". The following "modules" are recognized
452 // // "SD" - AliPHOSSDigitizer,
453 // // "D" - AliPHOSDigitizer
454 // // "C" - AliPHOSClusterizer
455 // // "TS" - AliPHOSTrackSegmentMaker
456 // // "RP" - AliPHOSPID
458 // if(!fIsInitialized)
461 // char * moduleName = new char[30];
462 // if(strstr(module,"SD"))
463 // sprintf(moduleName,"AliPHOSSDigitizer") ;
465 // if(strstr(module,"D") )
466 // sprintf(moduleName,"AliPHOSDigitizer") ;
468 // if(strstr(module,"C") || strstr(module,"RecPoint") )
469 // sprintf(moduleName,"AliPHOSClusterizer") ;
471 // if(strstr(module,"TS") || strstr(module,"Track") )
472 // sprintf(moduleName,"AliPHOSTrackSegmentMaker") ;
474 // if(strstr(module,"PID") || strstr(module,"Particle") || strstr(module,"RP") )
475 // sprintf(moduleName,"AliPHOSPID") ;
477 // Warning("StartFrom", "Do not know such a module / Rec Object ") ;
481 // TIter next(fTasks);
483 // Bool_t active = kFALSE ;
484 // while((task=(TTask*)next())){
485 // if (strcmp(moduleName,task->GetName())==0)
487 // task->SetActive(active) ;
488 // if(active && title){ // set title to branches
489 // switch(strlen(task->GetName()) ) {
490 // case 17: // "AliPHOSSDigitizer"
491 // fSDigitizer->SetSDigitsBranch(title) ;
492 // fDigitizer->SetSDigitsBranch(title) ;
493 // fSDigitsBranch = title ;
495 // case 16: //"AliPHOSDigitizer"
496 // fDigitizer->SetName(title) ;
497 // fClusterizer->SetName(title) ;
498 // fDigitsBranch = title ;
500 // case 18: //"AliPHOSClusterizer"
501 // fClusterizer->SetRecPointsBranch(title) ;
502 // fTSMaker->SetRecPointsBranch(title) ;
503 // fRecPointBranch = title ;
505 // case 24: //"AliPHOSTrackSegmentMaker"
506 // fTSMaker->SetTrackSegmentsBranch(title) ;
507 // fPID->SetTrackSegmentsBranch(title) ;
508 // fTSBranch = title ;
510 // case 10: // "AliPHOSPID"
511 // fPID->SetRecParticlesBranch(title) ;
512 // fRecPartBranch = title ;
519 // delete [] moduleName;
521 //____________________________________________________________________________
523 void AliPHOSReconstructioner::Print(Option_t * option)const {
524 // Print reconstructioner data
527 message = "-----------------AliPHOSReconstructioner---------------\n" ;
528 message += " Reconstruction of the header file %s\n" ;
529 message += " with the following modules:\n" ;
531 if(fSDigitizer->IsActive()){
532 message += " (+) %s to branch %s\n" ;
534 if(fDigitizer->IsActive()){
535 message += " (+) %s to branch %s\n" ;
538 if(fClusterizer->IsActive()){
539 message += " (+) %s to branch %s\n" ;
542 if(fTSMaker->IsActive()){
543 message += " (+) %s to branch %s\n" ;
546 if(fPID->IsActive()){
547 message += " (+) %s to branch %s\n" ;
549 Info("Print", message.Data(),
550 fHeaderFileName.Data(),
551 fSDigitizer->GetName(), fSDigitsBranch.Data(),
552 fDigitizer->GetName(), fDigitsBranch.Data() ,
553 fClusterizer->GetName(), fRecPointBranch.Data(),
554 fTSMaker->GetName(), fTSBranch.Data() ,
555 fPID->GetName(), fRecPartBranch.Data() ) ;