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 **************************************************************************/
19 ///////////////////////////////////////////////
20 // Manager and hits classes for set:MUON //
21 ////////////////////////////////////////////////
23 #include "Riostream.h"
28 #include <TDirectory.h>
30 #include <TGeometry.h>
34 #include <TObjArray.h>
36 #include <TObjectTable.h>
38 #include <TParticle.h>
41 #include <TRotMatrix.h>
46 #include <TVirtualMC.h>
48 //#include "AliHeader.h"
49 #include "AliLoader.h"
50 #include "AliRunDigitizer.h"
54 #include "AliMUONChamberTrigger.h"
55 #include "AliMUONConstants.h"
56 #include "AliMUONHit.h"
57 #include "AliMUONRawCluster.h"
58 #include "AliMUONTransientDigit.h"
59 #include "AliMUONTriggerCircuit.h"
60 #include "AliMUONGeometry.h"
61 #include "AliMUONGeometryTransformer.h"
62 #include "AliMUONGeometryBuilder.h"
63 #include "AliMUONCommonGeometryBuilder.h"
64 #include "AliMUONVGeometryBuilder.h"
65 #include "AliMUONGeometrySegmentation.h"
66 #include "AliMUONDigitizerv2.h"
67 #include "AliMUONSDigitizerv1.h"
68 #include "AliMUONRawData.h"
69 #include "AliMUONSegmentation.h"
72 // Defaults parameters for Z positions of chambers
73 // taken from values for "stations" in AliMUON::AliMUON
74 // const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
75 // and from array "dstation" in AliMUONv1::CreateGeometry
76 // Float_t dstation[5]={20., 20., 20, 20., 20.};
77 // for tracking chambers,
78 // according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
79 // for the first and second chambers in the station, respectively,
80 // and from "DTPLANES" in AliMUONv1::CreateGeometry
81 // const Float_t DTPLANES = 15.;
82 // for trigger chambers,
83 // according to (Z1 = zch) and (Z2 = zch + DTPLANES)
84 // for the first and second chambers in the station, respectively
88 //__________________________________________________________________
109 // Default Constructor
111 AliDebug(1,Form("default (empty) ctor this=%p",this));
115 //__________________________________________________________________
116 AliMUON::AliMUON(const char *name, const char *title)
117 : AliDetector(name,title),
118 fNCh(AliMUONConstants::NCh()),
119 fNTrackingCh(AliMUONConstants::NTrackingCh()),
131 fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200
132 fMaxDestepAlu(-1), // in the calculation of the tracking parameters
136 AliDebug(1,Form("ctor this=%p",this));
139 SetMarkerColor(kRed);//
142 fGeometryBuilder = new AliMUONGeometryBuilder(this);
144 // Common geometry definitions
146 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
149 // Creating List of Chambers
151 fChambers = new TObjArray(AliMUONConstants::NCh());
153 // Loop over stations
154 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
155 // Loop over 2 chambers in the station
156 for (Int_t stCH = 0; stCH < 2; stCH++) {
159 // Default Parameters for Muon Tracking Stations
161 if (ch < AliMUONConstants::NTrackingCh()) {
162 fChambers->AddAt(new AliMUONChamber(ch),ch);
164 fChambers->AddAt(new AliMUONChamberTrigger(ch, GetGeometryTransformer()),ch);
166 } // Chamber stCH (0, 1) in
167 } // Station st (0...)
169 // cp new design of AliMUONTriggerDecision
170 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
171 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
172 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
176 //____________________________________________________________________
177 AliMUON::AliMUON(const AliMUON& rMUON)
180 // Protected copy constructor
182 AliFatal("Not implemented.");
185 //____________________________________________________________________
189 AliDebug(1,Form("dtor this=%p",this));
196 if (fTriggerCircuits){
197 fTriggerCircuits->Delete();
198 delete fTriggerCircuits;
201 delete fGeometryBuilder;
202 delete fSegmentation;
205 //________________________________________________________________________
206 AliMUON& AliMUON::operator = (const AliMUON& rhs)
208 // Protected assignement operator
210 if (this == &rhs) return *this;
212 AliFatal("Not implemented.");
217 //_____________________________________________________________________________
218 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
220 // Adds 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 //__________________________________________________________________
264 void AliMUON::SetTreeAddress()
266 GetMUONData()->SetLoader(fLoader);
267 // GetMUONData()->MakeBranch("D,S,RC");
268 // GetMUONData()->SetTreeAddress("H,D,S,RC");
269 GetMUONData()->SetTreeAddress("H");
270 if (fHits != GetMUONData()->Hits()) {
271 if ( gAlice->GetMCApp() )
272 if ( gAlice->GetMCApp()->GetHitLists() ) {
273 fHits = GetMUONData()->Hits();
274 gAlice->GetMCApp()->AddHitList(fHits); // For purifyKine, only necessary when Hit list is created in AliMUONData
277 fHits = GetMUONData()->Hits(); // Added by Ivana to use the methods FisrtHit, NextHit of AliDetector
280 //_________________________________________________________________
281 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
283 // Set the inverse charge slope for chamber id
284 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
285 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
286 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
287 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
289 //__________________________________________________________________
290 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
292 // Set sigma of charge spread for chamber id
294 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
295 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
297 //___________________________________________________________________
298 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
300 // Set integration limits for charge spread
302 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
303 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
306 //__________________________________________________________________
307 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
309 // Set maximum number for ADCcounts (saturation)
311 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
312 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
315 //__________________________________________________________________
316 void AliMUON::SetMaxStepGas(Float_t p1)
318 // Set stepsize in gas
321 //__________________________________________________________________
322 void AliMUON::SetMaxStepAlu(Float_t p1)
324 // Set step size in Alu
327 //__________________________________________________________________
328 void AliMUON::SetMaxDestepGas(Float_t p1)
330 // Set maximum step size in Gas
333 //__________________________________________________________________
334 void AliMUON::SetMaxDestepAlu(Float_t p1)
336 // Set maximum step size in Alu
340 //____________________________________________________________________
341 Float_t AliMUON::GetMaxStepGas() const
343 // Return stepsize in gas
348 //____________________________________________________________________
349 Float_t AliMUON::GetMaxStepAlu() const
351 // Return step size in Alu
356 //____________________________________________________________________
357 Float_t AliMUON::GetMaxDestepGas() const
359 // Return maximum step size in Gas
361 return fMaxDestepGas;
364 //____________________________________________________________________
365 Float_t AliMUON::GetMaxDestepAlu() const
367 // Return maximum step size in Gas
369 return fMaxDestepAlu;
372 //____________________________________________________________________
373 void AliMUON::SetAlign(Bool_t align)
375 // Sets option for alignement to geometry builder
377 fGeometryBuilder->SetAlign(align);
380 //____________________________________________________________________
381 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
383 // Set the response for chamber id
384 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
386 //____________________________________________________________________
387 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
389 return new AliMUONDigitizerv2(manager);
391 //_____________________________________________________________________
392 void AliMUON::SDigits2Digits()
398 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
399 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
400 fLoader->TreeD()->Reset();
403 //_____________________________________________________________________
404 void AliMUON::Hits2SDigits()
406 // Adaption of AliMUONSDigitizerv1 to be excuted by the AliSimulation framework
407 AliRunLoader* runLoader = fLoader->GetRunLoader();
408 AliRunDigitizer * manager = new AliRunDigitizer(1,1);
409 manager->SetInputStream(0,runLoader->GetFileName(),AliConfig::GetDefaultEventFolderName());
410 AliMUONDigitizer * dMUON = new AliMUONSDigitizerv1(manager);
411 fLoader->LoadHits("READ");
412 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
413 runLoader->GetEvent(iEvent);
416 fLoader->UnloadHits();
418 //_____________________________________________________________________
419 void AliMUON::Digits2Raw()
421 // convert digits of the current event to raw data
422 AliMUONRawData* rawData;
424 rawData = new AliMUONRawData(fLoader);
425 if (!rawData->Digits2Raw()) AliInfo("pb writting raw data");
429 //_______________________________________________________________________
430 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
432 //builds standard getter (AliLoader type)
433 //if detector wants to use castomized getter, it must overload this method
436 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
437 GetName(),topfoldername));
438 fLoader = new AliLoader(GetName(),topfoldername);
439 fMUONData = new AliMUONData(fLoader,GetName(),GetName());
440 fMUONData->SetSplitLevel(fSplitLevel);
443 //_______________________________________________________________________
445 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
448 // Return rawcluster (icluster) for chamber ichamber and cathode icathod
450 TClonesArray *muonRawCluster = GetMUONData()->RawClusters(ichamber);
452 TTree *treeR = fLoader->TreeR();
453 Int_t nent=(Int_t)treeR->GetEntries();
454 treeR->GetEvent(nent-2+icathod-1);
455 //treeR->GetEvent(icathod);
456 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
458 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
459 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
463 //________________________________________________________________________