]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONReconstructor.cxx
Remove the NOSTATUSMAP option (Laurent)
[u/mrichter/AliRoot.git] / MUON / AliMUONReconstructor.cxx
CommitLineData
cac2eb58 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
cac2eb58 15/* $Id$ */
16
3d1463c8 17//-----------------------------------------------------------------------------
22899106 18/// \class AliMUONReconstructor
19///
20/// Implementation of AliReconstructor for MUON subsystem.
21///
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.
26///
27/// Valid options are :
28///
29/// SAVEDIGITS : if you want to save in the TreeD the *calibrated* digits
30/// that are used for the clustering
31///
32/// SIMPLEFIT : use the AliMUONClusterFinderSimpleFit clusterizer
33///
2060b217 34/// MLEM : another implementation of AZ, where preclustering is external (default)
93d7b017 35/// MLEMV3 : MLEM with preclustering=PRECLUSTERV2
36/// MLEMV3 : MLEM with preclustering=PRECLUSTERV3
37///
22899106 38/// PRECLUSTER : use only AliMUONPreClusterFinder. Only for debug as
39/// the produced clusters do not have a position, hence the tracking will not
40/// work
93d7b017 41/// PRECLUSTERV2 : another version of the preclustering
42/// PRECLUSTERV3 : yet another version of the preclustering
22899106 43///
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...
47///
48/// NOCLUSTERING : bypass completely the clustering stage
49///
22899106 50/// NOLOCALRECONSTRUCTION : for debug, to disable local reconstruction (and hence
51/// "recover" old behavior)
52///
53/// TRIGGERDISABLE : disable the treatment of MUON trigger
54///
93d7b017 55/// DIGITSTOREV1 : use the V1 implementation of the digitstore
56/// DIGITSTOREV2R : use the V2R implementation of the digitstore
57///
22899106 58/// \author Laurent Aphecetche, Subatech
3d1463c8 59//-----------------------------------------------------------------------------
30178c30 60
cf464691 61#include "AliMUONReconstructor.h"
b2d7df0b 62
22899106 63#include "AliCDBManager.h"
22899106 64#include "AliLog.h"
b2d7df0b 65#include "AliMUONCalibrationData.h"
22899106 66#include "AliMUONClusterFinderCOG.h"
67#include "AliMUONClusterFinderMLEM.h"
68#include "AliMUONClusterFinderSimpleFit.h"
b2d7df0b 69#include "AliMUONClusterReconstructor.h"
2060b217 70#include "AliMUONClusterStoreV2.h"
22899106 71#include "AliMUONConstants.h"
b2d7df0b 72#include "AliMUONDigitCalibrator.h"
2cf44ef3 73#include "AliMUONDigitMaker.h"
22899106 74#include "AliMUONDigitStoreV1.h"
93d7b017 75#include "AliMUONDigitStoreV2R.h"
22899106 76#include "AliMUONGeometryTransformer.h"
77#include "AliMUONPreClusterFinder.h"
93d7b017 78#include "AliMUONPreClusterFinderV2.h"
79#include "AliMUONPreClusterFinderV3.h"
196471e9 80#include "AliMUONTracker.h"
22899106 81#include "AliMUONVTrackStore.h"
8c0b5e70 82#include "AliMUONTriggerChamberEff.h"
e1a10d41 83#include "AliMUONTriggerCircuit.h"
96fdfe9a 84#include "AliMUONTriggerCrateStore.h"
22899106 85#include "AliMUONTriggerStoreV1.h"
86#include "AliMUONVClusterFinder.h"
88544f7e 87#include "AliMpCDB.h"
cf464691 88#include "AliRawReader.h"
93d7b017 89#include "AliCodeTimer.h"
22899106 90#include <Riostream.h>
91#include <TClonesArray.h>
92#include <TString.h>
93#include <TTree.h>
2060b217 94
9265505b 95/// \cond CLASSIMP
cac2eb58 96ClassImp(AliMUONReconstructor)
22899106 97/// \endcond
b2d7df0b 98
cac2eb58 99//_____________________________________________________________________________
22899106 100AliMUONReconstructor::AliMUONReconstructor() :
101AliReconstructor(),
102fCrateManager(0x0),
103fDigitMaker(0x0),
ef4cb4f1 104fTransformer(new AliMUONGeometryTransformer()),
22899106 105fDigitStore(0x0),
106fTriggerCircuit(0x0),
107fCalibrationData(0x0),
108fDigitCalibrator(0x0),
109fClusterReconstructor(0x0),
110fClusterStore(0x0),
111fTriggerStore(0x0),
112fTrackStore(0x0),
93d7b017 113fTrigChamberEff(0x0)
8789635b 114{
22899106 115 /// normal ctor
88544f7e 116
88544f7e 117 // Load mapping
a55f49a0 118 if ( ! AliMpCDB::LoadDDLStore() ) {
88544f7e 119 AliFatal("Could not access mapping from OCDB !");
120 }
121
a55f49a0 122 // Load geometry data
123 fTransformer->LoadGeometryData();
88544f7e 124
125
22899106 126}
d19b6003 127
22899106 128//_____________________________________________________________________________
129AliMUONReconstructor::~AliMUONReconstructor()
130{
131 /// dtor
132 delete fDigitMaker;
133 delete fDigitStore;
134 delete fTransformer;
135 delete fCrateManager;
136 delete fTriggerCircuit;
137 delete fCalibrationData;
138 delete fDigitCalibrator;
139 delete fClusterReconstructor;
140 delete fClusterStore;
141 delete fTriggerStore;
142 delete fTrackStore;
8c0b5e70 143 delete fTrigChamberEff;
22899106 144}
96fdfe9a 145
22899106 146//_____________________________________________________________________________
147void
148AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
149{
150 /// Calibrate the digitStore
151 if (!fDigitCalibrator)
152 {
153 CreateCalibrator();
154 }
93d7b017 155 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
22899106 156 fDigitCalibrator->Calibrate(digitStore);
157}
96fdfe9a 158
22899106 159//_____________________________________________________________________________
160void
161AliMUONReconstructor::Clusterize(const AliMUONVDigitStore& digitStore,
162 AliMUONVClusterStore& clusterStore) const
163{
164 /// Creates clusters from digits.
9c4b1ee7 165
22899106 166 TString sopt(GetOption());
167 sopt.ToUpper();
168 if ( sopt.Contains("NOCLUSTERING") ) return;
169
170 if (!fClusterReconstructor)
171 {
172 CreateClusterReconstructor();
173 }
9c4b1ee7 174
93d7b017 175 AliCodeTimerAuto(Form("%s::Digits2Clusters(const AliMUONVDigitStore&,AliMUONVClusterStore&)",
176 fClusterReconstructor->ClassName()))
22899106 177 fClusterReconstructor->Digits2Clusters(digitStore,clusterStore);
8789635b 178}
94f6fba9 179
8789635b 180//_____________________________________________________________________________
22899106 181AliMUONVClusterStore*
182AliMUONReconstructor::ClusterStore() const
cac2eb58 183{
22899106 184 /// Return (and create if necessary) the cluster container
185 if (!fClusterStore)
186 {
2060b217 187 fClusterStore = new AliMUONClusterStoreV2;
22899106 188 }
189 return fClusterStore;
190}
d19b6003 191
22899106 192//_____________________________________________________________________________
193void
194AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
195 AliMUONVDigitStore* digitStore,
196 AliMUONVTriggerStore* triggerStore) const
197{
198 /// Convert raw data into digit and trigger stores
199 CreateDigitMaker();
93d7b017 200
201 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
202 fDigitMaker->ClassName()))
22899106 203 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
93d7b017 204 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
205 fDigitMaker->ClassName()))
22899106 206 Calibrate(*digitStore);
cac2eb58 207}
b2d7df0b 208
209//_____________________________________________________________________________
22899106 210void
211AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
b2d7df0b 212{
22899106 213 /// convert raw data into a digit tree
2060b217 214 AliCodeTimerAuto("")
22899106 215
216 Bool_t alone = ( TriggerStore() == 0 );
b2d7df0b 217
22899106 218 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
219 if ( TriggerStore() )
b476b122 220 {
22899106 221 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
b476b122 222 }
ee103e97 223
22899106 224 if (!ok)
225 {
226 AliError("Could not make branches on TreeD");
227 }
228 else
229 {
230 ConvertDigits(rawReader,DigitStore(),TriggerStore());
2060b217 231 AliCodeTimerStart("Fill digits")
22899106 232 digitsTree->Fill();
2060b217 233 AliCodeTimerStop("Fill digits")
22899106 234 DigitStore()->Clear();
235 }
236}
237
238//_____________________________________________________________________________
239AliMUONTriggerCrateStore*
240AliMUONReconstructor::CrateManager() const
241{
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;
247}
248
249//_____________________________________________________________________________
250void
251AliMUONReconstructor::CreateDigitMaker() const
252{
253 /// Create (and create if necessary) the digit maker
254 if (fDigitMaker) return;
255
93d7b017 256 AliCodeTimerAuto("")
22899106 257
258 fDigitMaker = new AliMUONDigitMaker;
22899106 259}
260
261//_____________________________________________________________________________
262void
263AliMUONReconstructor::CreateTriggerCircuit() const
264{
265 /// Return (and create if necessary) the trigger circuit object
266 if (fTriggerCircuit) return;
267
93d7b017 268 AliCodeTimerAuto("")
22899106 269
32ab62c9 270 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
22899106 271
32ab62c9 272}
8c0b5e70 273
274//_____________________________________________________________________________
275void
276AliMUONReconstructor::CreateTriggerChamberEff() const
277{
278 /// Create (and create if necessary) the trigger chamber efficiency class
279 if (fTrigChamberEff) return;
280
93d7b017 281 AliCodeTimerAuto("")
8c0b5e70 282
283 fTrigChamberEff = new AliMUONTriggerChamberEff(fTransformer,fDigitMaker,kTRUE);
284 //fTrigChamberEff->SetDebugLevel(1);
285}
286
22899106 287//_____________________________________________________________________________
288AliTracker*
d76c31f4 289AliMUONReconstructor::CreateTracker() const
22899106 290{
291 /// Create the MUONTracker object
292 /// The MUONTracker is passed the GetOption(), i.e. our own options
ee103e97 293
22899106 294 CreateTriggerCircuit();
295 CreateDigitMaker();
8c0b5e70 296 CreateTriggerChamberEff();
22899106 297
d76c31f4 298 AliMUONTracker* tracker = new AliMUONTracker(fDigitMaker,fTransformer,fTriggerCircuit,fTrigChamberEff);
22899106 299 tracker->SetOption(GetOption());
300
301 return tracker;
b2d7df0b 302}
303
f9247068 304//_____________________________________________________________________________
22899106 305void
196471e9 306AliMUONReconstructor::CreateClusterReconstructor() const
f9247068 307{
22899106 308 /// Create cluster reconstructor, depending on GetOption()
309
93d7b017 310 AliCodeTimerAuto("")
06ca6d7b 311
22899106 312 AliDebug(1,"");
313
f9247068 314 AliMUONVClusterFinder* clusterFinder(0x0);
315
316 TString opt(GetOption());
317 opt.ToUpper();
318
93d7b017 319 if ( strstr(opt,"PRECLUSTERV2") )
320 {
321 clusterFinder = new AliMUONPreClusterFinderV2;
322 }
323 else if ( strstr(opt,"PRECLUSTERV3") )
324 {
325 clusterFinder = new AliMUONPreClusterFinderV3;
326 }
327 else if ( strstr(opt,"PRECLUSTER") )
f9247068 328 {
329 clusterFinder = new AliMUONPreClusterFinder;
330 }
331 else if ( strstr(opt,"COG") )
332 {
93d7b017 333 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
f9247068 334 }
93d7b017 335 else if ( strstr(opt,"SIMPLEFITV3") )
336 {
337 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
338 }
f9247068 339 else if ( strstr(opt,"SIMPLEFIT") )
340 {
93d7b017 341 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
f9247068 342 }
343 else if ( strstr(opt,"MLEM:DRAW") )
344 {
93d7b017 345 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
f9247068 346 }
93d7b017 347 else if ( strstr(opt,"MLEMV3") )
348 {
349 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
350 }
351 else if ( strstr(opt,"MLEMV2") )
352 {
353 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
354 }
f9247068 355 else if ( strstr(opt,"MLEM") )
356 {
93d7b017 357 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
f9247068 358 }
22899106 359 else
360 {
2060b217 361 // default is currently MLEM
362 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
22899106 363 }
f9247068 364
22899106 365 if ( clusterFinder )
f9247068 366 {
367 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
368 }
369
22899106 370 fClusterReconstructor = new AliMUONClusterReconstructor(clusterFinder,fTransformer);
f9247068 371}
372
cac2eb58 373//_____________________________________________________________________________
22899106 374void
375AliMUONReconstructor::CreateCalibrator() const
cac2eb58 376{
22899106 377 /// Create the calibrator
2457f726 378
93d7b017 379 AliCodeTimerAuto("")
3bc8b580 380
22899106 381 Int_t runNumber = AliCDBManager::Instance()->GetRun();
3bc8b580 382
22899106 383 AliInfo("Calibration will occur.");
384
385 fCalibrationData = new AliMUONCalibrationData(runNumber);
386 if ( !fCalibrationData->IsValid() )
387 {
388 AliError("Could not retrieve calibrations !");
389 delete fCalibrationData;
390 fCalibrationData = 0x0;
391 return;
392 }
393
394 // Check that we get all the calibrations we'll need
395 if ( !fCalibrationData->Pedestals() ||
396 !fCalibrationData->Gains() ||
397 !fCalibrationData->HV() )
398 {
399 AliFatal("Could not access all required calibration data");
9ffe3ef4 400 }
cc87ebcd 401
22899106 402 TString opt(GetOption());
403 opt.ToUpper();
404 Bool_t statusMap(kTRUE);
b2d7df0b 405
22899106 406 if ( strstr(opt,"NOSTATUSMAP") )
407 {
22f7c9ba 408 AliWarning("NOSTATUSMAP is obsolete");
22899106 409 }
22f7c9ba 410
411 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData);
22899106 412}
9c4b1ee7 413
22899106 414//_____________________________________________________________________________
415AliMUONVDigitStore*
416AliMUONReconstructor::DigitStore() const
417{
418 /// Return (and create if necessary) the digit container
419 if (!fDigitStore)
420 {
93d7b017 421 TString sopt(GetOption());
422 sopt.ToUpper();
423
424 AliInfo(Form("Options=%s",sopt.Data()));
425
426 if ( sopt.Contains("DIGITSTOREV1") )
427 {
428 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
429 }
430 else if ( sopt.Contains("DIGITSTOREV2R") )
431 {
432 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
433 }
434 else if ( sopt.Contains("DIGITSTOREV2S") )
435 {
436 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
437 }
438
439 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
440
441 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
22899106 442 }
443 return fDigitStore;
444}
94f6fba9 445
22899106 446//_____________________________________________________________________________
447void
448AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
449 AliMUONVClusterStore* clusterStore,
450 TTree& clustersTree) const
451{
452 /// Write the trigger and cluster information into TreeR
453
93d7b017 454 AliCodeTimerAuto("")
cc87ebcd 455
22899106 456 AliDebug(1,"");
457
458 Bool_t ok(kFALSE);
459 if ( triggerStore )
460 {
461 Bool_t alone = ( clusterStore ? kFALSE : kTRUE );
462 ok = triggerStore->Connect(clustersTree,alone);
463 if (!ok)
b2d7df0b 464 {
22899106 465 AliError("Could not create triggerStore branches in TreeR");
cc87ebcd 466 }
cac2eb58 467 }
22899106 468
469 if ( clusterStore )
470 {
471 Bool_t alone = ( triggerStore ? kFALSE : kTRUE );
472 ok = clusterStore->Connect(clustersTree,alone);
473 if (!ok)
474 {
475 AliError("Could not create triggerStore branches in TreeR");
476 }
477 }
478
479 if (ok) // at least one type of branches created successfully
480 {
481 clustersTree.Fill();
482 }
cac2eb58 483}
cf464691 484
485//_____________________________________________________________________________
22899106 486Bool_t
487AliMUONReconstructor::HasDigitConversion() const
cf464691 488{
22899106 489 /// We *do* have digit conversion, but we might advertise it only
490 /// if we want to save the digits.
491
492 TString opt(GetOption());
493 opt.ToUpper();
494 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
495 {
496 return kTRUE;
497 }
498 else
499 {
500 return kFALSE;
501 }
502}
f9247068 503
22899106 504//_____________________________________________________________________________
505void
506AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
507{
508 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
509 /// HasDigitConversion()==kFALSE
8cde4af5 510
22899106 511 if ( !clustersTree )
512 {
513 AliError("clustersTree is 0x0 !");
514 return;
515 }
b2d7df0b 516
93d7b017 517 ConvertDigits(rawReader,DigitStore(),TriggerStore());
518 Clusterize(*(DigitStore()),*(ClusterStore()));
22899106 519
520 FillTreeR(TriggerStore(),ClusterStore(),*clustersTree);
521}
64b056bc 522
196471e9 523//_____________________________________________________________________________
22899106 524void
525AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
a2da7817 526{
22899106 527 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
528 /// AND HasDigitConversion()==kTRUE
529
2060b217 530 AliCodeTimerAuto("")
93d7b017 531
22899106 532 AliDebug(1,"");
533
534 if (!digitsTree || !clustersTree)
535 {
536 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
537 digitsTree,clustersTree));
538 return;
539 }
d19b6003 540
22899106 541 if (!fDigitStore)
542 {
543 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
544 if (!fDigitStore)
545 {
546 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
547 }
548 else
549 {
550 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
551 }
552 }
553 if (!fTriggerStore)
554 {
555 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
556 if (!fTriggerStore)
557 {
558 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
559 }
560 else
561 {
562 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
563 }
564 }
565
566 if (!fTriggerStore && !fDigitStore)
567 {
568 AliError("No store at all. Nothing to do.");
569 return;
570 }
571
572 // insure we start with empty stores
573 if ( fDigitStore )
574 {
575 fDigitStore->Clear();
576 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
577 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
578 if (!ok)
579 {
580 AliError("Could not connect digitStore to digitsTree");
581 return;
582 }
583 }
584 if ( fTriggerStore )
585 {
586 fTriggerStore->Clear();
587 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
588 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
589 if (!ok)
590 {
591 AliError("Could not connect triggerStore to digitsTree");
592 return;
593 }
594 }
595
596 digitsTree->GetEvent(0);
597
598 if ( fDigitStore )
599 {
e729a0c8 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())
605 {
606 Calibrate(*fDigitStore);
607 }
22899106 608 Clusterize(*fDigitStore,*(ClusterStore()));
609 }
610
611 FillTreeR(fTriggerStore,ClusterStore(),*clustersTree);
cac2eb58 612}
196471e9 613
614//_____________________________________________________________________________
22899106 615AliMUONVTriggerStore*
616AliMUONReconstructor::TriggerStore() const
196471e9 617{
22899106 618 /// Return (and create if necessary and allowed) the trigger container
619 TString sopt(GetOption());
620 sopt.ToUpper();
621
622 if (sopt.Contains("TRIGGERDISABLE"))
623 {
624 delete fTriggerStore;
625 fTriggerStore = 0x0;
626 }
627 else
628 {
629 if (!fTriggerStore)
630 {
631 fTriggerStore = new AliMUONTriggerStoreV1;
632 }
633 }
634 return fTriggerStore;
196471e9 635}