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