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),
150 if ( ! AliMpCDB::LoadDDLStore() ) {
151 AliFatal("Could not access mapping from OCDB !");
154 // Load geometry data
155 fTransformer->LoadGeometryData();
159 //_____________________________________________________________________________
160 AliMUONReconstructor::~AliMUONReconstructor()
166 delete fTriggerCircuit;
167 delete fCalibrationData;
168 delete fDigitCalibrator;
169 delete fClusterServer;
170 delete fTriggerStore;
174 //_____________________________________________________________________________
175 const AliMUONRecoParam* AliMUONReconstructor::GetRecoParam()
177 /// get reconstruction parameters
181 // get reconstruction parameters from AliRecoParam if any
182 TObjArray *recoParams = AliRecoParam::Instance()->GetRecoParam("MUON");
186 fgRecoParam = (AliMUONRecoParam*) recoParams->Last();
190 // initialize reconstruction parameters if not already done
191 cout<<"W-AliMUONReconstructor::GetRecoParam: Reconstruction parameters not initialized - Use default one"<<endl;
192 fgRecoParam = AliMUONRecoParam::GetLowFluxParam();
193 AliRecoParam::Instance()->RegisterRecoParam(fgRecoParam);
202 //_____________________________________________________________________________
204 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
206 /// Calibrate the digitStore
207 if (!fDigitCalibrator)
211 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
212 fDigitCalibrator->Calibrate(digitStore);
215 //_____________________________________________________________________________
217 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
218 AliMUONVDigitStore* digitStore,
219 AliMUONVTriggerStore* triggerStore) const
221 /// Convert raw data into digit and trigger stores
224 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
225 fDigitMaker->ClassName()))
226 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
227 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
228 fDigitMaker->ClassName()))
229 Calibrate(*digitStore);
232 //_____________________________________________________________________________
234 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
236 /// convert raw data into a digit tree
239 Bool_t alone = ( TriggerStore() == 0 );
241 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
242 if ( TriggerStore() )
244 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
249 AliError("Could not make branches on TreeD");
253 ConvertDigits(rawReader,DigitStore(),TriggerStore());
254 AliCodeTimerStart("Fill digits")
256 AliCodeTimerStop("Fill digits")
257 DigitStore()->Clear();
261 //_____________________________________________________________________________
263 AliMUONReconstructor::CreateDigitMaker() const
265 /// Create (and create if necessary) the digit maker
266 if (fDigitMaker) return;
270 TString option = GetOption();
271 Bool_t enableErrorLogging = kTRUE;
272 Bool_t useFastTrackerDecoder = kTRUE;
273 Bool_t useFastTriggerDecoder = kTRUE;
274 if (option.Contains("NOFASTTRKDECODER"))
276 useFastTrackerDecoder = kFALSE;
278 if (option.Contains("NOFASTTRGDECODER"))
280 useFastTriggerDecoder = kFALSE;
282 if (option.Contains("NOFASTDECODERS"))
284 useFastTrackerDecoder = kFALSE;
285 useFastTriggerDecoder = kFALSE;
287 fDigitMaker = new AliMUONDigitMaker(
288 enableErrorLogging, useFastTrackerDecoder, useFastTriggerDecoder
291 if ( option.Contains("SAVEDIGITS" ))
293 fDigitMaker->SetMakeTriggerDigits(kTRUE);
297 //_____________________________________________________________________________
299 AliMUONReconstructor::CreateTriggerCircuit() const
301 /// Return (and create if necessary) the trigger circuit object
302 if (fTriggerCircuit) return;
306 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
310 //_____________________________________________________________________________
312 AliMUONReconstructor::CreateTracker() const
314 /// Create the MUONTracker object
316 CreateTriggerCircuit();
318 CreateClusterServer();
320 AliMUONTracker* tracker(0x0);
322 if ( ! AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco() )
324 tracker = new AliMUONTracker(0x0,
332 tracker = new AliMUONTracker(fClusterServer,
343 //_____________________________________________________________________________
344 AliMUONVClusterFinder*
345 AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
347 /// Create a given cluster finder instance
349 AliCodeTimerAutoGeneral("")
351 AliMUONVClusterFinder* clusterFinder(0x0);
353 TString opt(clusterFinderType);
356 if ( strstr(opt,"PRECLUSTERV2") )
358 clusterFinder = new AliMUONPreClusterFinderV2;
360 else if ( strstr(opt,"PRECLUSTERV3") )
362 clusterFinder = new AliMUONPreClusterFinderV3;
364 else if ( strstr(opt,"PRECLUSTER") )
366 clusterFinder = new AliMUONPreClusterFinder;
368 else if ( strstr(opt,"PEAKCOG") )
370 clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
372 else if ( strstr(opt,"PEAKFIT") )
374 clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
376 else if ( strstr(opt,"COG") )
378 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
380 else if ( strstr(opt,"SIMPLEFITV3") )
382 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
384 else if ( strstr(opt,"SIMPLEFIT") )
386 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
388 else if ( strstr(opt,"MLEM:DRAW") )
390 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
392 else if ( strstr(opt,"MLEMV3") )
394 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
396 else if ( strstr(opt,"MLEMV2") )
398 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
400 else if ( strstr(opt,"MLEM") )
402 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
406 AliErrorClass(Form("clustering mode \"%s\" does not exist",opt.Data()));
410 return clusterFinder;
413 //_____________________________________________________________________________
415 AliMUONReconstructor::CreateClusterServer() const
417 /// Create cluster server
419 if ( fClusterServer ) return;
421 AliCodeTimerAuto("");
423 AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
425 if ( !clusterFinder ) return;
427 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
429 fClusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
432 //_____________________________________________________________________________
434 AliMUONReconstructor::CreateCalibrator() const
436 /// Create the calibrator
440 Int_t runNumber = AliCDBManager::Instance()->GetRun();
442 AliInfo("Calibration will occur.");
444 fCalibrationData = new AliMUONCalibrationData(runNumber);
445 if ( !fCalibrationData->IsValid() )
447 AliError("Could not retrieve calibrations !");
448 delete fCalibrationData;
449 fCalibrationData = 0x0;
453 // Check that we get all the calibrations we'll need
454 if ( !fCalibrationData->Pedestals() ||
455 !fCalibrationData->Gains() ||
456 !fCalibrationData->HV() )
458 AliFatal("Could not access all required calibration data");
461 TString opt(GetOption());
464 if ( strstr(opt,"NOSTATUSMAP") )
466 AliWarning("NOSTATUSMAP is obsolete");
469 TString calibMode = GetRecoParam()->GetCalibrationMode();
471 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,calibMode.Data());
474 //_____________________________________________________________________________
476 AliMUONReconstructor::DigitStore() const
478 /// Return (and create if necessary) the digit container
481 TString sopt(GetOption());
484 AliInfo(Form("Options=%s",sopt.Data()));
486 if ( sopt.Contains("DIGITSTOREV1") )
488 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
490 else if ( sopt.Contains("DIGITSTOREV2R") )
492 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
494 else if ( sopt.Contains("DIGITSTOREV2S") )
496 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
499 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
501 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
506 //_____________________________________________________________________________
508 AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
509 TTree& clustersTree) const
511 /// Write the trigger and cluster information into TreeR
518 Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
520 if ( ! AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco() )
522 alone = kFALSE; // we'll get both tracker and trigger information in TreeR
527 ok = triggerStore->Connect(clustersTree,alone);
530 AliError("Could not create triggerStore branches in TreeR");
534 AliMUONVClusterStore* clusterStore(0x0);
538 clusterStore = new AliMUONClusterStoreV2;
540 CreateClusterServer();
542 TIter next(DigitStore()->CreateIterator());
543 fClusterServer->UseDigits(next);
547 AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
549 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
551 if (AliMUONReconstructor::GetRecoParam()->UseChamber(i))
553 if ( i >= 6 && AliMUONReconstructor::GetRecoParam()->BypassSt45() ) continue;
555 fClusterServer->Clusterize(i,*clusterStore,area);
559 Bool_t cok = clusterStore->Connect(clustersTree,alone);
561 if (!cok) AliError("Could not connect clusterStore to clusterTree");
563 AliDebug(1,Form("Number of clusters found = %d",clusterStore->GetSize()));
565 StdoutToAliDebug(1,clusterStore->Print());
568 if (ok) // at least one type of branches created successfully
576 //_____________________________________________________________________________
578 AliMUONReconstructor::HasDigitConversion() const
580 /// We *do* have digit conversion, but we might advertise it only
581 /// if we want to save the digits.
583 TString opt(GetOption());
585 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
595 //_____________________________________________________________________________
597 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
599 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
600 /// HasDigitConversion()==kFALSE
604 AliError("clustersTree is 0x0 !");
608 ConvertDigits(rawReader,DigitStore(),TriggerStore());
610 FillTreeR(TriggerStore(),*clustersTree);
613 //_____________________________________________________________________________
615 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
617 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
618 /// AND HasDigitConversion()==kTRUE
624 if (!digitsTree || !clustersTree)
626 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
627 digitsTree,clustersTree));
633 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
636 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
640 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
645 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
648 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
652 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
656 if (!fTriggerStore && !fDigitStore)
658 AliError("No store at all. Nothing to do.");
662 // insure we start with empty stores
665 fDigitStore->Clear();
666 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
667 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
670 AliError("Could not connect digitStore to digitsTree");
676 fTriggerStore->Clear();
677 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
678 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
681 AliError("Could not connect triggerStore to digitsTree");
686 digitsTree->GetEvent(0);
690 // Insure we got calibrated digits (if we reconstruct from pure simulated,
691 // i.e. w/o going through raw data, this will be the case)
692 TIter next(fDigitStore->CreateIterator());
693 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
694 if (digit && !digit->IsCalibrated())
696 Calibrate(*fDigitStore);
700 FillTreeR(fTriggerStore,*clustersTree);
703 //_____________________________________________________________________________
704 AliMUONVTriggerStore*
705 AliMUONReconstructor::TriggerStore() const
707 /// Return (and create if necessary and allowed) the trigger container
708 TString sopt(GetOption());
711 if (sopt.Contains("TRIGGERDISABLE"))
713 delete fTriggerStore;
720 fTriggerStore = new AliMUONTriggerStoreV1;
723 return fTriggerStore;