]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON.cxx
Changes in tracker raw data decoding and mchview :
[u/mrichter/AliRoot.git] / MUON / AliMUON.cxx
CommitLineData
4c039060 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 **************************************************************************/
4c039060 15
88cb7938 16/* $Id$ */
17
3d1463c8 18//-----------------------------------------------------------------------------
d19b6003 19// Class AliMUON
20// ------------------
21// AliDetector class for MUON subsystem
22// providing simulation data management
3d1463c8 23//-----------------------------------------------------------------------------
fe4da5cc 24
4069c48e 25#include "AliMUON.h"
88cb7938 26
4069c48e 27#include "AliMUONSDigitizerV2.h"
28#include "AliMUONDigitizerV3.h"
29#include "AliMUONDigitMaker.h"
30#include "AliMUONCalibrationData.h"
31
32#include "AliMUONDigitStoreV1.h"
33#include "AliMUONVTriggerStore.h"
34#include "AliMUONHitStoreV1.h"
fe4da5cc 35
88cb7938 36#include "AliMUONChamberTrigger.h"
88cb7938 37#include "AliMUONConstants.h"
504d0837 38#include "AliMUONGeometry.h"
39#include "AliMUONGeometryTransformer.h"
d4bb94a1 40#include "AliMUONGeometryBuilder.h"
d1cd2474 41#include "AliMUONVGeometryBuilder.h"
4069c48e 42#include "AliMUONCommonGeometryBuilder.h"
d5609cfc 43#include "AliMUONSt1GeometryBuilderV2.h"
44#include "AliMUONSt2GeometryBuilderV2.h"
45#include "AliMUONSlatGeometryBuilder.h"
46#include "AliMUONTriggerGeometryBuilder.h"
47
4069c48e 48#include "AliMUONRawWriter.h"
49
50#include "AliLoader.h"
51#include "AliCDBManager.h"
52#include "AliRunDigitizer.h"
53#include "AliMC.h"
54#include "AliRun.h"
55#include "AliRawDataHeaderSim.h"
56#include "AliLog.h"
57
58#include <TObjArray.h>
7435e1f8 59
a9e2aefa 60// Defaults parameters for Z positions of chambers
61// taken from values for "stations" in AliMUON::AliMUON
62// const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
63// and from array "dstation" in AliMUONv1::CreateGeometry
64// Float_t dstation[5]={20., 20., 20, 20., 20.};
65// for tracking chambers,
66// according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
67// for the first and second chambers in the station, respectively,
68// and from "DTPLANES" in AliMUONv1::CreateGeometry
69// const Float_t DTPLANES = 15.;
70// for trigger chambers,
71// according to (Z1 = zch) and (Z2 = zch + DTPLANES)
72// for the first and second chambers in the station, respectively
fe4da5cc 73
13985652 74/// \cond CLASSIMP
75ClassImp(AliMUON)
76/// \endcond
30178c30 77
ce3f5e87 78//__________________________________________________________________
fe4da5cc 79AliMUON::AliMUON()
30178c30 80 : AliDetector(),
81 fNCh(0),
82 fNTrackingCh(0),
30178c30 83 fSplitLevel(0),
84 fChambers(0),
d4bb94a1 85 fGeometryBuilder(0),
30178c30 86 fAccCut(kFALSE),
87 fAccMin(0.),
88 fAccMax(0.),
89 fMaxStepGas(0.),
90 fMaxStepAlu(0.),
91 fMaxDestepGas(0.),
92 fMaxDestepAlu(0.),
93 fMaxIterPad(0),
ced309a5 94 fCurIterPad(0),
68585390 95 fTriggerScalerEvent(kFALSE),
e93b11d0 96 fTriggerResponseV1(kFALSE),
97 fTriggerCoinc44(0),
afb3ccf0 98 fTriggerEffCells(0),
8c0b5e70 99 fDigitizerWithNoise(1),
5fe36481 100 fIsTailEffect(kTRUE),
241560c2 101 fRawWriter(0x0),
7435e1f8 102 fDigitMaker(0x0),
5ee595ac 103 fHitStore(0x0),
92c23b09 104 fDigitStoreConcreteClassName(),
105 fCalibrationData(0x0)
fe4da5cc 106{
d19b6003 107/// Default Constructor
108
109 AliDebug(1,Form("default (empty) ctor this=%p",this));
1bd26093 110 fIshunt = 0;
fe4da5cc 111}
30178c30 112
ce3f5e87 113//__________________________________________________________________
9bf406e1 114AliMUON::AliMUON(const char *name, const char* title)
115 : AliDetector(name, title),
30178c30 116 fNCh(AliMUONConstants::NCh()),
117 fNTrackingCh(AliMUONConstants::NTrackingCh()),
30178c30 118 fSplitLevel(0),
119 fChambers(0),
d4bb94a1 120 fGeometryBuilder(0),
30178c30 121 fAccCut(kFALSE),
122 fAccMin(0.),
123 fAccMax(0.),
124 fMaxStepGas(0.1),
125 fMaxStepAlu(0.1),
126 fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200
127 fMaxDestepAlu(-1), // in the calculation of the tracking parameters
128 fMaxIterPad(0),
ced309a5 129 fCurIterPad(0),
e93b11d0 130 fTriggerScalerEvent(kFALSE),
131 fTriggerResponseV1(kFALSE),
132 fTriggerCoinc44(0),
afb3ccf0 133 fTriggerEffCells(0),
8c0b5e70 134 fDigitizerWithNoise(1),
5fe36481 135 fIsTailEffect(kTRUE),
241560c2 136 fRawWriter(0x0),
7435e1f8 137 fDigitMaker(new AliMUONDigitMaker),
5ee595ac 138 fHitStore(0x0),
92c23b09 139 fDigitStoreConcreteClassName("AliMUONDigitStoreV2S"),
140 fCalibrationData()
141
fe4da5cc 142{
92c23b09 143 /// Standard constructor
d19b6003 144
145 AliDebug(1,Form("ctor this=%p",this));
30178c30 146 fIshunt = 0;
92c23b09 147
e939a978 148 //PH SetMarkerColor(kRed);//
e118b27e 149
150 // Geometry builder
151 fGeometryBuilder = new AliMUONGeometryBuilder(this);
152
153 // Common geometry definitions
154 fGeometryBuilder
155 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
92c23b09 156
d5609cfc 157 // By default, add also all the needed geometry builders.
158 // If you want to change this from outside, please use ResetGeometryBuilder
159 // method, followed by AddGeometryBuilder ones.
92c23b09 160
d5609cfc 161 AddGeometryBuilder(new AliMUONSt1GeometryBuilderV2(this));
162 AddGeometryBuilder(new AliMUONSt2GeometryBuilderV2(this));
163 AddGeometryBuilder(new AliMUONSlatGeometryBuilder(this));
164 AddGeometryBuilder(new AliMUONTriggerGeometryBuilder(this));
165
166 //
167 // Creating List of Chambers
a9e2aefa 168 Int_t ch;
f665c1ea 169 fChambers = new TObjArray(AliMUONConstants::NCh());
7435e1f8 170 fChambers->SetOwner(kTRUE);
171
a9e2aefa 172 // Loop over stations
f665c1ea 173 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
a9e2aefa 174 // Loop over 2 chambers in the station
ce3f5e87 175 for (Int_t stCH = 0; stCH < 2; stCH++) {
176 //
177 //
178 // Default Parameters for Muon Tracking Stations
179 ch = 2 * st + stCH;
180 if (ch < AliMUONConstants::NTrackingCh()) {
181 fChambers->AddAt(new AliMUONChamber(ch),ch);
182 } else {
504d0837 183 fChambers->AddAt(new AliMUONChamberTrigger(ch, GetGeometryTransformer()),ch);
ce3f5e87 184 }
ce3f5e87 185 } // Chamber stCH (0, 1) in
a9e2aefa 186 } // Station st (0...)
92c23b09 187
188 Int_t runnumber = AliCDBManager::Instance()->GetRun();
189
190 fCalibrationData = new AliMUONCalibrationData(runnumber);
fe4da5cc 191}
30178c30 192
ce3f5e87 193//____________________________________________________________________
fe4da5cc 194AliMUON::~AliMUON()
195{
d19b6003 196/// Destructor
197
edee5e63 198 AliDebug(1,Form("dtor this=%p",this));
7435e1f8 199 delete fChambers;
d4bb94a1 200 delete fGeometryBuilder;
d5609cfc 201 delete fRawWriter;
241560c2 202 delete fDigitMaker;
7435e1f8 203 delete fHitStore;
92c23b09 204 delete fCalibrationData;
d1cd2474 205}
30178c30 206
d1cd2474 207//_____________________________________________________________________________
208void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
209{
d19b6003 210/// Add the geometry builder to the list
d1cd2474 211
d4bb94a1 212 fGeometryBuilder->AddBuilder(geomBuilder);
a897a37a 213}
c9d10ab5 214
504d0837 215//____________________________________________________________________
216const AliMUONGeometry* AliMUON::GetGeometry() const
217{
d19b6003 218/// Return geometry parametrisation
504d0837 219
220 if ( !fGeometryBuilder) {
221 AliWarningStream() << "GeometryBuilder not defined." << std::endl;
222 return 0;
223 }
224
225 return fGeometryBuilder->GetGeometry();
226}
227
228//____________________________________________________________________
229const AliMUONGeometryTransformer* AliMUON::GetGeometryTransformer() const
230{
d19b6003 231/// Return geometry parametrisation
504d0837 232
233 const AliMUONGeometry* kGeometry = GetGeometry();
234
235 if ( !kGeometry) return 0;
236
237 return kGeometry->GetTransformer();
238}
239
ce3f5e87 240//__________________________________________________________________
7435e1f8 241void
242AliMUON::MakeBranch(Option_t* opt)
a897a37a 243{
7435e1f8 244 /// Create branche(s) to hold MUON hits
245 AliDebug(1,"");
246
247 TString sopt(opt);
248 if ( sopt != "H" ) return;
249
250 if (!fHitStore)
251 {
252 fHitStore = new AliMUONHitStoreV1;
ae31c826 253 if ( gAlice->GetMCApp() )
7435e1f8 254 {
255 if ( gAlice->GetMCApp()->GetHitLists() )
256 {
257 // AliStack::PurifyKine needs to be able to loop on our hits
258 // to remap the track numbers.
259 gAlice->GetMCApp()->AddHitList(fHitStore->Collection());
6d2f7cbd 260 }
7435e1f8 261 }
262 }
263
264 TTree* treeH = fLoader->TreeH();
265
266 if (!treeH)
267 {
268 AliFatal("No TreeH");
307d9d04 269 }
7435e1f8 270
271 fHitStore->Connect(*treeH);
272}
273
274//__________________________________________________________________
275void
276AliMUON::SetTreeAddress()
277{
278 /// Set Hits tree address
279
280// if ( gAlice->GetMCApp() && fHitStore )
281// {
282// TList* l = gAlice->GetMCApp()->GetHitLists();
283// if ( l )
284// {
285// TObject* o = l->First();
286// if (o!=fHitStore->HitCollection())
287// {
288// AliError(Form("Something is strange hitcollection=%x",fHitStore->HitCollection()));
289// l->Print();
290// }
291// }
292// }
293}
294
295//_________________________________________________________________
296void
297AliMUON::ResetHits()
298{
299 /// Reset hits
300
301 AliDebug(1,"");
302 if (fHitStore) fHitStore->Clear();
a9e2aefa 303}
304
ce3f5e87 305//_________________________________________________________________
a897a37a 306void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
fe4da5cc 307{
d19b6003 308/// Set the inverse charge slope for chamber id
309
ce3f5e87 310 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
311 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
2682e810 312 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
313 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
fe4da5cc 314}
ce3f5e87 315//__________________________________________________________________
a897a37a 316void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
fe4da5cc 317{
d19b6003 318/// Set sigma of charge spread for chamber id
319
fe4da5cc 320 Int_t i=2*(id-1);
2682e810 321 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
322 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
fe4da5cc 323}
ce3f5e87 324//___________________________________________________________________
a897a37a 325void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
fe4da5cc 326{
d19b6003 327/// Set integration limits for charge spread
fe4da5cc 328 Int_t i=2*(id-1);
2682e810 329 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
330 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
fe4da5cc 331}
332
ce3f5e87 333//__________________________________________________________________
d09fafb0 334void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
fe4da5cc 335{
d19b6003 336/// Set maximum number for ADCcounts (saturation)
337
fe4da5cc 338 Int_t i=2*(id-1);
2682e810 339 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
340 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
fe4da5cc 341}
d4bb94a1 342
ce3f5e87 343//__________________________________________________________________
a897a37a 344void AliMUON::SetMaxStepGas(Float_t p1)
fe4da5cc 345{
d19b6003 346/// Set stepsize in gas
347
ce3f5e87 348 fMaxStepGas=p1;
fe4da5cc 349}
ce3f5e87 350//__________________________________________________________________
a897a37a 351void AliMUON::SetMaxStepAlu(Float_t p1)
fe4da5cc 352{
d19b6003 353/// Set step size in Alu
354
fe4da5cc 355 fMaxStepAlu=p1;
356}
ce3f5e87 357//__________________________________________________________________
a897a37a 358void AliMUON::SetMaxDestepGas(Float_t p1)
fe4da5cc 359{
d19b6003 360/// Set maximum step size in Gas
361
fe4da5cc 362 fMaxDestepGas=p1;
363}
ce3f5e87 364//__________________________________________________________________
a897a37a 365void AliMUON::SetMaxDestepAlu(Float_t p1)
fe4da5cc 366{
d19b6003 367/// Set maximum step size in Alu
368
ce3f5e87 369 fMaxDestepAlu=p1;
fe4da5cc 370}
d4bb94a1 371
d1cd2474 372//____________________________________________________________________
373Float_t AliMUON::GetMaxStepGas() const
374{
d19b6003 375/// Return stepsize in gas
d1cd2474 376
377 return fMaxStepGas;
378}
379
380//____________________________________________________________________
381Float_t AliMUON::GetMaxStepAlu() const
382{
d19b6003 383/// Return step size in Alu
d1cd2474 384
385 return fMaxStepAlu;
386}
387
388//____________________________________________________________________
389Float_t AliMUON::GetMaxDestepGas() const
390{
d19b6003 391/// Return maximum step size in Gas
d1cd2474 392
393 return fMaxDestepGas;
394}
395
396//____________________________________________________________________
397Float_t AliMUON::GetMaxDestepAlu() const
398{
d19b6003 399/// Return maximum step size in Gas
d1cd2474 400
401 return fMaxDestepAlu;
402}
d4bb94a1 403
883746f3 404//____________________________________________________________________
405 void AliMUON::SetAlign(Bool_t align)
a713db22 406{
d19b6003 407/// Set option for alignement to geometry builder
883746f3 408
409 fGeometryBuilder->SetAlign(align);
410}
fe4da5cc 411
82d1ac0a 412//____________________________________________________________________
413 void AliMUON::SetAlign(const TString& fileName, Bool_t align)
414{
d19b6003 415/// Set option for alignement to geometry builder
82d1ac0a 416
417 fGeometryBuilder->SetAlign(fileName, align);
418}
419
ce3f5e87 420//____________________________________________________________________
7435e1f8 421void AliMUON::SetResponseModel(Int_t id, const AliMUONResponse& response)
fe4da5cc 422{
d19b6003 423/// Set the response for chamber id
2682e810 424 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
fe4da5cc 425}
d19b6003 426
ce3f5e87 427//____________________________________________________________________
c92eb8ad 428AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
85a5290f 429{
a3249004 430/// Return digitizer
68585390 431
92c23b09 432 AliMUONDigitizerV3* digitizer = new AliMUONDigitizerV3(manager, fDigitizerWithNoise);
b89ac3d6 433 digitizer->SetCalibrationData(fCalibrationData);
92c23b09 434 return digitizer;
85a5290f 435}
68585390 436
ce3f5e87 437//_____________________________________________________________________
2ab0c725 438void AliMUON::SDigits2Digits()
439{
d19b6003 440/// Write TreeD here only
d963c261 441
d963c261 442 char hname[30];
88cb7938 443 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
444 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
445 fLoader->TreeD()->Reset();
2ab0c725 446}
a9e2aefa 447
d1775029 448//_____________________________________________________________________
449void AliMUON::Hits2SDigits()
450{
a3249004 451/// Perform Hits2Digits using SDigitizerV2
68585390 452
7435e1f8 453 AliMUONSDigitizerV2 sdigitizer;
454 sdigitizer.ExecuteTask();
d1775029 455}
68585390 456
39e39255 457//_____________________________________________________________________
458void AliMUON::Digits2Raw()
459{
d19b6003 460/// Convert digits of the current event to raw data
461
0014fbe8 462 AliRawDataHeaderSim header;
463
d5609cfc 464 if (!fRawWriter)
465 {
7435e1f8 466 fRawWriter = new AliMUONRawWriter;
467 AliDebug(1,Form("Creating %s",fRawWriter->ClassName()));
d5609cfc 468 if (fTriggerScalerEvent == kTRUE)
469 {
84ceeb06 470 fRawWriter->SetScalersNumbers();
d5609cfc 471 }
472 }
473
7435e1f8 474 fLoader->LoadDigits("READ");
475
476 TTree* treeD = fLoader->TreeD();
477
478 if (!treeD)
479 {
480 AliError("Could not get TreeD");
481 return;
482 }
483
484 AliMUONVTriggerStore* triggerStore = AliMUONVTriggerStore::Create(*treeD);
485 AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
486
487 triggerStore->Connect(*treeD,kFALSE);
488 digitStore->Connect(*treeD,kFALSE);
489
490 treeD->GetEvent(0);
491
0014fbe8 492 fRawWriter->SetHeader(header);
7435e1f8 493 if (!fRawWriter->Digits2Raw(digitStore,triggerStore))
d5609cfc 494 {
495 AliError("pb writting raw data");
496 }
7435e1f8 497
498 delete triggerStore;
499 delete digitStore;
500
501 fLoader->UnloadDigits();
39e39255 502}
68585390 503
241560c2 504//_____________________________________________________________________
505Bool_t AliMUON::Raw2SDigits(AliRawReader* rawReader)
506{
507/// Convert raw data to SDigit
241560c2 508
7435e1f8 509 fLoader->LoadDigits("READ");
241560c2 510 if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
511
7435e1f8 512 TTree* treeS = fLoader->TreeS();
513
514 AliMUONVDigitStore* sDigitStore = new AliMUONDigitStoreV1;
515 sDigitStore->Connect(*treeS);
516
517 fDigitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
241560c2 518
519 fLoader->WriteSDigits("OVERWRITE");
7435e1f8 520
241560c2 521 fLoader->UnloadSDigits();
522
7435e1f8 523 delete sDigitStore;
524
241560c2 525 return kTRUE;
241560c2 526}
527
ce3f5e87 528//_______________________________________________________________________
3fa6cfdd 529AliLoader* AliMUON::MakeLoader(const char* topfoldername)
530{
d19b6003 531/// Build standard getter (AliLoader type);
532/// if detector wants to use castomized getter, it must overload this method
8c343c7c 533
534 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
535 GetName(),topfoldername));
128843d9 536 fLoader = new AliLoader(GetName(),topfoldername);
241560c2 537
3fa6cfdd 538 return fLoader;
539}
ffd9faa2 540
d5609cfc 541//________________________________________________________________________
542void
543AliMUON::ResetGeometryBuilder()
544{
d19b6003 545/// Only to be used by "experts" wanting to change the geometry builders
546/// to be used.
547/// As the ctor of AliMUON now defines a default geometrybuilder, this
548/// ResetGeometryBuilder() must be called prior to call the
549/// AddGeometryBuilder()
550
d5609cfc 551 delete fGeometryBuilder;
552 fGeometryBuilder = new AliMUONGeometryBuilder(this);
553 fGeometryBuilder
554 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
555}
44b96781 556
557//____________________________________________________________________
558Bool_t AliMUON::GetTriggerResponseV1() const
559{
560///
561/// Returns fTriggerResponseV1
562///
563 return fTriggerResponseV1;
564
565}
566
e93b11d0 567//____________________________________________________________________
568Int_t AliMUON::GetTriggerCoinc44() const
569{
570///
571/// Returns fTriggerCoinc44
572///
573 return fTriggerCoinc44;
574
afb3ccf0 575}
576
577//____________________________________________________________________
88570609 578Bool_t AliMUON::GetTriggerEffCells() const
afb3ccf0 579{
580///
581/// Returns fTriggerEffCells
582///
583 return fTriggerEffCells;
584
e93b11d0 585}
586
a3249004 587//____________________________________________________________________
8c0b5e70 588Int_t AliMUON::GetDigitizerWithNoise() const
a3249004 589{
590///
591/// Returns fDigitizerWithNoise
592///
593 return fDigitizerWithNoise;
594
595}
596
b6c94614 597