]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON.cxx
Updated for replacement of AliMpReader with AliMpSectorReader
[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
a9e2aefa 18
19///////////////////////////////////////////////
fe4da5cc 20// Manager and hits classes for set:MUON //
21////////////////////////////////////////////////
22
88cb7938 23#include "Riostream.h"
24
25#include <AliPDG.h>
a897a37a 26#include <TBRIK.h>
88cb7938 27#include <TCanvas.h>
28#include <TDirectory.h>
29#include <TFile.h>
94de3818 30#include <TGeometry.h>
88cb7938 31#include <TMinuit.h>
fe4da5cc 32#include <TNode.h>
88cb7938 33#include <TNtuple.h>
fe4da5cc 34#include <TObjArray.h>
88cb7938 35#include <TObject.h>
36#include <TObjectTable.h>
37#include <TPad.h>
a897a37a 38#include <TParticle.h>
39#include <TROOT.h>
88cb7938 40#include <TRandom.h>
41#include <TRotMatrix.h>
42#include <TTUBE.h>
a9e2aefa 43#include <TTUBE.h>
88cb7938 44#include <TTree.h>
45#include <TVector.h>
46#include <TVirtualMC.h>
fe4da5cc 47
d4bb94a1 48//#include "AliHeader.h"
88cb7938 49#include "AliLoader.h"
dbb4e169 50#include "AliRunDigitizer.h"
307d9d04 51#include "AliMC.h"
fac3a970 52#include "AliRun.h"
fe4da5cc 53#include "AliMUON.h"
88cb7938 54#include "AliMUONChamberTrigger.h"
88cb7938 55#include "AliMUONConstants.h"
ffd9faa2 56#include "AliMUONHit.h"
a9e2aefa 57#include "AliMUONRawCluster.h"
88cb7938 58#include "AliMUONTransientDigit.h"
ecfa008b 59#include "AliMUONTriggerCircuit.h"
d4bb94a1 60#include "AliMUONGeometryBuilder.h"
e118b27e 61#include "AliMUONCommonGeometryBuilder.h"
d1cd2474 62#include "AliMUONVGeometryBuilder.h"
e118b27e 63#include "AliMUONGeometryDEIndexing.h"
a713db22 64#include "AliMUONGeometrySegmentation.h"
dbb4e169 65#include "AliMUONDigitizerv2.h"
d1775029 66#include "AliMUONSDigitizerv1.h"
39e39255 67#include "AliMUONRawData.h"
002920d1 68#include "AliMUONFactoryV2.h"
8c343c7c 69#include "AliLog.h"
a9e2aefa 70
71// Defaults parameters for Z positions of chambers
72// taken from values for "stations" in AliMUON::AliMUON
73// const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
74// and from array "dstation" in AliMUONv1::CreateGeometry
75// Float_t dstation[5]={20., 20., 20, 20., 20.};
76// for tracking chambers,
77// according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
78// for the first and second chambers in the station, respectively,
79// and from "DTPLANES" in AliMUONv1::CreateGeometry
80// const Float_t DTPLANES = 15.;
81// for trigger chambers,
82// according to (Z1 = zch) and (Z2 = zch + DTPLANES)
83// for the first and second chambers in the station, respectively
fe4da5cc 84
fe4da5cc 85ClassImp(AliMUON)
30178c30 86
ce3f5e87 87//__________________________________________________________________
fe4da5cc 88AliMUON::AliMUON()
30178c30 89 : AliDetector(),
90 fNCh(0),
91 fNTrackingCh(0),
92 fMUONData(0),
93 fSplitLevel(0),
94 fChambers(0),
30178c30 95 fTriggerCircuits(0),
d4bb94a1 96 fGeometryBuilder(0),
e118b27e 97 fDEIndexing(0),
30178c30 98 fAccCut(kFALSE),
99 fAccMin(0.),
100 fAccMax(0.),
101 fMaxStepGas(0.),
102 fMaxStepAlu(0.),
103 fMaxDestepGas(0.),
104 fMaxDestepAlu(0.),
105 fMaxIterPad(0),
edee5e63 106 fCurIterPad(0)
fe4da5cc 107{
de05461e 108// Default Constructor
109//
edee5e63 110 AliDebug(1,Form("default (empty) ctor this=%p",this));
1bd26093 111 fIshunt = 0;
fe4da5cc 112}
30178c30 113
ce3f5e87 114//__________________________________________________________________
fe4da5cc 115AliMUON::AliMUON(const char *name, const char *title)
30178c30 116 : AliDetector(name,title),
117 fNCh(AliMUONConstants::NCh()),
118 fNTrackingCh(AliMUONConstants::NTrackingCh()),
119 fMUONData(0),
120 fSplitLevel(0),
121 fChambers(0),
30178c30 122 fTriggerCircuits(0),
d4bb94a1 123 fGeometryBuilder(0),
e118b27e 124 fDEIndexing(0),
30178c30 125 fAccCut(kFALSE),
126 fAccMin(0.),
127 fAccMax(0.),
128 fMaxStepGas(0.1),
129 fMaxStepAlu(0.1),
130 fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200
131 fMaxDestepAlu(-1), // in the calculation of the tracking parameters
132 fMaxIterPad(0),
edee5e63 133 fCurIterPad(0)
fe4da5cc 134{
edee5e63 135 AliDebug(1,Form("ctor this=%p",this));
30178c30 136 fIshunt = 0;
a897a37a 137
ce3f5e87 138 SetMarkerColor(kRed);//
e118b27e 139
140 // Geometry builder
141 fGeometryBuilder = new AliMUONGeometryBuilder(this);
142
143 // Common geometry definitions
144 fGeometryBuilder
145 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
146
147 // Define the global transformation:
148 // Transformation from the old ALICE coordinate system to a new one:
149 // x->-x, z->-z
150 TGeoRotation* rotGlobal
151 = new TGeoRotation("rotGlobal", 90., 180., 90., 90., 180., 0.);
152 fGeometryBuilder
153 ->SetGlobalTransformation (TGeoCombiTrans(0., 0., 0., rotGlobal));
154
155 // Detection elements indexing
156 fDEIndexing = new AliMUONGeometryDEIndexing();
157
a9e2aefa 158//
ce3f5e87 159// Creating List of Chambers
a9e2aefa 160 Int_t ch;
f665c1ea 161 fChambers = new TObjArray(AliMUONConstants::NCh());
d1cd2474 162
a9e2aefa 163 // Loop over stations
f665c1ea 164 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
a9e2aefa 165 // Loop over 2 chambers in the station
ce3f5e87 166 for (Int_t stCH = 0; stCH < 2; stCH++) {
167 //
168 //
169 // Default Parameters for Muon Tracking Stations
170 ch = 2 * st + stCH;
171 if (ch < AliMUONConstants::NTrackingCh()) {
172 fChambers->AddAt(new AliMUONChamber(ch),ch);
173 } else {
174 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
175 }
176 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
d1cd2474 177 //chamber->SetGid(0);
ce3f5e87 178 // Default values for Z of chambers
179 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
180 //
181 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
182 // Set chamber inner and outer radius to default
f4a7360f 183 chamber->SetRInner(AliMUONConstants::Dmin(st)/2.);
184 chamber->SetROuter(AliMUONConstants::Dmax(st)/2.);
ce3f5e87 185 //
186 } // Chamber stCH (0, 1) in
a9e2aefa 187 } // Station st (0...)
ce3f5e87 188
ce3f5e87 189 // cp new design of AliMUONTriggerDecision
190 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
191 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
192 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
193 }
fe4da5cc 194}
30178c30 195
ce3f5e87 196//____________________________________________________________________
30178c30 197AliMUON::AliMUON(const AliMUON& rMUON)
198 : AliDetector(rMUON)
a9e2aefa 199{
30178c30 200// Protected copy constructor
201
8c343c7c 202 AliFatal("Not implemented.");
a9e2aefa 203}
30178c30 204
ce3f5e87 205//____________________________________________________________________
fe4da5cc 206AliMUON::~AliMUON()
207{
de05461e 208// Destructor
edee5e63 209 AliDebug(1,Form("dtor this=%p",this));
ce3f5e87 210 fIshunt = 0;
d1cd2474 211
c6df4ef2 212 if (fChambers){
213 fChambers->Delete();
214 delete fChambers;
215 }
216 if (fTriggerCircuits){
217 fTriggerCircuits->Delete();
218 delete fTriggerCircuits;
219 }
220 delete fMUONData;
d4bb94a1 221 delete fGeometryBuilder;
e118b27e 222 delete fDEIndexing;
d1cd2474 223}
30178c30 224
225//________________________________________________________________________
226AliMUON& AliMUON::operator = (const AliMUON& rhs)
227{
228// Protected assignement operator
229
230 if (this == &rhs) return *this;
231
8c343c7c 232 AliFatal("Not implemented.");
30178c30 233
234 return *this;
235}
236
d1cd2474 237//_____________________________________________________________________________
238void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
239{
240// Adds the geometry builder to the list
241// ---
242
d4bb94a1 243 fGeometryBuilder->AddBuilder(geomBuilder);
a897a37a 244}
c9d10ab5 245
ce3f5e87 246//____________________________________________________________________
fe4da5cc 247void AliMUON::BuildGeometry()
248{
de05461e 249// Geometry for event display
c9d10ab5 250
002920d1 251
ae89d471 252// for (Int_t i = 0; i < AliMUONConstants::NCh(); i++)
253// this->Chamber(i).SegmentationModel2(1)->Draw("eventdisplay");// to be check !
254
002920d1 255
fe4da5cc 256}
c9d10ab5 257
ce3f5e87 258//__________________________________________________________________
259void AliMUON::SetTreeAddress()
a897a37a 260{
ce3f5e87 261 GetMUONData()->SetLoader(fLoader);
d1775029 262 // GetMUONData()->MakeBranch("D,S,RC");
263 // GetMUONData()->SetTreeAddress("H,D,S,RC");
52c9bc11 264 GetMUONData()->SetTreeAddress("H");
307d9d04 265 if (fHits != GetMUONData()->Hits()) {
ae31c826 266 if ( gAlice->GetMCApp() )
6d2f7cbd 267 if ( gAlice->GetMCApp()->GetHitLists() ) {
268 fHits = GetMUONData()->Hits();
269 gAlice->GetMCApp()->AddHitList(fHits); // For purifyKine, only necessary when Hit list is created in AliMUONData
270 }
307d9d04 271 }
6d2f7cbd 272 fHits = GetMUONData()->Hits(); // Added by Ivana to use the methods FisrtHit, NextHit of AliDetector
a9e2aefa 273}
274
fe4da5cc 275//___________________________________________
a9e2aefa 276void AliMUON::SetChambersZ(const Float_t *Z)
277{
278 // Set Z values for all chambers (tracking and trigger)
279 // from the array pointed to by "Z"
f665c1ea 280 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
2682e810 281 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
f665c1ea 282 return;
a9e2aefa 283}
ce3f5e87 284//_________________________________________________________________
a9e2aefa 285void AliMUON::SetChambersZToDefault()
fe4da5cc 286{
a9e2aefa 287 // Set Z values for all chambers (tracking and trigger)
288 // to default values
f665c1ea 289 SetChambersZ(AliMUONConstants::DefaultChamberZ());
a9e2aefa 290 return;
fe4da5cc 291}
ce3f5e87 292//_________________________________________________________________
a897a37a 293void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
fe4da5cc 294{
de05461e 295// Set the inverse charge slope for chamber id
ce3f5e87 296 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
297 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
2682e810 298 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
299 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
fe4da5cc 300}
ce3f5e87 301//__________________________________________________________________
a897a37a 302void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
fe4da5cc 303{
de05461e 304// Set sigma of charge spread for chamber id
fe4da5cc 305 Int_t i=2*(id-1);
2682e810 306 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
307 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
fe4da5cc 308}
ce3f5e87 309//___________________________________________________________________
a897a37a 310void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
fe4da5cc 311{
de05461e 312// Set integration limits for charge spread
fe4da5cc 313 Int_t i=2*(id-1);
2682e810 314 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
315 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
fe4da5cc 316}
317
ce3f5e87 318//__________________________________________________________________
d09fafb0 319void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
fe4da5cc 320{
de05461e 321// Set maximum number for ADCcounts (saturation)
fe4da5cc 322 Int_t i=2*(id-1);
2682e810 323 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
324 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
fe4da5cc 325}
d4bb94a1 326
ce3f5e87 327//__________________________________________________________________
a897a37a 328void AliMUON::SetMaxStepGas(Float_t p1)
fe4da5cc 329{
de05461e 330// Set stepsize in gas
ce3f5e87 331 fMaxStepGas=p1;
fe4da5cc 332}
ce3f5e87 333//__________________________________________________________________
a897a37a 334void AliMUON::SetMaxStepAlu(Float_t p1)
fe4da5cc 335{
de05461e 336// Set step size in Alu
fe4da5cc 337 fMaxStepAlu=p1;
338}
ce3f5e87 339//__________________________________________________________________
a897a37a 340void AliMUON::SetMaxDestepGas(Float_t p1)
fe4da5cc 341{
de05461e 342// Set maximum step size in Gas
fe4da5cc 343 fMaxDestepGas=p1;
344}
ce3f5e87 345//__________________________________________________________________
a897a37a 346void AliMUON::SetMaxDestepAlu(Float_t p1)
fe4da5cc 347{
de05461e 348// Set maximum step size in Alu
ce3f5e87 349 fMaxDestepAlu=p1;
fe4da5cc 350}
d4bb94a1 351
d1cd2474 352//____________________________________________________________________
353Float_t AliMUON::GetMaxStepGas() const
354{
355// Return stepsize in gas
356
357 return fMaxStepGas;
358}
359
360//____________________________________________________________________
361Float_t AliMUON::GetMaxStepAlu() const
362{
363// Return step size in Alu
364
365 return fMaxStepAlu;
366}
367
368//____________________________________________________________________
369Float_t AliMUON::GetMaxDestepGas() const
370{
371// Return maximum step size in Gas
372
373 return fMaxDestepGas;
374}
375
376//____________________________________________________________________
377Float_t AliMUON::GetMaxDestepAlu() const
378{
379// Return maximum step size in Gas
380
381 return fMaxDestepAlu;
382}
d4bb94a1 383
883746f3 384//____________________________________________________________________
385 void AliMUON::SetAlign(Bool_t align)
a713db22 386{
883746f3 387 // Sets option for alignement to geometry builder
388
389 fGeometryBuilder->SetAlign(align);
390}
391
a713db22 392//____________________________________________________________________
393void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliMUONGeometrySegmentation* segmentation)
394{
de05461e 395// Set the segmentation for chamber id cathode isec
2682e810 396 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
fe4da5cc 397
398}
ce3f5e87 399//____________________________________________________________________
a9e2aefa 400void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
fe4da5cc 401{
de05461e 402// Set the response for chamber id
2682e810 403 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
fe4da5cc 404}
ce3f5e87 405//____________________________________________________________________
c92eb8ad 406AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
85a5290f 407{
dbb4e169 408 return new AliMUONDigitizerv2(manager);
85a5290f 409}
ce3f5e87 410//_____________________________________________________________________
2ab0c725 411void AliMUON::SDigits2Digits()
412{
d963c261 413
414// write TreeD here
415
d963c261 416 char hname[30];
88cb7938 417 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
418 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
419 fLoader->TreeD()->Reset();
2ab0c725 420}
a9e2aefa 421
d1775029 422//_____________________________________________________________________
423void AliMUON::Hits2SDigits()
424{
dbb4e169 425 // Adaption of AliMUONSDigitizerv1 to be excuted by the AliSimulation framework
426 AliRunLoader* runLoader = fLoader->GetRunLoader();
427 AliRunDigitizer * manager = new AliRunDigitizer(1,1);
e191bb57 428 manager->SetInputStream(0,runLoader->GetFileName(),AliConfig::GetDefaultEventFolderName());
dbb4e169 429 AliMUONDigitizer * dMUON = new AliMUONSDigitizerv1(manager);
430 fLoader->LoadHits("READ");
431 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
432 runLoader->GetEvent(iEvent);
433 dMUON->Exec("");
434 }
435 fLoader->UnloadHits();
d1775029 436}
39e39255 437//_____________________________________________________________________
438void AliMUON::Digits2Raw()
439{
440 // convert digits of the current event to raw data
441 AliMUONRawData* rawData;
442
443 rawData = new AliMUONRawData(fLoader);
1197ff51 444 if (!rawData->Digits2Raw()) AliInfo("pb writting raw data");
39e39255 445 delete rawData;
446 return;
447}
ce3f5e87 448//_______________________________________________________________________
3fa6cfdd 449AliLoader* AliMUON::MakeLoader(const char* topfoldername)
450{
451//builds standard getter (AliLoader type)
452//if detector wants to use castomized getter, it must overload this method
453
8c343c7c 454
455 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
456 GetName(),topfoldername));
128843d9 457 fLoader = new AliLoader(GetName(),topfoldername);
ce3f5e87 458 fMUONData = new AliMUONData(fLoader,GetName(),GetName());
d652f85c 459 fMUONData->SetSplitLevel(fSplitLevel);
3fa6cfdd 460 return fLoader;
461}
ce3f5e87 462//_______________________________________________________________________
a897a37a 463
464AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
465{
de05461e 466//
467// Return rawcluster (icluster) for chamber ichamber and cathode icathod
468// Obsolete ??
ce3f5e87 469 TClonesArray *muonRawCluster = GetMUONData()->RawClusters(ichamber);
a897a37a 470 ResetRawClusters();
88cb7938 471 TTree *treeR = fLoader->TreeR();
a9e2aefa 472 Int_t nent=(Int_t)treeR->GetEntries();
473 treeR->GetEvent(nent-2+icathod-1);
474 //treeR->GetEvent(icathod);
475 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
a897a37a 476
a9e2aefa 477 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
a897a37a 478 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
479
480 return mRaw;
481}
ce3f5e87 482//________________________________________________________________________
ffd9faa2 483