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