]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONReconstructor.cxx
Add -Wconversion to Mac warnings
[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();
64f628e9 279
280 // Always make trigger digits
281 // (needed when calculating trigger chamber efficiency)
282 fDigitMaker->SetMakeTriggerDigits(kTRUE);
283
9074a9a9 284 if ( GetRecoParam()->TryRecover() )
285 {
286 fDigitMaker->SetTryRecover(kTRUE);
287 }
288 else
289 {
290 fDigitMaker->SetTryRecover(kFALSE);
291 }
22899106 292}
293
294//_____________________________________________________________________________
295void
296AliMUONReconstructor::CreateTriggerCircuit() const
297{
298 /// Return (and create if necessary) the trigger circuit object
299 if (fTriggerCircuit) return;
300
99c136e1 301 AliCodeTimerAuto("",0)
22899106 302
32ab62c9 303 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
22899106 304
32ab62c9 305}
8c0b5e70 306
22899106 307//_____________________________________________________________________________
308AliTracker*
d76c31f4 309AliMUONReconstructor::CreateTracker() const
22899106 310{
311 /// Create the MUONTracker object
ee103e97 312
22899106 313 CreateTriggerCircuit();
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(),
9bf6860b 323 fTransformer,
324 fTriggerCircuit);
325 }
326 else
327 {
a0dc65b4 328 tracker = new AliMUONTracker(GetRecoParam(),
329 fClusterServer,
9bf6860b 330 *DigitStore(),
9bf6860b 331 fTransformer,
332 fTriggerCircuit);
c5ce806f 333 }
22899106 334
22899106 335
336 return tracker;
b2d7df0b 337}
338
f9247068 339//_____________________________________________________________________________
c5ce806f 340AliMUONVClusterFinder*
9bf6860b 341AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
f9247068 342{
c5ce806f 343 /// Create a given cluster finder instance
22899106 344
99c136e1 345 AliCodeTimerAutoGeneral("",0)
06ca6d7b 346
f9247068 347 AliMUONVClusterFinder* clusterFinder(0x0);
348
c5ce806f 349 TString opt(clusterFinderType);
f9247068 350 opt.ToUpper();
351
93d7b017 352 if ( strstr(opt,"PRECLUSTERV2") )
353 {
354 clusterFinder = new AliMUONPreClusterFinderV2;
355 }
356 else if ( strstr(opt,"PRECLUSTERV3") )
357 {
358 clusterFinder = new AliMUONPreClusterFinderV3;
359 }
360 else if ( strstr(opt,"PRECLUSTER") )
f9247068 361 {
362 clusterFinder = new AliMUONPreClusterFinder;
363 }
3ab319aa 364 else if ( strstr(opt,"PEAKCOG") )
365 {
366 clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
367 }
368 else if ( strstr(opt,"PEAKFIT") )
369 {
370 clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
371 }
f9247068 372 else if ( strstr(opt,"COG") )
373 {
93d7b017 374 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
f9247068 375 }
93d7b017 376 else if ( strstr(opt,"SIMPLEFITV3") )
377 {
378 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
379 }
f9247068 380 else if ( strstr(opt,"SIMPLEFIT") )
381 {
93d7b017 382 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
f9247068 383 }
384 else if ( strstr(opt,"MLEM:DRAW") )
385 {
93d7b017 386 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
f9247068 387 }
93d7b017 388 else if ( strstr(opt,"MLEMV3") )
389 {
390 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
391 }
392 else if ( strstr(opt,"MLEMV2") )
393 {
394 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
395 }
f9247068 396 else if ( strstr(opt,"MLEM") )
397 {
93d7b017 398 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
f9247068 399 }
22899106 400 else
401 {
9bf6860b 402 AliErrorClass(Form("clustering mode \"%s\" does not exist",opt.Data()));
c5ce806f 403 return 0x0;
22899106 404 }
f9247068 405
c5ce806f 406 return clusterFinder;
407}
408
409//_____________________________________________________________________________
410void
411AliMUONReconstructor::CreateClusterServer() const
412{
413 /// Create cluster server
414
415 if ( fClusterServer ) return;
416
99c136e1 417 AliCodeTimerAuto("",0);
9bf6860b 418
15d30ed4 419 AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
c5ce806f 420
421 if ( !clusterFinder ) return;
422
3304fa09 423 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
f9247068 424
9bf6860b 425 fClusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
f9247068 426}
427
cac2eb58 428//_____________________________________________________________________________
22899106 429void
00d46f24 430AliMUONReconstructor::CreateCalibrationData() const
cac2eb58 431{
22899106 432 /// Create the calibrator
2457f726 433
00d46f24 434 AliCodeTimerAuto("",0);
3bc8b580 435
22899106 436 Int_t runNumber = AliCDBManager::Instance()->GetRun();
3bc8b580 437
22899106 438 fCalibrationData = new AliMUONCalibrationData(runNumber);
439 if ( !fCalibrationData->IsValid() )
440 {
441 AliError("Could not retrieve calibrations !");
442 delete fCalibrationData;
443 fCalibrationData = 0x0;
444 return;
445 }
446
00977a64 447 // It is now time to check whether we have everything to proceed.
448 // What we need depends on whether both tracker and trigger
449 // are in the readout chain, and what specific "bad channel policy"
450 // we use
451
452 Bool_t kTracker(kFALSE);
453 Bool_t kTrigger(kFALSE);
454
455 const AliRunInfo* runInfo = GetRunInfo();
456 if (!runInfo)
457 {
458 AliError("Could not get runinfo ?")
459 }
460 else
461 {
462 TString detectors(runInfo->GetActiveDetectors());
463 if (detectors.Contains("MUONTRK")) kTracker=kTRUE;
464 if (detectors.Contains("MUONTRG")) kTrigger=kTRUE;
465 }
466
467 AliInfo(Form("Run with MUON TRIGGER : %s and MUON TRACKER : %s",
468 kTrigger ? "YES":"NO" ,
469 kTracker ? "YES":"NO"));
470
471 if ( kTracker )
22899106 472 {
00977a64 473 // Check that we get all the calibrations we'll need
474 if ( !fCalibrationData->Pedestals() ||
475 !fCalibrationData->Gains() )
476 {
477 AliFatal(Form("Could not access all required calibration data (PED %p GAIN %p)",
478 fCalibrationData->Pedestals(),fCalibrationData->Gains()));
479 }
480
481 if ( !fCalibrationData->HV() )
482 {
483 // Special treatment of HV. We only break if the values
484 // are not there *AND* we cut on them.
485 UInt_t mask = GetRecoParam()->PadGoodnessMask();
486 TString smask(AliMUONPadStatusMaker::AsCondition(mask));
487 if ( smask.Contains("HV") )
488 {
489 AliFatal("Could not access all required calibration data (HV)");
490 }
491 }
9ffe3ef4 492 }
00d46f24 493}
494
495//_____________________________________________________________________________
496void
497AliMUONReconstructor::CreateCalibrator() const
498{
499 /// Create the calibrator
500
501 AliCodeTimerAuto("",0);
502
503 if ( ! fCalibrationData )
504 CreateCalibrationData();
505
506 AliInfo("Calibration will occur.");
507
22899106 508 TString opt(GetOption());
509 opt.ToUpper();
b2d7df0b 510
22899106 511 if ( strstr(opt,"NOSTATUSMAP") )
512 {
22f7c9ba 513 AliWarning("NOSTATUSMAP is obsolete");
22899106 514 }
22f7c9ba 515
de98fdc9 516 TString calibMode = GetRecoParam()->GetCalibrationMode();
517
de487b6e 518 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam(),calibMode.Data());
22899106 519}
9c4b1ee7 520
00d46f24 521//_____________________________________________________________________________
522void
523AliMUONReconstructor::ResponseRemovingChambers(AliMUONVTriggerStore* triggerStore) const
524{
525 /// Update trigger information with informatins obtained after
526 /// re-calculation of trigger response
527 AliCodeTimerAuto("",0);
528
529 if ( ! fCalibrationData )
530 CreateCalibrationData();
531
532 if ( ! fTriggerProcessor )
533 fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
534
535 fTriggerProcessor->ResponseRemovingChambers(*triggerStore);
536}
537
22899106 538//_____________________________________________________________________________
539AliMUONVDigitStore*
540AliMUONReconstructor::DigitStore() const
541{
542 /// Return (and create if necessary) the digit container
543 if (!fDigitStore)
544 {
93d7b017 545 TString sopt(GetOption());
546 sopt.ToUpper();
547
548 AliInfo(Form("Options=%s",sopt.Data()));
549
550 if ( sopt.Contains("DIGITSTOREV1") )
551 {
552 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
553 }
554 else if ( sopt.Contains("DIGITSTOREV2R") )
555 {
556 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
557 }
558 else if ( sopt.Contains("DIGITSTOREV2S") )
559 {
560 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
561 }
562
563 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
564
565 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
22899106 566 }
567 return fDigitStore;
568}
94f6fba9 569
22899106 570//_____________________________________________________________________________
571void
572AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
22899106 573 TTree& clustersTree) const
574{
575 /// Write the trigger and cluster information into TreeR
9074a9a9 576
99c136e1 577 AliCodeTimerAuto("",0)
cc87ebcd 578
22899106 579 Bool_t ok(kFALSE);
9bf6860b 580 Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
581
a0dc65b4 582 if ( ! GetRecoParam()->CombineClusterTrackReco() )
9bf6860b 583 {
584 alone = kFALSE; // we'll get both tracker and trigger information in TreeR
585 }
586
22899106 587 if ( triggerStore )
588 {
00d46f24 589 ResponseRemovingChambers(triggerStore);
9bf6860b 590 ok = triggerStore->Connect(clustersTree,alone);
22899106 591 if (!ok)
b2d7df0b 592 {
22899106 593 AliError("Could not create triggerStore branches in TreeR");
cc87ebcd 594 }
cac2eb58 595 }
9bf6860b 596
9bf6860b 597 if ( !alone )
598 {
9ec6a948 599 if (!fClusterStore)
600 {
601 fClusterStore = new AliMUONClusterStoreV2;
602 }
9bf6860b 603
604 CreateClusterServer();
605
606 TIter next(DigitStore()->CreateIterator());
2e2d0c44 607 fClusterServer->UseDigits(next,DigitStore());
9bf6860b 608
609 AliMpArea area;
610
611 AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
612
613 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
614 {
a0dc65b4 615 if (GetRecoParam()->UseChamber(i))
9bf6860b 616 {
a0dc65b4 617 if ( ( i == 6 || i == 7 ) && GetRecoParam()->BypassSt4() ) continue;
618 if ( ( i == 8 || i == 9 ) && GetRecoParam()->BypassSt5() ) continue;
9bf6860b 619
35be7ed7 620 fClusterServer->Clusterize(i,*fClusterStore,area,GetRecoParam());
9bf6860b 621 }
622 }
623
9ec6a948 624 Bool_t cok = fClusterStore->Connect(clustersTree,alone);
9bf6860b 625
626 if (!cok) AliError("Could not connect clusterStore to clusterTree");
627
9ec6a948 628 AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
9bf6860b 629
9ec6a948 630 StdoutToAliDebug(1,fClusterStore->Print());
9bf6860b 631 }
632
22899106 633 if (ok) // at least one type of branches created successfully
634 {
635 clustersTree.Fill();
636 }
9bf6860b 637
f73ad454 638 if (fClusterStore) fClusterStore->Clear();
cac2eb58 639}
cf464691 640
641//_____________________________________________________________________________
22899106 642Bool_t
643AliMUONReconstructor::HasDigitConversion() const
cf464691 644{
22899106 645 /// We *do* have digit conversion, but we might advertise it only
646 /// if we want to save the digits.
647
648 TString opt(GetOption());
649 opt.ToUpper();
650 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
651 {
652 return kTRUE;
653 }
654 else
655 {
656 return kFALSE;
657 }
658}
f9247068 659
22899106 660//_____________________________________________________________________________
661void
662AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
663{
664 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
665 /// HasDigitConversion()==kFALSE
8cde4af5 666
22899106 667 if ( !clustersTree )
668 {
669 AliError("clustersTree is 0x0 !");
670 return;
671 }
b2d7df0b 672
93d7b017 673 ConvertDigits(rawReader,DigitStore(),TriggerStore());
c5ce806f 674
675 FillTreeR(TriggerStore(),*clustersTree);
22899106 676}
64b056bc 677
196471e9 678//_____________________________________________________________________________
22899106 679void
680AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
a2da7817 681{
22899106 682 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
683 /// AND HasDigitConversion()==kTRUE
684
99c136e1 685 AliCodeTimerAuto("",0)
93d7b017 686
22899106 687 AliDebug(1,"");
688
689 if (!digitsTree || !clustersTree)
690 {
691 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
692 digitsTree,clustersTree));
693 return;
694 }
d19b6003 695
22899106 696 if (!fDigitStore)
697 {
698 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
699 if (!fDigitStore)
700 {
701 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
702 }
703 else
704 {
705 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
706 }
707 }
708 if (!fTriggerStore)
709 {
710 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
711 if (!fTriggerStore)
712 {
713 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
714 }
715 else
716 {
717 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
718 }
719 }
720
721 if (!fTriggerStore && !fDigitStore)
722 {
723 AliError("No store at all. Nothing to do.");
724 return;
725 }
726
727 // insure we start with empty stores
728 if ( fDigitStore )
729 {
730 fDigitStore->Clear();
731 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
732 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
733 if (!ok)
734 {
735 AliError("Could not connect digitStore to digitsTree");
736 return;
737 }
738 }
739 if ( fTriggerStore )
740 {
741 fTriggerStore->Clear();
742 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
743 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
744 if (!ok)
745 {
746 AliError("Could not connect triggerStore to digitsTree");
747 return;
748 }
749 }
750
751 digitsTree->GetEvent(0);
752
753 if ( fDigitStore )
754 {
e729a0c8 755 // Insure we got calibrated digits (if we reconstruct from pure simulated,
756 // i.e. w/o going through raw data, this will be the case)
757 TIter next(fDigitStore->CreateIterator());
758 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
ca4733b5 759 if (digit && !digit->IsCalibrated())
e729a0c8 760 {
761 Calibrate(*fDigitStore);
762 }
22899106 763 }
764
c5ce806f 765 FillTreeR(fTriggerStore,*clustersTree);
cac2eb58 766}
196471e9 767
768//_____________________________________________________________________________
22899106 769AliMUONVTriggerStore*
770AliMUONReconstructor::TriggerStore() const
196471e9 771{
22899106 772 /// Return (and create if necessary and allowed) the trigger container
773 TString sopt(GetOption());
774 sopt.ToUpper();
775
776 if (sopt.Contains("TRIGGERDISABLE"))
777 {
778 delete fTriggerStore;
779 fTriggerStore = 0x0;
780 }
781 else
782 {
783 if (!fTriggerStore)
784 {
785 fTriggerStore = new AliMUONTriggerStoreV1;
786 }
787 }
788 return fTriggerStore;
196471e9 789}