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 **************************************************************************/
21 // AliDetector class for MUON subsystem
22 // providing simulation data management
24 #include "Riostream.h"
29 #include <TDirectory.h>
31 #include <TGeometry.h>
35 #include <TObjArray.h>
37 #include <TObjectTable.h>
39 #include <TParticle.h>
42 #include <TRotMatrix.h>
47 #include <TVirtualMC.h>
49 //#include "AliHeader.h"
50 #include "AliLoader.h"
51 #include "AliRunDigitizer.h"
55 #include "AliMUONChamberTrigger.h"
56 #include "AliMUONConstants.h"
57 #include "AliMUONHit.h"
58 #include "AliMUONGeometry.h"
59 #include "AliMUONGeometryTransformer.h"
60 #include "AliMUONGeometryBuilder.h"
61 #include "AliMUONCommonGeometryBuilder.h"
62 #include "AliMUONVGeometryBuilder.h"
63 #include "AliMUONGeometrySegmentation.h"
64 #include "AliMUONRawWriter.h"
65 #include "AliMUONSegmentation.h"
68 #include "AliMUONSDigitizerV2.h"
69 #include "AliMUONDigitizerV3.h"
70 #include "AliMUONDigitMaker.h"
72 #include "AliMUONSt1GeometryBuilderV2.h"
73 #include "AliMUONSt2GeometryBuilderV2.h"
74 #include "AliMUONSlatGeometryBuilder.h"
75 #include "AliMUONTriggerGeometryBuilder.h"
77 // Defaults parameters for Z positions of chambers
78 // taken from values for "stations" in AliMUON::AliMUON
79 // const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
80 // and from array "dstation" in AliMUONv1::CreateGeometry
81 // Float_t dstation[5]={20., 20., 20, 20., 20.};
82 // for tracking chambers,
83 // according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
84 // for the first and second chambers in the station, respectively,
85 // and from "DTPLANES" in AliMUONv1::CreateGeometry
86 // const Float_t DTPLANES = 15.;
87 // for trigger chambers,
88 // according to (Z1 = zch) and (Z2 = zch + DTPLANES)
89 // for the first and second chambers in the station, respectively
95 //__________________________________________________________________
114 fTriggerScalerEvent(kFALSE),
115 fTriggerResponseV1(kFALSE),
118 fDigitizerWithNoise(kTRUE),
123 /// Default Constructor
125 AliDebug(1,Form("default (empty) ctor this=%p",this));
129 //__________________________________________________________________
130 AliMUON::AliMUON(const char *name, const char* title)
131 : AliDetector(name, title),
132 fNCh(AliMUONConstants::NCh()),
133 fNTrackingCh(AliMUONConstants::NTrackingCh()),
144 fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200
145 fMaxDestepAlu(-1), // in the calculation of the tracking parameters
148 fTriggerScalerEvent(kFALSE),
149 fTriggerResponseV1(kFALSE),
152 fDigitizerWithNoise(kTRUE),
154 fDigitMaker(new AliMUONDigitMaker(kFALSE))
156 /// Standard constructor
158 AliDebug(1,Form("ctor this=%p",this));
161 //PH SetMarkerColor(kRed);//
164 fGeometryBuilder = new AliMUONGeometryBuilder(this);
166 // Common geometry definitions
168 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
170 // By default, add also all the needed geometry builders.
171 // If you want to change this from outside, please use ResetGeometryBuilder
172 // method, followed by AddGeometryBuilder ones.
174 AddGeometryBuilder(new AliMUONSt1GeometryBuilderV2(this));
175 AddGeometryBuilder(new AliMUONSt2GeometryBuilderV2(this));
176 AddGeometryBuilder(new AliMUONSlatGeometryBuilder(this));
177 AddGeometryBuilder(new AliMUONTriggerGeometryBuilder(this));
180 // Creating List of Chambers
182 fChambers = new TObjArray(AliMUONConstants::NCh());
184 // Loop over stations
185 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
186 // Loop over 2 chambers in the station
187 for (Int_t stCH = 0; stCH < 2; stCH++) {
190 // Default Parameters for Muon Tracking Stations
192 if (ch < AliMUONConstants::NTrackingCh()) {
193 fChambers->AddAt(new AliMUONChamber(ch),ch);
195 fChambers->AddAt(new AliMUONChamberTrigger(ch, GetGeometryTransformer()),ch);
197 } // Chamber stCH (0, 1) in
198 } // Station st (0...)
202 //____________________________________________________________________
207 AliDebug(1,Form("dtor this=%p",this));
216 delete fGeometryBuilder;
217 delete fSegmentation;
222 //_____________________________________________________________________________
223 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
225 /// Add the geometry builder to the list
227 fGeometryBuilder->AddBuilder(geomBuilder);
230 //____________________________________________________________________
231 void AliMUON::BuildGeometry()
233 /// Geometry for event display
236 // for (Int_t i = 0; i < AliMUONConstants::NCh(); i++)
237 // this->Chamber(i).SegmentationModel2(1)->Draw("eventdisplay");// to be check !
242 //____________________________________________________________________
243 const AliMUONGeometry* AliMUON::GetGeometry() const
245 /// Return geometry parametrisation
247 if ( !fGeometryBuilder) {
248 AliWarningStream() << "GeometryBuilder not defined." << std::endl;
252 return fGeometryBuilder->GetGeometry();
255 //____________________________________________________________________
256 const AliMUONGeometryTransformer* AliMUON::GetGeometryTransformer() const
258 /// Return geometry parametrisation
260 const AliMUONGeometry* kGeometry = GetGeometry();
262 if ( !kGeometry) return 0;
264 return kGeometry->GetTransformer();
267 //__________________________________________________________________
268 void AliMUON::SetTreeAddress()
270 /// Set Hits tree address
272 GetMUONData()->SetLoader(fLoader);
273 // GetMUONData()->MakeBranch("D,S,RC");
274 // GetMUONData()->SetTreeAddress("H,D,S,RC");
275 GetMUONData()->SetTreeAddress("H");
276 if (fHits != GetMUONData()->Hits()) {
277 if ( gAlice->GetMCApp() )
278 if ( gAlice->GetMCApp()->GetHitLists() ) {
279 fHits = GetMUONData()->Hits();
280 gAlice->GetMCApp()->AddHitList(fHits); // For purifyKine, only necessary when Hit list is created in AliMUONData
283 fHits = GetMUONData()->Hits(); // Added by Ivana to use the methods FisrtHit, NextHit of AliDetector
286 //_________________________________________________________________
287 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
289 /// Set the inverse charge slope for chamber id
291 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
292 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
293 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
294 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
296 //__________________________________________________________________
297 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
299 /// Set sigma of charge spread for chamber id
302 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
303 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
305 //___________________________________________________________________
306 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
308 /// Set integration limits for charge spread
310 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
311 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
314 //__________________________________________________________________
315 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
317 /// Set maximum number for ADCcounts (saturation)
320 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
321 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
324 //__________________________________________________________________
325 void AliMUON::SetMaxStepGas(Float_t p1)
327 /// Set stepsize in gas
331 //__________________________________________________________________
332 void AliMUON::SetMaxStepAlu(Float_t p1)
334 /// Set step size in Alu
338 //__________________________________________________________________
339 void AliMUON::SetMaxDestepGas(Float_t p1)
341 /// Set maximum step size in Gas
345 //__________________________________________________________________
346 void AliMUON::SetMaxDestepAlu(Float_t p1)
348 /// Set maximum step size in Alu
353 //____________________________________________________________________
354 Float_t AliMUON::GetMaxStepGas() const
356 /// Return stepsize in gas
361 //____________________________________________________________________
362 Float_t AliMUON::GetMaxStepAlu() const
364 /// Return step size in Alu
369 //____________________________________________________________________
370 Float_t AliMUON::GetMaxDestepGas() const
372 /// Return maximum step size in Gas
374 return fMaxDestepGas;
377 //____________________________________________________________________
378 Float_t AliMUON::GetMaxDestepAlu() const
380 /// Return maximum step size in Gas
382 return fMaxDestepAlu;
385 //____________________________________________________________________
386 void AliMUON::SetAlign(Bool_t align)
388 /// Set option for alignement to geometry builder
390 fGeometryBuilder->SetAlign(align);
393 //____________________________________________________________________
394 void AliMUON::SetAlign(const TString& fileName, Bool_t align)
396 /// Set option for alignement to geometry builder
398 fGeometryBuilder->SetAlign(fileName, align);
401 //____________________________________________________________________
402 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
404 /// Set the response for chamber id
405 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
408 //____________________________________________________________________
409 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
413 return new AliMUONDigitizerV3(manager, fDigitizerWithNoise);
416 //_____________________________________________________________________
417 void AliMUON::SDigits2Digits()
419 /// Write TreeD here only
422 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
423 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
424 fLoader->TreeD()->Reset();
427 //_____________________________________________________________________
428 void AliMUON::Hits2SDigits()
430 /// Perform Hits2Digits using SDigitizerV2
432 TTask* sdigitizer = new AliMUONSDigitizerV2;
433 sdigitizer->ExecuteTask();
436 //_____________________________________________________________________
437 void AliMUON::Digits2Raw()
439 /// Convert digits of the current event to raw data
443 fRawWriter = new AliMUONRawWriter(fMUONData);
444 if (fTriggerScalerEvent == kTRUE)
446 fRawWriter->SetScalersNumbers();
450 if (!fRawWriter->Digits2Raw())
452 AliError("pb writting raw data");
456 //_____________________________________________________________________
457 Bool_t AliMUON::Raw2SDigits(AliRawReader* rawReader)
459 /// Convert raw data to SDigit
460 /// Only for tracking for the moment (ChF)
462 //fLoader->LoadDigits("READ");
463 if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
465 fMUONData->MakeBranch("S");
466 fMUONData->SetTreeAddress("S");
467 fDigitMaker->Raw2Digits(rawReader);
468 fMUONData->Fill("S");
470 fLoader->WriteSDigits("OVERWRITE");
471 fMUONData->ResetSDigits();
472 fLoader->UnloadSDigits();
478 //_______________________________________________________________________
479 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
481 /// Build standard getter (AliLoader type);
482 /// if detector wants to use castomized getter, it must overload this method
484 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
485 GetName(),topfoldername));
486 fLoader = new AliLoader(GetName(),topfoldername);
487 fMUONData = new AliMUONSimData(fLoader,GetName(),GetName());
488 fMUONData->SetSplitLevel(fSplitLevel);
490 fDigitMaker->SetMUONData(fMUONData);
495 //________________________________________________________________________
497 AliMUON::ResetGeometryBuilder()
499 /// Only to be used by "experts" wanting to change the geometry builders
501 /// As the ctor of AliMUON now defines a default geometrybuilder, this
502 /// ResetGeometryBuilder() must be called prior to call the
503 /// AddGeometryBuilder()
505 delete fGeometryBuilder;
506 fGeometryBuilder = new AliMUONGeometryBuilder(this);
508 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
511 //____________________________________________________________________
512 Bool_t AliMUON::GetTriggerResponseV1() const
515 /// Returns fTriggerResponseV1
517 return fTriggerResponseV1;
521 //____________________________________________________________________
522 Int_t AliMUON::GetTriggerCoinc44() const
525 /// Returns fTriggerCoinc44
527 return fTriggerCoinc44;
531 //____________________________________________________________________
532 Bool_t AliMUON::GetTriggerEffCells() const
535 /// Returns fTriggerEffCells
537 return fTriggerEffCells;
541 //____________________________________________________________________
542 Bool_t AliMUON::GetDigitizerWithNoise() const
545 /// Returns fDigitizerWithNoise
547 return fDigitizerWithNoise;