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