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 behavior of the MUON reconstruction can be changed, besides
23 /// the usual methods found in AliReconstruction (e.g. to disable tracking)
24 /// by using AliReconstruction::SetOption("MUON",options)
25 /// where options should be a space separated string.
27 /// Valid options are :
29 /// SAVEDIGITS : if you want to save in the TreeD the *calibrated* digits
30 /// that are used for the clustering
32 /// SIMPLEFIT : use the AliMUONClusterFinderSimpleFit clusterizer
34 /// MLEM : another implementation of AZ, where preclustering is external (default)
35 /// MLEMV3 : MLEM with preclustering=PRECLUSTERV2
36 /// MLEMV3 : MLEM with preclustering=PRECLUSTERV3
38 /// PRECLUSTER : use only AliMUONPreClusterFinder. Only for debug as
39 /// the produced clusters do not have a position, hence the tracking will not
41 /// PRECLUSTERV2 : another version of the preclustering
42 /// PRECLUSTERV3 : yet another version of the preclustering
44 /// COG : use AliMUONClusterFinderCOG clusterizer. Not really a production
45 /// option either, as center-of-gravity is generally not a good estimate
46 /// of the cluster position...
48 /// NOCLUSTERING : bypass completely the clustering stage
50 /// NOLOCALRECONSTRUCTION : for debug, to disable local reconstruction (and hence
51 /// "recover" old behavior)
53 /// TRIGGERDISABLE : disable the treatment of MUON trigger
55 /// DIGITSTOREV1 : use the V1 implementation of the digitstore
56 /// DIGITSTOREV2R : use the V2R implementation of the digitstore
58 /// \author Laurent Aphecetche, Subatech
59 //-----------------------------------------------------------------------------
61 #include "AliMUONReconstructor.h"
63 #include "AliCDBManager.h"
65 #include "AliMUONCalibrationData.h"
66 #include "AliMUONClusterFinderCOG.h"
67 #include "AliMUONClusterFinderMLEM.h"
68 #include "AliMUONClusterFinderSimpleFit.h"
69 #include "AliMUONClusterReconstructor.h"
70 #include "AliMUONClusterStoreV2.h"
71 #include "AliMUONConstants.h"
72 #include "AliMUONDigitCalibrator.h"
73 #include "AliMUONDigitMaker.h"
74 #include "AliMUONDigitStoreV1.h"
75 #include "AliMUONDigitStoreV2R.h"
76 #include "AliMUONGeometryTransformer.h"
77 #include "AliMUONPreClusterFinder.h"
78 #include "AliMUONPreClusterFinderV2.h"
79 #include "AliMUONPreClusterFinderV3.h"
80 #include "AliMUONTracker.h"
81 #include "AliMUONVTrackStore.h"
82 #include "AliMUONTriggerChamberEff.h"
83 #include "AliMUONTriggerCircuit.h"
84 #include "AliMUONTriggerCrateStore.h"
85 #include "AliMUONTriggerStoreV1.h"
86 #include "AliMUONVClusterFinder.h"
88 #include "AliRawReader.h"
89 #include "AliCodeTimer.h"
90 #include <Riostream.h>
91 #include <TClonesArray.h>
96 ClassImp(AliMUONReconstructor)
99 //_____________________________________________________________________________
100 AliMUONReconstructor::AliMUONReconstructor() :
104 fTransformer(new AliMUONGeometryTransformer()),
106 fTriggerCircuit(0x0),
107 fCalibrationData(0x0),
108 fDigitCalibrator(0x0),
109 fClusterReconstructor(0x0),
118 if ( ! AliMpCDB::LoadDDLStore() ) {
119 AliFatal("Could not access mapping from OCDB !");
122 // Load geometry data
123 fTransformer->LoadGeometryData();
128 //_____________________________________________________________________________
129 AliMUONReconstructor::~AliMUONReconstructor()
135 delete fCrateManager;
136 delete fTriggerCircuit;
137 delete fCalibrationData;
138 delete fDigitCalibrator;
139 delete fClusterReconstructor;
140 delete fClusterStore;
141 delete fTriggerStore;
143 delete fTrigChamberEff;
146 //_____________________________________________________________________________
148 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
150 /// Calibrate the digitStore
151 if (!fDigitCalibrator)
155 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
156 fDigitCalibrator->Calibrate(digitStore);
159 //_____________________________________________________________________________
161 AliMUONReconstructor::Clusterize(const AliMUONVDigitStore& digitStore,
162 AliMUONVClusterStore& clusterStore) const
164 /// Creates clusters from digits.
166 TString sopt(GetOption());
168 if ( sopt.Contains("NOCLUSTERING") ) return;
170 if (!fClusterReconstructor)
172 CreateClusterReconstructor();
175 AliCodeTimerAuto(Form("%s::Digits2Clusters(const AliMUONVDigitStore&,AliMUONVClusterStore&)",
176 fClusterReconstructor->ClassName()))
177 fClusterReconstructor->Digits2Clusters(digitStore,clusterStore);
180 //_____________________________________________________________________________
181 AliMUONVClusterStore*
182 AliMUONReconstructor::ClusterStore() const
184 /// Return (and create if necessary) the cluster container
187 fClusterStore = new AliMUONClusterStoreV2;
189 return fClusterStore;
192 //_____________________________________________________________________________
194 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
195 AliMUONVDigitStore* digitStore,
196 AliMUONVTriggerStore* triggerStore) const
198 /// Convert raw data into digit and trigger stores
201 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
202 fDigitMaker->ClassName()))
203 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
204 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
205 fDigitMaker->ClassName()))
206 Calibrate(*digitStore);
209 //_____________________________________________________________________________
211 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
213 /// convert raw data into a digit tree
216 Bool_t alone = ( TriggerStore() == 0 );
218 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
219 if ( TriggerStore() )
221 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
226 AliError("Could not make branches on TreeD");
230 ConvertDigits(rawReader,DigitStore(),TriggerStore());
231 AliCodeTimerStart("Fill digits")
233 AliCodeTimerStop("Fill digits")
234 DigitStore()->Clear();
238 //_____________________________________________________________________________
239 AliMUONTriggerCrateStore*
240 AliMUONReconstructor::CrateManager() const
242 /// Return (and create if necessary) the trigger crate store
243 if (fCrateManager) return fCrateManager;
244 fCrateManager = new AliMUONTriggerCrateStore;
245 fCrateManager->ReadFromFile();
246 return fCrateManager;
249 //_____________________________________________________________________________
251 AliMUONReconstructor::CreateDigitMaker() const
253 /// Create (and create if necessary) the digit maker
254 if (fDigitMaker) return;
258 fDigitMaker = new AliMUONDigitMaker;
261 //_____________________________________________________________________________
263 AliMUONReconstructor::CreateTriggerCircuit() const
265 /// Return (and create if necessary) the trigger circuit object
266 if (fTriggerCircuit) return;
270 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
274 //_____________________________________________________________________________
276 AliMUONReconstructor::CreateTriggerChamberEff() const
278 /// Create (and create if necessary) the trigger chamber efficiency class
279 if (fTrigChamberEff) return;
283 fTrigChamberEff = new AliMUONTriggerChamberEff(fTransformer,fDigitMaker,kTRUE);
284 //fTrigChamberEff->SetDebugLevel(1);
287 //_____________________________________________________________________________
289 AliMUONReconstructor::CreateTracker() const
291 /// Create the MUONTracker object
292 /// The MUONTracker is passed the GetOption(), i.e. our own options
294 CreateTriggerCircuit();
296 CreateTriggerChamberEff();
298 AliMUONTracker* tracker = new AliMUONTracker(fDigitMaker,fTransformer,fTriggerCircuit,fTrigChamberEff);
299 tracker->SetOption(GetOption());
304 //_____________________________________________________________________________
306 AliMUONReconstructor::CreateClusterReconstructor() const
308 /// Create cluster reconstructor, depending on GetOption()
314 AliMUONVClusterFinder* clusterFinder(0x0);
316 TString opt(GetOption());
319 if ( strstr(opt,"PRECLUSTERV2") )
321 clusterFinder = new AliMUONPreClusterFinderV2;
323 else if ( strstr(opt,"PRECLUSTERV3") )
325 clusterFinder = new AliMUONPreClusterFinderV3;
327 else if ( strstr(opt,"PRECLUSTER") )
329 clusterFinder = new AliMUONPreClusterFinder;
331 else if ( strstr(opt,"COG") )
333 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
335 else if ( strstr(opt,"SIMPLEFITV3") )
337 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
339 else if ( strstr(opt,"SIMPLEFIT") )
341 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
343 else if ( strstr(opt,"MLEM:DRAW") )
345 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
347 else if ( strstr(opt,"MLEMV3") )
349 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
351 else if ( strstr(opt,"MLEMV2") )
353 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
355 else if ( strstr(opt,"MLEM") )
357 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
361 // default is currently MLEM
362 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
367 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
370 fClusterReconstructor = new AliMUONClusterReconstructor(clusterFinder,fTransformer);
373 //_____________________________________________________________________________
375 AliMUONReconstructor::CreateCalibrator() const
377 /// Create the calibrator
381 Int_t runNumber = AliCDBManager::Instance()->GetRun();
383 AliInfo("Calibration will occur.");
385 fCalibrationData = new AliMUONCalibrationData(runNumber);
386 if ( !fCalibrationData->IsValid() )
388 AliError("Could not retrieve calibrations !");
389 delete fCalibrationData;
390 fCalibrationData = 0x0;
394 // Check that we get all the calibrations we'll need
395 if ( !fCalibrationData->Pedestals() ||
396 !fCalibrationData->Gains() ||
397 !fCalibrationData->HV() )
399 AliFatal("Could not access all required calibration data");
402 TString opt(GetOption());
404 Bool_t statusMap(kTRUE);
406 if ( strstr(opt,"NOSTATUSMAP") )
408 AliWarning("NOSTATUSMAP is obsolete");
411 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData);
414 //_____________________________________________________________________________
416 AliMUONReconstructor::DigitStore() const
418 /// Return (and create if necessary) the digit container
421 TString sopt(GetOption());
424 AliInfo(Form("Options=%s",sopt.Data()));
426 if ( sopt.Contains("DIGITSTOREV1") )
428 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
430 else if ( sopt.Contains("DIGITSTOREV2R") )
432 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
434 else if ( sopt.Contains("DIGITSTOREV2S") )
436 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
439 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
441 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
446 //_____________________________________________________________________________
448 AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
449 AliMUONVClusterStore* clusterStore,
450 TTree& clustersTree) const
452 /// Write the trigger and cluster information into TreeR
461 Bool_t alone = ( clusterStore ? kFALSE : kTRUE );
462 ok = triggerStore->Connect(clustersTree,alone);
465 AliError("Could not create triggerStore branches in TreeR");
471 Bool_t alone = ( triggerStore ? kFALSE : kTRUE );
472 ok = clusterStore->Connect(clustersTree,alone);
475 AliError("Could not create triggerStore branches in TreeR");
479 if (ok) // at least one type of branches created successfully
485 //_____________________________________________________________________________
487 AliMUONReconstructor::HasDigitConversion() const
489 /// We *do* have digit conversion, but we might advertise it only
490 /// if we want to save the digits.
492 TString opt(GetOption());
494 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
504 //_____________________________________________________________________________
506 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
508 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
509 /// HasDigitConversion()==kFALSE
513 AliError("clustersTree is 0x0 !");
517 ConvertDigits(rawReader,DigitStore(),TriggerStore());
518 Clusterize(*(DigitStore()),*(ClusterStore()));
520 FillTreeR(TriggerStore(),ClusterStore(),*clustersTree);
523 //_____________________________________________________________________________
525 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
527 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
528 /// AND HasDigitConversion()==kTRUE
534 if (!digitsTree || !clustersTree)
536 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
537 digitsTree,clustersTree));
543 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
546 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
550 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
555 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
558 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
562 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
566 if (!fTriggerStore && !fDigitStore)
568 AliError("No store at all. Nothing to do.");
572 // insure we start with empty stores
575 fDigitStore->Clear();
576 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
577 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
580 AliError("Could not connect digitStore to digitsTree");
586 fTriggerStore->Clear();
587 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
588 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
591 AliError("Could not connect triggerStore to digitsTree");
596 digitsTree->GetEvent(0);
600 // Insure we got calibrated digits (if we reconstruct from pure simulated,
601 // i.e. w/o going through raw data, this will be the case)
602 TIter next(fDigitStore->CreateIterator());
603 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
604 if (!digit->IsCalibrated())
606 Calibrate(*fDigitStore);
608 Clusterize(*fDigitStore,*(ClusterStore()));
611 FillTreeR(fTriggerStore,ClusterStore(),*clustersTree);
614 //_____________________________________________________________________________
615 AliMUONVTriggerStore*
616 AliMUONReconstructor::TriggerStore() const
618 /// Return (and create if necessary and allowed) the trigger container
619 TString sopt(GetOption());
622 if (sopt.Contains("TRIGGERDISABLE"))
624 delete fTriggerStore;
631 fTriggerStore = new AliMUONTriggerStoreV1;
634 return fTriggerStore;