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 "AliMUONRawWriter.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 //__________________________________________________________________
108 fTriggerScalerEvent(kFALSE)
110 // Default Constructor
112 AliDebug(1,Form("default (empty) ctor this=%p",this));
116 //__________________________________________________________________
117 AliMUON::AliMUON(const char *name, const char *title)
118 : AliDetector(name,title),
119 fNCh(AliMUONConstants::NCh()),
120 fNTrackingCh(AliMUONConstants::NTrackingCh()),
132 fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200
133 fMaxDestepAlu(-1), // in the calculation of the tracking parameters
136 fTriggerScalerEvent(kFALSE)
138 AliDebug(1,Form("ctor this=%p",this));
141 SetMarkerColor(kRed);//
144 fGeometryBuilder = new AliMUONGeometryBuilder(this);
146 // Common geometry definitions
148 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
151 // Creating List of Chambers
153 fChambers = new TObjArray(AliMUONConstants::NCh());
155 // Loop over stations
156 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
157 // Loop over 2 chambers in the station
158 for (Int_t stCH = 0; stCH < 2; stCH++) {
161 // Default Parameters for Muon Tracking Stations
163 if (ch < AliMUONConstants::NTrackingCh()) {
164 fChambers->AddAt(new AliMUONChamber(ch),ch);
166 fChambers->AddAt(new AliMUONChamberTrigger(ch, GetGeometryTransformer()),ch);
168 } // Chamber stCH (0, 1) in
169 } // Station st (0...)
171 // cp new design of AliMUONTriggerDecision
172 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
173 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
174 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
178 //____________________________________________________________________
179 AliMUON::AliMUON(const AliMUON& rMUON)
182 // Protected copy constructor
184 AliFatal("Not implemented.");
187 //____________________________________________________________________
191 AliDebug(1,Form("dtor this=%p",this));
198 if (fTriggerCircuits){
199 fTriggerCircuits->Delete();
200 delete fTriggerCircuits;
203 delete fGeometryBuilder;
204 delete fSegmentation;
207 //________________________________________________________________________
208 AliMUON& AliMUON::operator = (const AliMUON& rhs)
210 // Protected assignement operator
212 if (this == &rhs) return *this;
214 AliFatal("Not implemented.");
219 //_____________________________________________________________________________
220 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
222 // Adds the geometry builder to the list
225 fGeometryBuilder->AddBuilder(geomBuilder);
228 //____________________________________________________________________
229 void AliMUON::BuildGeometry()
231 // Geometry for event display
234 // for (Int_t i = 0; i < AliMUONConstants::NCh(); i++)
235 // this->Chamber(i).SegmentationModel2(1)->Draw("eventdisplay");// to be check !
240 //____________________________________________________________________
241 const AliMUONGeometry* AliMUON::GetGeometry() const
243 // Return geometry parametrisation
245 if ( !fGeometryBuilder) {
246 AliWarningStream() << "GeometryBuilder not defined." << std::endl;
250 return fGeometryBuilder->GetGeometry();
253 //____________________________________________________________________
254 const AliMUONGeometryTransformer* AliMUON::GetGeometryTransformer() const
256 // Return geometry parametrisation
258 const AliMUONGeometry* kGeometry = GetGeometry();
260 if ( !kGeometry) return 0;
262 return kGeometry->GetTransformer();
265 //__________________________________________________________________
266 void AliMUON::SetTreeAddress()
268 GetMUONData()->SetLoader(fLoader);
269 // GetMUONData()->MakeBranch("D,S,RC");
270 // GetMUONData()->SetTreeAddress("H,D,S,RC");
271 GetMUONData()->SetTreeAddress("H");
272 if (fHits != GetMUONData()->Hits()) {
273 if ( gAlice->GetMCApp() )
274 if ( gAlice->GetMCApp()->GetHitLists() ) {
275 fHits = GetMUONData()->Hits();
276 gAlice->GetMCApp()->AddHitList(fHits); // For purifyKine, only necessary when Hit list is created in AliMUONData
279 fHits = GetMUONData()->Hits(); // Added by Ivana to use the methods FisrtHit, NextHit of AliDetector
282 //_________________________________________________________________
283 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
285 // Set the inverse charge slope for chamber id
286 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
287 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
288 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
289 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
291 //__________________________________________________________________
292 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
294 // Set sigma of charge spread for chamber id
296 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
297 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
299 //___________________________________________________________________
300 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
302 // Set integration limits for charge spread
304 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
305 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
308 //__________________________________________________________________
309 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
311 // Set maximum number for ADCcounts (saturation)
313 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
314 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
317 //__________________________________________________________________
318 void AliMUON::SetMaxStepGas(Float_t p1)
320 // Set stepsize in gas
323 //__________________________________________________________________
324 void AliMUON::SetMaxStepAlu(Float_t p1)
326 // Set step size in Alu
329 //__________________________________________________________________
330 void AliMUON::SetMaxDestepGas(Float_t p1)
332 // Set maximum step size in Gas
335 //__________________________________________________________________
336 void AliMUON::SetMaxDestepAlu(Float_t p1)
338 // Set maximum step size in Alu
342 //____________________________________________________________________
343 Float_t AliMUON::GetMaxStepGas() const
345 // Return stepsize in gas
350 //____________________________________________________________________
351 Float_t AliMUON::GetMaxStepAlu() const
353 // Return step size in Alu
358 //____________________________________________________________________
359 Float_t AliMUON::GetMaxDestepGas() const
361 // Return maximum step size in Gas
363 return fMaxDestepGas;
366 //____________________________________________________________________
367 Float_t AliMUON::GetMaxDestepAlu() const
369 // Return maximum step size in Gas
371 return fMaxDestepAlu;
374 //____________________________________________________________________
375 void AliMUON::SetAlign(Bool_t align)
377 // Sets option for alignement to geometry builder
379 fGeometryBuilder->SetAlign(align);
382 //____________________________________________________________________
383 void AliMUON::SetAlign(const TString& fileName, Bool_t align)
385 // Sets option for alignement to geometry builder
387 fGeometryBuilder->SetAlign(fileName, align);
390 //____________________________________________________________________
391 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
393 // Set the response for chamber id
394 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
396 //____________________________________________________________________
397 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
399 return new AliMUONDigitizerv2(manager);
401 //_____________________________________________________________________
402 void AliMUON::SDigits2Digits()
408 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
409 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
410 fLoader->TreeD()->Reset();
413 //_____________________________________________________________________
414 void AliMUON::Hits2SDigits()
416 // Adaption of AliMUONSDigitizerv1 to be excuted by the AliSimulation framework
417 AliRunLoader* runLoader = fLoader->GetRunLoader();
418 AliRunDigitizer * manager = new AliRunDigitizer(1,1);
419 manager->SetInputStream(0,runLoader->GetFileName(),AliConfig::GetDefaultEventFolderName());
420 AliMUONDigitizer * dMUON = new AliMUONSDigitizerv1(manager);
421 fLoader->LoadHits("READ");
422 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
423 runLoader->GetEvent(iEvent);
426 fLoader->UnloadHits();
428 //_____________________________________________________________________
429 void AliMUON::Digits2Raw()
431 // convert digits of the current event to raw data
433 AliMUONRawWriter* rawData = new AliMUONRawWriter(fLoader,fMUONData);
435 if(fTriggerScalerEvent == kTRUE)
436 rawData->SetScalerEvent();
438 if (!rawData->Digits2Raw()) AliInfo("pb writting raw data");
442 //_______________________________________________________________________
443 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
445 //builds standard getter (AliLoader type)
446 //if detector wants to use castomized getter, it must overload this method
449 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
450 GetName(),topfoldername));
451 fLoader = new AliLoader(GetName(),topfoldername);
452 fMUONData = new AliMUONData(fLoader,GetName(),GetName());
453 fMUONData->SetSplitLevel(fSplitLevel);
456 //_______________________________________________________________________
458 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
461 // Return rawcluster (icluster) for chamber ichamber and cathode icathod
463 TClonesArray *muonRawCluster = GetMUONData()->RawClusters(ichamber);
465 TTree *treeR = fLoader->TreeR();
466 Int_t nent=(Int_t)treeR->GetEntries();
467 treeR->GetEvent(nent-2+icathod-1);
468 //treeR->GetEvent(icathod);
469 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
471 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
472 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
476 //________________________________________________________________________