]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUONReconstructor.cxx
more methods use the correction framework
[u/mrichter/AliRoot.git] / MUON / AliMUONReconstructor.cxx
... / ...
CommitLineData
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 **************************************************************************/
15/* $Id$ */
16
17//-----------------------------------------------------------------------------
18/// \class AliMUONReconstructor
19///
20/// Implementation of AliReconstructor for MUON subsystem.
21///
22/// The clustering mode and the associated parameters can be changed by using
23/// AliMUONRecoParam *muonRecoParam = AliMUONRecoParam::GetLow(High)FluxParam();
24/// muonRecoParam->Set...(); // see methods in AliMUONRecoParam.h for details
25/// AliRecoParam::Instance()->RegisterRecoParam(muonRecoParam);
26///
27/// Valid modes are :
28///
29/// SIMPLEFIT : use the AliMUONClusterFinderSimpleFit clusterizer
30///
31/// SIMPLEFITV3 : SIMPLEFIT with preclustering=PRECLUSTERV3
32///
33/// MLEM : use AliMUONClusterFinderMLEM and AliMUONPreClusterFinder for preclustering (default)
34/// MLEMV2 : MLEM with preclustering=PRECLUSTERV2
35/// MLEMV3 : MLEM with preclustering=PRECLUSTERV3
36///
37/// PRECLUSTER : use only AliMUONPreClusterFinder. Only for debug as
38/// the produced clusters do not have a position, hence the tracking will not
39/// work
40/// PRECLUSTERV2 : another version of the preclustering
41/// PRECLUSTERV3 : yet another version of the preclustering
42///
43/// COG : use AliMUONClusterFinderCOG clusterizer. Not really a production
44/// option either, as center-of-gravity is generally not a good estimate
45/// of the cluster position...
46///
47/// PEAKCOG : COG cluster finder around local maxima
48/// PEAKFIT : fit around local maxima with up to 3 peaks, COG otherwise
49///
50/// NOCLUSTERING : bypass completely the clustering stage
51///
52/// ------
53///
54/// The behavior of the MUON reconstruction can also be changed, besides
55/// the usual methods found in AliReconstruction (e.g. to disable tracking)
56/// by using AliReconstruction::SetOption("MUON",options)
57/// where options should be a space separated string.
58///
59/// Valid options are :
60///
61/// SAVEDIGITS : if you want to save in the TreeD the *calibrated* digits
62/// that are used for the clustering
63///
64/// DIGITSTOREV1 : use the V1 implementation of the digitstore
65/// DIGITSTOREV2R : use the V2R implementation of the digitstore
66///
67/// NOLOCALRECONSTRUCTION : for debug, to disable local reconstruction (and hence
68/// "recover" old behavior)
69///
70/// TRIGGERDISABLE : disable the treatment of MUON trigger
71///
72/// NOFASTTRKDECODER : makes the digit maker class use the non-high performance decoder
73/// AliMUONPayloadTracker instead of AliMUONTrackerDDLDecoder.
74///
75/// NOFASTTRGDECODER : makes the digit maker class use the non-high performance decoder
76/// AliMUONPayloadTrigger instead of AliMUONTriggerDDLDecoder.
77///
78/// NOFASTDECODERS : makes the digit maker class use the non-high performance decoders
79/// AliMUONPayloadTracker and AliMUONPayloadTrigger.
80///
81/// \author Laurent Aphecetche, Subatech
82//-----------------------------------------------------------------------------
83
84#include "AliMUONReconstructor.h"
85
86#include "AliMUONCalibrationData.h"
87#include "AliMUONClusterFinderCOG.h"
88#include "AliMUONClusterFinderMLEM.h"
89#include "AliMUONClusterFinderSimpleFit.h"
90#include "AliMUONClusterFinderPeakCOG.h"
91#include "AliMUONClusterFinderPeakFit.h"
92#include "AliMUONClusterStoreV1.h"
93#include "AliMUONClusterStoreV2.h"
94#include "AliMUONConstants.h"
95#include "AliMUONDigitCalibrator.h"
96#include "AliMUONDigitMaker.h"
97#include "AliMUONDigitStoreV1.h"
98#include "AliMUONDigitStoreV2R.h"
99#include "AliMUONGeometryTransformer.h"
100#include "AliMUONPreClusterFinder.h"
101#include "AliMUONPreClusterFinderV2.h"
102#include "AliMUONPreClusterFinderV3.h"
103#include "AliMUONSimpleClusterServer.h"
104#include "AliMUONTracker.h"
105#include "AliMUONTriggerCircuit.h"
106#include "AliMUONTriggerStoreV1.h"
107#include "AliMUONVClusterFinder.h"
108#include "AliMUONVClusterServer.h"
109#include "AliMUONVTrackStore.h"
110
111#include "AliMpArea.h"
112#include "AliMpCDB.h"
113#include "AliMpConstants.h"
114
115#include "AliRawReader.h"
116#include "AliCDBManager.h"
117#include "AliCodeTimer.h"
118#include "AliLog.h"
119
120#include <Riostream.h>
121#include <TObjArray.h>
122#include <TClonesArray.h>
123#include <TString.h>
124#include <TTree.h>
125
126/// \cond CLASSIMP
127ClassImp(AliMUONReconstructor)
128/// \endcond
129
130//_____________________________________________________________________________
131AliMUONReconstructor::AliMUONReconstructor() :
132AliReconstructor(),
133fDigitMaker(0x0),
134fTransformer(new AliMUONGeometryTransformer()),
135fDigitStore(0x0),
136fTriggerCircuit(0x0),
137fCalibrationData(0x0),
138fDigitCalibrator(0x0),
139fClusterServer(0x0),
140fTriggerStore(0x0),
141fTrackStore(0x0),
142fClusterStore(0x0)
143{
144 /// normal ctor
145
146 // Load mapping
147 if ( ! AliMpCDB::LoadDDLStore() ) {
148 AliFatal("Could not access mapping from OCDB !");
149 }
150
151 // Load geometry data
152 fTransformer->LoadGeometryData();
153
154}
155
156//_____________________________________________________________________________
157AliMUONReconstructor::~AliMUONReconstructor()
158{
159 /// dtor
160 delete fDigitMaker;
161 delete fDigitStore;
162 delete fTransformer;
163 delete fTriggerCircuit;
164 delete fCalibrationData;
165 delete fDigitCalibrator;
166 delete fClusterServer;
167 delete fTriggerStore;
168 delete fTrackStore;
169 delete fClusterStore;
170}
171
172//_____________________________________________________________________________
173void
174AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
175{
176 /// Calibrate the digitStore
177 if (!fDigitCalibrator)
178 {
179 CreateCalibrator();
180 }
181 AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
182 fDigitCalibrator->Calibrate(digitStore);
183}
184
185//_____________________________________________________________________________
186void
187AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
188 AliMUONVDigitStore* digitStore,
189 AliMUONVTriggerStore* triggerStore) const
190{
191 /// Convert raw data into digit and trigger stores
192 CreateDigitMaker();
193
194 AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
195 fDigitMaker->ClassName()))
196 fDigitMaker->Raw2Digits(rawReader,digitStore,triggerStore);
197 AliCodeTimerStop(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
198 fDigitMaker->ClassName()))
199 Calibrate(*digitStore);
200}
201
202//_____________________________________________________________________________
203void
204AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
205{
206 /// convert raw data into a digit tree
207 AliCodeTimerAuto("")
208
209 Bool_t alone = ( TriggerStore() == 0 );
210
211 Bool_t ok = DigitStore()->Connect(*digitsTree,alone);
212 if ( TriggerStore() )
213 {
214 ok = ok && TriggerStore()->Connect(*digitsTree,kFALSE);
215 }
216
217 if (!ok)
218 {
219 AliError("Could not make branches on TreeD");
220 }
221 else
222 {
223 ConvertDigits(rawReader,DigitStore(),TriggerStore());
224 AliCodeTimerStart("Fill digits")
225 digitsTree->Fill();
226 AliCodeTimerStop("Fill digits")
227 DigitStore()->Clear();
228 }
229}
230
231//_____________________________________________________________________________
232void
233AliMUONReconstructor::CreateDigitMaker() const
234{
235 /// Create (and create if necessary) the digit maker
236 if (fDigitMaker) return;
237
238 AliCodeTimerAuto("")
239
240 TString option = GetOption();
241 Bool_t enableErrorLogging = kTRUE;
242 Bool_t useFastTrackerDecoder = kTRUE;
243 Bool_t useFastTriggerDecoder = kTRUE;
244 if (option.Contains("NOFASTTRKDECODER"))
245 {
246 useFastTrackerDecoder = kFALSE;
247 }
248 if (option.Contains("NOFASTTRGDECODER"))
249 {
250 useFastTriggerDecoder = kFALSE;
251 }
252 if (option.Contains("NOFASTDECODERS"))
253 {
254 useFastTrackerDecoder = kFALSE;
255 useFastTriggerDecoder = kFALSE;
256 }
257 fDigitMaker = new AliMUONDigitMaker(
258 enableErrorLogging, useFastTrackerDecoder, useFastTriggerDecoder
259 );
260 option.ToUpper();
261 if ( option.Contains("SAVEDIGITS" ))
262 {
263 fDigitMaker->SetMakeTriggerDigits(kTRUE);
264 }
265}
266
267//_____________________________________________________________________________
268void
269AliMUONReconstructor::CreateTriggerCircuit() const
270{
271 /// Return (and create if necessary) the trigger circuit object
272 if (fTriggerCircuit) return;
273
274 AliCodeTimerAuto("")
275
276 fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
277
278}
279
280//_____________________________________________________________________________
281AliTracker*
282AliMUONReconstructor::CreateTracker() const
283{
284 /// Create the MUONTracker object
285
286 CreateTriggerCircuit();
287 CreateDigitMaker();
288 CreateClusterServer();
289
290 AliMUONTracker* tracker(0x0);
291
292 if ( ! GetRecoParam()->CombineClusterTrackReco() )
293 {
294 tracker = new AliMUONTracker(GetRecoParam(),
295 0x0,
296 *DigitStore(),
297 fDigitMaker,
298 fTransformer,
299 fTriggerCircuit);
300 }
301 else
302 {
303 tracker = new AliMUONTracker(GetRecoParam(),
304 fClusterServer,
305 *DigitStore(),
306 fDigitMaker,
307 fTransformer,
308 fTriggerCircuit);
309 }
310
311
312 return tracker;
313}
314
315//_____________________________________________________________________________
316AliMUONVClusterFinder*
317AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
318{
319 /// Create a given cluster finder instance
320
321 AliCodeTimerAutoGeneral("")
322
323 AliMUONVClusterFinder* clusterFinder(0x0);
324
325 TString opt(clusterFinderType);
326 opt.ToUpper();
327
328 if ( strstr(opt,"PRECLUSTERV2") )
329 {
330 clusterFinder = new AliMUONPreClusterFinderV2;
331 }
332 else if ( strstr(opt,"PRECLUSTERV3") )
333 {
334 clusterFinder = new AliMUONPreClusterFinderV3;
335 }
336 else if ( strstr(opt,"PRECLUSTER") )
337 {
338 clusterFinder = new AliMUONPreClusterFinder;
339 }
340 else if ( strstr(opt,"PEAKCOG") )
341 {
342 clusterFinder = new AliMUONClusterFinderPeakCOG(kFALSE,new AliMUONPreClusterFinder);
343 }
344 else if ( strstr(opt,"PEAKFIT") )
345 {
346 clusterFinder = new AliMUONClusterFinderPeakFit(kFALSE,new AliMUONPreClusterFinder);
347 }
348 else if ( strstr(opt,"COG") )
349 {
350 clusterFinder = new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder);
351 }
352 else if ( strstr(opt,"SIMPLEFITV3") )
353 {
354 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinderV3));
355 }
356 else if ( strstr(opt,"SIMPLEFIT") )
357 {
358 clusterFinder = new AliMUONClusterFinderSimpleFit(new AliMUONClusterFinderCOG(new AliMUONPreClusterFinder));
359 }
360 else if ( strstr(opt,"MLEM:DRAW") )
361 {
362 clusterFinder = new AliMUONClusterFinderMLEM(kTRUE,new AliMUONPreClusterFinder);
363 }
364 else if ( strstr(opt,"MLEMV3") )
365 {
366 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV3);
367 }
368 else if ( strstr(opt,"MLEMV2") )
369 {
370 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinderV2);
371 }
372 else if ( strstr(opt,"MLEM") )
373 {
374 clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
375 }
376 else
377 {
378 AliErrorClass(Form("clustering mode \"%s\" does not exist",opt.Data()));
379 return 0x0;
380 }
381
382 return clusterFinder;
383}
384
385//_____________________________________________________________________________
386void
387AliMUONReconstructor::CreateClusterServer() const
388{
389 /// Create cluster server
390
391 if ( fClusterServer ) return;
392
393 AliCodeTimerAuto("");
394
395 AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
396
397 if ( !clusterFinder ) return;
398
399 AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
400
401 fClusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
402}
403
404//_____________________________________________________________________________
405void
406AliMUONReconstructor::CreateCalibrator() const
407{
408 /// Create the calibrator
409
410 AliCodeTimerAuto("")
411
412 Int_t runNumber = AliCDBManager::Instance()->GetRun();
413
414 AliInfo("Calibration will occur.");
415
416 fCalibrationData = new AliMUONCalibrationData(runNumber);
417 if ( !fCalibrationData->IsValid() )
418 {
419 AliError("Could not retrieve calibrations !");
420 delete fCalibrationData;
421 fCalibrationData = 0x0;
422 return;
423 }
424
425 // Check that we get all the calibrations we'll need
426 if ( !fCalibrationData->Pedestals() ||
427 !fCalibrationData->Gains() ||
428 !fCalibrationData->HV() )
429 {
430 AliFatal("Could not access all required calibration data");
431 }
432
433 TString opt(GetOption());
434 opt.ToUpper();
435
436 if ( strstr(opt,"NOSTATUSMAP") )
437 {
438 AliWarning("NOSTATUSMAP is obsolete");
439 }
440
441 TString calibMode = GetRecoParam()->GetCalibrationMode();
442
443 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam(),calibMode.Data());
444}
445
446//_____________________________________________________________________________
447AliMUONVDigitStore*
448AliMUONReconstructor::DigitStore() const
449{
450 /// Return (and create if necessary) the digit container
451 if (!fDigitStore)
452 {
453 TString sopt(GetOption());
454 sopt.ToUpper();
455
456 AliInfo(Form("Options=%s",sopt.Data()));
457
458 if ( sopt.Contains("DIGITSTOREV1") )
459 {
460 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
461 }
462 else if ( sopt.Contains("DIGITSTOREV2R") )
463 {
464 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
465 }
466 else if ( sopt.Contains("DIGITSTOREV2S") )
467 {
468 fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
469 }
470
471 if (!fDigitStore) fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2R");
472
473 AliInfo(Form("Will use %s to store digits during reconstruction",fDigitStore->ClassName()));
474 }
475 return fDigitStore;
476}
477
478//_____________________________________________________________________________
479void
480AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
481 TTree& clustersTree) const
482{
483 /// Write the trigger and cluster information into TreeR
484
485 AliCodeTimerAuto("")
486
487 AliDebug(1,"");
488
489 Bool_t ok(kFALSE);
490 Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
491
492 if ( ! GetRecoParam()->CombineClusterTrackReco() )
493 {
494 alone = kFALSE; // we'll get both tracker and trigger information in TreeR
495 }
496
497 if ( triggerStore )
498 {
499 ok = triggerStore->Connect(clustersTree,alone);
500 if (!ok)
501 {
502 AliError("Could not create triggerStore branches in TreeR");
503 }
504 }
505
506 if ( !alone )
507 {
508 if (!fClusterStore)
509 {
510 fClusterStore = new AliMUONClusterStoreV2;
511 }
512
513 CreateClusterServer();
514
515 TIter next(DigitStore()->CreateIterator());
516 fClusterServer->UseDigits(next);
517
518 AliMpArea area;
519
520 AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
521
522 for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i )
523 {
524 if (GetRecoParam()->UseChamber(i))
525 {
526 if ( ( i == 6 || i == 7 ) && GetRecoParam()->BypassSt4() ) continue;
527 if ( ( i == 8 || i == 9 ) && GetRecoParam()->BypassSt5() ) continue;
528
529 fClusterServer->Clusterize(i,*fClusterStore,area);
530 }
531 }
532
533 Bool_t cok = fClusterStore->Connect(clustersTree,alone);
534
535 if (!cok) AliError("Could not connect clusterStore to clusterTree");
536
537 AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
538
539 StdoutToAliDebug(1,fClusterStore->Print());
540 }
541
542 if (ok) // at least one type of branches created successfully
543 {
544 clustersTree.Fill();
545 }
546
547 if (fClusterStore) fClusterStore->Clear();
548}
549
550//_____________________________________________________________________________
551Bool_t
552AliMUONReconstructor::HasDigitConversion() const
553{
554 /// We *do* have digit conversion, but we might advertise it only
555 /// if we want to save the digits.
556
557 TString opt(GetOption());
558 opt.ToUpper();
559 if ( opt.Contains("SAVEDIGITS" ) && !opt.Contains("NOLOCALRECONSTRUCTION") )
560 {
561 return kTRUE;
562 }
563 else
564 {
565 return kFALSE;
566 }
567}
568
569//_____________________________________________________________________________
570void
571AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
572{
573 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE AND
574 /// HasDigitConversion()==kFALSE
575
576 if ( !clustersTree )
577 {
578 AliError("clustersTree is 0x0 !");
579 return;
580 }
581
582 ConvertDigits(rawReader,DigitStore(),TriggerStore());
583
584 FillTreeR(TriggerStore(),*clustersTree);
585}
586
587//_____________________________________________________________________________
588void
589AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
590{
591 /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
592 /// AND HasDigitConversion()==kTRUE
593
594 AliCodeTimerAuto("")
595
596 AliDebug(1,"");
597
598 if (!digitsTree || !clustersTree)
599 {
600 AliError(Form("Tree is null : digitsTree=%p clustersTree=%p",
601 digitsTree,clustersTree));
602 return;
603 }
604
605 if (!fDigitStore)
606 {
607 fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
608 if (!fDigitStore)
609 {
610 AliError(Form("Could not get DigitStore from %s",digitsTree->GetName()));
611 }
612 else
613 {
614 AliInfo(Form("Created %s from %s",fDigitStore->ClassName(),digitsTree->GetName()));
615 }
616 }
617 if (!fTriggerStore)
618 {
619 fTriggerStore = AliMUONVTriggerStore::Create(*digitsTree);
620 if (!fTriggerStore)
621 {
622 AliError(Form("Could not get TriggerStore from %s",digitsTree->GetName()));
623 }
624 else
625 {
626 AliInfo(Form("Created %s from %s",fTriggerStore->ClassName(),digitsTree->GetName()));
627 }
628 }
629
630 if (!fTriggerStore && !fDigitStore)
631 {
632 AliError("No store at all. Nothing to do.");
633 return;
634 }
635
636 // insure we start with empty stores
637 if ( fDigitStore )
638 {
639 fDigitStore->Clear();
640 Bool_t alone = ( fTriggerStore ? kFALSE : kTRUE );
641 Bool_t ok = fDigitStore->Connect(*digitsTree,alone);
642 if (!ok)
643 {
644 AliError("Could not connect digitStore to digitsTree");
645 return;
646 }
647 }
648 if ( fTriggerStore )
649 {
650 fTriggerStore->Clear();
651 Bool_t alone = ( fDigitStore ? kFALSE : kTRUE );
652 Bool_t ok = fTriggerStore->Connect(*digitsTree,alone);
653 if (!ok)
654 {
655 AliError("Could not connect triggerStore to digitsTree");
656 return;
657 }
658 }
659
660 digitsTree->GetEvent(0);
661
662 if ( fDigitStore )
663 {
664 // Insure we got calibrated digits (if we reconstruct from pure simulated,
665 // i.e. w/o going through raw data, this will be the case)
666 TIter next(fDigitStore->CreateIterator());
667 AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(next());
668 if (digit && !digit->IsCalibrated())
669 {
670 Calibrate(*fDigitStore);
671 }
672 }
673
674 FillTreeR(fTriggerStore,*clustersTree);
675}
676
677//_____________________________________________________________________________
678AliMUONVTriggerStore*
679AliMUONReconstructor::TriggerStore() const
680{
681 /// Return (and create if necessary and allowed) the trigger container
682 TString sopt(GetOption());
683 sopt.ToUpper();
684
685 if (sopt.Contains("TRIGGERDISABLE"))
686 {
687 delete fTriggerStore;
688 fTriggerStore = 0x0;
689 }
690 else
691 {
692 if (!fTriggerStore)
693 {
694 fTriggerStore = new AliMUONTriggerStoreV1;
695 }
696 }
697 return fTriggerStore;
698}