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