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 clustering mode and the associated parameters can be changed by using
23 /// AliMUONRecoParam *muonRecoParam = AliMUONRecoParam::GetLow(High)FluxParam();
24 /// muonRecoParam->Set...(); // see methods in AliMUONRecoParam.h for details
25 /// AliRecoParam::Instance()->RegisterRecoParam(muonRecoParam);
29 /// SIMPLEFIT : use the AliMUONClusterFinderSimpleFit clusterizer
31 /// SIMPLEFITV3 : SIMPLEFIT with preclustering=PRECLUSTERV3
33 /// MLEM : use AliMUONClusterFinderMLEM and AliMUONPreClusterFinder for preclustering (default)
34 /// MLEMV2 : MLEM with preclustering=PRECLUSTERV2
35 /// MLEMV3 : MLEM with preclustering=PRECLUSTERV3
37 /// PRECLUSTER : use only AliMUONPreClusterFinder. Only for debug as
38 /// the produced clusters do not have a position, hence the tracking will not
40 /// PRECLUSTERV2 : another version of the preclustering
41 /// PRECLUSTERV3 : yet another version of the preclustering
43 /// COG : use AliMUONClusterFinderCOG clusterizer. Not really a production
44 /// option either, as center-of-gravity is generally not a good estimate
45 /// of the cluster position...
47 /// PEAKCOG : COG cluster finder around local maxima
48 /// PEAKFIT : fit around local maxima with up to 3 peaks, COG otherwise
50 /// NOCLUSTERING : bypass completely the clustering stage
54 /// The behavior of the MUON reconstruction can also be changed, besides
55 /// the usual methods found in AliReconstruction (e.g. to disable tracking)
56 /// by using AliReconstruction::SetOption("MUON",options)
57 /// where options should be a space separated string.
59 /// Valid options are :
61 /// SAVEDIGITS : if you want to save in the TreeD the *calibrated* digits
62 /// that are used for the clustering
64 /// DIGITSTOREV1 : use the V1 implementation of the digitstore
65 /// DIGITSTOREV2R : use the V2R implementation of the digitstore
67 /// NOLOCALRECONSTRUCTION : for debug, to disable local reconstruction (and hence
68 /// "recover" old behavior)
70 /// TRIGGERDISABLE : disable the treatment of MUON trigger
72 /// USEFASTDECODER : makes the digit maker class use the high performance decoder
73 /// AliMUONTrackerDDLDecoder instead of AliMUONPayloadTracker.
75 /// \author Laurent Aphecetche, Subatech
76 //-----------------------------------------------------------------------------
78 #include "AliMUONReconstructor.h"
80 #include "AliMUONCalibrationData.h"
81 #include "AliMUONClusterFinderCOG.h"
82 #include "AliMUONClusterFinderMLEM.h"
83 #include "AliMUONClusterFinderSimpleFit.h"
84 #include "AliMUONClusterFinderPeakCOG.h"
85 #include "AliMUONClusterFinderPeakFit.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 "AliMUONPreClusterFinder.h"
93 #include "AliMUONPreClusterFinderV2.h"
94 #include "AliMUONPreClusterFinderV3.h"
95 #include "AliMUONRecoParam.h"
96 #include "AliMUONSimpleClusterServer.h"
97 #include "AliMUONTracker.h"
98 #include "AliMUONTriggerCircuit.h"
99 #include "AliMUONTriggerCrateStore.h"
100 #include "AliMUONTriggerStoreV1.h"
101 #include "AliMUONVClusterFinder.h"
102 #include "AliMUONVClusterServer.h"
103 #include "AliMUONVTrackStore.h"
105 #include "AliMpArea.h"
106 #include "AliMpCDB.h"
107 #include "AliMpConstants.h"
109 #include "AliRecoParam.h"
110 #include "AliRawReader.h"
111 #include "AliCDBManager.h"
112 #include "AliCodeTimer.h"
115 #include <Riostream.h>
116 #include <TObjArray.h>
117 #include <TClonesArray.h>
122 ClassImp(AliMUONReconstructor)
125 AliMUONRecoParam* AliMUONReconstructor::fgRecoParam = 0x0; // reconstruction parameters
127 //_____________________________________________________________________________
128 AliMUONReconstructor::AliMUONReconstructor() :
132 fTransformer(new AliMUONGeometryTransformer()),
134 fTriggerCircuit(0x0),
135 fCalibrationData(0x0),
136 fDigitCalibrator(0x0),
144 if ( ! AliMpCDB::LoadDDLStore() ) {
145 AliFatal("Could not access mapping from OCDB !");
148 // Load geometry data
149 fTransformer->LoadGeometryData();
153 //_____________________________________________________________________________
154 AliMUONReconstructor::~AliMUONReconstructor()
160 delete fCrateManager;
161 delete fTriggerCircuit;
162 delete fCalibrationData;
163 delete fDigitCalibrator;
164 delete fClusterServer;
165 delete fTriggerStore;
169 //_____________________________________________________________________________
170 const AliMUONRecoParam* AliMUONReconstructor::GetRecoParam()
172 /// get reconstruction parameters
176 // get reconstruction parameters from AliRecoParam if any
177 TObjArray *recoParams = AliRecoParam::Instance()->GetRecoParam("MUON");
181 fgRecoParam = (AliMUONRecoParam*) recoParams->Last();
185 // initialize reconstruction parameters if not already done
186 cout<<"W-AliMUONReconstructor::GetRecoParam: Reconstruction parameters not initialized - Use default one"<<endl;
187 fgRecoParam = AliMUONRecoParam::GetLowFluxParam();
188 AliRecoParam::Instance()->RegisterRecoParam(fgRecoParam);
197 //_____________________________________________________________________________
199 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
201 /// Calibrate the digitStore
202 if (!fDigitCalibrator)
206 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
207 fDigitCalibrator->Calibrate(digitStore);
210 //_____________________________________________________________________________
212 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
213 AliMUONVDigitStore* digitStore,
214 AliMUONVTriggerStore* triggerStore) const
216 /// Convert raw data into digit and trigger stores
219 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
220 fDigitMaker->ClassName()))
221 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
222 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
223 fDigitMaker->ClassName()))
224 Calibrate(*digitStore);
227 //_____________________________________________________________________________
229 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
231 /// convert raw data into a digit tree
234 Bool_t alone = ( TriggerStore() == 0 );
236 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
237 if ( TriggerStore() )
239 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
244 AliError("Could not make branches on TreeD");
248 ConvertDigits(rawReader,DigitStore(),TriggerStore());
249 AliCodeTimerStart("Fill digits")
251 AliCodeTimerStop("Fill digits")
252 DigitStore()->Clear();
256 //_____________________________________________________________________________
257 AliMUONTriggerCrateStore*
258 AliMUONReconstructor::CrateManager() const
260 /// Return (and create if necessary) the trigger crate store
261 if (fCrateManager) return fCrateManager;
262 fCrateManager = new AliMUONTriggerCrateStore;
263 fCrateManager->ReadFromFile();
264 return fCrateManager;
267 //_____________________________________________________________________________
269 AliMUONReconstructor::CreateDigitMaker() const
271 /// Create (and create if necessary) the digit maker
272 if (fDigitMaker) return;
276 TString option = GetOption();
277 Bool_t enableErrorLogging = kTRUE;
278 Bool_t useFastDecoder = kFALSE;
279 if (option.Contains("USEFASTDECODER"))
281 useFastDecoder = kTRUE;
283 fDigitMaker = new AliMUONDigitMaker(enableErrorLogging, useFastDecoder);
285 if ( option.Contains("SAVEDIGITS" ))
287 fDigitMaker->SetMakeTriggerDigits(kTRUE);
291 //_____________________________________________________________________________
293 AliMUONReconstructor::CreateTriggerCircuit() const
295 /// Return (and create if necessary) the trigger circuit object
296 if (fTriggerCircuit) return;
300 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
304 //_____________________________________________________________________________
306 AliMUONReconstructor::CreateTracker() const
308 /// Create the MUONTracker object
310 CreateTriggerCircuit();
312 CreateClusterServer();
316 AliError("ClusterServer is NULL ! Cannot create tracker");
320 AliMUONTracker* tracker = new AliMUONTracker(*fClusterServer,
329 //_____________________________________________________________________________
330 AliMUONVClusterFinder*
331 AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType) const
333 /// Create a given cluster finder instance
337 AliMUONVClusterFinder* clusterFinder(0x0);
339 TString opt(clusterFinderType);
342 if ( strstr(opt,"PRECLUSTERV2") )
344 clusterFinder = new AliMUONPreClusterFinderV2;
346 else if ( strstr(opt,"PRECLUSTERV3") )
348 clusterFinder = new AliMUONPreClusterFinderV3;
350 else if ( strstr(opt,"PRECLUSTER") )
352 clusterFinder = new AliMUONPreClusterFinder;
354 else if ( strstr(opt,"PEAKCOG") )
356 clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
358 else if ( strstr(opt,"PEAKFIT") )
360 clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
362 else if ( strstr(opt,"COG") )
364 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
366 else if ( strstr(opt,"SIMPLEFITV3") )
368 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
370 else if ( strstr(opt,"SIMPLEFIT") )
372 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
374 else if ( strstr(opt,"MLEM:DRAW") )
376 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
378 else if ( strstr(opt,"MLEMV3") )
380 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
382 else if ( strstr(opt,"MLEMV2") )
384 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
386 else if ( strstr(opt,"MLEM") )
388 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
392 AliError(Form("clustering mode \"%s\" does not exist",opt.Data()));
396 return clusterFinder;
399 //_____________________________________________________________________________
401 AliMUONReconstructor::CreateClusterServer() const
403 /// Create cluster server
405 if ( fClusterServer ) return;
411 AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
413 if ( !clusterFinder ) return;
415 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
417 fClusterServer = new AliMUONSimpleClusterServer(*clusterFinder,*fTransformer);
420 //_____________________________________________________________________________
422 AliMUONReconstructor::CreateCalibrator() const
424 /// Create the calibrator
428 Int_t runNumber = AliCDBManager::Instance()->GetRun();
430 AliInfo("Calibration will occur.");
432 fCalibrationData = new AliMUONCalibrationData(runNumber);
433 if ( !fCalibrationData->IsValid() )
435 AliError("Could not retrieve calibrations !");
436 delete fCalibrationData;
437 fCalibrationData = 0x0;
441 // Check that we get all the calibrations we'll need
442 if ( !fCalibrationData->Pedestals() ||
443 !fCalibrationData->Gains() ||
444 !fCalibrationData->HV() )
446 AliFatal("Could not access all required calibration data");
449 TString opt(GetOption());
452 if ( strstr(opt,"NOSTATUSMAP") )
454 AliWarning("NOSTATUSMAP is obsolete");
457 TString calibMode = GetRecoParam()->GetCalibrationMode();
459 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,calibMode.Data());
462 //_____________________________________________________________________________
464 AliMUONReconstructor::DigitStore() const
466 /// Return (and create if necessary) the digit container
469 TString sopt(GetOption());
472 AliInfo(Form("Options=%s",sopt.Data()));
474 if ( sopt.Contains("DIGITSTOREV1") )
476 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
478 else if ( sopt.Contains("DIGITSTOREV2R") )
480 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
482 else if ( sopt.Contains("DIGITSTOREV2S") )
484 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
487 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
489 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
494 //_____________________________________________________________________________
496 AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
497 TTree& clustersTree) const
499 /// Write the trigger and cluster information into TreeR
508 ok = triggerStore->Connect(clustersTree,kTRUE);
511 AliError("Could not create triggerStore branches in TreeR");
515 if (ok) // at least one type of branches created successfully
521 //_____________________________________________________________________________
523 AliMUONReconstructor::HasDigitConversion() const
525 /// We *do* have digit conversion, but we might advertise it only
526 /// if we want to save the digits.
528 TString opt(GetOption());
530 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
540 //_____________________________________________________________________________
542 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
544 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
545 /// HasDigitConversion()==kFALSE
549 AliError("clustersTree is 0x0 !");
553 ConvertDigits(rawReader,DigitStore(),TriggerStore());
555 FillTreeR(TriggerStore(),*clustersTree);
558 //_____________________________________________________________________________
560 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
562 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
563 /// AND HasDigitConversion()==kTRUE
569 if (!digitsTree || !clustersTree)
571 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
572 digitsTree,clustersTree));
578 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
581 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
585 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
590 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
593 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
597 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
601 if (!fTriggerStore && !fDigitStore)
603 AliError("No store at all. Nothing to do.");
607 // insure we start with empty stores
610 fDigitStore->Clear();
611 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
612 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
615 AliError("Could not connect digitStore to digitsTree");
621 fTriggerStore->Clear();
622 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
623 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
626 AliError("Could not connect triggerStore to digitsTree");
631 digitsTree->GetEvent(0);
635 // Insure we got calibrated digits (if we reconstruct from pure simulated,
636 // i.e. w/o going through raw data, this will be the case)
637 TIter next(fDigitStore->CreateIterator());
638 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
639 if (digit && !digit->IsCalibrated())
641 Calibrate(*fDigitStore);
645 FillTreeR(fTriggerStore,*clustersTree);
648 //_____________________________________________________________________________
649 AliMUONVTriggerStore*
650 AliMUONReconstructor::TriggerStore() const
652 /// Return (and create if necessary and allowed) the trigger container
653 TString sopt(GetOption());
656 if (sopt.Contains("TRIGGERDISABLE"))
658 delete fTriggerStore;
665 fTriggerStore = new AliMUONTriggerStoreV1;
668 return fTriggerStore;