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 through the
23 /// AliMUONRecoParam object set in the reconstruction macro or read from the CDB
24 /// (see methods in AliMUONRecoParam.h file for details)
28 /// SIMPLEFIT : use the AliMUONClusterFinderSimpleFit clusterizer
30 /// SIMPLEFITV3 : SIMPLEFIT with preclustering=PRECLUSTERV3
32 /// MLEM : use AliMUONClusterFinderMLEM and AliMUONPreClusterFinder for preclustering (default)
33 /// MLEMV2 : MLEM with preclustering=PRECLUSTERV2
34 /// MLEMV3 : MLEM with preclustering=PRECLUSTERV3
36 /// PRECLUSTER : use only AliMUONPreClusterFinder. Only for debug as
37 /// the produced clusters do not have a position, hence the tracking will not
39 /// PRECLUSTERV2 : another version of the preclustering
40 /// PRECLUSTERV3 : yet another version of the preclustering
42 /// COG : use AliMUONClusterFinderCOG clusterizer. Not really a production
43 /// option either, as center-of-gravity is generally not a good estimate
44 /// of the cluster position...
46 /// PEAKCOG : COG cluster finder around local maxima
47 /// PEAKFIT : fit around local maxima with up to 3 peaks, COG otherwise
49 /// NOCLUSTERING : bypass completely the clustering stage
53 /// The behavior of the MUON reconstruction can also be changed, besides
54 /// the usual methods found in AliReconstruction (e.g. to disable tracking)
55 /// by using AliReconstruction::SetOption("MUON",options)
56 /// where options should be a space separated string.
58 /// Valid options are :
60 /// SAVEDIGITS : if you want to save in the TreeD the *calibrated* digits
61 /// that are used for the clustering
63 /// DIGITSTOREV1 : use the V1 implementation of the digitstore
64 /// DIGITSTOREV2R : use the V2R implementation of the digitstore
66 /// NOLOCALRECONSTRUCTION : for debug, to disable local reconstruction (and hence
67 /// "recover" old behavior)
69 /// TRIGGERDISABLE : disable the treatment of MUON trigger
71 /// NOFASTTRKDECODER : makes the digit maker class use the non-high performance decoder
72 /// AliMUONPayloadTracker instead of AliMUONTrackerDDLDecoder.
74 /// NOFASTTRGDECODER : makes the digit maker class use the non-high performance decoder
75 /// AliMUONPayloadTrigger instead of AliMUONTriggerDDLDecoder.
77 /// NOFASTDECODERS : makes the digit maker class use the non-high performance decoders
78 /// AliMUONPayloadTracker and AliMUONPayloadTrigger.
80 /// \author Laurent Aphecetche, Subatech
81 //-----------------------------------------------------------------------------
83 #include "AliMUONReconstructor.h"
85 #include "AliMUONCalibrationData.h"
86 #include "AliMUONClusterFinderCOG.h"
87 #include "AliMUONClusterFinderMLEM.h"
88 #include "AliMUONClusterFinderSimpleFit.h"
89 #include "AliMUONClusterFinderPeakCOG.h"
90 #include "AliMUONClusterFinderPeakFit.h"
91 #include "AliMUONClusterStoreV1.h"
92 #include "AliMUONClusterStoreV2.h"
93 #include "AliMUONConstants.h"
94 #include "AliMUONDigitCalibrator.h"
95 #include "AliMUONDigitMaker.h"
96 #include "AliMUONDigitStoreV1.h"
97 #include "AliMUONDigitStoreV2R.h"
98 #include "AliMUONGeometryTransformer.h"
99 #include "AliMUONPreClusterFinder.h"
100 #include "AliMUONPreClusterFinderV2.h"
101 #include "AliMUONPreClusterFinderV3.h"
102 #include "AliMUONSimpleClusterServer.h"
103 #include "AliMUONTracker.h"
104 #include "AliMUONTriggerCircuit.h"
105 #include "AliMUONTriggerStoreV1.h"
106 #include "AliMUONVClusterFinder.h"
107 #include "AliMUONVClusterServer.h"
108 #include "AliMUONVTrackStore.h"
110 #include "AliMpArea.h"
111 #include "AliMpCDB.h"
112 #include "AliMpConstants.h"
114 #include "AliRawReader.h"
115 #include "AliCDBManager.h"
116 #include "AliCodeTimer.h"
119 #include <Riostream.h>
120 #include <TObjArray.h>
121 #include <TClonesArray.h>
126 ClassImp(AliMUONReconstructor)
129 //_____________________________________________________________________________
130 AliMUONReconstructor::AliMUONReconstructor() :
133 fTransformer(new AliMUONGeometryTransformer()),
135 fTriggerCircuit(0x0),
136 fCalibrationData(0x0),
137 fDigitCalibrator(0x0),
146 if ( ! AliMpCDB::LoadDDLStore() ) {
147 AliFatal("Could not access mapping from OCDB !");
150 // Load geometry data
151 fTransformer->LoadGeometryData();
155 //_____________________________________________________________________________
156 AliMUONReconstructor::~AliMUONReconstructor()
162 delete fTriggerCircuit;
163 delete fCalibrationData;
164 delete fDigitCalibrator;
165 delete fClusterServer;
166 delete fTriggerStore;
168 delete fClusterStore;
171 //_____________________________________________________________________________
173 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
175 /// Calibrate the digitStore
176 if (!fDigitCalibrator)
180 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
181 fDigitCalibrator->Calibrate(digitStore);
184 //_____________________________________________________________________________
186 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
187 AliMUONVDigitStore* digitStore,
188 AliMUONVTriggerStore* triggerStore) const
190 /// Convert raw data into digit and trigger stores
193 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
194 fDigitMaker->ClassName()))
195 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
196 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
197 fDigitMaker->ClassName()))
198 Calibrate(*digitStore);
201 //_____________________________________________________________________________
203 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
205 /// convert raw data into a digit tree
208 Bool_t alone = ( TriggerStore() == 0 );
210 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
211 if ( TriggerStore() )
213 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
218 AliError("Could not make branches on TreeD");
222 ConvertDigits(rawReader,DigitStore(),TriggerStore());
223 AliCodeTimerStart("Fill digits")
225 AliCodeTimerStop("Fill digits")
226 DigitStore()->Clear();
230 //_____________________________________________________________________________
232 AliMUONReconstructor::CreateDigitMaker() const
234 /// Create (and create if necessary) the digit maker
235 if (fDigitMaker) return;
239 TString option = GetOption();
240 Bool_t enableErrorLogging = kTRUE;
241 Bool_t useFastTrackerDecoder = kTRUE;
242 Bool_t useFastTriggerDecoder = kTRUE;
243 if (option.Contains("NOFASTTRKDECODER"))
245 useFastTrackerDecoder = kFALSE;
247 if (option.Contains("NOFASTTRGDECODER"))
249 useFastTriggerDecoder = kFALSE;
251 if (option.Contains("NOFASTDECODERS"))
253 useFastTrackerDecoder = kFALSE;
254 useFastTriggerDecoder = kFALSE;
256 fDigitMaker = new AliMUONDigitMaker(
257 enableErrorLogging, useFastTrackerDecoder, useFastTriggerDecoder
260 if ( option.Contains("SAVEDIGITS" ))
262 fDigitMaker->SetMakeTriggerDigits(kTRUE);
266 //_____________________________________________________________________________
268 AliMUONReconstructor::CreateTriggerCircuit() const
270 /// Return (and create if necessary) the trigger circuit object
271 if (fTriggerCircuit) return;
275 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
279 //_____________________________________________________________________________
281 AliMUONReconstructor::CreateTracker() const
283 /// Create the MUONTracker object
285 CreateTriggerCircuit();
287 CreateClusterServer();
289 AliMUONTracker* tracker(0x0);
291 if ( ! GetRecoParam()->CombineClusterTrackReco() )
293 tracker = new AliMUONTracker(GetRecoParam(),
302 tracker = new AliMUONTracker(GetRecoParam(),
314 //_____________________________________________________________________________
315 AliMUONVClusterFinder*
316 AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
318 /// Create a given cluster finder instance
320 AliCodeTimerAutoGeneral("")
322 AliMUONVClusterFinder* clusterFinder(0x0);
324 TString opt(clusterFinderType);
327 if ( strstr(opt,"PRECLUSTERV2") )
329 clusterFinder = new AliMUONPreClusterFinderV2;
331 else if ( strstr(opt,"PRECLUSTERV3") )
333 clusterFinder = new AliMUONPreClusterFinderV3;
335 else if ( strstr(opt,"PRECLUSTER") )
337 clusterFinder = new AliMUONPreClusterFinder;
339 else if ( strstr(opt,"PEAKCOG") )
341 clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
343 else if ( strstr(opt,"PEAKFIT") )
345 clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
347 else if ( strstr(opt,"COG") )
349 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
351 else if ( strstr(opt,"SIMPLEFITV3") )
353 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
355 else if ( strstr(opt,"SIMPLEFIT") )
357 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
359 else if ( strstr(opt,"MLEM:DRAW") )
361 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
363 else if ( strstr(opt,"MLEMV3") )
365 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
367 else if ( strstr(opt,"MLEMV2") )
369 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
371 else if ( strstr(opt,"MLEM") )
373 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
377 AliErrorClass(Form("clustering mode \"%s\" does not exist",opt.Data()));
381 return clusterFinder;
384 //_____________________________________________________________________________
386 AliMUONReconstructor::CreateClusterServer() const
388 /// Create cluster server
390 if ( fClusterServer ) return;
392 AliCodeTimerAuto("");
394 AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
396 if ( !clusterFinder ) return;
398 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
400 fClusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
403 //_____________________________________________________________________________
405 AliMUONReconstructor::CreateCalibrator() const
407 /// Create the calibrator
411 Int_t runNumber = AliCDBManager::Instance()->GetRun();
413 AliInfo("Calibration will occur.");
415 fCalibrationData = new AliMUONCalibrationData(runNumber);
416 if ( !fCalibrationData->IsValid() )
418 AliError("Could not retrieve calibrations !");
419 delete fCalibrationData;
420 fCalibrationData = 0x0;
424 // Check that we get all the calibrations we'll need
425 if ( !fCalibrationData->Pedestals() ||
426 !fCalibrationData->Gains() ||
427 !fCalibrationData->HV() )
429 AliFatal("Could not access all required calibration data");
432 TString opt(GetOption());
435 if ( strstr(opt,"NOSTATUSMAP") )
437 AliWarning("NOSTATUSMAP is obsolete");
440 TString calibMode = GetRecoParam()->GetCalibrationMode();
442 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam(),calibMode.Data());
445 //_____________________________________________________________________________
447 AliMUONReconstructor::DigitStore() const
449 /// Return (and create if necessary) the digit container
452 TString sopt(GetOption());
455 AliInfo(Form("Options=%s",sopt.Data()));
457 if ( sopt.Contains("DIGITSTOREV1") )
459 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
461 else if ( sopt.Contains("DIGITSTOREV2R") )
463 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
465 else if ( sopt.Contains("DIGITSTOREV2S") )
467 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
470 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
472 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
477 //_____________________________________________________________________________
479 AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
480 TTree& clustersTree) const
482 /// Write the trigger and cluster information into TreeR
489 Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
491 if ( ! GetRecoParam()->CombineClusterTrackReco() )
493 alone = kFALSE; // we'll get both tracker and trigger information in TreeR
498 ok = triggerStore->Connect(clustersTree,alone);
501 AliError("Could not create triggerStore branches in TreeR");
509 fClusterStore = new AliMUONClusterStoreV2;
512 CreateClusterServer();
514 TIter next(DigitStore()->CreateIterator());
515 fClusterServer->UseDigits(next);
519 AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
521 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
523 if (GetRecoParam()->UseChamber(i))
525 if ( ( i == 6 || i == 7 ) && GetRecoParam()->BypassSt4() ) continue;
526 if ( ( i == 8 || i == 9 ) && GetRecoParam()->BypassSt5() ) continue;
528 fClusterServer->Clusterize(i,*fClusterStore,area,GetRecoParam());
532 Bool_t cok = fClusterStore->Connect(clustersTree,alone);
534 if (!cok) AliError("Could not connect clusterStore to clusterTree");
536 AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
538 StdoutToAliDebug(1,fClusterStore->Print());
541 if (ok) // at least one type of branches created successfully
546 if (fClusterStore) fClusterStore->Clear();
549 //_____________________________________________________________________________
551 AliMUONReconstructor::HasDigitConversion() const
553 /// We *do* have digit conversion, but we might advertise it only
554 /// if we want to save the digits.
556 TString opt(GetOption());
558 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
568 //_____________________________________________________________________________
570 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
572 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
573 /// HasDigitConversion()==kFALSE
577 AliError("clustersTree is 0x0 !");
581 ConvertDigits(rawReader,DigitStore(),TriggerStore());
583 FillTreeR(TriggerStore(),*clustersTree);
586 //_____________________________________________________________________________
588 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
590 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
591 /// AND HasDigitConversion()==kTRUE
597 if (!digitsTree || !clustersTree)
599 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
600 digitsTree,clustersTree));
606 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
609 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
613 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
618 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
621 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
625 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
629 if (!fTriggerStore && !fDigitStore)
631 AliError("No store at all. Nothing to do.");
635 // insure we start with empty stores
638 fDigitStore->Clear();
639 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
640 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
643 AliError("Could not connect digitStore to digitsTree");
649 fTriggerStore->Clear();
650 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
651 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
654 AliError("Could not connect triggerStore to digitsTree");
659 digitsTree->GetEvent(0);
663 // Insure we got calibrated digits (if we reconstruct from pure simulated,
664 // i.e. w/o going through raw data, this will be the case)
665 TIter next(fDigitStore->CreateIterator());
666 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
667 if (digit && !digit->IsCalibrated())
669 Calibrate(*fDigitStore);
673 FillTreeR(fTriggerStore,*clustersTree);
676 //_____________________________________________________________________________
677 AliMUONVTriggerStore*
678 AliMUONReconstructor::TriggerStore() const
680 /// Return (and create if necessary and allowed) the trigger container
681 TString sopt(GetOption());
684 if (sopt.Contains("TRIGGERDISABLE"))
686 delete fTriggerStore;
693 fTriggerStore = new AliMUONTriggerStoreV1;
696 return fTriggerStore;