]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONReconstructor.cxx
The logics of handling the geometry file for simulation has changed. The variables...
[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 and delete old mapping
147   AliCDBManager::Instance()->UnloadFromCache("MUON/Calib/Mapping");
148   AliCDBManager::Instance()->UnloadFromCache("MUON/Calib/DDLStore");
149   delete AliMpDDLStore::Instance();
150   delete AliMpSegmentation::Instance();
151
152   // Load mapping
153   if ( ! AliMpCDB::LoadDDLStore() ) {
154     AliFatal("Could not access mapping from OCDB !");
155   }
156   
157   // Load geometry data
158   fTransformer->LoadGeometryData();
159   
160 }
161
162 //_____________________________________________________________________________
163 AliMUONReconstructor::~AliMUONReconstructor()
164 {
165   /// dtor
166
167   AliDebug(1,"");
168
169   delete fDigitMaker;
170   delete fDigitStore;
171   delete fTransformer;
172   delete fTriggerCircuit;
173   delete fDigitCalibrator;
174   delete fCalibrationData;
175   delete fClusterServer;
176   delete fTriggerStore;
177   delete fTrackStore;
178   delete fClusterStore;
179   delete fTriggerProcessor;
180
181   delete AliMpSegmentation::Instance(false);
182   delete AliMpDDLStore::Instance(false);
183 }
184
185 //_____________________________________________________________________________
186 void
187 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
188 {
189   /// Calibrate the digitStore
190   if (!fDigitCalibrator)
191   {
192     CreateCalibrator();
193   }
194   AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()),0)
195   fDigitCalibrator->Calibrate(digitStore);      
196 }
197
198 //_____________________________________________________________________________
199 void
200 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, 
201                                     AliMUONVDigitStore* digitStore,
202                                     AliMUONVTriggerStore* triggerStore) const
203 {
204   /// Convert raw data into digit and trigger stores
205   CreateDigitMaker();
206
207   // Skip reconstruction if event is Calibration
208   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) {
209     digitStore->Clear(); // Remove possible digits from previous event
210     triggerStore->Clear(); // Remove possible triggers from previous event
211     AliInfo("Calibration event: do not convert digits");
212     return;
213   }
214   
215   AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
216                     fDigitMaker->ClassName()))
217   fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
218   AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
219                          fDigitMaker->ClassName()))
220   Calibrate(*digitStore);
221 }
222
223 //_____________________________________________________________________________
224 void 
225 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
226 {
227    /// convert raw data into a digit tree
228   AliCodeTimerAuto("",0)
229
230   Bool_t alone = ( TriggerStore() == 0 );
231   
232   Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
233   if ( TriggerStore() ) 
234   {
235     ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
236   }
237   
238   if (!ok)
239   {
240     AliError("Could not make branches on TreeD");
241   }
242   else
243   {
244     ConvertDigits(rawReader,DigitStore(),TriggerStore());
245     AliCodeTimerStart("Fill digits")
246     digitsTree->Fill();
247     AliCodeTimerStop("Fill digits")
248     DigitStore()->Clear();
249   }
250 }
251
252 //_____________________________________________________________________________
253 void
254 AliMUONReconstructor::CreateDigitMaker() const
255 {
256   /// Create (and create if necessary) the digit maker
257   if (fDigitMaker) return;
258
259   AliCodeTimerAuto("",0)
260
261   TString option = GetOption();
262   
263   Bool_t enableErrorLogging = kFALSE;
264
265   if (option.Contains("ENABLEERRORLOGGING"))
266   {
267     enableErrorLogging = kTRUE;
268   }
269
270   fDigitMaker = new AliMUONDigitMaker(enableErrorLogging);
271   option.ToUpper();
272   if ( option.Contains("SAVEDIGITS" ))
273     {
274       fDigitMaker->SetMakeTriggerDigits(kTRUE);
275     }
276 }
277
278 //_____________________________________________________________________________
279 void 
280 AliMUONReconstructor::CreateTriggerCircuit() const
281 {
282   /// Return (and create if necessary) the trigger circuit object
283   if (fTriggerCircuit) return;
284
285   AliCodeTimerAuto("",0)
286
287   fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
288
289 }
290
291 //_____________________________________________________________________________
292 AliTracker* 
293 AliMUONReconstructor::CreateTracker() const
294 {
295   /// Create the MUONTracker object
296   
297   CreateTriggerCircuit();
298   CreateDigitMaker();
299   CreateClusterServer();
300
301   AliMUONTracker* tracker(0x0);
302   
303   if ( ! GetRecoParam()->CombineClusterTrackReco() )
304   {
305     tracker = new AliMUONTracker(GetRecoParam(),
306                                  0x0,
307                                  *DigitStore(),
308                                  fDigitMaker,
309                                  fTransformer,
310                                  fTriggerCircuit);
311   }
312   else
313   {
314     tracker = new AliMUONTracker(GetRecoParam(),
315                                  fClusterServer,
316                                  *DigitStore(),
317                                  fDigitMaker,
318                                  fTransformer,
319                                  fTriggerCircuit);
320   }
321   
322   
323   return tracker;
324 }
325
326 //_____________________________________________________________________________
327 AliMUONVClusterFinder*
328 AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
329 {
330   /// Create a given cluster finder instance
331   
332   AliCodeTimerAutoGeneral("",0)
333
334   AliMUONVClusterFinder* clusterFinder(0x0);
335   
336   TString opt(clusterFinderType);
337   opt.ToUpper();
338   
339   if ( strstr(opt,"PRECLUSTERV2") )
340   {
341     clusterFinder = new AliMUONPreClusterFinderV2;
342   }    
343   else if ( strstr(opt,"PRECLUSTERV3") )
344   {
345     clusterFinder = new AliMUONPreClusterFinderV3;
346   }  
347   else if ( strstr(opt,"PRECLUSTER") )
348   {
349     clusterFinder = new AliMUONPreClusterFinder;
350   }  
351   else if ( strstr(opt,"PEAKCOG") )
352   {
353     clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
354   }
355   else if ( strstr(opt,"PEAKFIT") )
356   {
357     clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
358   }
359   else if ( strstr(opt,"COG") )
360   {
361     clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
362   }  
363   else if ( strstr(opt,"SIMPLEFITV3") )
364   {
365     clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
366   }
367   else if ( strstr(opt,"SIMPLEFIT") )
368   {
369     clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
370   }
371   else if ( strstr(opt,"MLEM:DRAW") )
372   {
373     clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
374   }
375   else if ( strstr(opt,"MLEMV3") )
376   {
377     clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
378   } 
379   else if ( strstr(opt,"MLEMV2") )
380   {
381     clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
382   } 
383   else if ( strstr(opt,"MLEM") )
384   {
385     clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
386   } 
387   else
388   {
389     AliErrorClass(Form("clustering mode \"%s\" does not exist",opt.Data()));
390     return 0x0;
391   }
392   
393   return clusterFinder;
394 }
395
396 //_____________________________________________________________________________
397 void
398 AliMUONReconstructor::CreateClusterServer() const
399 {
400   /// Create cluster server
401   
402   if ( fClusterServer ) return;
403   
404   AliCodeTimerAuto("",0);
405     
406   AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
407   
408   if ( !clusterFinder ) return;
409   
410   AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
411   
412   fClusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
413 }
414
415 //_____________________________________________________________________________
416 void
417 AliMUONReconstructor::CreateCalibrationData() const
418 {
419   /// Create the calibrator
420   
421   AliCodeTimerAuto("",0);
422   
423   Int_t runNumber = AliCDBManager::Instance()->GetRun();
424
425   fCalibrationData = new AliMUONCalibrationData(runNumber);
426   if ( !fCalibrationData->IsValid() )
427   {
428     AliError("Could not retrieve calibrations !");
429     delete fCalibrationData;
430     fCalibrationData = 0x0;
431     return;
432   }    
433   
434   // It is now time to check whether we have everything to proceed.
435   // What we need depends on whether both tracker and trigger
436   // are in the readout chain, and what specific "bad channel policy"
437   // we use
438   
439   Bool_t kTracker(kFALSE);
440   Bool_t kTrigger(kFALSE);
441   
442   const AliRunInfo* runInfo = GetRunInfo();
443   if (!runInfo)
444   {
445     AliError("Could not get runinfo ?")
446   }
447   else
448   {
449     TString detectors(runInfo->GetActiveDetectors());
450     if (detectors.Contains("MUONTRK")) kTracker=kTRUE;
451     if (detectors.Contains("MUONTRG")) kTrigger=kTRUE;
452   }
453    
454   AliInfo(Form("Run with MUON TRIGGER : %s and MUON TRACKER : %s",
455                kTrigger ? "YES":"NO" , 
456                kTracker ? "YES":"NO"));
457   
458   if ( kTracker ) 
459   {
460     // Check that we get all the calibrations we'll need
461     if ( !fCalibrationData->Pedestals() ||
462         !fCalibrationData->Gains() )
463     {
464       AliFatal(Form("Could not access all required calibration data (PED %p GAIN %p)",
465                     fCalibrationData->Pedestals(),fCalibrationData->Gains()));      
466     }
467     
468     if ( !fCalibrationData->HV() ) 
469     {
470       // Special treatment of HV. We only break if the values
471       // are not there *AND* we cut on them.
472       UInt_t mask = GetRecoParam()->PadGoodnessMask();
473       TString smask(AliMUONPadStatusMaker::AsCondition(mask));
474       if ( smask.Contains("HV") )
475       {
476         AliFatal("Could not access all required calibration data (HV)");      
477       }
478     } 
479   }
480 }
481
482 //_____________________________________________________________________________
483 void
484 AliMUONReconstructor::CreateCalibrator() const
485 {
486   /// Create the calibrator
487
488   AliCodeTimerAuto("",0);
489
490   if ( ! fCalibrationData )
491     CreateCalibrationData();
492
493   AliInfo("Calibration will occur.");
494
495   TString opt(GetOption());
496   opt.ToUpper();
497   
498   if ( strstr(opt,"NOSTATUSMAP") )
499   {
500     AliWarning("NOSTATUSMAP is obsolete");
501   }
502
503   TString calibMode = GetRecoParam()->GetCalibrationMode();
504
505   fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam(),calibMode.Data());
506 }
507
508 //_____________________________________________________________________________
509 void
510 AliMUONReconstructor::ResponseRemovingChambers(AliMUONVTriggerStore* triggerStore) const
511 {
512   /// Update trigger information with informatins obtained after
513   /// re-calculation of trigger response
514   AliCodeTimerAuto("",0);
515
516   if ( ! fCalibrationData )
517     CreateCalibrationData();
518
519   if ( ! fTriggerProcessor )
520     fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
521
522   fTriggerProcessor->ResponseRemovingChambers(*triggerStore);
523 }
524
525 //_____________________________________________________________________________
526 AliMUONVDigitStore*
527 AliMUONReconstructor::DigitStore() const
528 {
529   /// Return (and create if necessary) the digit container
530   if (!fDigitStore) 
531   {
532     TString sopt(GetOption());
533     sopt.ToUpper();
534     
535     AliInfo(Form("Options=%s",sopt.Data()));
536     
537     if ( sopt.Contains("DIGITSTOREV1") )
538     {
539       fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
540     }
541     else if ( sopt.Contains("DIGITSTOREV2R") ) 
542     {
543       fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
544     }
545     else if ( sopt.Contains("DIGITSTOREV2S") ) 
546     {
547       fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
548     }
549     
550     if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
551     
552     AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
553   }
554   return fDigitStore;
555 }
556
557 //_____________________________________________________________________________
558 void
559 AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
560                                 TTree& clustersTree) const
561 {
562   /// Write the trigger and cluster information into TreeR
563   
564   AliCodeTimerAuto("",0)
565
566   AliDebug(1,"");
567   
568   Bool_t ok(kFALSE);
569   Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
570   
571   if ( ! GetRecoParam()->CombineClusterTrackReco() )
572   {
573     alone = kFALSE; // we'll get both tracker and trigger information in TreeR
574   }
575   
576   if ( triggerStore ) 
577   {
578     ResponseRemovingChambers(triggerStore);
579     ok = triggerStore->Connect(clustersTree,alone);
580     if (!ok)
581     {
582       AliError("Could not create triggerStore branches in TreeR");
583     }
584   }
585
586   if ( !alone )
587   {
588     if (!fClusterStore)
589     {
590       fClusterStore = new AliMUONClusterStoreV2;
591     }
592     
593     CreateClusterServer();
594     
595     TIter next(DigitStore()->CreateIterator());
596     fClusterServer->UseDigits(next,DigitStore());
597
598     AliMpArea area;
599     
600     AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
601     
602     for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i ) 
603     {
604       if (GetRecoParam()->UseChamber(i))
605       {
606         if ( ( i == 6 || i == 7 )  && GetRecoParam()->BypassSt4() ) continue;
607         if ( ( i == 8 || i == 9 )  && GetRecoParam()->BypassSt5() ) continue;
608         
609         fClusterServer->Clusterize(i,*fClusterStore,area,GetRecoParam());
610       }
611     }
612     
613     Bool_t cok = fClusterStore->Connect(clustersTree,alone);
614     
615     if (!cok) AliError("Could not connect clusterStore to clusterTree");
616     
617     AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
618     
619     StdoutToAliDebug(1,fClusterStore->Print());
620   }
621          
622   if (ok) // at least one type of branches created successfully
623   {
624     clustersTree.Fill();
625   }
626   
627   if (fClusterStore) fClusterStore->Clear();
628 }
629
630 //_____________________________________________________________________________
631 Bool_t 
632 AliMUONReconstructor::HasDigitConversion() const
633 {
634   /// We *do* have digit conversion, but we might advertise it only 
635   /// if we want to save the digits.
636   
637   TString opt(GetOption());
638   opt.ToUpper();
639   if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
640   {
641     return kTRUE;
642   }
643   else
644   {
645     return kFALSE;
646   }
647 }
648
649 //_____________________________________________________________________________
650 void 
651 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
652 {
653   /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
654   /// HasDigitConversion()==kFALSE
655   
656   if ( !clustersTree ) 
657   {
658     AliError("clustersTree is 0x0 !");
659     return;
660   }
661   
662   ConvertDigits(rawReader,DigitStore(),TriggerStore());
663
664   FillTreeR(TriggerStore(),*clustersTree);
665 }
666
667 //_____________________________________________________________________________
668 void 
669 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
670 {
671   /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
672   /// AND HasDigitConversion()==kTRUE
673   
674   AliCodeTimerAuto("",0)
675   
676   AliDebug(1,"");
677   
678   if (!digitsTree || !clustersTree) 
679   {
680     AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
681                   digitsTree,clustersTree));
682     return;
683   }
684
685   if (!fDigitStore)
686   {
687     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
688     if (!fDigitStore)
689     {
690       AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
691     }
692     else
693     {
694       AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
695     }
696   }
697   if (!fTriggerStore)
698   {
699     fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
700     if (!fTriggerStore)
701     {
702       AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
703     }
704     else
705     {
706       AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
707     }
708   }
709   
710   if (!fTriggerStore && !fDigitStore)
711   {
712     AliError("No store at all. Nothing to do.");
713     return;
714   }
715   
716   // insure we start with empty stores
717   if ( fDigitStore ) 
718   {
719     fDigitStore->Clear(); 
720     Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
721     Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
722     if (!ok)
723     {
724       AliError("Could not connect digitStore to digitsTree");
725       return;
726     }
727   }
728   if ( fTriggerStore ) 
729   {
730     fTriggerStore->Clear();
731     Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
732     Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
733     if (!ok)
734     {
735       AliError("Could not connect triggerStore to digitsTree");
736       return;
737     }
738   }
739   
740   digitsTree->GetEvent(0);
741   
742   if ( fDigitStore ) 
743   {
744     // Insure we got calibrated digits (if we reconstruct from pure simulated,
745     // i.e. w/o going through raw data, this will be the case)
746     TIter next(fDigitStore->CreateIterator());
747     AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
748     if (digit && !digit->IsCalibrated())
749     {
750       Calibrate(*fDigitStore);
751     }
752   }
753     
754   FillTreeR(fTriggerStore,*clustersTree);
755 }
756
757 //_____________________________________________________________________________
758 AliMUONVTriggerStore*
759 AliMUONReconstructor::TriggerStore() const
760 {
761   /// Return (and create if necessary and allowed) the trigger container
762   TString sopt(GetOption());
763   sopt.ToUpper();
764   
765   if (sopt.Contains("TRIGGERDISABLE"))
766   {
767     delete fTriggerStore;
768     fTriggerStore = 0x0;
769   }
770   else
771   {
772     if (!fTriggerStore)
773     {
774       fTriggerStore = new AliMUONTriggerStoreV1;
775     }
776   }
777   return fTriggerStore;
778 }