From d59b2ec39e37db12f9d4b3914b5626db127e6bb5 Mon Sep 17 00:00:00 2001 From: martinez Date: Mon, 17 Jan 2005 11:04:00 +0000 Subject: [PATCH] AliMUONHit can store now optionnally either chamber Id either (Ivana) --- MUON/AliMUONData.cxx | 22 +-- MUON/AliMUONData.h | 7 +- MUON/AliMUONHit.cxx | 132 ++++++++++++- MUON/AliMUONHit.h | 29 ++- MUON/AliMUONv0.cxx | 66 ------- MUON/AliMUONv0.h | 3 +- MUON/AliMUONv1.cxx | 424 +++++++++++++++++++++++++++++++++++----- MUON/AliMUONv1.h | 8 +- MUON/Config_MUON_test.C | 5 +- MUON/MUONsimLinkDef.h | 3 +- MUON/libMUONsim.pkg | 2 +- 11 files changed, 555 insertions(+), 146 deletions(-) diff --git a/MUON/AliMUONData.cxx b/MUON/AliMUONData.cxx index b3d852b59a4..19d48d83cff 100644 --- a/MUON/AliMUONData.cxx +++ b/MUON/AliMUONData.cxx @@ -222,21 +222,23 @@ void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger ) TClonesArray &globalTrigger = *fGlobalTrigger; new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger); } -//_____________________________________________________________________________ +//____________________________________________________________________________ void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber, Int_t idpart, Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, Float_t theta, - Float_t phi, Float_t length, Float_t destep) + Float_t phi, Float_t length, Float_t destep, + Float_t Xref,Float_t Yref,Float_t Zref) { - // Add new hit to the hit list + // Add new hit to the hit list TClonesArray &lhits = *fHits; new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber, idpart, X, Y, Z, tof, momentum, theta, - phi, length, destep); + phi, length, destep, + Xref,Yref,Zref, true); } //____________________________________________________________________________ -void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber, +void AliMUONData::AddHit2(Int_t fIshunt, Int_t track, Int_t detElemId, Int_t idpart, Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, Float_t theta, Float_t phi, Float_t length, Float_t destep, @@ -244,17 +246,11 @@ void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber, { // Add new hit to the hit list TClonesArray &lhits = *fHits; - new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber, + new(lhits[fNhits++]) AliMUONHit(fIshunt, track, detElemId, idpart, X, Y, Z, tof, momentum, theta, phi, length, destep, - Xref,Yref,Zref); -} -//____________________________________________________________________________ -void AliMUONData::AddHit(const AliMUONHit& hit) -{ - TClonesArray &lhits = *fHits; - new(lhits[fNhits++]) AliMUONHit(hit); + Xref,Yref,Zref, true); } //____________________________________________________________________________ void AliMUONData::AddLocalTrigger(Int_t *localtr) diff --git a/MUON/AliMUONData.h b/MUON/AliMUONData.h index 9e49e09b785..f507535fee2 100644 --- a/MUON/AliMUONData.h +++ b/MUON/AliMUONData.h @@ -52,13 +52,14 @@ class AliMUONData : public TNamed virtual void AddHit(Int_t fIshunt, Int_t track, Int_t iChamber, Int_t idpart, Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, Float_t theta, - Float_t phi, Float_t length, Float_t destep); - virtual void AddHit(Int_t fIshunt, Int_t track, Int_t iChamber, + Float_t phi, Float_t length, Float_t destep, + Float_t Xref,Float_t Yref,Float_t Zref); + // TBR + virtual void AddHit2(Int_t fIshunt, Int_t track, Int_t detElemId, Int_t idpart, Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, Float_t theta, Float_t phi, Float_t length, Float_t destep, Float_t Xref,Float_t Yref,Float_t Zref); - virtual void AddHit(const AliMUONHit& hit); // use copy constructor virtual void AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus, Int_t *singleUndef, Int_t *pairUnlike, diff --git a/MUON/AliMUONHit.cxx b/MUON/AliMUONHit.cxx index d6c6e375b2e..82c249e0206 100644 --- a/MUON/AliMUONHit.cxx +++ b/MUON/AliMUONHit.cxx @@ -27,6 +27,8 @@ #include #include "AliMUONHit.h" +#include "AliMUONVGeometryDEIndexing.h" +#include "AliLog.h" ClassImp(AliMUONHit) @@ -42,7 +44,10 @@ AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits): AliHit(shunt, track) { // Constructor - fChamber = vol[0]; +// TBR + + fIsDetElemId = kFALSE; + fDetElemId = vol[0]; fParticle = hits[0]; fX = hits[1]; fY = hits[2]; @@ -62,6 +67,36 @@ AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits): fYref = 0.; fZref = 0.; } + +//___________________________________________ +AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits, + Bool_t /*isDetElemId*/) : + AliHit(shunt, track) +{ +// Constructor + + fIsDetElemId = kTRUE; + fDetElemId = vol[0]; + fParticle = hits[0]; + fX = hits[1]; + fY = hits[2]; + fZ = hits[3]; + fTheta = hits[4]; + fPhi = hits[5]; + fTlength = hits[6]; + fEloss = hits[7]; + fPHfirst = (Int_t) hits[8]; + fPHlast = (Int_t) hits[9]; + fPTot = hits[10]; + fPx = hits[11]; + fPy = hits[12]; + fPz = hits[13]; + fAge = hits[14]; + fXref = 0.; + fYref = 0.; + fZref = 0.; +} + //___________________________________________ AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t iChamber, Int_t idpart, Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, @@ -69,7 +104,10 @@ AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t iChamber, Int_t idpart, AliHit(shunt, track) { // Constructor - fChamber = iChamber; +// TBR + + fIsDetElemId = kFALSE; + fDetElemId = iChamber; fParticle = idpart; fX = X; fY = Y; @@ -89,6 +127,37 @@ AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t iChamber, Int_t idpart, fYref = 0.; fZref = 0.; } + +//___________________________________________ +AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t detElemId, Int_t idpart, + Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, + Float_t theta, Float_t phi, Float_t length, Float_t destep, + Bool_t /*isDetElemId*/): + AliHit(shunt, track) +{ +// Constructor + fIsDetElemId = kTRUE; + fDetElemId = detElemId; + fParticle = idpart; + fX = X; + fY = Y; + fZ = Z; + fTheta = theta; + fPhi = phi; + fTlength = length; + fEloss = destep; + fPHfirst = 0; + fPHlast = 0; + fPTot = momentum; + fPx = momentum * TMath::Sin(theta) * TMath::Cos(phi); + fPy = momentum * TMath::Sin(theta) * TMath::Sin(phi); + fPz = momentum * TMath::Cos(theta) ; + fAge = tof; + fXref = 0.; + fYref = 0.; + fZref = 0.; +} + //----------------------------------------------------------------------------------------------- AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t iChamber, Int_t idpart, Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, @@ -97,7 +166,10 @@ AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t iChamber, Int_t idpart, AliHit(shunt, track) { // Constructor - fChamber = iChamber; +// TBR + + fIsDetElemId = kFALSE; + fDetElemId = iChamber; fParticle = idpart; fX = X; fY = Y; @@ -118,4 +190,58 @@ AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t iChamber, Int_t idpart, fZref = Zref; } //----------------------------------------------------------------------------------------------- +AliMUONHit::AliMUONHit(Int_t shunt, Int_t track, Int_t detElemId, Int_t idpart, + Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, + Float_t theta, Float_t phi, Float_t length, Float_t destep, + Float_t Xref,Float_t Yref,Float_t Zref, + Bool_t /*isDetElemId*/): + AliHit(shunt, track) +{ +// Constructor + fIsDetElemId = kTRUE; + fDetElemId = detElemId; + fParticle = idpart; + fX = X; + fY = Y; + fZ = Z; + fTheta = theta; + fPhi = phi; + fTlength = length; + fEloss = destep; + fPHfirst = 0; + fPHlast = 0; + fPTot = momentum; + fPx = momentum * TMath::Sin(theta) * TMath::Cos(phi); + fPy = momentum * TMath::Sin(theta) * TMath::Sin(phi); + fPz = momentum * TMath::Cos(theta) ; + fAge = tof; + fXref = Xref; + fYref = Yref; + fZref = Zref; +} + +//----------------------------------------------------------------------------------------------- +Int_t AliMUONHit::DetElemId()const +{ +// Return detection element ID + + if (!fIsDetElemId) { + AliWarning("Detection element Id is not defined."); + return 0; + } + // end of TBR + + return fDetElemId; +} + +//----------------------------------------------------------------------------------------------- +Int_t AliMUONHit::Chamber() const +{ +// Return chamber ID + + if (!fIsDetElemId) + return fDetElemId; + else + return AliMUONVGeometryDEIndexing::GetModuleId(fDetElemId); +} diff --git a/MUON/AliMUONHit.h b/MUON/AliMUONHit.h index b70073c543d..d093fbf1f9f 100644 --- a/MUON/AliMUONHit.h +++ b/MUON/AliMUONHit.h @@ -23,14 +23,32 @@ class AliMUONHit : public AliHit { public: AliMUONHit(); - AliMUONHit(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *hits); - AliMUONHit(Int_t fIshunt, Int_t track, Int_t iChamber, Int_t idpart, Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, Float_t theta, Float_t phi, Float_t length, Float_t destep); + AliMUONHit(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *hits); + // TBR + AliMUONHit(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *hits, + Bool_t isNew); + + AliMUONHit(Int_t fIshunt, Int_t track, Int_t iChamber, Int_t idpart, + Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, + Float_t theta, Float_t phi, Float_t length, Float_t destep); + // TBR + AliMUONHit(Int_t fIshunt, Int_t track, Int_t detElemId, Int_t idpart, + Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, + Float_t theta, Float_t phi, Float_t length, Float_t destep, Bool_t isNew); + AliMUONHit(Int_t fIshunt, Int_t track, Int_t iChamber, Int_t idpart, Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, Float_t theta, Float_t phi, Float_t length, Float_t destep, Float_t Xref, Float_t Yref, Float_t Zref); + // TBR + AliMUONHit(Int_t fIshunt, Int_t track, Int_t detElemId, Int_t idpart, + Float_t X, Float_t Y, Float_t Z, Float_t tof, Float_t momentum, + Float_t theta, Float_t phi, Float_t length, Float_t destep, + Float_t Xref, Float_t Yref, Float_t Zref, Bool_t isNew); virtual ~AliMUONHit() {} - Int_t Chamber() const {return fChamber;} + + Int_t DetElemId()const; + Int_t Chamber() const; Float_t Particle() const {return fParticle;} Float_t Theta() const {return fTheta;} Float_t Phi() const {return fPhi;} @@ -52,8 +70,9 @@ class AliMUONHit : public AliHit { Float_t Yref() const {return fYref;} Float_t Zref() const {return fZref;} - private: - Int_t fChamber; // Chamber number + private: + Bool_t fIsDetElemId; // False if fDetElemId contains Chamber Id (old code) + Int_t fDetElemId; // Detection element ID Float_t fParticle; // Geant3 particle type Float_t fTheta ; // Incident theta angle in degrees Float_t fPhi ; // Incident phi angle in degrees diff --git a/MUON/AliMUONv0.cxx b/MUON/AliMUONv0.cxx index 0c902aaecec..05468bf2165 100644 --- a/MUON/AliMUONv0.cxx +++ b/MUON/AliMUONv0.cxx @@ -161,72 +161,6 @@ void AliMUONv0::Init() } } -void AliMUONv0::StepManager() -{ -// -// Step manager for hit density simulations - Int_t copy, id; - static Int_t idvol; - static Int_t vol[2]; - Int_t ipart; - TLorentzVector pos; - TLorentzVector mom; - Float_t theta,phi; - - // modifs perso - static Float_t hits[15]; - - TClonesArray &lhits = *fHits; - // - // Only gas gap inside chamber - // Tag chambers and record hits when track enters - idvol=-1; - id=gMC->CurrentVolID(copy); - - for (Int_t i=1; i<=AliMUONConstants::NCh(); i++) { - //if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){ - if ( ((AliMUONChamber*)(*fChambers)[i-1])->IsSensId(id) ) { - vol[0]=i; - idvol=i-1; - } - } - if (idvol == -1) return; - // - // Get current particle id (ipart), track position (pos) and momentum (mom) - gMC->TrackPosition(pos); - gMC->TrackMomentum(mom); - - ipart = gMC->TrackPid(); - // - // record hits when track enters ... - if( !(gMC->TrackCharge()) ) return; - if( gMC->IsTrackEntering()) { -// printf("\n Particle entering %f %f %f", pos[0], pos[1], pos[2] ); - - Double_t tc = mom[0]*mom[0]+mom[1]*mom[1]; - Double_t rt = TMath::Sqrt(tc); - theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg; - phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg; - hits[0] = Float_t(ipart); // Geant3 particle type - hits[1] = pos[0]; // X-position for hit - hits[2] = pos[1]; // Y-position for hit - hits[3] = pos[2]; // Z-position for hit - hits[4] = theta; // theta angle of incidence - hits[5] = phi; // phi angle of incidence - hits[8] = -1; // first padhit - hits[9] = -1; // last pad hit - hits[10] = mom[3]; // hit Energy - hits[11] = mom[0]; // Px - hits[12] = mom[1]; // Py - hits[13] = mom[2]; // Pz - hits[14] = gMC->TrackTime(); // time of flight - new(lhits[fNhits++]) - AliMUONHit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits); - - } -// if( gMC->IsTrackExiting()) gMC->StopTrack(); -} - diff --git a/MUON/AliMUONv0.h b/MUON/AliMUONv0.h index a2ece181fd3..57869771e39 100644 --- a/MUON/AliMUONv0.h +++ b/MUON/AliMUONv0.h @@ -22,8 +22,7 @@ public: virtual void CreateGeometry(); virtual void CreateMaterials(); virtual void Init(); - virtual Int_t IsVersion() const {return 0;} - virtual void StepManager(); + virtual Int_t IsVersion() const {return 0;} private: ClassDef(AliMUONv0,1) // MUON Detector class Version 0 }; diff --git a/MUON/AliMUONv1.cxx b/MUON/AliMUONv1.cxx index 7bed63f12b6..3c4f2830732 100644 --- a/MUON/AliMUONv1.cxx +++ b/MUON/AliMUONv1.cxx @@ -48,6 +48,7 @@ ClassImp(AliMUONv1) AliMUONv1::AliMUONv1() : AliMUON(), fStepManagerVersionOld(kFALSE), + fStepManagerVersionDE(kFALSE), fAngleEffect(kTRUE), fStepMaxInActiveGas(0.6), fStepSum(0x0), @@ -65,6 +66,7 @@ AliMUONv1::AliMUONv1() AliMUONv1::AliMUONv1(const char *name, const char *title) : AliMUON(name,title), fStepManagerVersionOld(kFALSE), + fStepManagerVersionDE(kFALSE), fAngleEffect(kTRUE), fStepMaxInActiveGas(0.6), fStepSum(0x0), @@ -188,23 +190,6 @@ void AliMUONv1::Init() } AliDebug(1,"Finished Init for Trigger Circuits"); //cp - - // - // Debug info - // - // Print transformations and SV map - for (i=0; iGetDetElementStore()->PrintLocalTransforms(); - - if (GetDebug() >1) Chamber(i).GetGeometry()->GetSVMap()->Print(""); - } - AliDebug(2,"\n"); } //__________________________________________________________________ @@ -254,6 +239,12 @@ TString AliMUONv1::CurrentVolumePath() const void AliMUONv1::StepManager() { // Stepmanager for the chambers + // TBR + + if (fStepManagerVersionDE) { + StepManager2(); + return; + } if (fStepManagerVersionOld) { StepManagerOld(); @@ -261,7 +252,7 @@ void AliMUONv1::StepManager() } // Only charged tracks - if( !(gMC->TrackCharge()) && !(gMC->TrackPid()==0) ) return; + if( !(gMC->TrackCharge()) ) return; // Only charged tracks // Only gas gap inside chamber @@ -281,18 +272,6 @@ void AliMUONv1::StepManager() idvol = iChamber -1; if (idvol == -1) return; - - if (GetDebug() > 1) { - // Fill the global position of detection elements - // Only for verification - AliMUONGeometrySVMap* svMap - = Chamber(iChamber-1).GetGeometry()->GetSVMap(); - Double_t x, y, z; - gMC->TrackPosition(x, y, z); - svMap->AddPosition(CurrentVolumePath(), TGeoTranslation(x, y, z)); - } - - if (gMC->TrackPid()==0) return; // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) ) @@ -424,10 +403,174 @@ void AliMUONv1::StepManager() } } +//_______________________________________________________________________________ +void AliMUONv1::StepManager2() +{ + // Stepmanager for the chambers + + if (fStepManagerVersionOld) { + StepManagerOld2(); + return; + } + + // Only charged tracks + if( !(gMC->TrackCharge()) ) return; + // Only charged tracks + + // Only gas gap inside chamber + // Tag chambers and record hits when track enters + static Int_t idvol=-1; + Int_t iChamber=0; + Int_t id=0; + Int_t copy; + const Float_t kBig = 1.e10; + + + // + // Only gas gap inside chamber + // Tag chambers and record hits when track enters + id=gMC->CurrentVolID(copy); + iChamber = GetChamberId(id); + idvol = iChamber -1; + + if (idvol == -1) return; + + // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers + if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) ) + AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber()); + + if( gMC->IsTrackEntering() ) { + Float_t theta = fTrackMomentum.Theta(); + if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative + } + +// if (GetDebug()) { +// Float_t z = ( (AliMUONChamber*)(*fChambers)[idvol])->Z() ; +// Info("StepManager Step","Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber, z); +// } + // Particule id and mass, + Int_t ipart = gMC->TrackPid(); + Float_t mass = gMC->TrackMass(); + + fDestepSum[idvol]+=gMC->Edep(); + // Get current particle id (ipart), track position (pos) and momentum (mom) + if ( fStepSum[idvol]==0.0 ) gMC->TrackMomentum(fTrackMomentum); + fStepSum[idvol]+=gMC->TrackStep(); + +// if (GetDebug()) { +// Info("StepManager Step","iChamber %d, Particle %d, theta %f phi %f mass %f StepSum %f eloss %g", +// 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()) ; +// gMC->TrackPosition(fTrackPosition); +// Info("StepManager Step","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ; +// } + + // Track left chamber or StepSum larger than fStepMaxInActiveGas + if ( gMC->IsTrackExiting() || + gMC->IsTrackStop() || + gMC->IsTrackDisappeared()|| + (fStepSum[idvol]>fStepMaxInActiveGas) ) { + + if ( gMC->IsTrackExiting() || + gMC->IsTrackStop() || + gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig); + + gMC->TrackPosition(fTrackPosition); + Float_t theta = fTrackMomentum.Theta(); + Float_t phi = fTrackMomentum.Phi(); + + TLorentzVector backToWire( fStepSum[idvol]/2.*sin(theta)*cos(phi), + fStepSum[idvol]/2.*sin(theta)*sin(phi), + fStepSum[idvol]/2.*cos(theta),0.0 ); + // if (GetDebug()) + // Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ; + // if (GetDebug()) + // Info("StepManager Exit ","Track backToWire %f %f %f",backToWire.X(),backToWire.Y(),backToWire.Z()) ; + fTrackPosition-=backToWire; + + //-------------- Angle effect + // Ratio between energy loss of particle and Mip as a function of BetaGamma of particle (Energy/Mass) + + Float_t betaxGamma = fTrackMomentum.P()/mass;// pc/mc2 + Float_t sigmaEffect10degrees; + Float_t sigmaEffectThetadegrees; + Float_t eLossParticleELossMip; + Float_t yAngleEffect=0.; + Float_t thetawires = TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative + + + if (fAngleEffect){ + if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) { + betaxGamma=TMath::Log(betaxGamma); + eLossParticleELossMip = fElossRatio->Eval(betaxGamma); + // 10 degrees is a reference for a model (arbitrary) + sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers + // Angle with respect to the wires assuming that chambers are perpendicular to the z axis. + sigmaEffectThetadegrees = sigmaEffect10degrees/fAngleEffectNorma->Eval(thetawires*kRaddeg); // For 5mm gap + if ( (iChamber==1) || (iChamber==2) ) + sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm) + yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm + } + } + + // Detection elements ids + AliMUONGeometryModule* geometry + = Chamber(iChamber-1).GetGeometry(); + + AliMUONGeometryDetElement* detElement + = geometry->FindBySensitiveVolume(CurrentVolumePath()); + + Int_t detElemId = 0; + if (detElement) detElemId = detElement->GetUniqueID(); + + if (!detElemId) { + cerr << "Chamber id: " + << setw(3) << iChamber << " " + << "Current SV: " + << CurrentVolumePath() + << " detElemId: " + << setw(5) << detElemId + << endl; + Double_t x, y, z; + gMC->TrackPosition(x, y, z); + cerr << " global position: " + << x << ", " << y << ", " << z + << endl; + AliError("DetElemId not identified."); + } + + // One hit per chamber + GetMUONData()->AddHit(fIshunt, + gAlice->GetMCApp()->GetCurrentTrackNumber(), + detElemId, ipart, + fTrackPosition.X(), + fTrackPosition.Y()+yAngleEffect, + fTrackPosition.Z(), + gMC->TrackTime(), + fTrackMomentum.P(), + theta, + phi, + fStepSum[idvol], + fDestepSum[idvol], + fTrackPosition.X(), + fTrackPosition.Y(), + fTrackPosition.Z()); + +// if (GetDebug()){ +// Info("StepManager Exit","Particle exiting from chamber %d",iChamber); +// Info("StepManager Exit","StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]); +// Info("StepManager Exit","Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ; +// } + fStepSum[idvol] =0; // Reset for the next event + fDestepSum[idvol]=0; // Reset for the next event + } +} + //__________________________________________ void AliMUONv1::StepManagerOld() { // Old Stepmanager for the chambers + // TBR + Int_t copy, id; static Int_t idvol =-1; static Int_t vol[2]; @@ -607,26 +750,213 @@ void AliMUONv1::StepManagerOld() } } -//______________________________________________________________________________ -void AliMUONv1::FinishRun() +//__________________________________________ +void AliMUONv1::StepManagerOld2() { -// Print debug info -// --- + // Old Stepmanager for the chambers + Int_t copy, id; + static Int_t idvol =-1; + static Int_t vol[2]; + Int_t ipart; + TLorentzVector pos; + TLorentzVector mom; + Float_t theta,phi; + Float_t destep, step; + + static Float_t sstep; + static Float_t eloss, eloss2, xhit, yhit, zhit, tof, tlength; + const Float_t kBig = 1.e10; + static Float_t hits[15]; + + TClonesArray &lhits = *fHits; + + // + // + // Only charged tracks + if( !(gMC->TrackCharge()) ) return; + // + // Only gas gap inside chamber + // Tag chambers and record hits when track enters + id=gMC->CurrentVolID(copy); + + Int_t iChamber = GetChamberId(id); + idvol = iChamber-1; + + if (idvol == -1) return; + + // Detection elements id + AliMUONGeometryModule* geometry + = Chamber(iChamber-1).GetGeometry(); + + AliMUONGeometryDetElement* detElement + = geometry->FindBySensitiveVolume(CurrentVolumePath()); + + Int_t detElemId = 0; + if (detElement) detElemId = detElement->GetUniqueID(); + + if (!detElemId) { + cerr << "Chamber id: " + << setw(3) << iChamber << " " + << "Current SV: " + << CurrentVolumePath() + << " detElemId: " + << setw(5) << detElemId + << endl; + Double_t x, y, z; + gMC->TrackPosition(x, y, z); + cerr << " global position: " + << x << ", " << y << ", " << z + << endl; + AliError("DetElemId not identified."); + } + vol[0] = detElemId; + + // + // Get current particle id (ipart), track position (pos) and momentum (mom) + gMC->TrackPosition(pos); + gMC->TrackMomentum(mom); + + ipart = gMC->TrackPid(); + + // + // momentum loss and steplength in last step + destep = gMC->Edep(); + step = gMC->TrackStep(); + // cout<<"------------"<IsTrackEntering()) { + + gMC->SetMaxStep(fMaxStepGas); + Double_t tc = mom[0]*mom[0]+mom[1]*mom[1]; + Double_t rt = TMath::Sqrt(tc); + Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]); + Double_t tx = mom[0]/pmom; + Double_t ty = mom[1]/pmom; + Double_t tz = mom[2]/pmom; + Double_t s = ((AliMUONChamber*)(*fChambers)[idvol]) + ->ResponseModel() + ->Pitch()/tz; + theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg; + phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg; + hits[0] = Float_t(ipart); // Geant3 particle type + hits[1] = pos[0]+s*tx; // X-position for hit + hits[2] = pos[1]+s*ty; // Y-position for hit + hits[3] = pos[2]+s*tz; // Z-position for hit + hits[4] = theta; // theta angle of incidence + hits[5] = phi; // phi angle of incidence + hits[8] = 0;//PadHits does not exist anymore (Float_t) fNPadHits; // first padhit + hits[9] = -1; // last pad hit + hits[10] = mom[3]; // hit momentum P + hits[11] = mom[0]; // Px + hits[12] = mom[1]; // Py + hits[13] = mom[2]; // Pz + tof=gMC->TrackTime(); + hits[14] = tof; // Time of flight + tlength = 0; + eloss = 0; + eloss2 = 0; + sstep=0; + xhit = pos[0]; + yhit = pos[1]; + zhit = pos[2]; + Chamber(idvol).ChargeCorrelationInit(); + // Only if not trigger chamber + +// printf("---------------------------\n"); +// printf(">>>> Y = %f \n",hits[2]); +// printf("---------------------------\n"); + + + + // if(idvol < AliMUONConstants::NTrackingCh()) { +// // +// // Initialize hit position (cursor) in the segmentation model +// ((AliMUONChamber*) (*fChambers)[idvol]) +// ->SigGenInit(pos[0], pos[1], pos[2]); +// } else { +// //geant3->Gpcxyz(); +// //printf("In the Trigger Chamber #%d\n",idvol-9); +// } + } + eloss2+=destep; + sstep+=step; + + // cout<IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){ + gMC->SetMaxStep(kBig); + eloss += destep; + tlength += step; + + Float_t x0,y0,z0; + Float_t localPos[3]; + Float_t globalPos[3] = {pos[0], pos[1], pos[2]}; + gMC->Gmtod(globalPos,localPos,1); + + if(idvol < AliMUONConstants::NTrackingCh()) { +// tracking chambers + x0 = 0.5*(xhit+pos[0]); + y0 = 0.5*(yhit+pos[1]); + z0 = 0.5*(zhit+pos[2]); + } else { +// trigger chambers + x0 = xhit; + y0 = yhit; + z0 = 0.; + } + - if (GetDebug() <= 1) return; + // if (eloss >0) MakePadHits(x0,y0,z0,eloss,tof,idvol); + + + hits[6] = tlength; // track length + hits[7] = eloss2; // de/dx energy loss - // Print the global positions of detection elements - for (Int_t i=0; iGetSVMap(); + // if (fNPadHits > (Int_t)hits[8]) { + // hits[8] = hits[8]+1; + // hits[9] = 0: // PadHits does not exist anymore (Float_t) fNPadHits; + //} +// +// new hit + + new(lhits[fNhits++]) + AliMUONHit(fIshunt, gAlice->GetMCApp()->GetCurrentTrackNumber(), vol,hits); + eloss = 0; + // + // Check additional signal generation conditions + // defined by the segmentation + // model (boundary crossing conditions) + // only for tracking chambers + } else if + ((idvol < AliMUONConstants::NTrackingCh()) && + ((AliMUONChamber*) (*fChambers)[idvol])->SigGenCond(pos[0], pos[1], pos[2])) + { + ((AliMUONChamber*) (*fChambers)[idvol]) + ->SigGenInit(pos[0], pos[1], pos[2]); - svMap->SortPositions(); - svMap->PrintPositions(); - svMap->ClearPositions(); + Float_t localPos[3]; + Float_t globalPos[3] = {pos[0], pos[1], pos[2]}; + gMC->Gmtod(globalPos,localPos,1); + + eloss += destep; + + // if (eloss > 0 && idvol < AliMUONConstants::NTrackingCh()) + // MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),pos[2],eloss,tof,idvol); + xhit = pos[0]; + yhit = pos[1]; + zhit = pos[2]; + eloss = 0; + tlength += step ; + // + // nothing special happened, add up energy loss + } else { + eloss += destep; + tlength += step ; } - AliDebug(2,"\n"); -} +} diff --git a/MUON/AliMUONv1.h b/MUON/AliMUONv1.h index ce7410bb7cc..3c3797c6f31 100644 --- a/MUON/AliMUONv1.h +++ b/MUON/AliMUONv1.h @@ -30,10 +30,15 @@ class AliMUONv1 : public AliMUON virtual void Init(); virtual Int_t IsVersion() const {return 1;} virtual void StepManager(); - virtual void FinishRun(); + //TBR + virtual void StepManager2(); void StepManagerOld(); + //TBR + void StepManagerOld2(); void SetStepManagerVersionOld(Bool_t Opt) { fStepManagerVersionOld = Opt; } + void SetStepManagerVersionDE(Bool_t Opt) + { fStepManagerVersionDE = Opt; } void SetAngleEffect(Bool_t Opt) { fAngleEffect = Opt; } void SetStepMaxInActiveGas(Float_t StepMax) @@ -47,6 +52,7 @@ class AliMUONv1 : public AliMUON TString CurrentVolumePath() const; Bool_t fStepManagerVersionOld; // Version of StepManager, Default is false + Bool_t fStepManagerVersionDE; // Version of StepManager with DE, Default is false Bool_t fAngleEffect; // Angle Effect along wires, Default is true Float_t fStepMaxInActiveGas; // Step max in active gas default 0.6cm diff --git a/MUON/Config_MUON_test.C b/MUON/Config_MUON_test.C index bfa13eccd7e..4170cbcba24 100644 --- a/MUON/Config_MUON_test.C +++ b/MUON/Config_MUON_test.C @@ -160,9 +160,8 @@ void Config(char directory[100]="", char option[6]="box") // If align = true, the detection elements transformations // are taken from the input files and not from the code - //MUON->SetDebug(2); - // To check setting of transformations from input files - // set align = true, debug level = 2 and run with scan generator + // ((AliMUONv1*)MUON)->SetStepManagerVersionDE(true); + // To save detection element Id in the hits //MUON->AddGeometryBuilder(new AliMUONSt1GeometryBuilder(MUON)); MUON->AddGeometryBuilder(new AliMUONSt1GeometryBuilderV2(MUON)); diff --git a/MUON/MUONsimLinkDef.h b/MUON/MUONsimLinkDef.h index ad8f2c8088a..3ff9b07d161 100644 --- a/MUON/MUONsimLinkDef.h +++ b/MUON/MUONsimLinkDef.h @@ -4,8 +4,6 @@ #pragma link off all functions; #pragma link C++ class AliMUONv0+; -#pragma link C++ class AliMUONv3+; - #pragma link C++ class AliMUONFactory+; @@ -29,6 +27,7 @@ #pragma link C++ class AliMUONTriggerDecision+; #pragma link C++ class AliMUONTest+; +#pragma link C++ enum AliMUONTests+; #endif diff --git a/MUON/libMUONsim.pkg b/MUON/libMUONsim.pkg index 3a78b51908c..64990d4d3c4 100644 --- a/MUON/libMUONsim.pkg +++ b/MUON/libMUONsim.pkg @@ -1,6 +1,6 @@ # $Id$ -SRCS:= AliMUONv0.cxx AliMUONv3.cxx \ +SRCS:= AliMUONv0.cxx \ AliMUONFactory.cxx \ AliMUONSt1Segmentation.cxx \ AliMUONSt12QuadrantSegmentation.cxx \ -- 2.39.3