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 "AliMUONSimpleClusterServer.h"
104 #include "AliMUONTracker.h"
105 #include "AliMUONTriggerCircuit.h"
106 #include "AliMUONTriggerStoreV1.h"
107 #include "AliMUONVClusterFinder.h"
108 #include "AliMUONVClusterServer.h"
109 #include "AliMUONVTrackStore.h"
111 #include "AliMpArea.h"
112 #include "AliMpCDB.h"
113 #include "AliMpConstants.h"
115 #include "AliRawReader.h"
116 #include "AliCDBManager.h"
117 #include "AliCodeTimer.h"
120 #include <Riostream.h>
121 #include <TObjArray.h>
122 #include <TClonesArray.h>
127 ClassImp(AliMUONReconstructor)
130 //_____________________________________________________________________________
131 AliMUONReconstructor::AliMUONReconstructor() :
134 fTransformer(new AliMUONGeometryTransformer()),
136 fTriggerCircuit(0x0),
137 fCalibrationData(0x0),
138 fDigitCalibrator(0x0),
147 if ( ! AliMpCDB::LoadDDLStore() ) {
148 AliFatal("Could not access mapping from OCDB !");
151 // Load geometry data
152 fTransformer->LoadGeometryData();
156 //_____________________________________________________________________________
157 AliMUONReconstructor::~AliMUONReconstructor()
163 delete fTriggerCircuit;
164 delete fCalibrationData;
165 delete fDigitCalibrator;
166 delete fClusterServer;
167 delete fTriggerStore;
169 delete fClusterStore;
172 //_____________________________________________________________________________
174 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
176 /// Calibrate the digitStore
177 if (!fDigitCalibrator)
181 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
182 fDigitCalibrator->Calibrate(digitStore);
185 //_____________________________________________________________________________
187 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
188 AliMUONVDigitStore* digitStore,
189 AliMUONVTriggerStore* triggerStore) const
191 /// Convert raw data into digit and trigger stores
194 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
195 fDigitMaker->ClassName()))
196 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
197 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
198 fDigitMaker->ClassName()))
199 Calibrate(*digitStore);
202 //_____________________________________________________________________________
204 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
206 /// convert raw data into a digit tree
209 Bool_t alone = ( TriggerStore() == 0 );
211 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
212 if ( TriggerStore() )
214 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
219 AliError("Could not make branches on TreeD");
223 ConvertDigits(rawReader,DigitStore(),TriggerStore());
224 AliCodeTimerStart("Fill digits")
226 AliCodeTimerStop("Fill digits")
227 DigitStore()->Clear();
231 //_____________________________________________________________________________
233 AliMUONReconstructor::CreateDigitMaker() const
235 /// Create (and create if necessary) the digit maker
236 if (fDigitMaker) return;
240 TString option = GetOption();
241 Bool_t enableErrorLogging = kTRUE;
242 Bool_t useFastTrackerDecoder = kTRUE;
243 Bool_t useFastTriggerDecoder = kTRUE;
244 if (option.Contains("NOFASTTRKDECODER"))
246 useFastTrackerDecoder = kFALSE;
248 if (option.Contains("NOFASTTRGDECODER"))
250 useFastTriggerDecoder = kFALSE;
252 if (option.Contains("NOFASTDECODERS"))
254 useFastTrackerDecoder = kFALSE;
255 useFastTriggerDecoder = kFALSE;
257 fDigitMaker = new AliMUONDigitMaker(
258 enableErrorLogging, useFastTrackerDecoder, useFastTriggerDecoder
261 if ( option.Contains("SAVEDIGITS" ))
263 fDigitMaker->SetMakeTriggerDigits(kTRUE);
267 //_____________________________________________________________________________
269 AliMUONReconstructor::CreateTriggerCircuit() const
271 /// Return (and create if necessary) the trigger circuit object
272 if (fTriggerCircuit) return;
276 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
280 //_____________________________________________________________________________
282 AliMUONReconstructor::CreateTracker() const
284 /// Create the MUONTracker object
286 CreateTriggerCircuit();
288 CreateClusterServer();
290 AliMUONTracker* tracker(0x0);
292 if ( ! GetRecoParam()->CombineClusterTrackReco() )
294 tracker = new AliMUONTracker(GetRecoParam(),
303 tracker = new AliMUONTracker(GetRecoParam(),
315 //_____________________________________________________________________________
316 AliMUONVClusterFinder*
317 AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
319 /// Create a given cluster finder instance
321 AliCodeTimerAutoGeneral("")
323 AliMUONVClusterFinder* clusterFinder(0x0);
325 TString opt(clusterFinderType);
328 if ( strstr(opt,"PRECLUSTERV2") )
330 clusterFinder = new AliMUONPreClusterFinderV2;
332 else if ( strstr(opt,"PRECLUSTERV3") )
334 clusterFinder = new AliMUONPreClusterFinderV3;
336 else if ( strstr(opt,"PRECLUSTER") )
338 clusterFinder = new AliMUONPreClusterFinder;
340 else if ( strstr(opt,"PEAKCOG") )
342 clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
344 else if ( strstr(opt,"PEAKFIT") )
346 clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
348 else if ( strstr(opt,"COG") )
350 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
352 else if ( strstr(opt,"SIMPLEFITV3") )
354 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
356 else if ( strstr(opt,"SIMPLEFIT") )
358 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
360 else if ( strstr(opt,"MLEM:DRAW") )
362 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
364 else if ( strstr(opt,"MLEMV3") )
366 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
368 else if ( strstr(opt,"MLEMV2") )
370 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
372 else if ( strstr(opt,"MLEM") )
374 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
378 AliErrorClass(Form("clustering mode \"%s\" does not exist",opt.Data()));
382 return clusterFinder;
385 //_____________________________________________________________________________
387 AliMUONReconstructor::CreateClusterServer() const
389 /// Create cluster server
391 if ( fClusterServer ) return;
393 AliCodeTimerAuto("");
395 AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
397 if ( !clusterFinder ) return;
399 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
401 fClusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
404 //_____________________________________________________________________________
406 AliMUONReconstructor::CreateCalibrator() const
408 /// Create the calibrator
412 Int_t runNumber = AliCDBManager::Instance()->GetRun();
414 AliInfo("Calibration will occur.");
416 fCalibrationData = new AliMUONCalibrationData(runNumber);
417 if ( !fCalibrationData->IsValid() )
419 AliError("Could not retrieve calibrations !");
420 delete fCalibrationData;
421 fCalibrationData = 0x0;
425 // Check that we get all the calibrations we'll need
426 if ( !fCalibrationData->Pedestals() ||
427 !fCalibrationData->Gains() ||
428 !fCalibrationData->HV() )
430 AliFatal("Could not access all required calibration data");
433 TString opt(GetOption());
436 if ( strstr(opt,"NOSTATUSMAP") )
438 AliWarning("NOSTATUSMAP is obsolete");
441 TString calibMode = GetRecoParam()->GetCalibrationMode();
443 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam(),calibMode.Data());
446 //_____________________________________________________________________________
448 AliMUONReconstructor::DigitStore() const
450 /// Return (and create if necessary) the digit container
453 TString sopt(GetOption());
456 AliInfo(Form("Options=%s",sopt.Data()));
458 if ( sopt.Contains("DIGITSTOREV1") )
460 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
462 else if ( sopt.Contains("DIGITSTOREV2R") )
464 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
466 else if ( sopt.Contains("DIGITSTOREV2S") )
468 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
471 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
473 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
478 //_____________________________________________________________________________
480 AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
481 TTree& clustersTree) const
483 /// Write the trigger and cluster information into TreeR
490 Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
492 if ( ! GetRecoParam()->CombineClusterTrackReco() )
494 alone = kFALSE; // we'll get both tracker and trigger information in TreeR
499 ok = triggerStore->Connect(clustersTree,alone);
502 AliError("Could not create triggerStore branches in TreeR");
510 fClusterStore = new AliMUONClusterStoreV2;
513 CreateClusterServer();
515 TIter next(DigitStore()->CreateIterator());
516 fClusterServer->UseDigits(next);
520 AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
522 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
524 if (GetRecoParam()->UseChamber(i))
526 if ( ( i == 6 || i == 7 ) && GetRecoParam()->BypassSt4() ) continue;
527 if ( ( i == 8 || i == 9 ) && GetRecoParam()->BypassSt5() ) continue;
529 fClusterServer->Clusterize(i,*fClusterStore,area);
533 Bool_t cok = fClusterStore->Connect(clustersTree,alone);
535 if (!cok) AliError("Could not connect clusterStore to clusterTree");
537 AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
539 StdoutToAliDebug(1,fClusterStore->Print());
542 if (ok) // at least one type of branches created successfully
547 if (fClusterStore) fClusterStore->Clear();
550 //_____________________________________________________________________________
552 AliMUONReconstructor::HasDigitConversion() const
554 /// We *do* have digit conversion, but we might advertise it only
555 /// if we want to save the digits.
557 TString opt(GetOption());
559 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
569 //_____________________________________________________________________________
571 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
573 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
574 /// HasDigitConversion()==kFALSE
578 AliError("clustersTree is 0x0 !");
582 ConvertDigits(rawReader,DigitStore(),TriggerStore());
584 FillTreeR(TriggerStore(),*clustersTree);
587 //_____________________________________________________________________________
589 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
591 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
592 /// AND HasDigitConversion()==kTRUE
598 if (!digitsTree || !clustersTree)
600 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
601 digitsTree,clustersTree));
607 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
610 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
614 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
619 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
622 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
626 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
630 if (!fTriggerStore && !fDigitStore)
632 AliError("No store at all. Nothing to do.");
636 // insure we start with empty stores
639 fDigitStore->Clear();
640 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
641 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
644 AliError("Could not connect digitStore to digitsTree");
650 fTriggerStore->Clear();
651 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
652 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
655 AliError("Could not connect triggerStore to digitsTree");
660 digitsTree->GetEvent(0);
664 // Insure we got calibrated digits (if we reconstruct from pure simulated,
665 // i.e. w/o going through raw data, this will be the case)
666 TIter next(fDigitStore->CreateIterator());
667 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
668 if (digit && !digit->IsCalibrated())
670 Calibrate(*fDigitStore);
674 FillTreeR(fTriggerStore,*clustersTree);
677 //_____________________________________________________________________________
678 AliMUONVTriggerStore*
679 AliMUONReconstructor::TriggerStore() const
681 /// Return (and create if necessary and allowed) the trigger container
682 TString sopt(GetOption());
685 if (sopt.Contains("TRIGGERDISABLE"))
687 delete fTriggerStore;
694 fTriggerStore = new AliMUONTriggerStoreV1;
697 return fTriggerStore;