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
183 // get reconstruction parameters from AliRecoParam if any
184 TObjArray *recoParams = AliRecoParam::Instance()->GetRecoParam("MUON");
188 fgRecoParam = (AliMUONRecoParam*) recoParams->Last();
192 // initialize reconstruction parameters if not already done
193 cout<<"W-AliMUONReconstructor::GetRecoParam: Reconstruction parameters not initialized - Use default one"<<endl;
194 fgRecoParam = AliMUONRecoParam::GetLowFluxParam();
195 AliRecoParam::Instance()->RegisterRecoParam(fgRecoParam);
204 //_____________________________________________________________________________
206 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
208 /// Calibrate the digitStore
209 if (!fDigitCalibrator)
213 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
214 fDigitCalibrator->Calibrate(digitStore);
217 //_____________________________________________________________________________
219 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
220 AliMUONVDigitStore* digitStore,
221 AliMUONVTriggerStore* triggerStore) const
223 /// Convert raw data into digit and trigger stores
226 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
227 fDigitMaker->ClassName()))
228 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
229 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
230 fDigitMaker->ClassName()))
231 Calibrate(*digitStore);
234 //_____________________________________________________________________________
236 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
238 /// convert raw data into a digit tree
241 Bool_t alone = ( TriggerStore() == 0 );
243 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
244 if ( TriggerStore() )
246 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
251 AliError("Could not make branches on TreeD");
255 ConvertDigits(rawReader,DigitStore(),TriggerStore());
256 AliCodeTimerStart("Fill digits")
258 AliCodeTimerStop("Fill digits")
259 DigitStore()->Clear();
263 //_____________________________________________________________________________
265 AliMUONReconstructor::CreateDigitMaker() const
267 /// Create (and create if necessary) the digit maker
268 if (fDigitMaker) return;
272 TString option = GetOption();
273 Bool_t enableErrorLogging = kTRUE;
274 Bool_t useFastTrackerDecoder = kTRUE;
275 Bool_t useFastTriggerDecoder = kTRUE;
276 if (option.Contains("NOFASTTRKDECODER"))
278 useFastTrackerDecoder = kFALSE;
280 if (option.Contains("NOFASTTRGDECODER"))
282 useFastTriggerDecoder = kFALSE;
284 if (option.Contains("NOFASTDECODERS"))
286 useFastTrackerDecoder = kFALSE;
287 useFastTriggerDecoder = kFALSE;
289 fDigitMaker = new AliMUONDigitMaker(
290 enableErrorLogging, useFastTrackerDecoder, useFastTriggerDecoder
293 if ( option.Contains("SAVEDIGITS" ))
295 fDigitMaker->SetMakeTriggerDigits(kTRUE);
299 //_____________________________________________________________________________
301 AliMUONReconstructor::CreateTriggerCircuit() const
303 /// Return (and create if necessary) the trigger circuit object
304 if (fTriggerCircuit) return;
308 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
312 //_____________________________________________________________________________
314 AliMUONReconstructor::CreateTracker() const
316 /// Create the MUONTracker object
318 CreateTriggerCircuit();
320 CreateClusterServer();
322 AliMUONTracker* tracker(0x0);
324 if ( ! AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco() )
326 tracker = new AliMUONTracker(0x0,
334 tracker = new AliMUONTracker(fClusterServer,
345 //_____________________________________________________________________________
346 AliMUONVClusterFinder*
347 AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
349 /// Create a given cluster finder instance
351 AliCodeTimerAutoGeneral("")
353 AliMUONVClusterFinder* clusterFinder(0x0);
355 TString opt(clusterFinderType);
358 if ( strstr(opt,"PRECLUSTERV2") )
360 clusterFinder = new AliMUONPreClusterFinderV2;
362 else if ( strstr(opt,"PRECLUSTERV3") )
364 clusterFinder = new AliMUONPreClusterFinderV3;
366 else if ( strstr(opt,"PRECLUSTER") )
368 clusterFinder = new AliMUONPreClusterFinder;
370 else if ( strstr(opt,"PEAKCOG") )
372 clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
374 else if ( strstr(opt,"PEAKFIT") )
376 clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
378 else if ( strstr(opt,"COG") )
380 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
382 else if ( strstr(opt,"SIMPLEFITV3") )
384 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
386 else if ( strstr(opt,"SIMPLEFIT") )
388 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
390 else if ( strstr(opt,"MLEM:DRAW") )
392 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
394 else if ( strstr(opt,"MLEMV3") )
396 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
398 else if ( strstr(opt,"MLEMV2") )
400 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
402 else if ( strstr(opt,"MLEM") )
404 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
408 AliErrorClass(Form("clustering mode \"%s\" does not exist",opt.Data()));
412 return clusterFinder;
415 //_____________________________________________________________________________
417 AliMUONReconstructor::CreateClusterServer() const
419 /// Create cluster server
421 if ( fClusterServer ) return;
423 AliCodeTimerAuto("");
425 AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
427 if ( !clusterFinder ) return;
429 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
431 fClusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
434 //_____________________________________________________________________________
436 AliMUONReconstructor::CreateCalibrator() const
438 /// Create the calibrator
442 Int_t runNumber = AliCDBManager::Instance()->GetRun();
444 AliInfo("Calibration will occur.");
446 fCalibrationData = new AliMUONCalibrationData(runNumber);
447 if ( !fCalibrationData->IsValid() )
449 AliError("Could not retrieve calibrations !");
450 delete fCalibrationData;
451 fCalibrationData = 0x0;
455 // Check that we get all the calibrations we'll need
456 if ( !fCalibrationData->Pedestals() ||
457 !fCalibrationData->Gains() ||
458 !fCalibrationData->HV() )
460 AliFatal("Could not access all required calibration data");
463 TString opt(GetOption());
466 if ( strstr(opt,"NOSTATUSMAP") )
468 AliWarning("NOSTATUSMAP is obsolete");
471 TString calibMode = GetRecoParam()->GetCalibrationMode();
473 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,calibMode.Data());
476 //_____________________________________________________________________________
478 AliMUONReconstructor::DigitStore() const
480 /// Return (and create if necessary) the digit container
483 TString sopt(GetOption());
486 AliInfo(Form("Options=%s",sopt.Data()));
488 if ( sopt.Contains("DIGITSTOREV1") )
490 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
492 else if ( sopt.Contains("DIGITSTOREV2R") )
494 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
496 else if ( sopt.Contains("DIGITSTOREV2S") )
498 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
501 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
503 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
508 //_____________________________________________________________________________
510 AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
511 TTree& clustersTree) const
513 /// Write the trigger and cluster information into TreeR
520 Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
522 if ( ! AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco() )
524 alone = kFALSE; // we'll get both tracker and trigger information in TreeR
529 ok = triggerStore->Connect(clustersTree,alone);
532 AliError("Could not create triggerStore branches in TreeR");
540 fClusterStore = new AliMUONClusterStoreV2;
543 CreateClusterServer();
545 TIter next(DigitStore()->CreateIterator());
546 fClusterServer->UseDigits(next);
550 AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
552 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
554 if (AliMUONReconstructor::GetRecoParam()->UseChamber(i))
556 if ( i >= 6 && AliMUONReconstructor::GetRecoParam()->BypassSt45() ) continue;
558 fClusterServer->Clusterize(i,*fClusterStore,area);
562 Bool_t cok = fClusterStore->Connect(clustersTree,alone);
564 if (!cok) AliError("Could not connect clusterStore to clusterTree");
566 AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
568 StdoutToAliDebug(1,fClusterStore->Print());
571 if (ok) // at least one type of branches created successfully
576 if (fClusterStore) fClusterStore->Clear();
579 //_____________________________________________________________________________
581 AliMUONReconstructor::HasDigitConversion() const
583 /// We *do* have digit conversion, but we might advertise it only
584 /// if we want to save the digits.
586 TString opt(GetOption());
588 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
598 //_____________________________________________________________________________
600 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
602 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
603 /// HasDigitConversion()==kFALSE
607 AliError("clustersTree is 0x0 !");
611 ConvertDigits(rawReader,DigitStore(),TriggerStore());
613 FillTreeR(TriggerStore(),*clustersTree);
616 //_____________________________________________________________________________
618 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
620 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
621 /// AND HasDigitConversion()==kTRUE
627 if (!digitsTree || !clustersTree)
629 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
630 digitsTree,clustersTree));
636 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
639 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
643 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
648 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
651 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
655 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
659 if (!fTriggerStore && !fDigitStore)
661 AliError("No store at all. Nothing to do.");
665 // insure we start with empty stores
668 fDigitStore->Clear();
669 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
670 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
673 AliError("Could not connect digitStore to digitsTree");
679 fTriggerStore->Clear();
680 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
681 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
684 AliError("Could not connect triggerStore to digitsTree");
689 digitsTree->GetEvent(0);
693 // Insure we got calibrated digits (if we reconstruct from pure simulated,
694 // i.e. w/o going through raw data, this will be the case)
695 TIter next(fDigitStore->CreateIterator());
696 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
697 if (digit && !digit->IsCalibrated())
699 Calibrate(*fDigitStore);
703 FillTreeR(fTriggerStore,*clustersTree);
706 //_____________________________________________________________________________
707 AliMUONVTriggerStore*
708 AliMUONReconstructor::TriggerStore() const
710 /// Return (and create if necessary and allowed) the trigger container
711 TString sopt(GetOption());
714 if (sopt.Contains("TRIGGERDISABLE"))
716 delete fTriggerStore;
723 fTriggerStore = new AliMUONTriggerStoreV1;
726 return fTriggerStore;