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