1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * SigmaEffect_thetadegrees *
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 purpeateose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 /////////////////////////////////////////////////////////
19 // Manager and hits classes for set:MUON version 1 //
20 /////////////////////////////////////////////////////////
24 #include <TClonesArray.h>
26 #include <TVirtualMC.h>
27 #include <TGeoMatrix.h>
29 #include "AliMUONv1.h"
31 #include "AliMUONChamber.h"
32 #include "AliMUONConstants.h"
33 #include "AliMUONFactory.h"
34 #include "AliMUONHit.h"
35 #include "AliMUONTriggerCircuit.h"
36 #include "AliMUONGeometryBuilder.h"
37 #include "AliMUONGeometrySVMap.h"
44 //___________________________________________
45 AliMUONv1::AliMUONv1()
47 fStepManagerVersionOld(kFALSE),
49 fStepMaxInActiveGas(0.6),
56 fAngleEffectNorma(0x0)
58 // Default constructor
61 //___________________________________________
62 AliMUONv1::AliMUONv1(const char *name, const char *title)
63 : AliMUON(name,title),
64 fStepManagerVersionOld(kFALSE),
66 fStepMaxInActiveGas(0.6),
73 fAngleEffectNorma(0x0)
75 // Standard onstructor
77 // By default include all stations
78 AliMUONFactory factory;
79 factory.Build(this, title);
81 fStepSum = new Float_t [AliMUONConstants::NCh()];
82 fDestepSum = new Float_t [AliMUONConstants::NCh()];
83 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
87 // Ratio of particle mean eloss with respect MIP's Khalil Boudjemline, sep 2003, PhD.Thesis and Particle Data Book
88 fElossRatio = new TF1("ElossRatio","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",0.5,5.);
89 fElossRatio->SetParameter(0,1.02138);
90 fElossRatio->SetParameter(1,-9.54149e-02);
91 fElossRatio->SetParameter(2,+7.83433e-02);
92 fElossRatio->SetParameter(3,-9.98208e-03);
93 fElossRatio->SetParameter(4,+3.83279e-04);
95 // Angle effect in tracking chambers at theta =10 degres as a function of ElossRatio (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis) (in micrometers)
96 fAngleEffect10 = new TF1("AngleEffect10","[0]+[1]*x+[2]*x*x",0.5,3.0);
97 fAngleEffect10->SetParameter(0, 1.90691e+02);
98 fAngleEffect10->SetParameter(1,-6.62258e+01);
99 fAngleEffect10->SetParameter(2,+1.28247e+01);
100 // Angle effect: Normalisation form theta=10 degres to theta between 0 and 10 (Khalil BOUDJEMLINE sep 2003 Ph.D Thesis)
101 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
102 fAngleEffectNorma = new TF1("AngleEffectNorma","[0]+[1]*x+[2]*x*x+[3]*x*x*x",0.0,10.0);
103 fAngleEffectNorma->SetParameter(0,4.148);
104 fAngleEffectNorma->SetParameter(1,-6.809e-01);
105 fAngleEffectNorma->SetParameter(2,5.151e-02);
106 fAngleEffectNorma->SetParameter(3,-1.490e-03);
109 //_____________________________________________________________________________
110 AliMUONv1::AliMUONv1(const AliMUONv1& right)
113 // copy constructor (not implemented)
115 Fatal("AliMUONv1", "Copy constructor not provided.");
118 //___________________________________________
119 AliMUONv1::~AliMUONv1()
124 delete [] fDestepSum;
126 delete fAngleEffect10;
127 delete fAngleEffectNorma;
130 //_____________________________________________________________________________
131 AliMUONv1& AliMUONv1::operator=(const AliMUONv1& right)
133 // assignement operator (not implemented)
135 // check assignement to self
136 if (this == &right) return *this;
138 Fatal("operator =", "Assignement operator not provided.");
143 //__________________________________________________
144 void AliMUONv1::CreateGeometry()
147 // Construct geometry using geometry builder
150 fGeometryBuilder->CreateGeometry();
153 //________________________________________________________________
154 void AliMUONv1::CreateMaterials()
157 // Construct materials using geometry builder
160 fGeometryBuilder->CreateMaterials();
163 #include "AliMUONChamberGeometry.h"
164 #include "AliMUONGeometryTransformStore.h"
165 //___________________________________________
166 void AliMUONv1::Init()
169 // Initialize Tracking Chambers
172 if(fDebug) printf("\n%s: Start Init for version 1 - CPC chamber type\n\n",ClassName());
174 for (i=0; i<AliMUONConstants::NCh(); i++) {
175 ( (AliMUONChamber*) (*fChambers)[i])->Init();
179 // Initialize geometry
181 fGeometryBuilder->InitGeometry();
182 if(fDebug) printf("\n%s: Finished Init for version 1 - CPC chamber type\n",ClassName());
185 if(fDebug) printf("\n%s: Start Init for Trigger Circuits\n",ClassName());
186 for (i=0; i<AliMUONConstants::NTriggerCircuit(); i++) {
187 ( (AliMUONTriggerCircuit*) (*fTriggerCircuits)[i])->Init(i);
189 if(fDebug) printf("%s: Finished Init for Trigger Circuits\n",ClassName());
196 // Print transformations and SV map
197 for (i=0; i<AliMUONConstants::NCh(); i++) {
199 cout << "Chamber: " << i+1 << endl;
200 cout << "===================" << endl;
202 Chamber(i).GetGeometry()
203 ->GetTransformStore()->Print("");
205 Chamber(i).GetGeometry()
206 ->GetSVMap()->Print("");
212 //__________________________________________________________________
213 Int_t AliMUONv1::GetChamberId(Int_t volId) const
215 // Check if the volume with specified volId is a sensitive volume (gas)
216 // of some chamber and returns the chamber number;
217 // if not sensitive volume - return 0.
221 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
222 if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
224 for (Int_t i = 1; i <= AliMUONConstants::NCh(); i++)
225 if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(volId) ) return i;
230 //_______________________________________________________________________________
231 TString AliMUONv1::CurrentVolumePath() const
233 // Returns current volume path
234 // (Could be removed when this function is available via gMC)
242 name = gMC->CurrentVolOffName(imother);
243 gMC->CurrentVolOffID(imother++, copyNo);
250 while ( name != TString("ALIC") );
255 //_______________________________________________________________________________
256 void AliMUONv1::StepManager()
258 // Stepmanager for the chambers
260 if (fStepManagerVersionOld) {
265 // Only charged tracks
266 if( !(gMC->TrackCharge()) && !(gMC->TrackPid()==0) ) return;
267 // Only charged tracks
269 // Only gas gap inside chamber
270 // Tag chambers and record hits when track enters
271 static Int_t idvol=-1;
275 const Float_t kBig = 1.e10;
279 // Only gas gap inside chamber
280 // Tag chambers and record hits when track enters
281 id=gMC->CurrentVolID(copy);
282 iChamber = GetChamberId(id);
285 if (idvol == -1) return;
287 if (GetDebug() > 1) {
288 // Fill the global position of detection elements
289 // Only for verification
290 AliMUONGeometrySVMap* svMap
291 = Chamber(iChamber-1).GetGeometry()->GetSVMap();
293 gMC->TrackPosition(x, y, z);
294 svMap->AddPosition(CurrentVolumePath(), TGeoTranslation(x, y, z));
297 if (gMC->TrackPid()==0) return;
299 // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
300 if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) )
301 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
303 if( gMC->IsTrackEntering() ) {
304 Float_t theta = fTrackMomentum.Theta();
305 if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
309 // Float_t z = ( (AliMUONChamber*)(*fChambers)[idvol])->Z() ;
310 // Info("StepManager Step","Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber, z);
312 // Particule id and mass,
313 Int_t ipart = gMC->TrackPid();
314 Float_t mass = gMC->TrackMass();
316 fDestepSum[idvol]+=gMC->Edep();
317 // Get current particle id (ipart), track position (pos) and momentum (mom)
318 if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum);
319 fStepSum[idvol]+=gMC->TrackStep();
322 // Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g",
323 // iChamber,ipart, fTrackMomentum.Theta()*kRaddeg, fTrackMomentum.Phi()*kRaddeg, mass, fStepSum[idvol], gMC->Edep());// Info("StepManager Step","Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(), fTrackMomentum.Z()) ;
324 // gMC->TrackPosition(fTrackPosition);
325 // Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
328 // Track left chamber or StepSum larger than fStepMaxInActiveGas
329 if ( gMC->IsTrackExiting() ||
330 gMC->IsTrackStop() ||
331 gMC->IsTrackDisappeared()||
332 (fStepSum[idvol]>fStepMaxInActiveGas) ) {
334 if ( gMC->IsTrackExiting() ||
335 gMC->IsTrackStop() ||
336 gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
338 gMC->TrackPosition(fTrackPosition);
339 Float_t theta = fTrackMomentum.Theta();
340 Float_t phi = fTrackMomentum.Phi();
342 TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi),
343 fStepSum[idvol]/2.*sin(theta)*sin(phi),
344 fStepSum[idvol]/2.*cos(theta),0.0 );
346 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
348 // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ;
349 fTrackPosition-=backToWire;
351 //-------------- Angle effect
352 // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass)
354 Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2
355 Float_t sigmaEffect10degrees;
356 Float_t sigmaEffectThetadegrees;
357 Float_t eLossParticleELossMip;
358 Float_t yAngleEffect=0.;
359 Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
363 if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) {
364 betaxGamma=TMath::Log(betaxGamma);
365 eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
366 // 10 degrees is a reference for a model (arbitrary)
367 sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
368 // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
369 sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap
370 if ( (iChamber==1) || (iChamber==2) )
371 sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
372 yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
376 // Detection elements ids
377 AliMUONGeometryTransformStore* transforms
378 = Chamber(iChamber-1).GetGeometry()->GetTransformStore();
379 const TGeoCombiTrans* kTransform
380 = transforms->FindBySensitiveVolume(CurrentVolumePath());
383 if (kTransform) detElemId = kTransform->GetUniqueID();
386 cerr << "Chamber id: "
387 << setw(3) << iChamber << " "
389 << CurrentVolumePath()
391 << setw(5) << detElemId
394 gMC->TrackPosition(x, y, z);
395 cerr << " global position: "
396 << x << ", " << y << ", " << z
398 Warning("StepManager", "DetElemId not identified.");
401 // One hit per chamber
402 GetMUONData()->AddHit(fIshunt,
403 gAlice->GetMCApp()->GetCurrentTrackNumber(),
406 fTrackPosition.Y()+yAngleEffect,
419 // Info("StepManager Exit","Particle exiting from chamber %d",iChamber);
420 // Info("StepManager Exit","StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]);
421 // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
423 fStepSum[idvol] =0; // Reset for the next event
424 fDestepSum[idvol]=0; // Reset for the next event
428 //__________________________________________
429 void AliMUONv1::StepManagerOld()
431 // Old Stepmanager for the chambers
433 static Int_t idvol =-1;
439 Float_t destep, step;
441 static Float_t sstep;
442 static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength;
443 const Float_t kBig = 1.e10;
444 static Float_t hits[15];
446 TClonesArray &lhits = *fHits;
450 // Only charged tracks
451 if( !(gMC->TrackCharge()) ) return;
453 // Only gas gap inside chamber
454 // Tag chambers and record hits when track enters
455 id=gMC->CurrentVolID(copy);
456 vol[0] = GetChamberId(id);
459 if (idvol == -1) return;
462 // Get current particle id (ipart), track position (pos) and momentum (mom)
463 gMC->TrackPosition(pos);
464 gMC->TrackMomentum(mom);
466 ipart = gMC->TrackPid();
469 // momentum loss and steplength in last step
470 destep = gMC->Edep();
471 step = gMC->TrackStep();
472 // cout<<"------------"<<step<<endl;
474 // record hits when track enters ...
475 if( gMC->IsTrackEntering()) {
477 gMC->SetMaxStep(fMaxStepGas);
478 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
479 Double_t rt = TMath::Sqrt(tc);
480 Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
481 Double_t tx = mom[0]/pmom;
482 Double_t ty = mom[1]/pmom;
483 Double_t tz = mom[2]/pmom;
484 Double_t s = ((AliMUONChamber*)(*fChambers)[idvol])
487 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
488 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
489 hits[0] = Float_t(ipart); // Geant3 particle type
490 hits[1] = pos[0]+s*tx; // X-position for hit
491 hits[2] = pos[1]+s*ty; // Y-position for hit
492 hits[3] = pos[2]+s*tz; // Z-position for hit
493 hits[4] = theta; // theta angle of incidence
494 hits[5] = phi; // phi angle of incidence
495 hits[8] = 0;//PadHits does not exist anymore (Float_t) fNPadHits; // first padhit
496 hits[9] = -1; // last pad hit
497 hits[10] = mom[3]; // hit momentum P
498 hits[11] = mom[0]; // Px
499 hits[12] = mom[1]; // Py
500 hits[13] = mom[2]; // Pz
501 tof=gMC->TrackTime();
502 hits[14] = tof; // Time of flight
510 Chamber(idvol).ChargeCorrelationInit();
511 // Only if not trigger chamber
513 // printf("---------------------------\n");
514 // printf(">>>> Y = %f \n",hits[2]);
515 // printf("---------------------------\n");
519 // if(idvol < AliMUONConstants::NTrackingCh()) {
521 // // Initialize hit position (cursor) in the segmentation model
522 // ((AliMUONChamber*) (*fChambers)[idvol])
523 // ->SigGenInit(pos[0], pos[1], pos[2]);
525 // //geant3->Gpcxyz();
526 // //printf("In the Trigger Chamber #%d\n",idvol-9);
532 // cout<<sstep<<endl;
535 // Calculate the charge induced on a pad (disintegration) in case
537 // Mip left chamber ...
538 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
539 gMC->SetMaxStep(kBig);
545 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
546 gMC->Gmtod(globalPos,localPos,1);
548 if(idvol < AliMUONConstants::NTrackingCh()) {
550 x0 = 0.5*(xhit+pos[0]);
551 y0 = 0.5*(yhit+pos[1]);
552 z0 = 0.5*(zhit+pos[2]);
561 // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol);
564 hits[6] = tlength; // track length
565 hits[7] = eloss2; // de/dx energy loss
568 // if (fNPadHits > (Int_t)hits[8]) {
569 // hits[8] = hits[8]+1;
570 // hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits;
576 AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits);
579 // Check additional signal generation conditions
580 // defined by the segmentation
581 // model (boundary crossing conditions)
582 // only for tracking chambers
584 ((idvol < AliMUONConstants::NTrackingCh()) &&
585 ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2]))
587 ((AliMUONChamber*) (*fChambers)[idvol])
588 ->SigGenInit(pos[0], pos[1], pos[2]);
591 Float_t globalPos[3] = {pos[0], pos[1], pos[2]};
592 gMC->Gmtod(globalPos,localPos,1);
596 // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh())
597 // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol);
604 // nothing special happened, add up energy loss
611 //______________________________________________________________________________
612 void AliMUONv1::FinishRun()
617 if (GetDebug() <= 1) return;
619 // Print the global positions of detection elements
620 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
622 cout << "Chamber: " << i+1 << endl;
623 cout << "===================" << endl;
625 AliMUONGeometrySVMap* svMap
626 = Chamber(i).GetGeometry()->GetSVMap();
628 svMap->SortPositions();
629 svMap->PrintPositions();
630 svMap->ClearPositions();