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 fDigitizerNSigmas(4.0),
101 fIsTailEffect(kTRUE),
105 fDigitStoreConcreteClassName(),
106 fCalibrationData(0x0)
108 /// Default Constructor
110 AliDebug(1,Form("default (empty) ctor this=%p",this));
114 //__________________________________________________________________
115 AliMUON::AliMUON(const char *name, const char* title)
116 : AliDetector(name, title),
117 fNCh(AliMUONConstants::NCh()),
118 fNTrackingCh(AliMUONConstants::NTrackingCh()),
127 fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200
128 fMaxDestepAlu(-1), // in the calculation of the tracking parameters
131 fTriggerScalerEvent(kFALSE),
132 fTriggerResponseV1(kFALSE),
135 fDigitizerWithNoise(1),
136 fDigitizerNSigmas(4.0),
137 fIsTailEffect(kTRUE),
139 fDigitMaker(new AliMUONDigitMaker),
141 fDigitStoreConcreteClassName("AliMUONDigitStoreV2S"),
144 /// Standard constructor
146 AliDebug(1,Form("ctor this=%p",this));
149 //PH SetMarkerColor(kRed);//
152 fGeometryBuilder = new AliMUONGeometryBuilder(this);
154 // Common geometry definitions
156 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
158 // By default, add also all the needed geometry builders.
159 // If you want to change this from outside, please use ResetGeometryBuilder
160 // method, followed by AddGeometryBuilder ones.
162 AddGeometryBuilder(new AliMUONSt1GeometryBuilderV2(this));
163 AddGeometryBuilder(new AliMUONSt2GeometryBuilderV2(this));
164 AddGeometryBuilder(new AliMUONSlatGeometryBuilder(this));
165 AddGeometryBuilder(new AliMUONTriggerGeometryBuilder(this));
168 // Creating List of Chambers
170 fChambers = new TObjArray(AliMUONConstants::NCh());
171 fChambers->SetOwner(kTRUE);
173 // Loop over stations
174 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
175 // Loop over 2 chambers in the station
176 for (Int_t stCH = 0; stCH < 2; stCH++) {
179 // Default Parameters for Muon Tracking Stations
181 if (ch < AliMUONConstants::NTrackingCh()) {
182 fChambers->AddAt(new AliMUONChamber(ch),ch);
184 fChambers->AddAt(new AliMUONChamberTrigger(ch, GetGeometryTransformer()),ch);
186 } // Chamber stCH (0, 1) in
187 } // Station st (0...)
189 Int_t runnumber = AliCDBManager::Instance()->GetRun();
191 fCalibrationData = new AliMUONCalibrationData(runnumber);
194 //____________________________________________________________________
199 AliDebug(1,Form("dtor this=%p",this));
201 delete fGeometryBuilder;
205 delete fCalibrationData;
208 //_____________________________________________________________________________
209 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
211 /// Add the geometry builder to the list
213 fGeometryBuilder->AddBuilder(geomBuilder);
216 //____________________________________________________________________
217 const AliMUONGeometry* AliMUON::GetGeometry() const
219 /// Return geometry parametrisation
221 if ( !fGeometryBuilder) {
222 AliWarningStream() << "GeometryBuilder not defined." << std::endl;
226 return fGeometryBuilder->GetGeometry();
229 //____________________________________________________________________
230 const AliMUONGeometryTransformer* AliMUON::GetGeometryTransformer() const
232 /// Return geometry parametrisation
234 const AliMUONGeometry* kGeometry = GetGeometry();
236 if ( !kGeometry) return 0;
238 return kGeometry->GetTransformer();
241 //__________________________________________________________________
243 AliMUON::MakeBranch(Option_t* opt)
245 /// Create branche(s) to hold MUON hits
249 if ( sopt != "H" ) return;
253 fHitStore = new AliMUONHitStoreV1;
254 if ( gAlice->GetMCApp() )
256 if ( gAlice->GetMCApp()->GetHitLists() )
258 // AliStack::PurifyKine needs to be able to loop on our hits
259 // to remap the track numbers.
260 gAlice->GetMCApp()->AddHitList(fHitStore->Collection());
265 TTree* treeH = fLoader->TreeH();
269 AliFatal("No TreeH");
272 fHitStore->Connect(*treeH);
275 //__________________________________________________________________
277 AliMUON::SetTreeAddress()
279 /// Set Hits tree address
281 // if ( gAlice->GetMCApp() && fHitStore )
283 // TList* l = gAlice->GetMCApp()->GetHitLists();
286 // TObject* o = l->First();
287 // if (o!=fHitStore->HitCollection())
289 // AliError(Form("Something is strange hitcollection=%x",fHitStore->HitCollection()));
296 //_________________________________________________________________
303 if (fHitStore) fHitStore->Clear();
306 //_________________________________________________________________
307 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
309 /// Set the inverse charge slope for chamber id
311 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
312 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
313 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
314 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
316 //__________________________________________________________________
317 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
319 /// Set sigma of charge spread for chamber id
322 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
323 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
325 //___________________________________________________________________
326 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
328 /// Set integration limits for charge spread
330 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
331 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
334 //__________________________________________________________________
335 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
337 /// Set maximum number for ADCcounts (saturation)
340 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
341 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
344 //__________________________________________________________________
345 void AliMUON::SetMaxStepGas(Float_t p1)
347 /// Set stepsize in gas
351 //__________________________________________________________________
352 void AliMUON::SetMaxStepAlu(Float_t p1)
354 /// Set step size in Alu
358 //__________________________________________________________________
359 void AliMUON::SetMaxDestepGas(Float_t p1)
361 /// Set maximum step size in Gas
365 //__________________________________________________________________
366 void AliMUON::SetMaxDestepAlu(Float_t p1)
368 /// Set maximum step size in Alu
373 //____________________________________________________________________
374 Float_t AliMUON::GetMaxStepGas() const
376 /// Return stepsize in gas
381 //____________________________________________________________________
382 Float_t AliMUON::GetMaxStepAlu() const
384 /// Return step size in Alu
389 //____________________________________________________________________
390 Float_t AliMUON::GetMaxDestepGas() const
392 /// Return maximum step size in Gas
394 return fMaxDestepGas;
397 //____________________________________________________________________
398 Float_t AliMUON::GetMaxDestepAlu() const
400 /// Return maximum step size in Gas
402 return fMaxDestepAlu;
405 //____________________________________________________________________
406 void AliMUON::SetAlign(Bool_t align)
408 /// Set option for alignement to geometry builder
410 fGeometryBuilder->SetAlign(align);
413 //____________________________________________________________________
414 void AliMUON::SetAlign(const TString& fileName, Bool_t align)
416 /// Set option for alignement to geometry builder
418 fGeometryBuilder->SetAlign(fileName, align);
421 //____________________________________________________________________
422 void AliMUON::SetResponseModel(Int_t id, const AliMUONResponse& response)
424 /// Set the response for chamber id
425 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
428 //____________________________________________________________________
429 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
433 AliMUONDigitizerV3* digitizer = new AliMUONDigitizerV3(manager, fDigitizerWithNoise);
434 AliMUONDigitizerV3::SetNSigmas(fDigitizerNSigmas);
435 digitizer->SetCalibrationData(fCalibrationData);
439 //_____________________________________________________________________
440 void AliMUON::SDigits2Digits()
442 /// Write TreeD here only
445 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
446 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
447 fLoader->TreeD()->Reset();
450 //_____________________________________________________________________
451 void AliMUON::Hits2SDigits()
453 /// Perform Hits2Digits using SDigitizerV2
455 AliMUONSDigitizerV2 sdigitizer;
456 sdigitizer.ExecuteTask();
459 //_____________________________________________________________________
460 void AliMUON::Digits2Raw()
462 /// Convert digits of the current event to raw data
464 AliRawDataHeaderSim header;
468 fRawWriter = new AliMUONRawWriter;
469 AliDebug(1,Form("Creating %s",fRawWriter->ClassName()));
470 if (fTriggerScalerEvent == kTRUE)
472 fRawWriter->SetScalersNumbers();
476 fLoader->LoadDigits("READ");
478 TTree* treeD = fLoader->TreeD();
482 AliError("Could not get TreeD");
486 AliMUONVTriggerStore* triggerStore = AliMUONVTriggerStore::Create(*treeD);
487 AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
489 triggerStore->Connect(*treeD,kFALSE);
490 digitStore->Connect(*treeD,kFALSE);
494 fRawWriter->SetHeader(header);
495 if (!fRawWriter->Digits2Raw(digitStore,triggerStore))
497 AliError("pb writting raw data");
503 fLoader->UnloadDigits();
506 //_____________________________________________________________________
507 Bool_t AliMUON::Raw2SDigits(AliRawReader* rawReader)
509 /// Convert raw data to SDigit
511 fLoader->LoadDigits("READ");
512 if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
514 TTree* treeS = fLoader->TreeS();
516 AliMUONVDigitStore* sDigitStore = new AliMUONDigitStoreV1;
517 sDigitStore->Connect(*treeS);
519 fDigitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
521 fLoader->WriteSDigits("OVERWRITE");
523 fLoader->UnloadSDigits();
530 //_______________________________________________________________________
531 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
533 /// Build standard getter (AliLoader type);
534 /// if detector wants to use castomized getter, it must overload this method
536 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
537 GetName(),topfoldername));
538 fLoader = new AliLoader(GetName(),topfoldername);
543 //________________________________________________________________________
545 AliMUON::ResetGeometryBuilder()
547 /// Only to be used by "experts" wanting to change the geometry builders
549 /// As the ctor of AliMUON now defines a default geometrybuilder, this
550 /// ResetGeometryBuilder() must be called prior to call the
551 /// AddGeometryBuilder()
553 delete fGeometryBuilder;
554 fGeometryBuilder = new AliMUONGeometryBuilder(this);
556 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
559 //____________________________________________________________________
560 Bool_t AliMUON::GetTriggerResponseV1() const
563 /// Returns fTriggerResponseV1
565 return fTriggerResponseV1;
569 //____________________________________________________________________
570 Int_t AliMUON::GetTriggerCoinc44() const
573 /// Returns fTriggerCoinc44
575 return fTriggerCoinc44;
579 //____________________________________________________________________
580 Bool_t AliMUON::GetTriggerEffCells() const
583 /// Returns fTriggerEffCells
585 return fTriggerEffCells;
589 //____________________________________________________________________
590 Int_t AliMUON::GetDigitizerWithNoise() const
593 /// Returns fDigitizerWithNoise
595 return fDigitizerWithNoise;