]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONReconstructor.cxx
bugfix #83123: registration of configurations in multiple handlers. The bug caused...
[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///
ad3c6eda 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)
22899106 25///
96ebe67e 26/// Valid modes are :
22899106 27///
28/// SIMPLEFIT : use the AliMUONClusterFinderSimpleFit clusterizer
29///
96ebe67e 30/// SIMPLEFITV3 : SIMPLEFIT with preclustering=PRECLUSTERV3
31///
32/// MLEM : use AliMUONClusterFinderMLEM and AliMUONPreClusterFinder for preclustering (default)
33/// MLEMV2 : MLEM with preclustering=PRECLUSTERV2
93d7b017 34/// MLEMV3 : MLEM with preclustering=PRECLUSTERV3
35///
22899106 36/// PRECLUSTER : use only AliMUONPreClusterFinder. Only for debug as
37/// the produced clusters do not have a position, hence the tracking will not
38/// work
93d7b017 39/// PRECLUSTERV2 : another version of the preclustering
40/// PRECLUSTERV3 : yet another version of the preclustering
22899106 41///
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...
45///
3ab319aa 46/// PEAKCOG : COG cluster finder around local maxima
47/// PEAKFIT : fit around local maxima with up to 3 peaks, COG otherwise
48///
22899106 49/// NOCLUSTERING : bypass completely the clustering stage
50///
96ebe67e 51/// ------
22899106 52///
96ebe67e 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.
57///
58/// Valid options are :
59///
60/// SAVEDIGITS : if you want to save in the TreeD the *calibrated* digits
61/// that are used for the clustering
22899106 62///
93d7b017 63/// DIGITSTOREV1 : use the V1 implementation of the digitstore
64/// DIGITSTOREV2R : use the V2R implementation of the digitstore
65///
96ebe67e 66/// NOLOCALRECONSTRUCTION : for debug, to disable local reconstruction (and hence
67/// "recover" old behavior)
68///
69/// TRIGGERDISABLE : disable the treatment of MUON trigger
70///
b6f591ae 71/// ENABLEERRORLOGGING : enable error logging (this activates also warnings in RawStreamTracker)
481d8064 72///
22899106 73/// \author Laurent Aphecetche, Subatech
3d1463c8 74//-----------------------------------------------------------------------------
30178c30 75
cf464691 76#include "AliMUONReconstructor.h"
b2d7df0b 77
b2d7df0b 78#include "AliMUONCalibrationData.h"
22899106 79#include "AliMUONClusterFinderCOG.h"
80#include "AliMUONClusterFinderMLEM.h"
81#include "AliMUONClusterFinderSimpleFit.h"
3ab319aa 82#include "AliMUONClusterFinderPeakCOG.h"
83#include "AliMUONClusterFinderPeakFit.h"
9bf6860b 84#include "AliMUONClusterStoreV1.h"
85#include "AliMUONClusterStoreV2.h"
22899106 86#include "AliMUONConstants.h"
b2d7df0b 87#include "AliMUONDigitCalibrator.h"
2cf44ef3 88#include "AliMUONDigitMaker.h"
22899106 89#include "AliMUONDigitStoreV1.h"
93d7b017 90#include "AliMUONDigitStoreV2R.h"
22899106 91#include "AliMUONGeometryTransformer.h"
00977a64 92#include "AliMUONPadStatusMaker.h"
22899106 93#include "AliMUONPreClusterFinder.h"
93d7b017 94#include "AliMUONPreClusterFinderV2.h"
95#include "AliMUONPreClusterFinderV3.h"
c5ce806f 96#include "AliMUONSimpleClusterServer.h"
196471e9 97#include "AliMUONTracker.h"
e1a10d41 98#include "AliMUONTriggerCircuit.h"
22899106 99#include "AliMUONTriggerStoreV1.h"
100#include "AliMUONVClusterFinder.h"
c5ce806f 101#include "AliMUONVClusterServer.h"
102#include "AliMUONVTrackStore.h"
00d46f24 103#include "AliMUONTriggerElectronics.h"
d5315275 104#include "AliMUONTriggerUtilities.h"
c5ce806f 105
106#include "AliMpArea.h"
88544f7e 107#include "AliMpCDB.h"
c5ce806f 108#include "AliMpConstants.h"
acd0cf59 109#include "AliMpDDLStore.h"
110#include "AliMpSegmentation.h"
c5ce806f 111
cf464691 112#include "AliRawReader.h"
c5ce806f 113#include "AliCDBManager.h"
93d7b017 114#include "AliCodeTimer.h"
c5ce806f 115#include "AliLog.h"
00977a64 116#include "AliRunInfo.h"
c5ce806f 117
22899106 118#include <Riostream.h>
15d30ed4 119#include <TObjArray.h>
22899106 120#include <TClonesArray.h>
121#include <TString.h>
122#include <TTree.h>
2060b217 123
9265505b 124/// \cond CLASSIMP
cac2eb58 125ClassImp(AliMUONReconstructor)
22899106 126/// \endcond
b2d7df0b 127
cac2eb58 128//_____________________________________________________________________________
22899106 129AliMUONReconstructor::AliMUONReconstructor() :
130AliReconstructor(),
22899106 131fDigitMaker(0x0),
ef4cb4f1 132fTransformer(new AliMUONGeometryTransformer()),
22899106 133fDigitStore(0x0),
134fTriggerCircuit(0x0),
135fCalibrationData(0x0),
136fDigitCalibrator(0x0),
22899106 137fTriggerStore(0x0),
9ec6a948 138fTrackStore(0x0),
00d46f24 139fClusterStore(0x0),
d5315275 140fTriggerProcessor(0x0),
cfeca9e2 141fTriggerUtilities(0x0),
142fClusterServers(),
143fTrackers()
8789635b 144{
22899106 145 /// normal ctor
88544f7e 146
acd0cf59 147 AliDebug(1,"");
78dfbced 148
149 // Unload mapping objects
150 // if they have been loaded from the obsolete OCDB mapping objects
151
152 if ( AliMpDDLStore::Instance(false) ) {
153 AliCDBManager::Instance()->UnloadFromCache("MUON/Calib/DDLStore");
154 delete AliMpDDLStore::Instance();
155 }
156
157 if ( AliMpSegmentation::Instance(false) ) {
158 AliCDBManager::Instance()->UnloadFromCache("MUON/Calib/Mapping");
159 delete AliMpSegmentation::Instance();
160 }
acd0cf59 161
88544f7e 162 // Load mapping
a55f49a0 163 if ( ! AliMpCDB::LoadDDLStore() ) {
88544f7e 164 AliFatal("Could not access mapping from OCDB !");
165 }
166
a55f49a0 167 // Load geometry data
168 fTransformer->LoadGeometryData();
cfeca9e2 169
170 fClusterServers.SetOwner(kTRUE);
171 fTrackers.SetOwner(kTRUE);
22899106 172}
d19b6003 173
22899106 174//_____________________________________________________________________________
175AliMUONReconstructor::~AliMUONReconstructor()
176{
7d5d0cc5 177 /// dtor
178
acd0cf59 179 AliDebug(1,"");
180
05315e71 181 delete fDigitCalibrator;
182
22899106 183 delete fDigitMaker;
184 delete fDigitStore;
185 delete fTransformer;
22899106 186 delete fTriggerCircuit;
22899106 187 delete fTriggerStore;
188 delete fTrackStore;
9ec6a948 189 delete fClusterStore;
00d46f24 190 delete fTriggerProcessor;
d5315275 191 delete fTriggerUtilities;
acd0cf59 192
193 delete AliMpSegmentation::Instance(false);
05315e71 194 delete AliMpDDLStore::Instance(false);
195
cfeca9e2 196 delete fCalibrationData;
22899106 197}
96fdfe9a 198
22899106 199//_____________________________________________________________________________
200void
201AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
202{
203 /// Calibrate the digitStore
204 if (!fDigitCalibrator)
205 {
206 CreateCalibrator();
207 }
99c136e1 208 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()),0)
00977a64 209 fDigitCalibrator->Calibrate(digitStore);
22899106 210}
96fdfe9a 211
22899106 212//_____________________________________________________________________________
213void
214AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
215 AliMUONVDigitStore* digitStore,
216 AliMUONVTriggerStore* triggerStore) const
217{
218 /// Convert raw data into digit and trigger stores
219 CreateDigitMaker();
c6e702f8 220
221 // Skip reconstruction if event is Calibration
222 if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) {
223 digitStore->Clear(); // Remove possible digits from previous event
224 triggerStore->Clear(); // Remove possible triggers from previous event
225 AliInfo("Calibration event: do not convert digits");
226 return;
227 }
93d7b017 228
229 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
230 fDigitMaker->ClassName()))
22899106 231 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
93d7b017 232 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
233 fDigitMaker->ClassName()))
22899106 234 Calibrate(*digitStore);
cac2eb58 235}
b2d7df0b 236
237//_____________________________________________________________________________
22899106 238void
239AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
b2d7df0b 240{
22899106 241 /// convert raw data into a digit tree
99c136e1 242 AliCodeTimerAuto("",0)
22899106 243
244 Bool_t alone = ( TriggerStore() == 0 );
b2d7df0b 245
22899106 246 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
247 if ( TriggerStore() )
b476b122 248 {
22899106 249 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
b476b122 250 }
ee103e97 251
22899106 252 if (!ok)
253 {
254 AliError("Could not make branches on TreeD");
255 }
256 else
257 {
258 ConvertDigits(rawReader,DigitStore(),TriggerStore());
2060b217 259 AliCodeTimerStart("Fill digits")
22899106 260 digitsTree->Fill();
2060b217 261 AliCodeTimerStop("Fill digits")
22899106 262 DigitStore()->Clear();
263 }
264}
265
22899106 266//_____________________________________________________________________________
267void
268AliMUONReconstructor::CreateDigitMaker() const
269{
270 /// Create (and create if necessary) the digit maker
271 if (fDigitMaker) return;
272
99c136e1 273 AliCodeTimerAuto("",0)
22899106 274
e3a2b9c9 275 TString option = GetOption();
b6f591ae 276
277 Bool_t enableErrorLogging = kFALSE;
278
279 if (option.Contains("ENABLEERRORLOGGING"))
e3a2b9c9 280 {
b6f591ae 281 enableErrorLogging = kTRUE;
e3a2b9c9 282 }
b6f591ae 283
284 fDigitMaker = new AliMUONDigitMaker(enableErrorLogging);
5483c51b 285 option.ToUpper();
64f628e9 286
287 // Always make trigger digits
288 // (needed when calculating trigger chamber efficiency)
289 fDigitMaker->SetMakeTriggerDigits(kTRUE);
290
9074a9a9 291 if ( GetRecoParam()->TryRecover() )
292 {
293 fDigitMaker->SetTryRecover(kTRUE);
294 }
295 else
296 {
297 fDigitMaker->SetTryRecover(kFALSE);
298 }
22899106 299}
300
301//_____________________________________________________________________________
302void
303AliMUONReconstructor::CreateTriggerCircuit() const
304{
305 /// Return (and create if necessary) the trigger circuit object
306 if (fTriggerCircuit) return;
307
99c136e1 308 AliCodeTimerAuto("",0)
22899106 309
32ab62c9 310 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
22899106 311
32ab62c9 312}
8c0b5e70 313
d5315275 314//_____________________________________________________________________________
315void
316AliMUONReconstructor::CreateTriggerUtilities() const
317{
318 /// Return (and create if necessary) the trigger utilities object
319 if ( fTriggerUtilities ) return;
320
321 AliCodeTimerAuto("",0)
322
323 if ( ! fCalibrationData ) CreateCalibrationData();
324
325 fTriggerUtilities = new AliMUONTriggerUtilities(fCalibrationData);
326}
327
22899106 328//_____________________________________________________________________________
329AliTracker*
d76c31f4 330AliMUONReconstructor::CreateTracker() const
22899106 331{
332 /// Create the MUONTracker object
ee103e97 333
22899106 334 CreateTriggerCircuit();
d5315275 335 CreateTriggerUtilities();
c5ce806f 336
cfeca9e2 337 const AliMUONRecoParam* rp = GetRecoParam();
338
339 Int_t es = rp->GetEventSpecie();
340
341 AliTracker* tracker = static_cast<AliTracker*>(fTrackers.At(es));
342
343 if (!tracker )
9bf6860b 344 {
cfeca9e2 345 if ( ! rp->CombineClusterTrackReco() )
346 {
347 tracker = new AliMUONTracker(rp,
348 0x0,
349 *DigitStore(),
350 fTransformer,
351 fTriggerCircuit,
352 fTriggerUtilities);
353
354 AliInfo(Form("Created tracker %p for recoparam of type %s es=%d",
355 tracker,
356 AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(rp->GetEventSpecie())),es));
357 }
358 else
359 {
360
361 tracker = new AliMUONTracker(rp,
362 CreateClusterServer(*rp),
363 *DigitStore(),
364 fTransformer,
365 fTriggerCircuit,
366 fTriggerUtilities);
367
368 AliInfo(Form("Created (combined) tracker %p for recoparam of type %s es=%d",
369 tracker,
370 AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(rp->GetEventSpecie())),es));
371 }
372
373 fTrackers.AddAtAndExpand(tracker,es);
c5ce806f 374 }
22899106 375
22899106 376
377 return tracker;
b2d7df0b 378}
379
f9247068 380//_____________________________________________________________________________
c5ce806f 381AliMUONVClusterFinder*
9bf6860b 382AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
f9247068 383{
c5ce806f 384 /// Create a given cluster finder instance
22899106 385
99c136e1 386 AliCodeTimerAutoGeneral("",0)
06ca6d7b 387
f9247068 388 AliMUONVClusterFinder* clusterFinder(0x0);
389
c5ce806f 390 TString opt(clusterFinderType);
f9247068 391 opt.ToUpper();
392
93d7b017 393 if ( strstr(opt,"PRECLUSTERV2") )
394 {
395 clusterFinder = new AliMUONPreClusterFinderV2;
396 }
397 else if ( strstr(opt,"PRECLUSTERV3") )
398 {
399 clusterFinder = new AliMUONPreClusterFinderV3;
400 }
401 else if ( strstr(opt,"PRECLUSTER") )
f9247068 402 {
403 clusterFinder = new AliMUONPreClusterFinder;
404 }
3ab319aa 405 else if ( strstr(opt,"PEAKCOG") )
406 {
407 clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
408 }
409 else if ( strstr(opt,"PEAKFIT") )
410 {
411 clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
412 }
f9247068 413 else if ( strstr(opt,"COG") )
414 {
93d7b017 415 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
f9247068 416 }
93d7b017 417 else if ( strstr(opt,"SIMPLEFITV3") )
418 {
419 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
420 }
f9247068 421 else if ( strstr(opt,"SIMPLEFIT") )
422 {
93d7b017 423 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
f9247068 424 }
425 else if ( strstr(opt,"MLEM:DRAW") )
426 {
93d7b017 427 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
f9247068 428 }
93d7b017 429 else if ( strstr(opt,"MLEMV3") )
430 {
431 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
432 }
433 else if ( strstr(opt,"MLEMV2") )
434 {
435 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
436 }
f9247068 437 else if ( strstr(opt,"MLEM") )
438 {
93d7b017 439 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
f9247068 440 }
22899106 441 else
442 {
9bf6860b 443 AliErrorClass(Form("clustering mode \"%s\" does not exist",opt.Data()));
c5ce806f 444 return 0x0;
22899106 445 }
f9247068 446
c5ce806f 447 return clusterFinder;
448}
449
450//_____________________________________________________________________________
cfeca9e2 451AliMUONVClusterServer*
452AliMUONReconstructor::CreateClusterServer(const AliMUONRecoParam& rp) const
c5ce806f 453{
454 /// Create cluster server
455
99c136e1 456 AliCodeTimerAuto("",0);
c5ce806f 457
cfeca9e2 458 AliMUONVClusterServer* clusterServer = static_cast<AliMUONVClusterServer*>(fClusterServers.At(rp.GetEventSpecie()));
c5ce806f 459
cfeca9e2 460 if (!clusterServer )
461 {
462 AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(rp.GetClusteringMode());
463
464 if ( !clusterFinder ) return 0x0;
465
466 clusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
467
054ef6d1 468 AliInfo(Form("Created AliMUONSimpleClusterServer (%p) for specie %d with clustering = %s (following requesting clustering mode %s)",
469 clusterServer,rp.GetEventSpecie(),clusterFinder->ClassName(),rp.GetClusteringMode()));
cfeca9e2 470
471 fClusterServers.AddAtAndExpand(clusterServer,rp.GetEventSpecie());
472 }
f9247068 473
cfeca9e2 474 return clusterServer;
f9247068 475}
476
cac2eb58 477//_____________________________________________________________________________
22899106 478void
00d46f24 479AliMUONReconstructor::CreateCalibrationData() const
cac2eb58 480{
22899106 481 /// Create the calibrator
2457f726 482
00d46f24 483 AliCodeTimerAuto("",0);
3bc8b580 484
22899106 485 Int_t runNumber = AliCDBManager::Instance()->GetRun();
3bc8b580 486
22899106 487 fCalibrationData = new AliMUONCalibrationData(runNumber);
488 if ( !fCalibrationData->IsValid() )
489 {
490 AliError("Could not retrieve calibrations !");
491 delete fCalibrationData;
492 fCalibrationData = 0x0;
493 return;
494 }
495
00977a64 496 // It is now time to check whether we have everything to proceed.
497 // What we need depends on whether both tracker and trigger
498 // are in the readout chain, and what specific "bad channel policy"
499 // we use
500
501 Bool_t kTracker(kFALSE);
502 Bool_t kTrigger(kFALSE);
503
504 const AliRunInfo* runInfo = GetRunInfo();
505 if (!runInfo)
506 {
13242232 507 AliError("Could not get runinfo ?");
00977a64 508 }
509 else
510 {
511 TString detectors(runInfo->GetActiveDetectors());
512 if (detectors.Contains("MUONTRK")) kTracker=kTRUE;
513 if (detectors.Contains("MUONTRG")) kTrigger=kTRUE;
514 }
515
516 AliInfo(Form("Run with MUON TRIGGER : %s and MUON TRACKER : %s",
517 kTrigger ? "YES":"NO" ,
518 kTracker ? "YES":"NO"));
519
520 if ( kTracker )
22899106 521 {
00977a64 522 // Check that we get all the calibrations we'll need
523 if ( !fCalibrationData->Pedestals() ||
524 !fCalibrationData->Gains() )
525 {
526 AliFatal(Form("Could not access all required calibration data (PED %p GAIN %p)",
527 fCalibrationData->Pedestals(),fCalibrationData->Gains()));
528 }
529
530 if ( !fCalibrationData->HV() )
531 {
532 // Special treatment of HV. We only break if the values
533 // are not there *AND* we cut on them.
534 UInt_t mask = GetRecoParam()->PadGoodnessMask();
535 TString smask(AliMUONPadStatusMaker::AsCondition(mask));
536 if ( smask.Contains("HV") )
537 {
538 AliFatal("Could not access all required calibration data (HV)");
539 }
540 }
9ffe3ef4 541 }
00d46f24 542}
543
544//_____________________________________________________________________________
545void
546AliMUONReconstructor::CreateCalibrator() const
547{
548 /// Create the calibrator
549
550 AliCodeTimerAuto("",0);
551
552 if ( ! fCalibrationData )
553 CreateCalibrationData();
554
555 AliInfo("Calibration will occur.");
556
22899106 557 TString opt(GetOption());
558 opt.ToUpper();
b2d7df0b 559
22899106 560 if ( strstr(opt,"NOSTATUSMAP") )
561 {
22f7c9ba 562 AliWarning("NOSTATUSMAP is obsolete");
22899106 563 }
22f7c9ba 564
05315e71 565 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam());
22899106 566}
9c4b1ee7 567
00d46f24 568//_____________________________________________________________________________
569void
570AliMUONReconstructor::ResponseRemovingChambers(AliMUONVTriggerStore* triggerStore) const
571{
572 /// Update trigger information with informatins obtained after
573 /// re-calculation of trigger response
574 AliCodeTimerAuto("",0);
575
576 if ( ! fCalibrationData )
577 CreateCalibrationData();
578
579 if ( ! fTriggerProcessor )
580 fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
581
582 fTriggerProcessor->ResponseRemovingChambers(*triggerStore);
583}
584
22899106 585//_____________________________________________________________________________
586AliMUONVDigitStore*
587AliMUONReconstructor::DigitStore() const
588{
589 /// Return (and create if necessary) the digit container
590 if (!fDigitStore)
591 {
93d7b017 592 TString sopt(GetOption());
593 sopt.ToUpper();
594
595 AliInfo(Form("Options=%s",sopt.Data()));
596
597 if ( sopt.Contains("DIGITSTOREV1") )
598 {
599 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
600 }
601 else if ( sopt.Contains("DIGITSTOREV2R") )
602 {
603 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
604 }
605 else if ( sopt.Contains("DIGITSTOREV2S") )
606 {
607 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
608 }
609
610 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
611
612 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
22899106 613 }
614 return fDigitStore;
615}
94f6fba9 616
22899106 617//_____________________________________________________________________________
618void
619AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
22899106 620 TTree& clustersTree) const
621{
622 /// Write the trigger and cluster information into TreeR
9074a9a9 623
99c136e1 624 AliCodeTimerAuto("",0)
cc87ebcd 625
22899106 626 Bool_t ok(kFALSE);
9bf6860b 627 Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
628
cfeca9e2 629 const AliMUONRecoParam* rp = GetRecoParam();
630
631 if ( ! rp->CombineClusterTrackReco() )
9bf6860b 632 {
633 alone = kFALSE; // we'll get both tracker and trigger information in TreeR
634 }
635
22899106 636 if ( triggerStore )
637 {
00d46f24 638 ResponseRemovingChambers(triggerStore);
9bf6860b 639 ok = triggerStore->Connect(clustersTree,alone);
22899106 640 if (!ok)
b2d7df0b 641 {
22899106 642 AliError("Could not create triggerStore branches in TreeR");
cc87ebcd 643 }
cac2eb58 644 }
9bf6860b 645
9bf6860b 646 if ( !alone )
647 {
9ec6a948 648 if (!fClusterStore)
649 {
650 fClusterStore = new AliMUONClusterStoreV2;
651 }
9bf6860b 652
cfeca9e2 653 AliMUONVClusterServer* clusterServer = CreateClusterServer(*rp);
9bf6860b 654
655 TIter next(DigitStore()->CreateIterator());
cfeca9e2 656 clusterServer->UseDigits(next,DigitStore());
9bf6860b 657
658 AliMpArea area;
659
cfeca9e2 660 AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",clusterServer->ClassName()));
9bf6860b 661
662 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
663 {
cfeca9e2 664 if (rp->UseChamber(i))
9bf6860b 665 {
cfeca9e2 666 if ( ( i == 6 || i == 7 ) && rp->BypassSt4() ) continue;
667 if ( ( i == 8 || i == 9 ) && rp->BypassSt5() ) continue;
9bf6860b 668
cfeca9e2 669 clusterServer->Clusterize(i,*fClusterStore,area,rp);
9bf6860b 670 }
671 }
672
9ec6a948 673 Bool_t cok = fClusterStore->Connect(clustersTree,alone);
9bf6860b 674
675 if (!cok) AliError("Could not connect clusterStore to clusterTree");
676
9ec6a948 677 AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
9bf6860b 678
9ec6a948 679 StdoutToAliDebug(1,fClusterStore->Print());
9bf6860b 680 }
681
22899106 682 if (ok) // at least one type of branches created successfully
683 {
684 clustersTree.Fill();
685 }
9bf6860b 686
f73ad454 687 if (fClusterStore) fClusterStore->Clear();
cac2eb58 688}
cf464691 689
cfeca9e2 690//_____________________________________________________________________________
691const AliMUONRecoParam* AliMUONReconstructor::GetRecoParam()
692{
693 /// Get the recoparam from reconstruction
694 return dynamic_cast<const AliMUONRecoParam*>(AliReconstructor::GetRecoParam(AliReconstruction::GetDetIndex("MUON")));
695}
696
697
cf464691 698//_____________________________________________________________________________
22899106 699Bool_t
700AliMUONReconstructor::HasDigitConversion() const
cf464691 701{
22899106 702 /// We *do* have digit conversion, but we might advertise it only
703 /// if we want to save the digits.
704
705 TString opt(GetOption());
706 opt.ToUpper();
707 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
708 {
709 return kTRUE;
710 }
711 else
712 {
713 return kFALSE;
714 }
715}
f9247068 716
22899106 717//_____________________________________________________________________________
718void
719AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
720{
721 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
722 /// HasDigitConversion()==kFALSE
8cde4af5 723
22899106 724 if ( !clustersTree )
725 {
726 AliError("clustersTree is 0x0 !");
727 return;
728 }
b2d7df0b 729
93d7b017 730 ConvertDigits(rawReader,DigitStore(),TriggerStore());
c5ce806f 731
732 FillTreeR(TriggerStore(),*clustersTree);
22899106 733}
64b056bc 734
196471e9 735//_____________________________________________________________________________
22899106 736void
737AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
a2da7817 738{
22899106 739 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
740 /// AND HasDigitConversion()==kTRUE
741
99c136e1 742 AliCodeTimerAuto("",0)
93d7b017 743
22899106 744 AliDebug(1,"");
745
746 if (!digitsTree || !clustersTree)
747 {
748 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
749 digitsTree,clustersTree));
750 return;
751 }
d19b6003 752
22899106 753 if (!fDigitStore)
754 {
755 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
756 if (!fDigitStore)
757 {
758 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
759 }
760 else
761 {
762 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
763 }
764 }
765 if (!fTriggerStore)
766 {
767 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
768 if (!fTriggerStore)
769 {
770 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
771 }
772 else
773 {
774 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
775 }
776 }
777
778 if (!fTriggerStore && !fDigitStore)
779 {
780 AliError("No store at all. Nothing to do.");
781 return;
782 }
783
784 // insure we start with empty stores
785 if ( fDigitStore )
786 {
787 fDigitStore->Clear();
788 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
789 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
790 if (!ok)
791 {
792 AliError("Could not connect digitStore to digitsTree");
793 return;
794 }
795 }
796 if ( fTriggerStore )
797 {
798 fTriggerStore->Clear();
799 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
800 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
801 if (!ok)
802 {
803 AliError("Could not connect triggerStore to digitsTree");
804 return;
805 }
806 }
807
808 digitsTree->GetEvent(0);
809
810 if ( fDigitStore )
811 {
e729a0c8 812 // Insure we got calibrated digits (if we reconstruct from pure simulated,
813 // i.e. w/o going through raw data, this will be the case)
814 TIter next(fDigitStore->CreateIterator());
815 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
ca4733b5 816 if (digit && !digit->IsCalibrated())
e729a0c8 817 {
818 Calibrate(*fDigitStore);
819 }
22899106 820 }
821
c5ce806f 822 FillTreeR(fTriggerStore,*clustersTree);
cac2eb58 823}
196471e9 824
825//_____________________________________________________________________________
22899106 826AliMUONVTriggerStore*
827AliMUONReconstructor::TriggerStore() const
196471e9 828{
22899106 829 /// Return (and create if necessary and allowed) the trigger container
830 TString sopt(GetOption());
831 sopt.ToUpper();
832
833 if (sopt.Contains("TRIGGERDISABLE"))
834 {
835 delete fTriggerStore;
836 fTriggerStore = 0x0;
837 }
838 else
839 {
840 if (!fTriggerStore)
841 {
842 fTriggerStore = new AliMUONTriggerStoreV1;
843 }
844 }
845 return fTriggerStore;
196471e9 846}