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(1),
122 fDigitStoreConcreteClassName()
124 /// Default Constructor
126 AliDebug(1,Form("default (empty) ctor this=%p",this));
130 //__________________________________________________________________
131 AliMUON::AliMUON(const char *name, const char* title)
132 : AliDetector(name, title),
133 fNCh(AliMUONConstants::NCh()),
134 fNTrackingCh(AliMUONConstants::NTrackingCh()),
143 fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200
144 fMaxDestepAlu(-1), // in the calculation of the tracking parameters
147 fTriggerScalerEvent(kFALSE),
148 fTriggerResponseV1(kFALSE),
151 fDigitizerWithNoise(1),
153 fDigitMaker(new AliMUONDigitMaker),
155 fDigitStoreConcreteClassName("AliMUONDigitStoreV2S")
157 /// Standard constructor
159 AliDebug(1,Form("ctor this=%p",this));
162 //PH SetMarkerColor(kRed);//
165 fGeometryBuilder = new AliMUONGeometryBuilder(this);
167 // Common geometry definitions
169 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
171 // By default, add also all the needed geometry builders.
172 // If you want to change this from outside, please use ResetGeometryBuilder
173 // method, followed by AddGeometryBuilder ones.
175 AddGeometryBuilder(new AliMUONSt1GeometryBuilderV2(this));
176 AddGeometryBuilder(new AliMUONSt2GeometryBuilderV2(this));
177 AddGeometryBuilder(new AliMUONSlatGeometryBuilder(this));
178 AddGeometryBuilder(new AliMUONTriggerGeometryBuilder(this));
181 // Creating List of Chambers
183 fChambers = new TObjArray(AliMUONConstants::NCh());
184 fChambers->SetOwner(kTRUE);
186 // Loop over stations
187 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
188 // Loop over 2 chambers in the station
189 for (Int_t stCH = 0; stCH < 2; stCH++) {
192 // Default Parameters for Muon Tracking Stations
194 if (ch < AliMUONConstants::NTrackingCh()) {
195 fChambers->AddAt(new AliMUONChamber(ch),ch);
197 fChambers->AddAt(new AliMUONChamberTrigger(ch, GetGeometryTransformer()),ch);
199 } // Chamber stCH (0, 1) in
200 } // Station st (0...)
204 //____________________________________________________________________
209 AliDebug(1,Form("dtor this=%p",this));
211 delete fGeometryBuilder;
217 //_____________________________________________________________________________
218 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
220 /// Add the geometry builder to the list
222 fGeometryBuilder->AddBuilder(geomBuilder);
225 //____________________________________________________________________
226 void AliMUON::BuildGeometry()
228 /// Geometry for event display
231 // for (Int_t i = 0; i < AliMUONConstants::NCh(); i++)
232 // this->Chamber(i).SegmentationModel2(1)->Draw("eventdisplay");// to be check !
237 //____________________________________________________________________
238 const AliMUONGeometry* AliMUON::GetGeometry() const
240 /// Return geometry parametrisation
242 if ( !fGeometryBuilder) {
243 AliWarningStream() << "GeometryBuilder not defined." << std::endl;
247 return fGeometryBuilder->GetGeometry();
250 //____________________________________________________________________
251 const AliMUONGeometryTransformer* AliMUON::GetGeometryTransformer() const
253 /// Return geometry parametrisation
255 const AliMUONGeometry* kGeometry = GetGeometry();
257 if ( !kGeometry) return 0;
259 return kGeometry->GetTransformer();
262 //__________________________________________________________________
264 AliMUON::MakeBranch(Option_t* opt)
266 /// Create branche(s) to hold MUON hits
270 if ( sopt != "H" ) return;
274 fHitStore = new AliMUONHitStoreV1;
275 if ( gAlice->GetMCApp() )
277 if ( gAlice->GetMCApp()->GetHitLists() )
279 // AliStack::PurifyKine needs to be able to loop on our hits
280 // to remap the track numbers.
281 gAlice->GetMCApp()->AddHitList(fHitStore->Collection());
286 TTree* treeH = fLoader->TreeH();
290 AliFatal("No TreeH");
293 fHitStore->Connect(*treeH);
296 //__________________________________________________________________
298 AliMUON::SetTreeAddress()
300 /// Set Hits tree address
302 // if ( gAlice->GetMCApp() && fHitStore )
304 // TList* l = gAlice->GetMCApp()->GetHitLists();
307 // TObject* o = l->First();
308 // if (o!=fHitStore->HitCollection())
310 // AliError(Form("Something is strange hitcollection=%x",fHitStore->HitCollection()));
317 //_________________________________________________________________
324 if (fHitStore) fHitStore->Clear();
327 //_________________________________________________________________
328 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
330 /// Set the inverse charge slope for chamber id
332 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
333 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
334 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
335 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
337 //__________________________________________________________________
338 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
340 /// Set sigma of charge spread for chamber id
343 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
344 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
346 //___________________________________________________________________
347 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
349 /// Set integration limits for charge spread
351 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
352 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
355 //__________________________________________________________________
356 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
358 /// Set maximum number for ADCcounts (saturation)
361 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
362 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
365 //__________________________________________________________________
366 void AliMUON::SetMaxStepGas(Float_t p1)
368 /// Set stepsize in gas
372 //__________________________________________________________________
373 void AliMUON::SetMaxStepAlu(Float_t p1)
375 /// Set step size in Alu
379 //__________________________________________________________________
380 void AliMUON::SetMaxDestepGas(Float_t p1)
382 /// Set maximum step size in Gas
386 //__________________________________________________________________
387 void AliMUON::SetMaxDestepAlu(Float_t p1)
389 /// Set maximum step size in Alu
394 //____________________________________________________________________
395 Float_t AliMUON::GetMaxStepGas() const
397 /// Return stepsize in gas
402 //____________________________________________________________________
403 Float_t AliMUON::GetMaxStepAlu() const
405 /// Return step size in Alu
410 //____________________________________________________________________
411 Float_t AliMUON::GetMaxDestepGas() const
413 /// Return maximum step size in Gas
415 return fMaxDestepGas;
418 //____________________________________________________________________
419 Float_t AliMUON::GetMaxDestepAlu() const
421 /// Return maximum step size in Gas
423 return fMaxDestepAlu;
426 //____________________________________________________________________
427 void AliMUON::SetAlign(Bool_t align)
429 /// Set option for alignement to geometry builder
431 fGeometryBuilder->SetAlign(align);
434 //____________________________________________________________________
435 void AliMUON::SetAlign(const TString& fileName, Bool_t align)
437 /// Set option for alignement to geometry builder
439 fGeometryBuilder->SetAlign(fileName, align);
442 //____________________________________________________________________
443 void AliMUON::SetResponseModel(Int_t id, const AliMUONResponse& response)
445 /// Set the response for chamber id
446 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
449 //____________________________________________________________________
450 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
454 return new AliMUONDigitizerV3(manager, fDigitizerWithNoise);
457 //_____________________________________________________________________
458 void AliMUON::SDigits2Digits()
460 /// Write TreeD here only
463 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
464 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
465 fLoader->TreeD()->Reset();
468 //_____________________________________________________________________
469 void AliMUON::Hits2SDigits()
471 /// Perform Hits2Digits using SDigitizerV2
473 AliMUONSDigitizerV2 sdigitizer;
474 sdigitizer.ExecuteTask();
477 //_____________________________________________________________________
478 void AliMUON::Digits2Raw()
480 /// Convert digits of the current event to raw data
484 fRawWriter = new AliMUONRawWriter;
485 AliDebug(1,Form("Creating %s",fRawWriter->ClassName()));
486 if (fTriggerScalerEvent == kTRUE)
488 fRawWriter->SetScalersNumbers();
492 fLoader->LoadDigits("READ");
494 TTree* treeD = fLoader->TreeD();
498 AliError("Could not get TreeD");
502 AliMUONVTriggerStore* triggerStore = AliMUONVTriggerStore::Create(*treeD);
503 AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
505 triggerStore->Connect(*treeD,kFALSE);
506 digitStore->Connect(*treeD,kFALSE);
510 if (!fRawWriter->Digits2Raw(digitStore,triggerStore))
512 AliError("pb writting raw data");
518 fLoader->UnloadDigits();
521 //_____________________________________________________________________
522 Bool_t AliMUON::Raw2SDigits(AliRawReader* rawReader)
524 /// Convert raw data to SDigit
525 /// Only for tracking for the moment (ChF)
527 fLoader->LoadDigits("READ");
528 if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
530 TTree* treeS = fLoader->TreeS();
532 AliMUONVDigitStore* sDigitStore = new AliMUONDigitStoreV1;
533 sDigitStore->Connect(*treeS);
535 fDigitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
537 fLoader->WriteSDigits("OVERWRITE");
539 fLoader->UnloadSDigits();
546 //_______________________________________________________________________
547 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
549 /// Build standard getter (AliLoader type);
550 /// if detector wants to use castomized getter, it must overload this method
552 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
553 GetName(),topfoldername));
554 fLoader = new AliLoader(GetName(),topfoldername);
559 //________________________________________________________________________
561 AliMUON::ResetGeometryBuilder()
563 /// Only to be used by "experts" wanting to change the geometry builders
565 /// As the ctor of AliMUON now defines a default geometrybuilder, this
566 /// ResetGeometryBuilder() must be called prior to call the
567 /// AddGeometryBuilder()
569 delete fGeometryBuilder;
570 fGeometryBuilder = new AliMUONGeometryBuilder(this);
572 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
575 //____________________________________________________________________
576 Bool_t AliMUON::GetTriggerResponseV1() const
579 /// Returns fTriggerResponseV1
581 return fTriggerResponseV1;
585 //____________________________________________________________________
586 Int_t AliMUON::GetTriggerCoinc44() const
589 /// Returns fTriggerCoinc44
591 return fTriggerCoinc44;
595 //____________________________________________________________________
596 Bool_t AliMUON::GetTriggerEffCells() const
599 /// Returns fTriggerEffCells
601 return fTriggerEffCells;
605 //____________________________________________________________________
606 Int_t AliMUON::GetDigitizerWithNoise() const
609 /// Returns fDigitizerWithNoise
611 return fDigitizerWithNoise;