]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONReconstructor.cxx
Fix coverity defects
[u/mrichter/AliRoot.git] / MUON / AliMUONReconstructor.cxx
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 /* $Id$ */
16
17 //-----------------------------------------------------------------------------
18 /// \class AliMUONReconstructor
19 ///
20 /// Implementation of AliReconstructor for MUON subsystem.
21 ///
22 /// The clustering mode and the associated parameters can be changed through the
23 /// AliMUONRecoParam object set in the reconstruction macro or read from the CDB
24 /// (see methods in AliMUONRecoParam.h file for details)
25 ///
26 /// Valid modes are :
27 ///
28 /// SIMPLEFIT : use the AliMUONClusterFinderSimpleFit clusterizer
29 ///
30 /// SIMPLEFITV3 : SIMPLEFIT with preclustering=PRECLUSTERV3
31 ///
32 /// MLEM : use AliMUONClusterFinderMLEM and AliMUONPreClusterFinder for preclustering (default)
33 /// MLEMV2 : MLEM with preclustering=PRECLUSTERV2
34 /// MLEMV3 : MLEM with preclustering=PRECLUSTERV3
35 ///
36 /// PRECLUSTER : use only AliMUONPreClusterFinder. Only for debug as
37 /// the produced clusters do not have a position, hence the tracking will not
38 /// work
39 /// PRECLUSTERV2 : another version of the preclustering
40 /// PRECLUSTERV3 : yet another version of the preclustering
41 ///
42 /// COG : use AliMUONClusterFinderCOG clusterizer. Not really a production
43 /// option either, as center-of-gravity is generally not a good estimate
44 /// of the cluster position...
45 ///
46 /// PEAKCOG : COG cluster finder around local maxima
47 /// PEAKFIT : fit around local maxima with up to 3 peaks, COG otherwise
48 ///
49 /// NOCLUSTERING : bypass completely the clustering stage
50 ///
51 /// ------
52 ///
53 /// The behavior of the MUON reconstruction can also be changed, besides
54 /// the usual methods found in AliReconstruction (e.g. to disable tracking)
55 /// by using AliReconstruction::SetOption("MUON",options)
56 /// where options should be a space separated string.
57 ///
58 /// Valid options are :
59 ///
60 /// SAVEDIGITS : if you want to save in the TreeD the *calibrated* digits
61 ///     that are used for the clustering
62 ///
63 /// DIGITSTOREV1 : use the V1 implementation of the digitstore 
64 /// DIGITSTOREV2R : use the V2R implementation of the digitstore 
65 ///
66 /// NOLOCALRECONSTRUCTION : for debug, to disable local reconstruction (and hence
67 /// "recover" old behavior)
68 ///
69 /// TRIGGERDISABLE : disable the treatment of MUON trigger
70 ///
71 /// ENABLEERRORLOGGING : enable error logging (this activates also warnings in RawStreamTracker)
72 ///
73 /// \author Laurent Aphecetche, Subatech
74 //-----------------------------------------------------------------------------
75
76 #include "AliMUONReconstructor.h"
77
78 #include "AliMUONCalibrationData.h"
79 #include "AliMUONClusterFinderCOG.h"
80 #include "AliMUONClusterFinderMLEM.h"
81 #include "AliMUONClusterFinderSimpleFit.h"
82 #include "AliMUONClusterFinderPeakCOG.h"
83 #include "AliMUONClusterFinderPeakFit.h"
84 #include "AliMUONClusterStoreV1.h"
85 #include "AliMUONClusterStoreV2.h"
86 #include "AliMUONConstants.h"
87 #include "AliMUONDigitCalibrator.h"
88 #include "AliMUONDigitMaker.h"
89 #include "AliMUONDigitStoreV1.h"
90 #include "AliMUONDigitStoreV2R.h"
91 #include "AliMUONGeometryTransformer.h"
92 #include "AliMUONPadStatusMaker.h"
93 #include "AliMUONPreClusterFinder.h"
94 #include "AliMUONPreClusterFinderV2.h"
95 #include "AliMUONPreClusterFinderV3.h"
96 #include "AliMUONSimpleClusterServer.h"
97 #include "AliMUONTracker.h"
98 #include "AliMUONTriggerCircuit.h"
99 #include "AliMUONTriggerStoreV1.h"
100 #include "AliMUONVClusterFinder.h"
101 #include "AliMUONVClusterServer.h"
102 #include "AliMUONVTrackStore.h"
103 #include "AliMUONTriggerElectronics.h"
104
105 #include "AliMpArea.h"
106 #include "AliMpCDB.h"
107 #include "AliMpConstants.h"
108 #include "AliMpDDLStore.h"
109 #include "AliMpSegmentation.h"
110
111 #include "AliRawReader.h"
112 #include "AliCDBManager.h"
113 #include "AliCodeTimer.h"
114 #include "AliLog.h"
115 #include "AliRunInfo.h"
116
117 #include <Riostream.h>
118 #include <TObjArray.h>
119 #include <TClonesArray.h>
120 #include <TString.h>
121 #include <TTree.h>
122
123 /// \cond CLASSIMP
124 ClassImp(AliMUONReconstructor)
125 /// \endcond 
126
127 //_____________________________________________________________________________
128 AliMUONReconstructor::AliMUONReconstructor() : 
129 AliReconstructor(),
130 fDigitMaker(0x0),
131 fTransformer(new AliMUONGeometryTransformer()),
132 fDigitStore(0x0),
133 fTriggerCircuit(0x0),
134 fCalibrationData(0x0),
135 fDigitCalibrator(0x0),
136 fClusterServer(0x0),
137 fTriggerStore(0x0),
138 fTrackStore(0x0),
139 fClusterStore(0x0),
140 fTriggerProcessor(0x0)  
141 {
142   /// normal ctor
143
144   AliDebug(1,"");
145   
146   // Unload mapping objects
147   // if they have been loaded from the obsolete OCDB mapping objects
148
149   if ( AliMpDDLStore::Instance(false) ) {
150     AliCDBManager::Instance()->UnloadFromCache("MUON/Calib/DDLStore");
151     delete AliMpDDLStore::Instance();
152   }  
153
154   if ( AliMpSegmentation::Instance(false) ) { 
155     AliCDBManager::Instance()->UnloadFromCache("MUON/Calib/Mapping");
156     delete AliMpSegmentation::Instance();
157   }  
158
159   // Load mapping
160   if ( ! AliMpCDB::LoadDDLStore() ) {
161     AliFatal("Could not access mapping from OCDB !");
162   }
163   
164   // Load geometry data
165   fTransformer->LoadGeometryData();
166   
167 }
168
169 //_____________________________________________________________________________
170 AliMUONReconstructor::~AliMUONReconstructor()
171 {
172   /// dtor
173
174   AliDebug(1,"");
175
176   delete fDigitMaker;
177   delete fDigitStore;
178   delete fTransformer;
179   delete fTriggerCircuit;
180   delete fDigitCalibrator;
181   delete fCalibrationData;
182   delete fClusterServer;
183   delete fTriggerStore;
184   delete fTrackStore;
185   delete fClusterStore;
186   delete fTriggerProcessor;
187
188   delete AliMpSegmentation::Instance(false);
189   delete AliMpDDLStore::Instance(false);
190 }
191
192 //_____________________________________________________________________________
193 void
194 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
195 {
196   /// Calibrate the digitStore
197   if (!fDigitCalibrator)
198   {
199     CreateCalibrator();
200   }
201   AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()),0)
202   fDigitCalibrator->Calibrate(digitStore);      
203 }
204
205 //_____________________________________________________________________________
206 void
207 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, 
208                                     AliMUONVDigitStore* digitStore,
209                                     AliMUONVTriggerStore* triggerStore) const
210 {
211   /// Convert raw data into digit and trigger stores
212   CreateDigitMaker();
213
214   // Skip reconstruction if event is Calibration
215   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) {
216     digitStore->Clear(); // Remove possible digits from previous event
217     triggerStore->Clear(); // Remove possible triggers from previous event
218     AliInfo("Calibration event: do not convert digits");
219     return;
220   }
221   
222   AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
223                     fDigitMaker->ClassName()))
224   fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
225   AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
226                          fDigitMaker->ClassName()))
227   Calibrate(*digitStore);
228 }
229
230 //_____________________________________________________________________________
231 void 
232 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
233 {
234    /// convert raw data into a digit tree
235   AliCodeTimerAuto("",0)
236
237   Bool_t alone = ( TriggerStore() == 0 );
238   
239   Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
240   if ( TriggerStore() ) 
241   {
242     ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
243   }
244   
245   if (!ok)
246   {
247     AliError("Could not make branches on TreeD");
248   }
249   else
250   {
251     ConvertDigits(rawReader,DigitStore(),TriggerStore());
252     AliCodeTimerStart("Fill digits")
253     digitsTree->Fill();
254     AliCodeTimerStop("Fill digits")
255     DigitStore()->Clear();
256   }
257 }
258
259 //_____________________________________________________________________________
260 void
261 AliMUONReconstructor::CreateDigitMaker() const
262 {
263   /// Create (and create if necessary) the digit maker
264   if (fDigitMaker) return;
265
266   AliCodeTimerAuto("",0)
267
268   TString option = GetOption();
269   
270   Bool_t enableErrorLogging = kFALSE;
271
272   if (option.Contains("ENABLEERRORLOGGING"))
273   {
274     enableErrorLogging = kTRUE;
275   }
276
277   fDigitMaker = new AliMUONDigitMaker(enableErrorLogging);
278   option.ToUpper();
279
280   // Always make trigger digits
281   // (needed when calculating trigger chamber efficiency)
282   fDigitMaker->SetMakeTriggerDigits(kTRUE);
283
284   if ( GetRecoParam()->TryRecover() )
285   {
286     fDigitMaker->SetTryRecover(kTRUE);
287   }
288   else
289   {
290     fDigitMaker->SetTryRecover(kFALSE);    
291   }
292 }
293
294 //_____________________________________________________________________________
295 void 
296 AliMUONReconstructor::CreateTriggerCircuit() const
297 {
298   /// Return (and create if necessary) the trigger circuit object
299   if (fTriggerCircuit) return;
300
301   AliCodeTimerAuto("",0)
302
303   fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
304
305 }
306
307 //_____________________________________________________________________________
308 AliTracker* 
309 AliMUONReconstructor::CreateTracker() const
310 {
311   /// Create the MUONTracker object
312   
313   CreateTriggerCircuit();
314   CreateClusterServer();
315
316   AliMUONTracker* tracker(0x0);
317   
318   if ( ! GetRecoParam()->CombineClusterTrackReco() )
319   {
320     tracker = new AliMUONTracker(GetRecoParam(),
321                                  0x0,
322                                  *DigitStore(),
323                                  fTransformer,
324                                  fTriggerCircuit);
325   }
326   else
327   {
328     tracker = new AliMUONTracker(GetRecoParam(),
329                                  fClusterServer,
330                                  *DigitStore(),
331                                  fTransformer,
332                                  fTriggerCircuit);
333   }
334   
335   
336   return tracker;
337 }
338
339 //_____________________________________________________________________________
340 AliMUONVClusterFinder*
341 AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
342 {
343   /// Create a given cluster finder instance
344   
345   AliCodeTimerAutoGeneral("",0)
346
347   AliMUONVClusterFinder* clusterFinder(0x0);
348   
349   TString opt(clusterFinderType);
350   opt.ToUpper();
351   
352   if ( strstr(opt,"PRECLUSTERV2") )
353   {
354     clusterFinder = new AliMUONPreClusterFinderV2;
355   }    
356   else if ( strstr(opt,"PRECLUSTERV3") )
357   {
358     clusterFinder = new AliMUONPreClusterFinderV3;
359   }  
360   else if ( strstr(opt,"PRECLUSTER") )
361   {
362     clusterFinder = new AliMUONPreClusterFinder;
363   }  
364   else if ( strstr(opt,"PEAKCOG") )
365   {
366     clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
367   }
368   else if ( strstr(opt,"PEAKFIT") )
369   {
370     clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
371   }
372   else if ( strstr(opt,"COG") )
373   {
374     clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
375   }  
376   else if ( strstr(opt,"SIMPLEFITV3") )
377   {
378     clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
379   }
380   else if ( strstr(opt,"SIMPLEFIT") )
381   {
382     clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
383   }
384   else if ( strstr(opt,"MLEM:DRAW") )
385   {
386     clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
387   }
388   else if ( strstr(opt,"MLEMV3") )
389   {
390     clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
391   } 
392   else if ( strstr(opt,"MLEMV2") )
393   {
394     clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
395   } 
396   else if ( strstr(opt,"MLEM") )
397   {
398     clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
399   } 
400   else
401   {
402     AliErrorClass(Form("clustering mode \"%s\" does not exist",opt.Data()));
403     return 0x0;
404   }
405   
406   return clusterFinder;
407 }
408
409 //_____________________________________________________________________________
410 void
411 AliMUONReconstructor::CreateClusterServer() const
412 {
413   /// Create cluster server
414   
415   if ( fClusterServer ) return;
416   
417   AliCodeTimerAuto("",0);
418     
419   AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
420   
421   if ( !clusterFinder ) return;
422   
423   AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
424   
425   fClusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
426 }
427
428 //_____________________________________________________________________________
429 void
430 AliMUONReconstructor::CreateCalibrationData() const
431 {
432   /// Create the calibrator
433   
434   AliCodeTimerAuto("",0);
435   
436   Int_t runNumber = AliCDBManager::Instance()->GetRun();
437
438   fCalibrationData = new AliMUONCalibrationData(runNumber);
439   if ( !fCalibrationData->IsValid() )
440   {
441     AliError("Could not retrieve calibrations !");
442     delete fCalibrationData;
443     fCalibrationData = 0x0;
444     return;
445   }    
446   
447   // It is now time to check whether we have everything to proceed.
448   // What we need depends on whether both tracker and trigger
449   // are in the readout chain, and what specific "bad channel policy"
450   // we use
451   
452   Bool_t kTracker(kFALSE);
453   Bool_t kTrigger(kFALSE);
454   
455   const AliRunInfo* runInfo = GetRunInfo();
456   if (!runInfo)
457   {
458     AliError("Could not get runinfo ?")
459   }
460   else
461   {
462     TString detectors(runInfo->GetActiveDetectors());
463     if (detectors.Contains("MUONTRK")) kTracker=kTRUE;
464     if (detectors.Contains("MUONTRG")) kTrigger=kTRUE;
465   }
466    
467   AliInfo(Form("Run with MUON TRIGGER : %s and MUON TRACKER : %s",
468                kTrigger ? "YES":"NO" , 
469                kTracker ? "YES":"NO"));
470   
471   if ( kTracker ) 
472   {
473     // Check that we get all the calibrations we'll need
474     if ( !fCalibrationData->Pedestals() ||
475         !fCalibrationData->Gains() )
476     {
477       AliFatal(Form("Could not access all required calibration data (PED %p GAIN %p)",
478                     fCalibrationData->Pedestals(),fCalibrationData->Gains()));      
479     }
480     
481     if ( !fCalibrationData->HV() ) 
482     {
483       // Special treatment of HV. We only break if the values
484       // are not there *AND* we cut on them.
485       UInt_t mask = GetRecoParam()->PadGoodnessMask();
486       TString smask(AliMUONPadStatusMaker::AsCondition(mask));
487       if ( smask.Contains("HV") )
488       {
489         AliFatal("Could not access all required calibration data (HV)");      
490       }
491     } 
492   }
493 }
494
495 //_____________________________________________________________________________
496 void
497 AliMUONReconstructor::CreateCalibrator() const
498 {
499   /// Create the calibrator
500
501   AliCodeTimerAuto("",0);
502
503   if ( ! fCalibrationData )
504     CreateCalibrationData();
505
506   AliInfo("Calibration will occur.");
507
508   TString opt(GetOption());
509   opt.ToUpper();
510   
511   if ( strstr(opt,"NOSTATUSMAP") )
512   {
513     AliWarning("NOSTATUSMAP is obsolete");
514   }
515
516   TString calibMode = GetRecoParam()->GetCalibrationMode();
517
518   fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam(),calibMode.Data());
519 }
520
521 //_____________________________________________________________________________
522 void
523 AliMUONReconstructor::ResponseRemovingChambers(AliMUONVTriggerStore* triggerStore) const
524 {
525   /// Update trigger information with informatins obtained after
526   /// re-calculation of trigger response
527   AliCodeTimerAuto("",0);
528
529   if ( ! fCalibrationData )
530     CreateCalibrationData();
531
532   if ( ! fTriggerProcessor )
533     fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
534
535   fTriggerProcessor->ResponseRemovingChambers(*triggerStore);
536 }
537
538 //_____________________________________________________________________________
539 AliMUONVDigitStore*
540 AliMUONReconstructor::DigitStore() const
541 {
542   /// Return (and create if necessary) the digit container
543   if (!fDigitStore) 
544   {
545     TString sopt(GetOption());
546     sopt.ToUpper();
547     
548     AliInfo(Form("Options=%s",sopt.Data()));
549     
550     if ( sopt.Contains("DIGITSTOREV1") )
551     {
552       fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
553     }
554     else if ( sopt.Contains("DIGITSTOREV2R") ) 
555     {
556       fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
557     }
558     else if ( sopt.Contains("DIGITSTOREV2S") ) 
559     {
560       fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
561     }
562     
563     if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
564     
565     AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
566   }
567   return fDigitStore;
568 }
569
570 //_____________________________________________________________________________
571 void
572 AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
573                                 TTree& clustersTree) const
574 {
575   /// Write the trigger and cluster information into TreeR
576
577   AliCodeTimerAuto("",0)
578
579   Bool_t ok(kFALSE);
580   Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
581   
582   if ( ! GetRecoParam()->CombineClusterTrackReco() )
583   {
584     alone = kFALSE; // we'll get both tracker and trigger information in TreeR
585   }
586   
587   if ( triggerStore ) 
588   {
589     ResponseRemovingChambers(triggerStore);
590     ok = triggerStore->Connect(clustersTree,alone);
591     if (!ok)
592     {
593       AliError("Could not create triggerStore branches in TreeR");
594     }
595   }
596
597   if ( !alone )
598   {
599     if (!fClusterStore)
600     {
601       fClusterStore = new AliMUONClusterStoreV2;
602     }
603     
604     CreateClusterServer();
605     
606     TIter next(DigitStore()->CreateIterator());
607     fClusterServer->UseDigits(next,DigitStore());
608
609     AliMpArea area;
610     
611     AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
612     
613     for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i ) 
614     {
615       if (GetRecoParam()->UseChamber(i))
616       {
617         if ( ( i == 6 || i == 7 )  && GetRecoParam()->BypassSt4() ) continue;
618         if ( ( i == 8 || i == 9 )  && GetRecoParam()->BypassSt5() ) continue;
619         
620         fClusterServer->Clusterize(i,*fClusterStore,area,GetRecoParam());
621       }
622     }
623     
624     Bool_t cok = fClusterStore->Connect(clustersTree,alone);
625     
626     if (!cok) AliError("Could not connect clusterStore to clusterTree");
627     
628     AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
629     
630     StdoutToAliDebug(1,fClusterStore->Print());
631   }
632          
633   if (ok) // at least one type of branches created successfully
634   {
635     clustersTree.Fill();
636   }
637   
638   if (fClusterStore) fClusterStore->Clear();
639 }
640
641 //_____________________________________________________________________________
642 Bool_t 
643 AliMUONReconstructor::HasDigitConversion() const
644 {
645   /// We *do* have digit conversion, but we might advertise it only 
646   /// if we want to save the digits.
647   
648   TString opt(GetOption());
649   opt.ToUpper();
650   if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
651   {
652     return kTRUE;
653   }
654   else
655   {
656     return kFALSE;
657   }
658 }
659
660 //_____________________________________________________________________________
661 void 
662 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
663 {
664   /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
665   /// HasDigitConversion()==kFALSE
666   
667   if ( !clustersTree ) 
668   {
669     AliError("clustersTree is 0x0 !");
670     return;
671   }
672   
673   ConvertDigits(rawReader,DigitStore(),TriggerStore());
674
675   FillTreeR(TriggerStore(),*clustersTree);
676 }
677
678 //_____________________________________________________________________________
679 void 
680 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
681 {
682   /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
683   /// AND HasDigitConversion()==kTRUE
684   
685   AliCodeTimerAuto("",0)
686   
687   AliDebug(1,"");
688   
689   if (!digitsTree || !clustersTree) 
690   {
691     AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
692                   digitsTree,clustersTree));
693     return;
694   }
695
696   if (!fDigitStore)
697   {
698     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
699     if (!fDigitStore)
700     {
701       AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
702     }
703     else
704     {
705       AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
706     }
707   }
708   if (!fTriggerStore)
709   {
710     fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
711     if (!fTriggerStore)
712     {
713       AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
714     }
715     else
716     {
717       AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
718     }
719   }
720   
721   if (!fTriggerStore && !fDigitStore)
722   {
723     AliError("No store at all. Nothing to do.");
724     return;
725   }
726   
727   // insure we start with empty stores
728   if ( fDigitStore ) 
729   {
730     fDigitStore->Clear(); 
731     Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
732     Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
733     if (!ok)
734     {
735       AliError("Could not connect digitStore to digitsTree");
736       return;
737     }
738   }
739   if ( fTriggerStore ) 
740   {
741     fTriggerStore->Clear();
742     Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
743     Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
744     if (!ok)
745     {
746       AliError("Could not connect triggerStore to digitsTree");
747       return;
748     }
749   }
750   
751   digitsTree->GetEvent(0);
752   
753   if ( fDigitStore ) 
754   {
755     // Insure we got calibrated digits (if we reconstruct from pure simulated,
756     // i.e. w/o going through raw data, this will be the case)
757     TIter next(fDigitStore->CreateIterator());
758     AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
759     if (digit && !digit->IsCalibrated())
760     {
761       Calibrate(*fDigitStore);
762     }
763   }
764     
765   FillTreeR(fTriggerStore,*clustersTree);
766 }
767
768 //_____________________________________________________________________________
769 AliMUONVTriggerStore*
770 AliMUONReconstructor::TriggerStore() const
771 {
772   /// Return (and create if necessary and allowed) the trigger container
773   TString sopt(GetOption());
774   sopt.ToUpper();
775   
776   if (sopt.Contains("TRIGGERDISABLE"))
777   {
778     delete fTriggerStore;
779     fTriggerStore = 0x0;
780   }
781   else
782   {
783     if (!fTriggerStore)
784     {
785       fTriggerStore = new AliMUONTriggerStoreV1;
786     }
787   }
788   return fTriggerStore;
789 }