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 /// NOCLUSTERING : bypass completely the clustering stage
51 /// The behavior of the MUON reconstruction can also be changed, besides
52 /// the usual methods found in AliReconstruction (e.g. to disable tracking)
53 /// by using AliReconstruction::SetOption("MUON",options)
54 /// where options should be a space separated string.
56 /// Valid options are :
58 /// SAVEDIGITS : if you want to save in the TreeD the *calibrated* digits
59 /// that are used for the clustering
61 /// DIGITSTOREV1 : use the V1 implementation of the digitstore
62 /// DIGITSTOREV2R : use the V2R implementation of the digitstore
64 /// NOLOCALRECONSTRUCTION : for debug, to disable local reconstruction (and hence
65 /// "recover" old behavior)
67 /// TRIGGERDISABLE : disable the treatment of MUON trigger
69 /// USEFASTDECODER : makes the digit maker class use the high performance decoder
70 /// AliMUONTrackerDDLDecoder instead of AliMUONPayloadTracker.
72 /// \author Laurent Aphecetche, Subatech
73 //-----------------------------------------------------------------------------
75 #include "AliMUONReconstructor.h"
77 #include "AliMUONCalibrationData.h"
78 #include "AliMUONClusterFinderCOG.h"
79 #include "AliMUONClusterFinderMLEM.h"
80 #include "AliMUONClusterFinderSimpleFit.h"
81 #include "AliMUONConstants.h"
82 #include "AliMUONDigitCalibrator.h"
83 #include "AliMUONDigitMaker.h"
84 #include "AliMUONDigitStoreV1.h"
85 #include "AliMUONDigitStoreV2R.h"
86 #include "AliMUONGeometryTransformer.h"
87 #include "AliMUONPreClusterFinder.h"
88 #include "AliMUONPreClusterFinderV2.h"
89 #include "AliMUONPreClusterFinderV3.h"
90 #include "AliMUONRecoParam.h"
91 #include "AliMUONSimpleClusterServer.h"
92 #include "AliMUONTracker.h"
93 #include "AliMUONTriggerChamberEff.h"
94 #include "AliMUONTriggerCircuit.h"
95 #include "AliMUONTriggerCrateStore.h"
96 #include "AliMUONTriggerStoreV1.h"
97 #include "AliMUONVClusterFinder.h"
98 #include "AliMUONVClusterServer.h"
99 #include "AliMUONVTrackStore.h"
101 #include "AliMpArea.h"
102 #include "AliMpCDB.h"
103 #include "AliMpConstants.h"
105 #include "AliRecoParam.h"
106 #include "AliRawReader.h"
107 #include "AliCDBManager.h"
108 #include "AliCodeTimer.h"
111 #include <Riostream.h>
112 #include <TObjArray.h>
113 #include <TClonesArray.h>
118 ClassImp(AliMUONReconstructor)
121 AliMUONRecoParam* AliMUONReconstructor::fgRecoParam = 0x0; // reconstruction parameters
123 //_____________________________________________________________________________
124 AliMUONReconstructor::AliMUONReconstructor() :
128 fTransformer(new AliMUONGeometryTransformer()),
130 fTriggerCircuit(0x0),
131 fCalibrationData(0x0),
132 fDigitCalibrator(0x0),
141 if ( ! AliMpCDB::LoadDDLStore() ) {
142 AliFatal("Could not access mapping from OCDB !");
145 // Load geometry data
146 fTransformer->LoadGeometryData();
150 //_____________________________________________________________________________
151 AliMUONReconstructor::~AliMUONReconstructor()
157 delete fCrateManager;
158 delete fTriggerCircuit;
159 delete fCalibrationData;
160 delete fDigitCalibrator;
161 delete fClusterServer;
162 delete fTriggerStore;
164 delete fTrigChamberEff;
167 //_____________________________________________________________________________
168 const AliMUONRecoParam* AliMUONReconstructor::GetRecoParam()
170 /// get reconstruction parameters
174 // get reconstruction parameters from AliRecoParam if any
175 TObjArray *recoParams = AliRecoParam::Instance()->GetRecoParam("MUON");
179 fgRecoParam = (AliMUONRecoParam*) recoParams->Last();
183 // initialize reconstruction parameters if not already done
184 cout<<"W-AliMUONReconstructor::GetRecoParam: Reconstruction parameters not initialized - Use default one"<<endl;
185 fgRecoParam = AliMUONRecoParam::GetLowFluxParam();
186 AliRecoParam::Instance()->RegisterRecoParam(fgRecoParam);
195 //_____________________________________________________________________________
197 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
199 /// Calibrate the digitStore
200 if (!fDigitCalibrator)
204 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
205 fDigitCalibrator->Calibrate(digitStore);
208 //_____________________________________________________________________________
210 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
211 AliMUONVDigitStore* digitStore,
212 AliMUONVTriggerStore* triggerStore) const
214 /// Convert raw data into digit and trigger stores
217 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
218 fDigitMaker->ClassName()))
219 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
220 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
221 fDigitMaker->ClassName()))
222 Calibrate(*digitStore);
225 //_____________________________________________________________________________
227 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
229 /// convert raw data into a digit tree
232 Bool_t alone = ( TriggerStore() == 0 );
234 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
235 if ( TriggerStore() )
237 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
242 AliError("Could not make branches on TreeD");
246 ConvertDigits(rawReader,DigitStore(),TriggerStore());
247 AliCodeTimerStart("Fill digits")
249 AliCodeTimerStop("Fill digits")
250 DigitStore()->Clear();
254 //_____________________________________________________________________________
255 AliMUONTriggerCrateStore*
256 AliMUONReconstructor::CrateManager() const
258 /// Return (and create if necessary) the trigger crate store
259 if (fCrateManager) return fCrateManager;
260 fCrateManager = new AliMUONTriggerCrateStore;
261 fCrateManager->ReadFromFile();
262 return fCrateManager;
265 //_____________________________________________________________________________
267 AliMUONReconstructor::CreateDigitMaker() const
269 /// Create (and create if necessary) the digit maker
270 if (fDigitMaker) return;
274 TString option = GetOption();
275 Bool_t enableErrorLogging = kTRUE;
276 Bool_t useFastDecoder = kFALSE;
277 if (option.Contains("USEFASTDECODER"))
279 useFastDecoder = kTRUE;
281 fDigitMaker = new AliMUONDigitMaker(enableErrorLogging, useFastDecoder);
284 //_____________________________________________________________________________
286 AliMUONReconstructor::CreateTriggerCircuit() const
288 /// Return (and create if necessary) the trigger circuit object
289 if (fTriggerCircuit) return;
293 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
297 //_____________________________________________________________________________
299 AliMUONReconstructor::CreateTriggerChamberEff() const
301 /// Create (and create if necessary) the trigger chamber efficiency class
302 if (fTrigChamberEff) return;
306 fTrigChamberEff = new AliMUONTriggerChamberEff(fTransformer,fDigitMaker,kTRUE);
307 //fTrigChamberEff->SetDebugLevel(1);
310 //_____________________________________________________________________________
312 AliMUONReconstructor::CreateTracker() const
314 /// Create the MUONTracker object
316 CreateTriggerCircuit();
318 CreateTriggerChamberEff();
319 CreateClusterServer();
323 AliError("ClusterServer is NULL ! Cannot create tracker");
327 fClusterServer->UseDigitStore(*(DigitStore()));
329 AliMUONTracker* tracker = new AliMUONTracker(*fClusterServer,
338 //_____________________________________________________________________________
339 AliMUONVClusterFinder*
340 AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType) const
342 /// Create a given cluster finder instance
346 AliMUONVClusterFinder* clusterFinder(0x0);
348 TString opt(clusterFinderType);
351 if ( strstr(opt,"PRECLUSTERV2") )
353 clusterFinder = new AliMUONPreClusterFinderV2;
355 else if ( strstr(opt,"PRECLUSTERV3") )
357 clusterFinder = new AliMUONPreClusterFinderV3;
359 else if ( strstr(opt,"PRECLUSTER") )
361 clusterFinder = new AliMUONPreClusterFinder;
363 else if ( strstr(opt,"COG") )
365 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
367 else if ( strstr(opt,"SIMPLEFITV3") )
369 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
371 else if ( strstr(opt,"SIMPLEFIT") )
373 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
375 else if ( strstr(opt,"MLEM:DRAW") )
377 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
379 else if ( strstr(opt,"MLEMV3") )
381 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
383 else if ( strstr(opt,"MLEMV2") )
385 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
387 else if ( strstr(opt,"MLEM") )
389 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
393 AliError(Form("clustering mode \"%s\" does not exist",opt.Data()));
397 return clusterFinder;
400 //_____________________________________________________________________________
402 AliMUONReconstructor::CreateClusterServer() const
404 /// Create cluster server
406 if ( fClusterServer ) return;
412 AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
414 if ( !clusterFinder ) return;
416 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
418 fClusterServer = new AliMUONSimpleClusterServer(*clusterFinder,*fTransformer);
421 //_____________________________________________________________________________
423 AliMUONReconstructor::CreateCalibrator() const
425 /// Create the calibrator
429 Int_t runNumber = AliCDBManager::Instance()->GetRun();
431 AliInfo("Calibration will occur.");
433 fCalibrationData = new AliMUONCalibrationData(runNumber);
434 if ( !fCalibrationData->IsValid() )
436 AliError("Could not retrieve calibrations !");
437 delete fCalibrationData;
438 fCalibrationData = 0x0;
442 // Check that we get all the calibrations we'll need
443 if ( !fCalibrationData->Pedestals() ||
444 !fCalibrationData->Gains() ||
445 !fCalibrationData->HV() )
447 AliFatal("Could not access all required calibration data");
450 TString opt(GetOption());
453 if ( strstr(opt,"NOSTATUSMAP") )
455 AliWarning("NOSTATUSMAP is obsolete");
458 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData);
461 //_____________________________________________________________________________
463 AliMUONReconstructor::DigitStore() const
465 /// Return (and create if necessary) the digit container
468 TString sopt(GetOption());
471 AliInfo(Form("Options=%s",sopt.Data()));
473 if ( sopt.Contains("DIGITSTOREV1") )
475 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
477 else if ( sopt.Contains("DIGITSTOREV2R") )
479 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
481 else if ( sopt.Contains("DIGITSTOREV2S") )
483 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
486 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
488 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
493 //_____________________________________________________________________________
495 AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
496 TTree& clustersTree) const
498 /// Write the trigger and cluster information into TreeR
507 ok = triggerStore->Connect(clustersTree,kTRUE);
510 AliError("Could not create triggerStore branches in TreeR");
514 if (ok) // at least one type of branches created successfully
520 //_____________________________________________________________________________
522 AliMUONReconstructor::HasDigitConversion() const
524 /// We *do* have digit conversion, but we might advertise it only
525 /// if we want to save the digits.
527 TString opt(GetOption());
529 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
539 //_____________________________________________________________________________
541 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
543 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
544 /// HasDigitConversion()==kFALSE
548 AliError("clustersTree is 0x0 !");
552 ConvertDigits(rawReader,DigitStore(),TriggerStore());
554 FillTreeR(TriggerStore(),*clustersTree);
557 //_____________________________________________________________________________
559 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
561 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
562 /// AND HasDigitConversion()==kTRUE
568 if (!digitsTree || !clustersTree)
570 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
571 digitsTree,clustersTree));
577 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
580 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
584 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
589 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
592 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
596 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
600 if (!fTriggerStore && !fDigitStore)
602 AliError("No store at all. Nothing to do.");
606 // insure we start with empty stores
609 fDigitStore->Clear();
610 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
611 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
614 AliError("Could not connect digitStore to digitsTree");
620 fTriggerStore->Clear();
621 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
622 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
625 AliError("Could not connect triggerStore to digitsTree");
630 digitsTree->GetEvent(0);
634 // Insure we got calibrated digits (if we reconstruct from pure simulated,
635 // i.e. w/o going through raw data, this will be the case)
636 TIter next(fDigitStore->CreateIterator());
637 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
638 if (!digit->IsCalibrated())
640 Calibrate(*fDigitStore);
644 FillTreeR(fTriggerStore,*clustersTree);
647 //_____________________________________________________________________________
648 AliMUONVTriggerStore*
649 AliMUONReconstructor::TriggerStore() const
651 /// Return (and create if necessary and allowed) the trigger container
652 TString sopt(GetOption());
655 if (sopt.Contains("TRIGGERDISABLE"))
657 delete fTriggerStore;
664 fTriggerStore = new AliMUONTriggerStoreV1;
667 return fTriggerStore;