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