1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
21 // AliDetector class for MUON subsystem
22 // providing simulation data management
23 //-----------------------------------------------------------------------------
27 #include "AliMUONSDigitizerV2.h"
28 #include "AliMUONDigitizerV3.h"
29 #include "AliMUONDigitMaker.h"
30 #include "AliMUONCalibrationData.h"
32 #include "AliMUONDigitStoreV1.h"
33 #include "AliMUONVTriggerStore.h"
34 #include "AliMUONHitStoreV1.h"
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"
48 #include "AliMUONRawWriter.h"
50 #include "AliLoader.h"
51 #include "AliCDBManager.h"
52 #include "AliRunDigitizer.h"
55 #include "AliRawDataHeaderSim.h"
58 #include <TObjArray.h>
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
78 //__________________________________________________________________
95 fTriggerScalerEvent(kFALSE),
96 fTriggerResponseV1(kFALSE),
99 fDigitizerWithNoise(1),
100 fIsTailEffect(kTRUE),
104 fDigitStoreConcreteClassName(),
105 fCalibrationData(0x0),
109 /// Default Constructor
111 AliDebug(1,Form("default (empty) ctor this=%p",this));
115 //__________________________________________________________________
116 AliMUON::AliMUON(const char *name, const char* title)
117 : AliDetector(name, title),
118 fNCh(AliMUONConstants::NCh()),
119 fNTrackingCh(AliMUONConstants::NTrackingCh()),
128 fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200
129 fMaxDestepAlu(-1), // in the calculation of the tracking parameters
132 fTriggerScalerEvent(kFALSE),
133 fTriggerResponseV1(kFALSE),
136 fDigitizerWithNoise(1),
137 fIsTailEffect(kTRUE),
139 fDigitMaker(new AliMUONDigitMaker),
141 fDigitStoreConcreteClassName("AliMUONDigitStoreV2S"),
147 /// Standard constructor
149 AliDebug(1,Form("ctor this=%p",this));
152 //PH SetMarkerColor(kRed);//
155 fGeometryBuilder = new AliMUONGeometryBuilder(this);
157 // Common geometry definitions
159 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
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.
165 AddGeometryBuilder(new AliMUONSt1GeometryBuilderV2(this));
166 AddGeometryBuilder(new AliMUONSt2GeometryBuilderV2(this));
167 AddGeometryBuilder(new AliMUONSlatGeometryBuilder(this));
168 AddGeometryBuilder(new AliMUONTriggerGeometryBuilder(this));
171 // Creating List of Chambers
173 fChambers = new TObjArray(AliMUONConstants::NCh());
174 fChambers->SetOwner(kTRUE);
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++) {
182 // Default Parameters for Muon Tracking Stations
184 if (ch < AliMUONConstants::NTrackingCh()) {
185 fChambers->AddAt(new AliMUONChamber(ch),ch);
187 fChambers->AddAt(new AliMUONChamberTrigger(ch, GetGeometryTransformer()),ch);
189 } // Chamber stCH (0, 1) in
190 } // Station st (0...)
192 Int_t runnumber = AliCDBManager::Instance()->GetRun();
194 fCalibrationData = new AliMUONCalibrationData(runnumber);
197 //____________________________________________________________________
202 AliDebug(1,Form("dtor this=%p",this));
204 delete fGeometryBuilder;
208 delete fCalibrationData;
211 //_____________________________________________________________________________
212 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
214 /// Add the geometry builder to the list
216 fGeometryBuilder->AddBuilder(geomBuilder);
219 //____________________________________________________________________
220 const AliMUONGeometry* AliMUON::GetGeometry() const
222 /// Return geometry parametrisation
224 if ( !fGeometryBuilder) {
225 AliWarningStream() << "GeometryBuilder not defined." << std::endl;
229 return fGeometryBuilder->GetGeometry();
232 //____________________________________________________________________
233 const AliMUONGeometryTransformer* AliMUON::GetGeometryTransformer() const
235 /// Return geometry parametrisation
237 const AliMUONGeometry* kGeometry = GetGeometry();
239 if ( !kGeometry) return 0;
241 return kGeometry->GetTransformer();
244 //__________________________________________________________________
246 AliMUON::MakeBranch(Option_t* opt)
248 /// Create branche(s) to hold MUON hits
252 if ( sopt != "H" ) return;
256 fHitStore = new AliMUONHitStoreV1;
257 if ( gAlice->GetMCApp() )
259 if ( gAlice->GetMCApp()->GetHitLists() )
261 // AliStack::PurifyKine needs to be able to loop on our hits
262 // to remap the track numbers.
263 gAlice->GetMCApp()->AddHitList(fHitStore->Collection());
268 TTree* treeH = fLoader->TreeH();
272 AliFatal("No TreeH");
275 fHitStore->Connect(*treeH);
278 //__________________________________________________________________
280 AliMUON::SetTreeAddress()
282 /// Set Hits tree address
284 // if ( gAlice->GetMCApp() && fHitStore )
286 // TList* l = gAlice->GetMCApp()->GetHitLists();
289 // TObject* o = l->First();
290 // if (o!=fHitStore->HitCollection())
292 // AliError(Form("Something is strange hitcollection=%x",fHitStore->HitCollection()));
299 //_________________________________________________________________
306 if (fHitStore) fHitStore->Clear();
309 //_________________________________________________________________
310 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
312 /// Set the inverse charge slope for chamber id
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);
319 //__________________________________________________________________
320 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
322 /// Set sigma of charge spread for chamber id
325 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
326 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
328 //___________________________________________________________________
329 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
331 /// Set integration limits for charge spread
333 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
334 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
337 //__________________________________________________________________
338 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
340 /// Set maximum number for ADCcounts (saturation)
343 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
344 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
347 //__________________________________________________________________
348 void AliMUON::SetMaxStepGas(Float_t p1)
350 /// Set stepsize in gas
354 //__________________________________________________________________
355 void AliMUON::SetMaxStepAlu(Float_t p1)
357 /// Set step size in Alu
361 //__________________________________________________________________
362 void AliMUON::SetMaxDestepGas(Float_t p1)
364 /// Set maximum step size in Gas
368 //__________________________________________________________________
369 void AliMUON::SetMaxDestepAlu(Float_t p1)
371 /// Set maximum step size in Alu
376 //____________________________________________________________________
377 Float_t AliMUON::GetMaxStepGas() const
379 /// Return stepsize in gas
384 //____________________________________________________________________
385 Float_t AliMUON::GetMaxStepAlu() const
387 /// Return step size in Alu
392 //____________________________________________________________________
393 Float_t AliMUON::GetMaxDestepGas() const
395 /// Return maximum step size in Gas
397 return fMaxDestepGas;
400 //____________________________________________________________________
401 Float_t AliMUON::GetMaxDestepAlu() const
403 /// Return maximum step size in Gas
405 return fMaxDestepAlu;
408 //____________________________________________________________________
409 void AliMUON::SetAlign(Bool_t align)
411 /// Set option for alignement to geometry builder
413 fGeometryBuilder->SetAlign(align);
416 //____________________________________________________________________
417 void AliMUON::SetAlign(const TString& fileName, Bool_t align)
419 /// Set option for alignement to geometry builder
421 fGeometryBuilder->SetAlign(fileName, align);
424 //____________________________________________________________________
425 void AliMUON::SetResponseModel(Int_t id, const AliMUONResponse& response)
427 /// Set the response for chamber id
428 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
431 //____________________________________________________________________
432 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
436 AliMUONDigitizerV3* digitizer = new AliMUONDigitizerV3(manager, fDigitizerWithNoise);
437 digitizer->SetCalibrationData(fCalibrationData);
441 //_____________________________________________________________________
442 void AliMUON::SDigits2Digits()
444 /// Write TreeD here only
447 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
448 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
449 fLoader->TreeD()->Reset();
452 //_____________________________________________________________________
453 void AliMUON::Hits2SDigits()
455 /// Perform Hits2Digits using SDigitizerV2
457 AliMUONSDigitizerV2 sdigitizer;
458 sdigitizer.ExecuteTask();
461 //_____________________________________________________________________
462 void AliMUON::Digits2Raw()
464 /// Convert digits of the current event to raw data
466 AliRawDataHeaderSim header;
470 fRawWriter = new AliMUONRawWriter;
471 AliDebug(1,Form("Creating %s",fRawWriter->ClassName()));
472 if (fTriggerScalerEvent == kTRUE)
474 fRawWriter->SetScalersNumbers();
478 fLoader->LoadDigits("READ");
480 TTree* treeD = fLoader->TreeD();
484 AliError("Could not get TreeD");
488 AliMUONVTriggerStore* triggerStore = AliMUONVTriggerStore::Create(*treeD);
489 AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
491 triggerStore->Connect(*treeD,kFALSE);
492 digitStore->Connect(*treeD,kFALSE);
496 fRawWriter->SetHeader(header);
497 if (!fRawWriter->Digits2Raw(digitStore,triggerStore))
499 AliError("pb writting raw data");
505 fLoader->UnloadDigits();
508 //_____________________________________________________________________
509 Bool_t AliMUON::Raw2SDigits(AliRawReader* rawReader)
511 /// Convert raw data to SDigit
513 fLoader->LoadDigits("READ");
514 if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
516 TTree* treeS = fLoader->TreeS();
518 AliMUONVDigitStore* sDigitStore = new AliMUONDigitStoreV1;
519 sDigitStore->Connect(*treeS);
521 fDigitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
523 fLoader->WriteSDigits("OVERWRITE");
525 fLoader->UnloadSDigits();
532 //_______________________________________________________________________
533 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
535 /// Build standard getter (AliLoader type);
536 /// if detector wants to use castomized getter, it must overload this method
538 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
539 GetName(),topfoldername));
540 fLoader = new AliLoader(GetName(),topfoldername);
545 //________________________________________________________________________
547 AliMUON::ResetGeometryBuilder()
549 /// Only to be used by "experts" wanting to change the geometry builders
551 /// As the ctor of AliMUON now defines a default geometrybuilder, this
552 /// ResetGeometryBuilder() must be called prior to call the
553 /// AddGeometryBuilder()
555 delete fGeometryBuilder;
556 fGeometryBuilder = new AliMUONGeometryBuilder(this);
558 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
561 //____________________________________________________________________
562 Bool_t AliMUON::GetTriggerResponseV1() const
565 /// Returns fTriggerResponseV1
567 return fTriggerResponseV1;
571 //____________________________________________________________________
572 Int_t AliMUON::GetTriggerCoinc44() const
575 /// Returns fTriggerCoinc44
577 return fTriggerCoinc44;
581 //____________________________________________________________________
582 Bool_t AliMUON::GetTriggerEffCells() const
585 /// Returns fTriggerEffCells
587 return fTriggerEffCells;
591 //____________________________________________________________________
592 Int_t AliMUON::GetDigitizerWithNoise() const
595 /// Returns fDigitizerWithNoise
597 return fDigitizerWithNoise;