1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 //-----------------------------------------------------------------------------
18 /// \class AliMUONReconstructor
20 /// Implementation of AliReconstructor for MUON subsystem.
22 /// The behavior of the MUON reconstruction can be changed, besides
23 /// the usual methods found in AliReconstruction (e.g. to disable tracking)
24 /// by using AliReconstruction::SetOption("MUON",options)
25 /// where options should be a space separated string.
27 /// Valid options are :
29 /// SAVEDIGITS : if you want to save in the TreeD the *calibrated* digits
30 /// that are used for the clustering
32 /// SIMPLEFIT : use the AliMUONClusterFinderSimpleFit clusterizer
34 /// MLEM : another implementation of AZ, where preclustering is external (default)
35 /// MLEMV3 : MLEM with preclustering=PRECLUSTERV2
36 /// MLEMV3 : MLEM with preclustering=PRECLUSTERV3
38 /// PRECLUSTER : use only AliMUONPreClusterFinder. Only for debug as
39 /// the produced clusters do not have a position, hence the tracking will not
41 /// PRECLUSTERV2 : another version of the preclustering
42 /// PRECLUSTERV3 : yet another version of the preclustering
44 /// COG : use AliMUONClusterFinderCOG clusterizer. Not really a production
45 /// option either, as center-of-gravity is generally not a good estimate
46 /// of the cluster position...
48 /// NOCLUSTERING : bypass completely the clustering stage
50 /// NOSTATUSMAP : disable the computation and usage of the pad status map. Only
53 /// NOLOCALRECONSTRUCTION : for debug, to disable local reconstruction (and hence
54 /// "recover" old behavior)
56 /// TRIGGERDISABLE : disable the treatment of MUON trigger
58 /// DIGITSTOREV1 : use the V1 implementation of the digitstore
59 /// DIGITSTOREV2R : use the V2R implementation of the digitstore
61 /// \author Laurent Aphecetche, Subatech
62 //-----------------------------------------------------------------------------
64 #include "AliMUONReconstructor.h"
66 #include "AliCDBManager.h"
68 #include "AliMUONCalibrationData.h"
69 #include "AliMUONClusterFinderCOG.h"
70 #include "AliMUONClusterFinderMLEM.h"
71 #include "AliMUONClusterFinderSimpleFit.h"
72 #include "AliMUONClusterReconstructor.h"
73 #include "AliMUONClusterStoreV2.h"
74 #include "AliMUONConstants.h"
75 #include "AliMUONDigitCalibrator.h"
76 #include "AliMUONDigitMaker.h"
77 #include "AliMUONDigitStoreV1.h"
78 #include "AliMUONDigitStoreV2R.h"
79 #include "AliMUONGeometryTransformer.h"
80 #include "AliMUONPreClusterFinder.h"
81 #include "AliMUONPreClusterFinderV2.h"
82 #include "AliMUONPreClusterFinderV3.h"
83 #include "AliMUONTracker.h"
84 #include "AliMUONVTrackStore.h"
85 #include "AliMUONTriggerChamberEff.h"
86 #include "AliMUONTriggerCircuit.h"
87 #include "AliMUONTriggerCrateStore.h"
88 #include "AliMUONTriggerStoreV1.h"
89 #include "AliMUONVClusterFinder.h"
91 #include "AliRawReader.h"
92 #include "AliCodeTimer.h"
93 #include <Riostream.h>
94 #include <TClonesArray.h>
99 ClassImp(AliMUONReconstructor)
102 //_____________________________________________________________________________
103 AliMUONReconstructor::AliMUONReconstructor() :
107 fTransformer(new AliMUONGeometryTransformer()),
109 fTriggerCircuit(0x0),
110 fCalibrationData(0x0),
111 fDigitCalibrator(0x0),
112 fClusterReconstructor(0x0),
121 if ( ! AliMpCDB::LoadDDLStore() ) {
122 AliFatal("Could not access mapping from OCDB !");
125 // Load geometry data
126 fTransformer->LoadGeometryData();
131 //_____________________________________________________________________________
132 AliMUONReconstructor::~AliMUONReconstructor()
138 delete fCrateManager;
139 delete fTriggerCircuit;
140 delete fCalibrationData;
141 delete fDigitCalibrator;
142 delete fClusterReconstructor;
143 delete fClusterStore;
144 delete fTriggerStore;
146 delete fTrigChamberEff;
149 //_____________________________________________________________________________
151 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
153 /// Calibrate the digitStore
154 if (!fDigitCalibrator)
158 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
159 fDigitCalibrator->Calibrate(digitStore);
162 //_____________________________________________________________________________
164 AliMUONReconstructor::Clusterize(const AliMUONVDigitStore& digitStore,
165 AliMUONVClusterStore& clusterStore) const
167 /// Creates clusters from digits.
169 TString sopt(GetOption());
171 if ( sopt.Contains("NOCLUSTERING") ) return;
173 if (!fClusterReconstructor)
175 CreateClusterReconstructor();
178 AliCodeTimerAuto(Form("%s::Digits2Clusters(const AliMUONVDigitStore&,AliMUONVClusterStore&)",
179 fClusterReconstructor->ClassName()))
180 fClusterReconstructor->Digits2Clusters(digitStore,clusterStore);
183 //_____________________________________________________________________________
184 AliMUONVClusterStore*
185 AliMUONReconstructor::ClusterStore() const
187 /// Return (and create if necessary) the cluster container
190 fClusterStore = new AliMUONClusterStoreV2;
192 return fClusterStore;
195 //_____________________________________________________________________________
197 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
198 AliMUONVDigitStore* digitStore,
199 AliMUONVTriggerStore* triggerStore) const
201 /// Convert raw data into digit and trigger stores
204 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
205 fDigitMaker->ClassName()))
206 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
207 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
208 fDigitMaker->ClassName()))
209 Calibrate(*digitStore);
212 //_____________________________________________________________________________
214 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
216 /// convert raw data into a digit tree
219 Bool_t alone = ( TriggerStore() == 0 );
221 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
222 if ( TriggerStore() )
224 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
229 AliError("Could not make branches on TreeD");
233 ConvertDigits(rawReader,DigitStore(),TriggerStore());
234 AliCodeTimerStart("Fill digits")
236 AliCodeTimerStop("Fill digits")
237 DigitStore()->Clear();
241 //_____________________________________________________________________________
242 AliMUONTriggerCrateStore*
243 AliMUONReconstructor::CrateManager() const
245 /// Return (and create if necessary) the trigger crate store
246 if (fCrateManager) return fCrateManager;
247 fCrateManager = new AliMUONTriggerCrateStore;
248 fCrateManager->ReadFromFile();
249 return fCrateManager;
252 //_____________________________________________________________________________
254 AliMUONReconstructor::CreateDigitMaker() const
256 /// Create (and create if necessary) the digit maker
257 if (fDigitMaker) return;
261 fDigitMaker = new AliMUONDigitMaker;
264 //_____________________________________________________________________________
266 AliMUONReconstructor::CreateTriggerCircuit() const
268 /// Return (and create if necessary) the trigger circuit object
269 if (fTriggerCircuit) return;
273 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
277 //_____________________________________________________________________________
279 AliMUONReconstructor::CreateTriggerChamberEff() const
281 /// Create (and create if necessary) the trigger chamber efficiency class
282 if (fTrigChamberEff) return;
286 fTrigChamberEff = new AliMUONTriggerChamberEff(fTransformer,fDigitMaker,kTRUE);
287 //fTrigChamberEff->SetDebugLevel(1);
290 //_____________________________________________________________________________
292 AliMUONReconstructor::CreateTracker() const
294 /// Create the MUONTracker object
295 /// The MUONTracker is passed the GetOption(), i.e. our own options
297 CreateTriggerCircuit();
299 CreateTriggerChamberEff();
301 AliMUONTracker* tracker = new AliMUONTracker(fDigitMaker,fTransformer,fTriggerCircuit,fTrigChamberEff);
302 tracker->SetOption(GetOption());
307 //_____________________________________________________________________________
309 AliMUONReconstructor::CreateClusterReconstructor() const
311 /// Create cluster reconstructor, depending on GetOption()
317 AliMUONVClusterFinder* clusterFinder(0x0);
319 TString opt(GetOption());
322 if ( strstr(opt,"PRECLUSTERV2") )
324 clusterFinder = new AliMUONPreClusterFinderV2;
326 else if ( strstr(opt,"PRECLUSTERV3") )
328 clusterFinder = new AliMUONPreClusterFinderV3;
330 else if ( strstr(opt,"PRECLUSTER") )
332 clusterFinder = new AliMUONPreClusterFinder;
334 else if ( strstr(opt,"COG") )
336 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
338 else if ( strstr(opt,"SIMPLEFITV3") )
340 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
342 else if ( strstr(opt,"SIMPLEFIT") )
344 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
346 else if ( strstr(opt,"MLEM:DRAW") )
348 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
350 else if ( strstr(opt,"MLEMV3") )
352 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
354 else if ( strstr(opt,"MLEMV2") )
356 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
358 else if ( strstr(opt,"MLEM") )
360 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
364 // default is currently MLEM
365 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
370 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
373 fClusterReconstructor = new AliMUONClusterReconstructor(clusterFinder,fTransformer);
376 //_____________________________________________________________________________
378 AliMUONReconstructor::CreateCalibrator() const
380 /// Create the calibrator
384 Int_t runNumber = AliCDBManager::Instance()->GetRun();
386 AliInfo("Calibration will occur.");
388 fCalibrationData = new AliMUONCalibrationData(runNumber);
389 if ( !fCalibrationData->IsValid() )
391 AliError("Could not retrieve calibrations !");
392 delete fCalibrationData;
393 fCalibrationData = 0x0;
397 // Check that we get all the calibrations we'll need
398 if ( !fCalibrationData->Pedestals() ||
399 !fCalibrationData->Gains() ||
400 !fCalibrationData->HV() )
402 AliFatal("Could not access all required calibration data");
405 TString opt(GetOption());
407 Bool_t statusMap(kTRUE);
409 if ( strstr(opt,"NOSTATUSMAP") )
411 AliWarning("Disconnecting status map : SHOULD BE USED FOR DEBUG ONLY. NOT FOR PRODUCTION !!!");
414 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,statusMap);
417 //_____________________________________________________________________________
419 AliMUONReconstructor::DigitStore() const
421 /// Return (and create if necessary) the digit container
424 TString sopt(GetOption());
427 AliInfo(Form("Options=%s",sopt.Data()));
429 if ( sopt.Contains("DIGITSTOREV1") )
431 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
433 else if ( sopt.Contains("DIGITSTOREV2R") )
435 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
437 else if ( sopt.Contains("DIGITSTOREV2S") )
439 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
442 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
444 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
449 //_____________________________________________________________________________
451 AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
452 AliMUONVClusterStore* clusterStore,
453 TTree& clustersTree) const
455 /// Write the trigger and cluster information into TreeR
464 Bool_t alone = ( clusterStore ? kFALSE : kTRUE );
465 ok = triggerStore->Connect(clustersTree,alone);
468 AliError("Could not create triggerStore branches in TreeR");
474 Bool_t alone = ( triggerStore ? kFALSE : kTRUE );
475 ok = clusterStore->Connect(clustersTree,alone);
478 AliError("Could not create triggerStore branches in TreeR");
482 if (ok) // at least one type of branches created successfully
488 //_____________________________________________________________________________
490 AliMUONReconstructor::HasDigitConversion() const
492 /// We *do* have digit conversion, but we might advertise it only
493 /// if we want to save the digits.
495 TString opt(GetOption());
497 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
507 //_____________________________________________________________________________
509 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
511 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
512 /// HasDigitConversion()==kFALSE
516 AliError("clustersTree is 0x0 !");
520 ConvertDigits(rawReader,DigitStore(),TriggerStore());
521 Clusterize(*(DigitStore()),*(ClusterStore()));
523 FillTreeR(TriggerStore(),ClusterStore(),*clustersTree);
526 //_____________________________________________________________________________
528 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
530 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
531 /// AND HasDigitConversion()==kTRUE
537 if (!digitsTree || !clustersTree)
539 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
540 digitsTree,clustersTree));
546 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
549 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
553 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
558 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
561 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
565 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
569 if (!fTriggerStore && !fDigitStore)
571 AliError("No store at all. Nothing to do.");
575 // insure we start with empty stores
578 fDigitStore->Clear();
579 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
580 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
583 AliError("Could not connect digitStore to digitsTree");
589 fTriggerStore->Clear();
590 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
591 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
594 AliError("Could not connect triggerStore to digitsTree");
599 digitsTree->GetEvent(0);
603 // Insure we got calibrated digits (if we reconstruct from pure simulated,
604 // i.e. w/o going through raw data, this will be the case)
605 TIter next(fDigitStore->CreateIterator());
606 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
607 if (!digit->IsCalibrated())
609 Calibrate(*fDigitStore);
611 Clusterize(*fDigitStore,*(ClusterStore()));
614 FillTreeR(fTriggerStore,ClusterStore(),*clustersTree);
617 //_____________________________________________________________________________
618 AliMUONVTriggerStore*
619 AliMUONReconstructor::TriggerStore() const
621 /// Return (and create if necessary and allowed) the trigger container
622 TString sopt(GetOption());
625 if (sopt.Contains("TRIGGERDISABLE"))
627 delete fTriggerStore;
634 fTriggerStore = new AliMUONTriggerStoreV1;
637 return fTriggerStore;