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 //-----------------------------------------------------------------------------
25 #include "Riostream.h"
30 #include <TDirectory.h>
32 #include <TGeometry.h>
36 #include <TObjArray.h>
38 #include <TObjectTable.h>
40 #include <TParticle.h>
43 #include <TRotMatrix.h>
48 #include <TVirtualMC.h>
50 //#include "AliHeader.h"
51 #include "AliLoader.h"
52 #include "AliRunDigitizer.h"
56 #include "AliMUONChamberTrigger.h"
57 #include "AliMUONConstants.h"
58 #include "AliMUONHit.h"
59 #include "AliMUONGeometry.h"
60 #include "AliMUONGeometryTransformer.h"
61 #include "AliMUONGeometryBuilder.h"
62 #include "AliMUONCommonGeometryBuilder.h"
63 #include "AliMUONVGeometryBuilder.h"
64 #include "AliMUONRawWriter.h"
67 #include "AliMUONSDigitizerV2.h"
68 #include "AliMUONDigitizerV3.h"
69 #include "AliMUONDigitMaker.h"
71 #include "AliMUONSt1GeometryBuilderV2.h"
72 #include "AliMUONSt2GeometryBuilderV2.h"
73 #include "AliMUONSlatGeometryBuilder.h"
74 #include "AliMUONTriggerGeometryBuilder.h"
76 #include "AliMUONDigitStoreV1.h"
77 #include "AliMUONVTriggerStore.h"
78 #include "AliMUONHitStoreV1.h"
80 // Defaults parameters for Z positions of chambers
81 // taken from values for "stations" in AliMUON::AliMUON
82 // const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
83 // and from array "dstation" in AliMUONv1::CreateGeometry
84 // Float_t dstation[5]={20., 20., 20, 20., 20.};
85 // for tracking chambers,
86 // according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
87 // for the first and second chambers in the station, respectively,
88 // and from "DTPLANES" in AliMUONv1::CreateGeometry
89 // const Float_t DTPLANES = 15.;
90 // for trigger chambers,
91 // according to (Z1 = zch) and (Z2 = zch + DTPLANES)
92 // for the first and second chambers in the station, respectively
98 //__________________________________________________________________
115 fTriggerScalerEvent(kFALSE),
116 fTriggerResponseV1(kFALSE),
119 fDigitizerWithNoise(1),
123 fDigitStoreConcreteClassName()
125 /// Default Constructor
127 AliDebug(1,Form("default (empty) ctor this=%p",this));
131 //__________________________________________________________________
132 AliMUON::AliMUON(const char *name, const char* title)
133 : AliDetector(name, title),
134 fNCh(AliMUONConstants::NCh()),
135 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(1),
154 fDigitMaker(new AliMUONDigitMaker),
156 fDigitStoreConcreteClassName("AliMUONDigitStoreV2S")
158 /// Standard constructor
160 AliDebug(1,Form("ctor this=%p",this));
163 //PH SetMarkerColor(kRed);//
166 fGeometryBuilder = new AliMUONGeometryBuilder(this);
168 // Common geometry definitions
170 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
172 // By default, add also all the needed geometry builders.
173 // If you want to change this from outside, please use ResetGeometryBuilder
174 // method, followed by AddGeometryBuilder ones.
176 AddGeometryBuilder(new AliMUONSt1GeometryBuilderV2(this));
177 AddGeometryBuilder(new AliMUONSt2GeometryBuilderV2(this));
178 AddGeometryBuilder(new AliMUONSlatGeometryBuilder(this));
179 AddGeometryBuilder(new AliMUONTriggerGeometryBuilder(this));
182 // Creating List of Chambers
184 fChambers = new TObjArray(AliMUONConstants::NCh());
185 fChambers->SetOwner(kTRUE);
187 // Loop over stations
188 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
189 // Loop over 2 chambers in the station
190 for (Int_t stCH = 0; stCH < 2; stCH++) {
193 // Default Parameters for Muon Tracking Stations
195 if (ch < AliMUONConstants::NTrackingCh()) {
196 fChambers->AddAt(new AliMUONChamber(ch),ch);
198 fChambers->AddAt(new AliMUONChamberTrigger(ch, GetGeometryTransformer()),ch);
200 } // Chamber stCH (0, 1) in
201 } // Station st (0...)
205 //____________________________________________________________________
210 AliDebug(1,Form("dtor this=%p",this));
212 delete fGeometryBuilder;
218 //_____________________________________________________________________________
219 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
221 /// Add the geometry builder to the list
223 fGeometryBuilder->AddBuilder(geomBuilder);
226 //____________________________________________________________________
227 void AliMUON::BuildGeometry()
229 /// Geometry for event display
232 // for (Int_t i = 0; i < AliMUONConstants::NCh(); i++)
233 // this->Chamber(i).SegmentationModel2(1)->Draw("eventdisplay");// to be check !
238 //____________________________________________________________________
239 const AliMUONGeometry* AliMUON::GetGeometry() const
241 /// Return geometry parametrisation
243 if ( !fGeometryBuilder) {
244 AliWarningStream() << "GeometryBuilder not defined." << std::endl;
248 return fGeometryBuilder->GetGeometry();
251 //____________________________________________________________________
252 const AliMUONGeometryTransformer* AliMUON::GetGeometryTransformer() const
254 /// Return geometry parametrisation
256 const AliMUONGeometry* kGeometry = GetGeometry();
258 if ( !kGeometry) return 0;
260 return kGeometry->GetTransformer();
263 //__________________________________________________________________
265 AliMUON::MakeBranch(Option_t* opt)
267 /// Create branche(s) to hold MUON hits
271 if ( sopt != "H" ) return;
275 fHitStore = new AliMUONHitStoreV1;
276 if ( gAlice->GetMCApp() )
278 if ( gAlice->GetMCApp()->GetHitLists() )
280 // AliStack::PurifyKine needs to be able to loop on our hits
281 // to remap the track numbers.
282 gAlice->GetMCApp()->AddHitList(fHitStore->Collection());
287 TTree* treeH = fLoader->TreeH();
291 AliFatal("No TreeH");
294 fHitStore->Connect(*treeH);
297 //__________________________________________________________________
299 AliMUON::SetTreeAddress()
301 /// Set Hits tree address
303 // if ( gAlice->GetMCApp() && fHitStore )
305 // TList* l = gAlice->GetMCApp()->GetHitLists();
308 // TObject* o = l->First();
309 // if (o!=fHitStore->HitCollection())
311 // AliError(Form("Something is strange hitcollection=%x",fHitStore->HitCollection()));
318 //_________________________________________________________________
325 if (fHitStore) fHitStore->Clear();
328 //_________________________________________________________________
329 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
331 /// Set the inverse charge slope for chamber id
333 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
334 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
335 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
336 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
338 //__________________________________________________________________
339 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
341 /// Set sigma of charge spread for chamber id
344 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
345 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
347 //___________________________________________________________________
348 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
350 /// Set integration limits for charge spread
352 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
353 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
356 //__________________________________________________________________
357 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
359 /// Set maximum number for ADCcounts (saturation)
362 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
363 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
366 //__________________________________________________________________
367 void AliMUON::SetMaxStepGas(Float_t p1)
369 /// Set stepsize in gas
373 //__________________________________________________________________
374 void AliMUON::SetMaxStepAlu(Float_t p1)
376 /// Set step size in Alu
380 //__________________________________________________________________
381 void AliMUON::SetMaxDestepGas(Float_t p1)
383 /// Set maximum step size in Gas
387 //__________________________________________________________________
388 void AliMUON::SetMaxDestepAlu(Float_t p1)
390 /// Set maximum step size in Alu
395 //____________________________________________________________________
396 Float_t AliMUON::GetMaxStepGas() const
398 /// Return stepsize in gas
403 //____________________________________________________________________
404 Float_t AliMUON::GetMaxStepAlu() const
406 /// Return step size in Alu
411 //____________________________________________________________________
412 Float_t AliMUON::GetMaxDestepGas() const
414 /// Return maximum step size in Gas
416 return fMaxDestepGas;
419 //____________________________________________________________________
420 Float_t AliMUON::GetMaxDestepAlu() const
422 /// Return maximum step size in Gas
424 return fMaxDestepAlu;
427 //____________________________________________________________________
428 void AliMUON::SetAlign(Bool_t align)
430 /// Set option for alignement to geometry builder
432 fGeometryBuilder->SetAlign(align);
435 //____________________________________________________________________
436 void AliMUON::SetAlign(const TString& fileName, Bool_t align)
438 /// Set option for alignement to geometry builder
440 fGeometryBuilder->SetAlign(fileName, align);
443 //____________________________________________________________________
444 void AliMUON::SetResponseModel(Int_t id, const AliMUONResponse& response)
446 /// Set the response for chamber id
447 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
450 //____________________________________________________________________
451 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
455 return new AliMUONDigitizerV3(manager, fDigitizerWithNoise);
458 //_____________________________________________________________________
459 void AliMUON::SDigits2Digits()
461 /// Write TreeD here only
464 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
465 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
466 fLoader->TreeD()->Reset();
469 //_____________________________________________________________________
470 void AliMUON::Hits2SDigits()
472 /// Perform Hits2Digits using SDigitizerV2
474 AliMUONSDigitizerV2 sdigitizer;
475 sdigitizer.ExecuteTask();
478 //_____________________________________________________________________
479 void AliMUON::Digits2Raw()
481 /// Convert digits of the current event to raw data
485 fRawWriter = new AliMUONRawWriter;
486 AliDebug(1,Form("Creating %s",fRawWriter->ClassName()));
487 if (fTriggerScalerEvent == kTRUE)
489 fRawWriter->SetScalersNumbers();
493 fLoader->LoadDigits("READ");
495 TTree* treeD = fLoader->TreeD();
499 AliError("Could not get TreeD");
503 AliMUONVTriggerStore* triggerStore = AliMUONVTriggerStore::Create(*treeD);
504 AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
506 triggerStore->Connect(*treeD,kFALSE);
507 digitStore->Connect(*treeD,kFALSE);
511 if (!fRawWriter->Digits2Raw(digitStore,triggerStore))
513 AliError("pb writting raw data");
519 fLoader->UnloadDigits();
522 //_____________________________________________________________________
523 Bool_t AliMUON::Raw2SDigits(AliRawReader* rawReader)
525 /// Convert raw data to SDigit
526 /// Only for tracking for the moment (ChF)
528 fLoader->LoadDigits("READ");
529 if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
531 TTree* treeS = fLoader->TreeS();
533 AliMUONVDigitStore* sDigitStore = new AliMUONDigitStoreV1;
534 sDigitStore->Connect(*treeS);
536 fDigitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
538 fLoader->WriteSDigits("OVERWRITE");
540 fLoader->UnloadSDigits();
547 //_______________________________________________________________________
548 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
550 /// Build standard getter (AliLoader type);
551 /// if detector wants to use castomized getter, it must overload this method
553 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
554 GetName(),topfoldername));
555 fLoader = new AliLoader(GetName(),topfoldername);
560 //________________________________________________________________________
562 AliMUON::ResetGeometryBuilder()
564 /// Only to be used by "experts" wanting to change the geometry builders
566 /// As the ctor of AliMUON now defines a default geometrybuilder, this
567 /// ResetGeometryBuilder() must be called prior to call the
568 /// AddGeometryBuilder()
570 delete fGeometryBuilder;
571 fGeometryBuilder = new AliMUONGeometryBuilder(this);
573 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
576 //____________________________________________________________________
577 Bool_t AliMUON::GetTriggerResponseV1() const
580 /// Returns fTriggerResponseV1
582 return fTriggerResponseV1;
586 //____________________________________________________________________
587 Int_t AliMUON::GetTriggerCoinc44() const
590 /// Returns fTriggerCoinc44
592 return fTriggerCoinc44;
596 //____________________________________________________________________
597 Bool_t AliMUON::GetTriggerEffCells() const
600 /// Returns fTriggerEffCells
602 return fTriggerEffCells;
606 //____________________________________________________________________
607 Int_t AliMUON::GetDigitizerWithNoise() const
610 /// Returns fDigitizerWithNoise
612 return fDigitizerWithNoise;