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 "AliMUONRawWriter.h"
66 #include "AliMUONSDigitizerV2.h"
67 #include "AliMUONDigitizerV3.h"
68 #include "AliMUONDigitMaker.h"
70 #include "AliMUONSt1GeometryBuilderV2.h"
71 #include "AliMUONSt2GeometryBuilderV2.h"
72 #include "AliMUONSlatGeometryBuilder.h"
73 #include "AliMUONTriggerGeometryBuilder.h"
75 #include "AliMUONDigitStoreV1.h"
76 #include "AliMUONVTriggerStore.h"
77 #include "AliMUONHitStoreV1.h"
79 // Defaults parameters for Z positions of chambers
80 // taken from values for "stations" in AliMUON::AliMUON
81 // const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
82 // and from array "dstation" in AliMUONv1::CreateGeometry
83 // Float_t dstation[5]={20., 20., 20, 20., 20.};
84 // for tracking chambers,
85 // according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
86 // for the first and second chambers in the station, respectively,
87 // and from "DTPLANES" in AliMUONv1::CreateGeometry
88 // const Float_t DTPLANES = 15.;
89 // for trigger chambers,
90 // according to (Z1 = zch) and (Z2 = zch + DTPLANES)
91 // for the first and second chambers in the station, respectively
97 //__________________________________________________________________
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()),
142 fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200
143 fMaxDestepAlu(-1), // in the calculation of the tracking parameters
146 fTriggerScalerEvent(kFALSE),
147 fTriggerResponseV1(kFALSE),
150 fDigitizerWithNoise(kTRUE),
152 fDigitMaker(new AliMUONDigitMaker),
155 /// Standard constructor
157 AliDebug(1,Form("ctor this=%p",this));
160 //PH SetMarkerColor(kRed);//
163 fGeometryBuilder = new AliMUONGeometryBuilder(this);
165 // Common geometry definitions
167 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
169 // By default, add also all the needed geometry builders.
170 // If you want to change this from outside, please use ResetGeometryBuilder
171 // method, followed by AddGeometryBuilder ones.
173 AddGeometryBuilder(new AliMUONSt1GeometryBuilderV2(this));
174 AddGeometryBuilder(new AliMUONSt2GeometryBuilderV2(this));
175 AddGeometryBuilder(new AliMUONSlatGeometryBuilder(this));
176 AddGeometryBuilder(new AliMUONTriggerGeometryBuilder(this));
179 // Creating List of Chambers
181 fChambers = new TObjArray(AliMUONConstants::NCh());
182 fChambers->SetOwner(kTRUE);
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));
209 delete fGeometryBuilder;
215 //_____________________________________________________________________________
216 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
218 /// Add the geometry builder to the list
220 fGeometryBuilder->AddBuilder(geomBuilder);
223 //____________________________________________________________________
224 void AliMUON::BuildGeometry()
226 /// Geometry for event display
229 // for (Int_t i = 0; i < AliMUONConstants::NCh(); i++)
230 // this->Chamber(i).SegmentationModel2(1)->Draw("eventdisplay");// to be check !
235 //____________________________________________________________________
236 const AliMUONGeometry* AliMUON::GetGeometry() const
238 /// Return geometry parametrisation
240 if ( !fGeometryBuilder) {
241 AliWarningStream() << "GeometryBuilder not defined." << std::endl;
245 return fGeometryBuilder->GetGeometry();
248 //____________________________________________________________________
249 const AliMUONGeometryTransformer* AliMUON::GetGeometryTransformer() const
251 /// Return geometry parametrisation
253 const AliMUONGeometry* kGeometry = GetGeometry();
255 if ( !kGeometry) return 0;
257 return kGeometry->GetTransformer();
260 //__________________________________________________________________
262 AliMUON::MakeBranch(Option_t* opt)
264 /// Create branche(s) to hold MUON hits
268 if ( sopt != "H" ) return;
272 fHitStore = new AliMUONHitStoreV1;
273 if ( gAlice->GetMCApp() )
275 if ( gAlice->GetMCApp()->GetHitLists() )
277 // AliStack::PurifyKine needs to be able to loop on our hits
278 // to remap the track numbers.
279 gAlice->GetMCApp()->AddHitList(fHitStore->Collection());
284 TTree* treeH = fLoader->TreeH();
288 AliFatal("No TreeH");
291 fHitStore->Connect(*treeH);
294 //__________________________________________________________________
296 AliMUON::SetTreeAddress()
298 /// Set Hits tree address
300 // if ( gAlice->GetMCApp() && fHitStore )
302 // TList* l = gAlice->GetMCApp()->GetHitLists();
305 // TObject* o = l->First();
306 // if (o!=fHitStore->HitCollection())
308 // AliError(Form("Something is strange hitcollection=%x",fHitStore->HitCollection()));
315 //_________________________________________________________________
322 if (fHitStore) fHitStore->Clear();
325 //_________________________________________________________________
326 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
328 /// Set the inverse charge slope for chamber id
330 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
331 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
332 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
333 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
335 //__________________________________________________________________
336 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
338 /// Set sigma of charge spread for chamber id
341 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
342 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
344 //___________________________________________________________________
345 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
347 /// Set integration limits for charge spread
349 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
350 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
353 //__________________________________________________________________
354 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
356 /// Set maximum number for ADCcounts (saturation)
359 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
360 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
363 //__________________________________________________________________
364 void AliMUON::SetMaxStepGas(Float_t p1)
366 /// Set stepsize in gas
370 //__________________________________________________________________
371 void AliMUON::SetMaxStepAlu(Float_t p1)
373 /// Set step size in Alu
377 //__________________________________________________________________
378 void AliMUON::SetMaxDestepGas(Float_t p1)
380 /// Set maximum step size in Gas
384 //__________________________________________________________________
385 void AliMUON::SetMaxDestepAlu(Float_t p1)
387 /// Set maximum step size in Alu
392 //____________________________________________________________________
393 Float_t AliMUON::GetMaxStepGas() const
395 /// Return stepsize in gas
400 //____________________________________________________________________
401 Float_t AliMUON::GetMaxStepAlu() const
403 /// Return step size in Alu
408 //____________________________________________________________________
409 Float_t AliMUON::GetMaxDestepGas() const
411 /// Return maximum step size in Gas
413 return fMaxDestepGas;
416 //____________________________________________________________________
417 Float_t AliMUON::GetMaxDestepAlu() const
419 /// Return maximum step size in Gas
421 return fMaxDestepAlu;
424 //____________________________________________________________________
425 void AliMUON::SetAlign(Bool_t align)
427 /// Set option for alignement to geometry builder
429 fGeometryBuilder->SetAlign(align);
432 //____________________________________________________________________
433 void AliMUON::SetAlign(const TString& fileName, Bool_t align)
435 /// Set option for alignement to geometry builder
437 fGeometryBuilder->SetAlign(fileName, align);
440 //____________________________________________________________________
441 void AliMUON::SetResponseModel(Int_t id, const AliMUONResponse& response)
443 /// Set the response for chamber id
444 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
447 //____________________________________________________________________
448 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
452 return new AliMUONDigitizerV3(manager, fDigitizerWithNoise);
455 //_____________________________________________________________________
456 void AliMUON::SDigits2Digits()
458 /// Write TreeD here only
461 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
462 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
463 fLoader->TreeD()->Reset();
466 //_____________________________________________________________________
467 void AliMUON::Hits2SDigits()
469 /// Perform Hits2Digits using SDigitizerV2
471 AliMUONSDigitizerV2 sdigitizer;
472 sdigitizer.ExecuteTask();
475 //_____________________________________________________________________
476 void AliMUON::Digits2Raw()
478 /// Convert digits of the current event to raw data
482 fRawWriter = new AliMUONRawWriter;
483 AliDebug(1,Form("Creating %s",fRawWriter->ClassName()));
484 if (fTriggerScalerEvent == kTRUE)
486 fRawWriter->SetScalersNumbers();
490 fLoader->LoadDigits("READ");
492 TTree* treeD = fLoader->TreeD();
496 AliError("Could not get TreeD");
500 AliMUONVTriggerStore* triggerStore = AliMUONVTriggerStore::Create(*treeD);
501 AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
503 triggerStore->Connect(*treeD,kFALSE);
504 digitStore->Connect(*treeD,kFALSE);
508 if (!fRawWriter->Digits2Raw(digitStore,triggerStore))
510 AliError("pb writting raw data");
516 fLoader->UnloadDigits();
519 //_____________________________________________________________________
520 Bool_t AliMUON::Raw2SDigits(AliRawReader* rawReader)
522 /// Convert raw data to SDigit
523 /// Only for tracking for the moment (ChF)
525 fLoader->LoadDigits("READ");
526 if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
528 TTree* treeS = fLoader->TreeS();
530 AliMUONVDigitStore* sDigitStore = new AliMUONDigitStoreV1;
531 sDigitStore->Connect(*treeS);
533 fDigitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
535 fLoader->WriteSDigits("OVERWRITE");
537 fLoader->UnloadSDigits();
544 //_______________________________________________________________________
545 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
547 /// Build standard getter (AliLoader type);
548 /// if detector wants to use castomized getter, it must overload this method
550 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
551 GetName(),topfoldername));
552 fLoader = new AliLoader(GetName(),topfoldername);
557 //________________________________________________________________________
559 AliMUON::ResetGeometryBuilder()
561 /// Only to be used by "experts" wanting to change the geometry builders
563 /// As the ctor of AliMUON now defines a default geometrybuilder, this
564 /// ResetGeometryBuilder() must be called prior to call the
565 /// AddGeometryBuilder()
567 delete fGeometryBuilder;
568 fGeometryBuilder = new AliMUONGeometryBuilder(this);
570 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
573 //____________________________________________________________________
574 Bool_t AliMUON::GetTriggerResponseV1() const
577 /// Returns fTriggerResponseV1
579 return fTriggerResponseV1;
583 //____________________________________________________________________
584 Int_t AliMUON::GetTriggerCoinc44() const
587 /// Returns fTriggerCoinc44
589 return fTriggerCoinc44;
593 //____________________________________________________________________
594 Bool_t AliMUON::GetTriggerEffCells() const
597 /// Returns fTriggerEffCells
599 return fTriggerEffCells;
603 //____________________________________________________________________
604 Bool_t AliMUON::GetDigitizerWithNoise() const
607 /// Returns fDigitizerWithNoise
609 return fDigitizerWithNoise;