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