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 /// NOFASTTRKDECODER : makes the digit maker class use the non-high performance decoder
73 /// AliMUONPayloadTracker instead of AliMUONTrackerDDLDecoder.
75 /// NOFASTTRGDECODER : makes the digit maker class use the non-high performance decoder
76 /// AliMUONPayloadTrigger instead of AliMUONTriggerDDLDecoder.
78 /// NOFASTDECODERS : makes the digit maker class use the non-high performance decoders
79 /// AliMUONPayloadTracker and AliMUONPayloadTrigger.
81 /// \author Laurent Aphecetche, Subatech
82 //-----------------------------------------------------------------------------
84 #include "AliMUONReconstructor.h"
86 #include "AliMUONCalibrationData.h"
87 #include "AliMUONClusterFinderCOG.h"
88 #include "AliMUONClusterFinderMLEM.h"
89 #include "AliMUONClusterFinderSimpleFit.h"
90 #include "AliMUONClusterFinderPeakCOG.h"
91 #include "AliMUONClusterFinderPeakFit.h"
92 #include "AliMUONClusterStoreV1.h"
93 #include "AliMUONClusterStoreV2.h"
94 #include "AliMUONConstants.h"
95 #include "AliMUONDigitCalibrator.h"
96 #include "AliMUONDigitMaker.h"
97 #include "AliMUONDigitStoreV1.h"
98 #include "AliMUONDigitStoreV2R.h"
99 #include "AliMUONGeometryTransformer.h"
100 #include "AliMUONPreClusterFinder.h"
101 #include "AliMUONPreClusterFinderV2.h"
102 #include "AliMUONPreClusterFinderV3.h"
103 #include "AliMUONRecoParam.h"
104 #include "AliMUONSimpleClusterServer.h"
105 #include "AliMUONTracker.h"
106 #include "AliMUONTriggerCircuit.h"
107 #include "AliMUONTriggerStoreV1.h"
108 #include "AliMUONVClusterFinder.h"
109 #include "AliMUONVClusterServer.h"
110 #include "AliMUONVTrackStore.h"
112 #include "AliMpArea.h"
113 #include "AliMpCDB.h"
114 #include "AliMpConstants.h"
116 #include "AliRecoParam.h"
117 #include "AliRawReader.h"
118 #include "AliCDBManager.h"
119 #include "AliCodeTimer.h"
122 #include <Riostream.h>
123 #include <TObjArray.h>
124 #include <TClonesArray.h>
129 ClassImp(AliMUONReconstructor)
132 AliMUONRecoParam* AliMUONReconstructor::fgRecoParam = 0x0; // reconstruction parameters
134 //_____________________________________________________________________________
135 AliMUONReconstructor::AliMUONReconstructor() :
138 fTransformer(new AliMUONGeometryTransformer()),
140 fTriggerCircuit(0x0),
141 fCalibrationData(0x0),
142 fDigitCalibrator(0x0),
151 if ( ! AliMpCDB::LoadDDLStore() ) {
152 AliFatal("Could not access mapping from OCDB !");
155 // Load geometry data
156 fTransformer->LoadGeometryData();
160 //_____________________________________________________________________________
161 AliMUONReconstructor::~AliMUONReconstructor()
167 delete fTriggerCircuit;
168 delete fCalibrationData;
169 delete fDigitCalibrator;
170 delete fClusterServer;
171 delete fTriggerStore;
173 delete fClusterStore;
176 //_____________________________________________________________________________
177 const AliMUONRecoParam* AliMUONReconstructor::GetRecoParam()
179 /// get reconstruction parameters
181 // initialize reconstruction parameters if not already done
183 cout<<"W-AliMUONReconstructor::GetRecoParam: Reconstruction parameters not initialized - Use default one"<<endl;
184 fgRecoParam = AliMUONRecoParam::GetLowFluxParam();
190 //_____________________________________________________________________________
192 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
194 /// Calibrate the digitStore
195 if (!fDigitCalibrator)
199 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
200 fDigitCalibrator->Calibrate(digitStore);
203 //_____________________________________________________________________________
205 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
206 AliMUONVDigitStore* digitStore,
207 AliMUONVTriggerStore* triggerStore) const
209 /// Convert raw data into digit and trigger stores
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);
220 //_____________________________________________________________________________
222 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
224 /// convert raw data into a digit tree
227 Bool_t alone = ( TriggerStore() == 0 );
229 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
230 if ( TriggerStore() )
232 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
237 AliError("Could not make branches on TreeD");
241 ConvertDigits(rawReader,DigitStore(),TriggerStore());
242 AliCodeTimerStart("Fill digits")
244 AliCodeTimerStop("Fill digits")
245 DigitStore()->Clear();
249 //_____________________________________________________________________________
251 AliMUONReconstructor::CreateDigitMaker() const
253 /// Create (and create if necessary) the digit maker
254 if (fDigitMaker) return;
258 TString option = GetOption();
259 Bool_t enableErrorLogging = kTRUE;
260 Bool_t useFastTrackerDecoder = kTRUE;
261 Bool_t useFastTriggerDecoder = kTRUE;
262 if (option.Contains("NOFASTTRKDECODER"))
264 useFastTrackerDecoder = kFALSE;
266 if (option.Contains("NOFASTTRGDECODER"))
268 useFastTriggerDecoder = kFALSE;
270 if (option.Contains("NOFASTDECODERS"))
272 useFastTrackerDecoder = kFALSE;
273 useFastTriggerDecoder = kFALSE;
275 fDigitMaker = new AliMUONDigitMaker(
276 enableErrorLogging, useFastTrackerDecoder, useFastTriggerDecoder
279 if ( option.Contains("SAVEDIGITS" ))
281 fDigitMaker->SetMakeTriggerDigits(kTRUE);
285 //_____________________________________________________________________________
287 AliMUONReconstructor::CreateTriggerCircuit() const
289 /// Return (and create if necessary) the trigger circuit object
290 if (fTriggerCircuit) return;
294 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
298 //_____________________________________________________________________________
300 AliMUONReconstructor::CreateTracker() const
302 /// Create the MUONTracker object
304 CreateTriggerCircuit();
306 CreateClusterServer();
308 AliMUONTracker* tracker(0x0);
310 if ( ! AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco() )
312 tracker = new AliMUONTracker(0x0,
320 tracker = new AliMUONTracker(fClusterServer,
331 //_____________________________________________________________________________
332 AliMUONVClusterFinder*
333 AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
335 /// Create a given cluster finder instance
337 AliCodeTimerAutoGeneral("")
339 AliMUONVClusterFinder* clusterFinder(0x0);
341 TString opt(clusterFinderType);
344 if ( strstr(opt,"PRECLUSTERV2") )
346 clusterFinder = new AliMUONPreClusterFinderV2;
348 else if ( strstr(opt,"PRECLUSTERV3") )
350 clusterFinder = new AliMUONPreClusterFinderV3;
352 else if ( strstr(opt,"PRECLUSTER") )
354 clusterFinder = new AliMUONPreClusterFinder;
356 else if ( strstr(opt,"PEAKCOG") )
358 clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
360 else if ( strstr(opt,"PEAKFIT") )
362 clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
364 else if ( strstr(opt,"COG") )
366 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
368 else if ( strstr(opt,"SIMPLEFITV3") )
370 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
372 else if ( strstr(opt,"SIMPLEFIT") )
374 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
376 else if ( strstr(opt,"MLEM:DRAW") )
378 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
380 else if ( strstr(opt,"MLEMV3") )
382 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
384 else if ( strstr(opt,"MLEMV2") )
386 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
388 else if ( strstr(opt,"MLEM") )
390 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
394 AliErrorClass(Form("clustering mode \"%s\" does not exist",opt.Data()));
398 return clusterFinder;
401 //_____________________________________________________________________________
403 AliMUONReconstructor::CreateClusterServer() const
405 /// Create cluster server
407 if ( fClusterServer ) return;
409 AliCodeTimerAuto("");
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
506 Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
508 if ( ! AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco() )
510 alone = kFALSE; // we'll get both tracker and trigger information in TreeR
515 ok = triggerStore->Connect(clustersTree,alone);
518 AliError("Could not create triggerStore branches in TreeR");
526 fClusterStore = new AliMUONClusterStoreV2;
529 CreateClusterServer();
531 TIter next(DigitStore()->CreateIterator());
532 fClusterServer->UseDigits(next);
536 AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
538 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
540 if (AliMUONReconstructor::GetRecoParam()->UseChamber(i))
542 if ( i >= 6 && AliMUONReconstructor::GetRecoParam()->BypassSt45() ) continue;
544 fClusterServer->Clusterize(i,*fClusterStore,area);
548 Bool_t cok = fClusterStore->Connect(clustersTree,alone);
550 if (!cok) AliError("Could not connect clusterStore to clusterTree");
552 AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
554 StdoutToAliDebug(1,fClusterStore->Print());
557 if (ok) // at least one type of branches created successfully
562 if (fClusterStore) fClusterStore->Clear();
565 //_____________________________________________________________________________
567 AliMUONReconstructor::HasDigitConversion() const
569 /// We *do* have digit conversion, but we might advertise it only
570 /// if we want to save the digits.
572 TString opt(GetOption());
574 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
584 //_____________________________________________________________________________
586 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
588 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
589 /// HasDigitConversion()==kFALSE
593 AliError("clustersTree is 0x0 !");
597 ConvertDigits(rawReader,DigitStore(),TriggerStore());
599 FillTreeR(TriggerStore(),*clustersTree);
602 //_____________________________________________________________________________
604 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
606 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
607 /// AND HasDigitConversion()==kTRUE
613 if (!digitsTree || !clustersTree)
615 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
616 digitsTree,clustersTree));
622 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
625 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
629 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
634 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
637 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
641 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
645 if (!fTriggerStore && !fDigitStore)
647 AliError("No store at all. Nothing to do.");
651 // insure we start with empty stores
654 fDigitStore->Clear();
655 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
656 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
659 AliError("Could not connect digitStore to digitsTree");
665 fTriggerStore->Clear();
666 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
667 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
670 AliError("Could not connect triggerStore to digitsTree");
675 digitsTree->GetEvent(0);
679 // Insure we got calibrated digits (if we reconstruct from pure simulated,
680 // i.e. w/o going through raw data, this will be the case)
681 TIter next(fDigitStore->CreateIterator());
682 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
683 if (digit && !digit->IsCalibrated())
685 Calibrate(*fDigitStore);
689 FillTreeR(fTriggerStore,*clustersTree);
692 //_____________________________________________________________________________
693 AliMUONVTriggerStore*
694 AliMUONReconstructor::TriggerStore() const
696 /// Return (and create if necessary and allowed) the trigger container
697 TString sopt(GetOption());
700 if (sopt.Contains("TRIGGERDISABLE"))
702 delete fTriggerStore;
709 fTriggerStore = new AliMUONTriggerStoreV1;
712 return fTriggerStore;