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"
113 #include "AliMpDDLStore.h"
114 #include "AliMpSegmentation.h"
116 #include "AliRawReader.h"
117 #include "AliCDBManager.h"
118 #include "AliCodeTimer.h"
121 #include <Riostream.h>
122 #include <TObjArray.h>
123 #include <TClonesArray.h>
128 ClassImp(AliMUONReconstructor)
131 //_____________________________________________________________________________
132 AliMUONReconstructor::AliMUONReconstructor() :
135 fTransformer(new AliMUONGeometryTransformer()),
137 fTriggerCircuit(0x0),
138 fCalibrationData(0x0),
139 fDigitCalibrator(0x0),
149 // Unload and delete old mapping
150 AliCDBManager::Instance()->UnloadFromCache("MUON/Calib/Mapping");
151 AliCDBManager::Instance()->UnloadFromCache("MUON/Calib/DDLStore");
152 delete AliMpDDLStore::Instance();
153 delete AliMpSegmentation::Instance();
156 if ( ! AliMpCDB::LoadDDLStore() ) {
157 AliFatal("Could not access mapping from OCDB !");
160 // Load geometry data
161 fTransformer->LoadGeometryData();
165 //_____________________________________________________________________________
166 AliMUONReconstructor::~AliMUONReconstructor()
175 delete fTriggerCircuit;
176 delete fCalibrationData;
177 delete fDigitCalibrator;
178 delete fClusterServer;
179 delete fTriggerStore;
181 delete fClusterStore;
183 delete AliMpSegmentation::Instance(false);
184 delete AliMpDDLStore::Instance(false);
187 //_____________________________________________________________________________
189 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
191 /// Calibrate the digitStore
192 if (!fDigitCalibrator)
196 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
197 fDigitCalibrator->Calibrate(digitStore);
200 //_____________________________________________________________________________
202 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
203 AliMUONVDigitStore* digitStore,
204 AliMUONVTriggerStore* triggerStore) const
206 /// Convert raw data into digit and trigger stores
209 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
210 fDigitMaker->ClassName()))
211 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
212 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
213 fDigitMaker->ClassName()))
214 Calibrate(*digitStore);
217 //_____________________________________________________________________________
219 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
221 /// convert raw data into a digit tree
224 Bool_t alone = ( TriggerStore() == 0 );
226 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
227 if ( TriggerStore() )
229 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
234 AliError("Could not make branches on TreeD");
238 ConvertDigits(rawReader,DigitStore(),TriggerStore());
239 AliCodeTimerStart("Fill digits")
241 AliCodeTimerStop("Fill digits")
242 DigitStore()->Clear();
246 //_____________________________________________________________________________
248 AliMUONReconstructor::CreateDigitMaker() const
250 /// Create (and create if necessary) the digit maker
251 if (fDigitMaker) return;
255 TString option = GetOption();
256 Bool_t enableErrorLogging = kTRUE;
257 Bool_t useFastTrackerDecoder = kTRUE;
258 Bool_t useFastTriggerDecoder = kTRUE;
259 if (option.Contains("NOFASTTRKDECODER"))
261 useFastTrackerDecoder = kFALSE;
263 if (option.Contains("NOFASTTRGDECODER"))
265 useFastTriggerDecoder = kFALSE;
267 if (option.Contains("NOFASTDECODERS"))
269 useFastTrackerDecoder = kFALSE;
270 useFastTriggerDecoder = kFALSE;
272 fDigitMaker = new AliMUONDigitMaker(
273 enableErrorLogging, useFastTrackerDecoder, useFastTriggerDecoder
276 if ( option.Contains("SAVEDIGITS" ))
278 fDigitMaker->SetMakeTriggerDigits(kTRUE);
282 //_____________________________________________________________________________
284 AliMUONReconstructor::CreateTriggerCircuit() const
286 /// Return (and create if necessary) the trigger circuit object
287 if (fTriggerCircuit) return;
291 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
295 //_____________________________________________________________________________
297 AliMUONReconstructor::CreateTracker() const
299 /// Create the MUONTracker object
301 CreateTriggerCircuit();
303 CreateClusterServer();
305 AliMUONTracker* tracker(0x0);
307 if ( ! GetRecoParam()->CombineClusterTrackReco() )
309 tracker = new AliMUONTracker(GetRecoParam(),
318 tracker = new AliMUONTracker(GetRecoParam(),
330 //_____________________________________________________________________________
331 AliMUONVClusterFinder*
332 AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
334 /// Create a given cluster finder instance
336 AliCodeTimerAutoGeneral("")
338 AliMUONVClusterFinder* clusterFinder(0x0);
340 TString opt(clusterFinderType);
343 if ( strstr(opt,"PRECLUSTERV2") )
345 clusterFinder = new AliMUONPreClusterFinderV2;
347 else if ( strstr(opt,"PRECLUSTERV3") )
349 clusterFinder = new AliMUONPreClusterFinderV3;
351 else if ( strstr(opt,"PRECLUSTER") )
353 clusterFinder = new AliMUONPreClusterFinder;
355 else if ( strstr(opt,"PEAKCOG") )
357 clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
359 else if ( strstr(opt,"PEAKFIT") )
361 clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,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 AliErrorClass(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;
408 AliCodeTimerAuto("");
410 AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
412 if ( !clusterFinder ) return;
414 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
416 fClusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
419 //_____________________________________________________________________________
421 AliMUONReconstructor::CreateCalibrator() const
423 /// Create the calibrator
427 Int_t runNumber = AliCDBManager::Instance()->GetRun();
429 AliInfo("Calibration will occur.");
431 fCalibrationData = new AliMUONCalibrationData(runNumber);
432 if ( !fCalibrationData->IsValid() )
434 AliError("Could not retrieve calibrations !");
435 delete fCalibrationData;
436 fCalibrationData = 0x0;
440 // Check that we get all the calibrations we'll need
441 if ( !fCalibrationData->Pedestals() ||
442 !fCalibrationData->Gains() ||
443 !fCalibrationData->HV() )
445 AliFatal("Could not access all required calibration data");
448 TString opt(GetOption());
451 if ( strstr(opt,"NOSTATUSMAP") )
453 AliWarning("NOSTATUSMAP is obsolete");
456 TString calibMode = GetRecoParam()->GetCalibrationMode();
458 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam(),calibMode.Data());
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
505 Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
507 if ( ! GetRecoParam()->CombineClusterTrackReco() )
509 alone = kFALSE; // we'll get both tracker and trigger information in TreeR
514 ok = triggerStore->Connect(clustersTree,alone);
517 AliError("Could not create triggerStore branches in TreeR");
525 fClusterStore = new AliMUONClusterStoreV2;
528 CreateClusterServer();
530 TIter next(DigitStore()->CreateIterator());
531 fClusterServer->UseDigits(next,DigitStore());
535 AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
537 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
539 if (GetRecoParam()->UseChamber(i))
541 if ( ( i == 6 || i == 7 ) && GetRecoParam()->BypassSt4() ) continue;
542 if ( ( i == 8 || i == 9 ) && GetRecoParam()->BypassSt5() ) continue;
544 fClusterServer->Clusterize(i,*fClusterStore,area,GetRecoParam());
548 Bool_t cok = fClusterStore->Connect(clustersTree,alone);
550 if (!cok) AliError("Could not connect clusterStore to clusterTree");
552 AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
554 StdoutToAliDebug(1,fClusterStore->Print());
557 if (ok) // at least one type of branches created successfully
562 if (fClusterStore) fClusterStore->Clear();
565 //_____________________________________________________________________________
567 AliMUONReconstructor::HasDigitConversion() const
569 /// We *do* have digit conversion, but we might advertise it only
570 /// if we want to save the digits.
572 TString opt(GetOption());
574 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
584 //_____________________________________________________________________________
586 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
588 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
589 /// HasDigitConversion()==kFALSE
593 AliError("clustersTree is 0x0 !");
597 ConvertDigits(rawReader,DigitStore(),TriggerStore());
599 FillTreeR(TriggerStore(),*clustersTree);
602 //_____________________________________________________________________________
604 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
606 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
607 /// AND HasDigitConversion()==kTRUE
613 if (!digitsTree || !clustersTree)
615 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
616 digitsTree,clustersTree));
622 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
625 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
629 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
634 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
637 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
641 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
645 if (!fTriggerStore && !fDigitStore)
647 AliError("No store at all. Nothing to do.");
651 // insure we start with empty stores
654 fDigitStore->Clear();
655 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
656 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
659 AliError("Could not connect digitStore to digitsTree");
665 fTriggerStore->Clear();
666 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
667 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
670 AliError("Could not connect triggerStore to digitsTree");
675 digitsTree->GetEvent(0);
679 // Insure we got calibrated digits (if we reconstruct from pure simulated,
680 // i.e. w/o going through raw data, this will be the case)
681 TIter next(fDigitStore->CreateIterator());
682 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
683 if (digit && !digit->IsCalibrated())
685 Calibrate(*fDigitStore);
689 FillTreeR(fTriggerStore,*clustersTree);
692 //_____________________________________________________________________________
693 AliMUONVTriggerStore*
694 AliMUONReconstructor::TriggerStore() const
696 /// Return (and create if necessary and allowed) the trigger container
697 TString sopt(GetOption());
700 if (sopt.Contains("TRIGGERDISABLE"))
702 delete fTriggerStore;
709 fTriggerStore = new AliMUONTriggerStoreV1;
712 return fTriggerStore;