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 //__________________________________________________________________
96 fTriggerScalerEvent(kFALSE),
97 fTriggerResponseV1(kFALSE),
100 fDigitizerWithNoise(1),
101 fDigitizerNSigmas(4.0),
102 fIsTailEffect(kTRUE),
106 fDigitStoreConcreteClassName(),
107 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
133 fTriggerScalerEvent(kFALSE),
134 fTriggerResponseV1(kFALSE),
137 fDigitizerWithNoise(1),
138 fDigitizerNSigmas(4.0),
139 fIsTailEffect(kTRUE),
141 fDigitMaker(new AliMUONDigitMaker),
143 fDigitStoreConcreteClassName("AliMUONDigitStoreV2S"),
146 /// Standard constructor
148 AliDebug(1,Form("ctor this=%p",this));
151 //PH SetMarkerColor(kRed);//
154 fGeometryBuilder = new AliMUONGeometryBuilder(this);
156 // Common geometry definitions
158 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
160 // By default, add also all the needed geometry builders.
161 // If you want to change this from outside, please use ResetGeometryBuilder
162 // method, followed by AddGeometryBuilder ones.
164 AddGeometryBuilder(new AliMUONSt1GeometryBuilderV2(this));
165 AddGeometryBuilder(new AliMUONSt2GeometryBuilderV2(this));
166 AddGeometryBuilder(new AliMUONSlatGeometryBuilder(this));
167 AddGeometryBuilder(new AliMUONTriggerGeometryBuilder(this));
170 // Creating List of Chambers
172 fChambers = new TObjArray(AliMUONConstants::NCh());
173 fChambers->SetOwner(kTRUE);
175 // Loop over stations
176 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
177 // Loop over 2 chambers in the station
178 for (Int_t stCH = 0; stCH < 2; stCH++) {
181 // Default Parameters for Muon Tracking Stations
183 if (ch < AliMUONConstants::NTrackingCh()) {
184 fChambers->AddAt(new AliMUONChamber(ch),ch);
186 fChambers->AddAt(new AliMUONChamberTrigger(ch, GetGeometryTransformer()),ch);
188 } // Chamber stCH (0, 1) in
189 } // Station st (0...)
191 Int_t runnumber = AliCDBManager::Instance()->GetRun();
193 fCalibrationData = new AliMUONCalibrationData(runnumber);
196 //____________________________________________________________________
201 AliDebug(1,Form("dtor this=%p",this));
203 delete fGeometryBuilder;
207 delete fCalibrationData;
210 //_____________________________________________________________________________
211 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
213 /// Add the geometry builder to the list
215 fGeometryBuilder->AddBuilder(geomBuilder);
218 //____________________________________________________________________
219 const AliMUONGeometry* AliMUON::GetGeometry() const
221 /// Return geometry parametrisation
223 if ( !fGeometryBuilder) {
224 AliWarningStream() << "GeometryBuilder not defined." << std::endl;
228 return fGeometryBuilder->GetGeometry();
231 //____________________________________________________________________
232 const AliMUONGeometryTransformer* AliMUON::GetGeometryTransformer() const
234 /// Return geometry parametrisation
236 const AliMUONGeometry* kGeometry = GetGeometry();
238 if ( !kGeometry) return 0;
240 return kGeometry->GetTransformer();
243 //__________________________________________________________________
245 AliMUON::MakeBranch(Option_t* opt)
247 /// Create branche(s) to hold MUON hits
251 if ( sopt != "H" ) return;
255 fHitStore = new AliMUONHitStoreV1;
256 if ( gAlice->GetMCApp() )
258 if ( gAlice->GetMCApp()->GetHitLists() )
260 // AliStack::PurifyKine needs to be able to loop on our hits
261 // to remap the track numbers.
262 gAlice->GetMCApp()->AddHitList(fHitStore->Collection());
267 TTree* treeH = fLoader->TreeH();
271 AliFatal("No TreeH");
274 fHitStore->Connect(*treeH);
277 //__________________________________________________________________
279 AliMUON::SetTreeAddress()
281 /// Set Hits tree address
283 // if ( gAlice->GetMCApp() && fHitStore )
285 // TList* l = gAlice->GetMCApp()->GetHitLists();
288 // TObject* o = l->First();
289 // if (o!=fHitStore->HitCollection())
291 // AliError(Form("Something is strange hitcollection=%x",fHitStore->HitCollection()));
298 //_________________________________________________________________
305 if (fHitStore) fHitStore->Clear();
308 //_________________________________________________________________
309 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
311 /// Set the inverse charge slope for chamber id
313 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
314 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
315 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
316 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
318 //__________________________________________________________________
319 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
321 /// Set sigma of charge spread for chamber id
324 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
325 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
327 //___________________________________________________________________
328 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
330 /// Set integration limits for charge spread
332 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
333 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
336 //__________________________________________________________________
337 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
339 /// Set maximum number for ADCcounts (saturation)
342 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
343 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
346 //__________________________________________________________________
347 void AliMUON::SetMaxStepGas(Float_t p1)
349 /// Set stepsize in gas
353 //__________________________________________________________________
354 void AliMUON::SetMaxStepAlu(Float_t p1)
356 /// Set step size in Alu
360 //__________________________________________________________________
361 void AliMUON::SetMaxDestepGas(Float_t p1)
363 /// Set maximum step size in Gas
367 //__________________________________________________________________
368 void AliMUON::SetMaxDestepAlu(Float_t p1)
370 /// Set maximum step size in Alu
375 //____________________________________________________________________
376 Float_t AliMUON::GetMaxStepGas() const
378 /// Return stepsize in gas
383 //____________________________________________________________________
384 Float_t AliMUON::GetMaxStepAlu() const
386 /// Return step size in Alu
391 //____________________________________________________________________
392 Float_t AliMUON::GetMaxDestepGas() const
394 /// Return maximum step size in Gas
396 return fMaxDestepGas;
399 //____________________________________________________________________
400 Float_t AliMUON::GetMaxDestepAlu() const
402 /// Return maximum step size in Gas
404 return fMaxDestepAlu;
407 //____________________________________________________________________
408 void AliMUON::SetAlign(Bool_t align)
410 /// Set option for alignement to geometry builder
412 fGeometryBuilder->SetAlign(align);
415 //____________________________________________________________________
416 void AliMUON::SetAlign(const TString& fileName, Bool_t align)
418 /// Set option for alignement to geometry builder
420 fGeometryBuilder->SetAlign(fileName, align);
423 //____________________________________________________________________
424 void AliMUON::SetResponseModel(Int_t id, const AliMUONResponse& response)
426 /// Set the response for chamber id
427 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
430 //____________________________________________________________________
431 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
435 AliMUONDigitizerV3* digitizer = new AliMUONDigitizerV3(manager, fDigitizerWithNoise);
436 AliMUONDigitizerV3::SetNSigmas(fDigitizerNSigmas);
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 if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
515 TTree* treeS = fLoader->TreeS();
517 AliMUONVDigitStore* sDigitStore = new AliMUONDigitStoreV1;
518 sDigitStore->Connect(*treeS);
520 fDigitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
522 fLoader->WriteSDigits("OVERWRITE");
524 fLoader->UnloadSDigits();
531 //_______________________________________________________________________
532 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
534 /// Build standard getter (AliLoader type);
535 /// if detector wants to use castomized getter, it must overload this method
537 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
538 GetName(),topfoldername));
539 fLoader = new AliLoader(GetName(),topfoldername);
544 //________________________________________________________________________
546 AliMUON::ResetGeometryBuilder()
548 /// Only to be used by "experts" wanting to change the geometry builders
550 /// As the ctor of AliMUON now defines a default geometrybuilder, this
551 /// ResetGeometryBuilder() must be called prior to call the
552 /// AddGeometryBuilder()
554 delete fGeometryBuilder;
555 fGeometryBuilder = new AliMUONGeometryBuilder(this);
557 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
560 //____________________________________________________________________
561 Bool_t AliMUON::GetTriggerResponseV1() const
564 /// Returns fTriggerResponseV1
566 return fTriggerResponseV1;
570 //____________________________________________________________________
571 Int_t AliMUON::GetTriggerCoinc44() const
574 /// Returns fTriggerCoinc44
576 return fTriggerCoinc44;
580 //____________________________________________________________________
581 Bool_t AliMUON::GetTriggerEffCells() const
584 /// Returns fTriggerEffCells
586 return fTriggerEffCells;
590 //____________________________________________________________________
591 Int_t AliMUON::GetDigitizerWithNoise() const
594 /// Returns fDigitizerWithNoise
596 return fDigitizerWithNoise;