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 "AliMUONGeometryBuilder.h"
61 #include "AliMUONCommonGeometryBuilder.h"
62 #include "AliMUONVGeometryBuilder.h"
63 #include "AliMUONGeometryDEIndexing.h"
64 #include "AliMUONGeometrySegmentation.h"
65 #include "AliMUONDigitizerv2.h"
66 #include "AliMUONSDigitizerv1.h"
67 #include "AliMUONRawData.h"
68 #include "AliMUONFactoryV2.h"
71 // Defaults parameters for Z positions of chambers
72 // taken from values for "stations" in AliMUON::AliMUON
73 // const Float_t zch[7]={528, 690., 975., 1249., 1449., 1610, 1710.};
74 // and from array "dstation" in AliMUONv1::CreateGeometry
75 // Float_t dstation[5]={20., 20., 20, 20., 20.};
76 // for tracking chambers,
77 // according to (Z1 = zch - dstation) and (Z2 = zch + dstation)
78 // for the first and second chambers in the station, respectively,
79 // and from "DTPLANES" in AliMUONv1::CreateGeometry
80 // const Float_t DTPLANES = 15.;
81 // for trigger chambers,
82 // according to (Z1 = zch) and (Z2 = zch + DTPLANES)
83 // for the first and second chambers in the station, respectively
87 //__________________________________________________________________
97 fSegmentationType(2),// set to 2 default wise new seg
110 // Default Constructor
115 //__________________________________________________________________
116 AliMUON::AliMUON(const char *name, const char *title)
117 : AliDetector(name,title),
118 fNCh(AliMUONConstants::NCh()),
119 fNTrackingCh(AliMUONConstants::NTrackingCh()),
125 fSegmentationType(2),// set to 2 default wise new seg
132 fMaxDestepGas(-1), // Negatives values are ignored by geant3 CONS200
133 fMaxDestepAlu(-1), // in the calculation of the tracking parameters
141 SetMarkerColor(kRed);//
144 fGeometryBuilder = new AliMUONGeometryBuilder(this);
146 // Common geometry definitions
148 ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
150 // Define the global transformation:
151 // Transformation from the old ALICE coordinate system to a new one:
153 TGeoRotation* rotGlobal
154 = new TGeoRotation("rotGlobal", 90., 180., 90., 90., 180., 0.);
156 ->SetGlobalTransformation (TGeoCombiTrans(0., 0., 0., rotGlobal));
158 // Detection elements indexing
159 fDEIndexing = new AliMUONGeometryDEIndexing();
162 // Creating List of Chambers
164 fChambers = new TObjArray(AliMUONConstants::NCh());
166 // Loop over stations
167 for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
168 // Loop over 2 chambers in the station
169 for (Int_t stCH = 0; stCH < 2; stCH++) {
172 // Default Parameters for Muon Tracking Stations
174 if (ch < AliMUONConstants::NTrackingCh()) {
175 fChambers->AddAt(new AliMUONChamber(ch),ch);
177 fChambers->AddAt(new AliMUONChamberTrigger(ch),ch);
179 AliMUONChamber* chamber = (AliMUONChamber*) fChambers->At(ch);
180 //chamber->SetGid(0);
181 // Default values for Z of chambers
182 chamber->SetZ(AliMUONConstants::DefaultChamberZ(ch));
184 chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
185 // Set chamber inner and outer radius to default
186 chamber->SetRInner(AliMUONConstants::Dmin(st)/2.);
187 chamber->SetROuter(AliMUONConstants::Dmax(st)/2.);
189 } // Chamber stCH (0, 1) in
190 } // Station st (0...)
192 // cp new design of AliMUONTriggerDecision
193 fTriggerCircuits = new TObjArray(AliMUONConstants::NTriggerCircuit());
194 for (Int_t circ=0; circ<AliMUONConstants::NTriggerCircuit(); circ++) {
195 fTriggerCircuits->AddAt(new AliMUONTriggerCircuit(),circ);
199 //____________________________________________________________________
200 AliMUON::AliMUON(const AliMUON& rMUON)
203 // Protected copy constructor
205 AliFatal("Not implemented.");
208 //____________________________________________________________________
212 AliDebug(1,"Calling AliMUON destructor");
219 if (fTriggerCircuits){
220 fTriggerCircuits->Delete();
221 delete fTriggerCircuits;
224 delete fGeometryBuilder;
229 //________________________________________________________________________
230 AliMUON& AliMUON::operator = (const AliMUON& rhs)
232 // Protected assignement operator
234 if (this == &rhs) return *this;
236 AliFatal("Not implemented.");
241 //_____________________________________________________________________________
242 void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
244 // Adds the geometry builder to the list
247 fGeometryBuilder->AddBuilder(geomBuilder);
250 //____________________________________________________________________
251 void AliMUON::BuildGeometry()
253 // Geometry for event display
255 if (!fSegmentationType) {
256 AliFatal("No Segmentation Type defined.");
261 // for (Int_t i = 0; i < AliMUONConstants::NCh(); i++)
262 // this->Chamber(i).SegmentationModel2(1)->Draw("eventdisplay");// to be check !
267 //__________________________________________________________________
268 void AliMUON::SetTreeAddress()
270 GetMUONData()->SetLoader(fLoader);
271 // GetMUONData()->MakeBranch("D,S,RC");
272 // GetMUONData()->SetTreeAddress("H,D,S,RC");
273 GetMUONData()->SetTreeAddress("H");
274 if (fHits != GetMUONData()->Hits()) {
275 if ( gAlice->GetMCApp() )
276 if ( gAlice->GetMCApp()->GetHitLists() ) {
277 fHits = GetMUONData()->Hits();
278 gAlice->GetMCApp()->AddHitList(fHits); // For purifyKine, only necessary when Hit list is created in AliMUONData
281 fHits = GetMUONData()->Hits(); // Added by Ivana to use the methods FisrtHit, NextHit of AliDetector
284 //___________________________________________
285 void AliMUON::SetChambersZ(const Float_t *Z)
287 // Set Z values for all chambers (tracking and trigger)
288 // from the array pointed to by "Z"
289 for (Int_t ch = 0; ch < AliMUONConstants::NCh(); ch++)
290 ((AliMUONChamber*) fChambers->At(ch))->SetZ(Z[ch]);
293 //_________________________________________________________________
294 void AliMUON::SetChambersZToDefault()
296 // Set Z values for all chambers (tracking and trigger)
298 SetChambersZ(AliMUONConstants::DefaultChamberZ());
301 //_________________________________________________________________
302 void AliMUON::SetChargeSlope(Int_t id, Float_t p1)
304 // Set the inverse charge slope for chamber id
305 Int_t i=2*(id-1); //PH ((AliMUONChamber*) (*fChambers)[i])->SetSigmaIntegration(p1);
306 //PH ((AliMUONChamber*) (*fChambers)[i+1])->SetSigmaIntegration(p1);
307 ((AliMUONChamber*) fChambers->At(i))->SetChargeSlope(p1);
308 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSlope(p1);
310 //__________________________________________________________________
311 void AliMUON::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
313 // Set sigma of charge spread for chamber id
315 ((AliMUONChamber*) fChambers->At(i))->SetChargeSpread(p1,p2);
316 ((AliMUONChamber*) fChambers->At(i+1))->SetChargeSpread(p1,p2);
318 //___________________________________________________________________
319 void AliMUON::SetSigmaIntegration(Int_t id, Float_t p1)
321 // Set integration limits for charge spread
323 ((AliMUONChamber*) fChambers->At(i))->SetSigmaIntegration(p1);
324 ((AliMUONChamber*) fChambers->At(i+1))->SetSigmaIntegration(p1);
327 //__________________________________________________________________
328 void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
330 // Set maximum number for ADCcounts (saturation)
332 ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
333 ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
336 //__________________________________________________________________
337 void AliMUON::SetMaxStepGas(Float_t p1)
339 // Set stepsize in gas
342 //__________________________________________________________________
343 void AliMUON::SetMaxStepAlu(Float_t p1)
345 // Set step size in Alu
348 //__________________________________________________________________
349 void AliMUON::SetMaxDestepGas(Float_t p1)
351 // Set maximum step size in Gas
354 //__________________________________________________________________
355 void AliMUON::SetMaxDestepAlu(Float_t p1)
357 // Set maximum step size in Alu
361 //____________________________________________________________________
362 Float_t AliMUON::GetMaxStepGas() const
364 // Return stepsize in gas
369 //____________________________________________________________________
370 Float_t AliMUON::GetMaxStepAlu() const
372 // Return step size in Alu
377 //____________________________________________________________________
378 Float_t AliMUON::GetMaxDestepGas() const
380 // Return maximum step size in Gas
382 return fMaxDestepGas;
385 //____________________________________________________________________
386 Float_t AliMUON::GetMaxDestepAlu() const
388 // Return maximum step size in Gas
390 return fMaxDestepAlu;
393 //____________________________________________________________________
394 void AliMUON::SetAlign(Bool_t align)
396 // Sets option for alignement to geometry builder
398 fGeometryBuilder->SetAlign(align);
401 //____________________________________________________________________
402 void AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliMUONGeometrySegmentation* segmentation)
404 // Set the segmentation for chamber id cathode isec
405 ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
408 //____________________________________________________________________
409 void AliMUON::SetResponseModel(Int_t id, AliMUONResponse *response)
411 // Set the response for chamber id
412 ((AliMUONChamber*) fChambers->At(id))->SetResponseModel(response);
414 //____________________________________________________________________
415 void AliMUON::SetNsec(Int_t id, Int_t nsec)
417 // Set number of segmented cathods for chamber id
418 ((AliMUONChamber*) fChambers->At(id))->SetNsec(nsec);
420 //____________________________________________________________________
421 AliDigitizer* AliMUON::CreateDigitizer(AliRunDigitizer* manager) const
423 return new AliMUONDigitizerv2(manager);
425 //_____________________________________________________________________
426 void AliMUON::SDigits2Digits()
432 // sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
433 fLoader->TreeD()->Write(hname,TObject::kOverwrite);
434 fLoader->TreeD()->Reset();
437 //_____________________________________________________________________
438 void AliMUON::Hits2SDigits()
440 // Adaption of AliMUONSDigitizerv1 to be excuted by the AliSimulation framework
441 AliRunLoader* runLoader = fLoader->GetRunLoader();
442 AliRunDigitizer * manager = new AliRunDigitizer(1,1);
443 manager->SetInputStream(0,runLoader->GetFileName(),AliConfig::GetDefaultEventFolderName());
444 AliMUONDigitizer * dMUON = new AliMUONSDigitizerv1(manager);
445 fLoader->LoadHits("READ");
446 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
447 runLoader->GetEvent(iEvent);
450 fLoader->UnloadHits();
452 //_____________________________________________________________________
453 void AliMUON::Digits2Raw()
455 // convert digits of the current event to raw data
456 AliMUONRawData* rawData;
458 rawData = new AliMUONRawData(fLoader);
459 if (!rawData->WriteRawData()) AliInfo("pb writting raw data");
463 //_______________________________________________________________________
464 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
466 //builds standard getter (AliLoader type)
467 //if detector wants to use castomized getter, it must overload this method
470 AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
471 GetName(),topfoldername));
472 fLoader = new AliLoader(GetName(),topfoldername);
473 fMUONData = new AliMUONData(fLoader,GetName(),GetName());
474 fMUONData->SetSplitLevel(fSplitLevel);
477 //_______________________________________________________________________
479 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
482 // Return rawcluster (icluster) for chamber ichamber and cathode icathod
484 TClonesArray *muonRawCluster = GetMUONData()->RawClusters(ichamber);
486 TTree *treeR = fLoader->TreeR();
487 Int_t nent=(Int_t)treeR->GetEntries();
488 treeR->GetEvent(nent-2+icathod-1);
489 //treeR->GetEvent(icathod);
490 //Int_t nrawcl = (Int_t)muonRawCluster->GetEntriesFast();
492 AliMUONRawCluster * mRaw = (AliMUONRawCluster*)muonRawCluster->UncheckedAt(icluster);
493 //printf("RawCluster _ nent nrawcl icluster mRaw %d %d %d%p\n",nent,nrawcl,icluster,mRaw);
497 //________________________________________________________________________