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