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