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