X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONv1.cxx;h=ce0a6974e595cda09b05f8c6e02445c3eb91e4f0;hb=8e5db053220202db87da44e2abf1bba86c54ed13;hp=40190668676d18c83bbb7bb4fb2cb518b97796c4;hpb=0c527060550bc9f3b782d2b40cc8b36d7ef747f5;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONv1.cxx b/MUON/AliMUONv1.cxx index 40190668676..ce0a6974e59 100644 --- a/MUON/AliMUONv1.cxx +++ b/MUON/AliMUONv1.cxx @@ -15,21 +15,17 @@ /* $Id$ */ -// -------------------- +//----------------------------------------------------------------------------- // Class AliMUONv1 // -------------------- // AliDetector class for MUON subsystem which implements // functions for simulation +//----------------------------------------------------------------------------- #include "AliMUONv1.h" #include "AliMUONConstants.h" -#include "AliMUONSegFactory.h" #include "AliMUONResponseFactory.h" -#include "AliMUONSegmentation.h" #include "AliMUONHit.h" -#include "AliMUONTriggerCircuit.h" -#include "AliMUONTriggerCircuitNew.h" -#include "AliMUONTriggerCrateStore.h" #include "AliMUONGeometryBuilder.h" #include "AliMUONGeometry.h" #include "AliMUONGeometryTransformer.h" @@ -37,29 +33,38 @@ #include "AliMUONStringIntMap.h" #include "AliMUONGeometryDetElement.h" +#include "AliMpCDB.h" +#include "AliMpDEManager.h" + #include "AliConst.h" #include "AliMagF.h" #include "AliRun.h" #include "AliMC.h" +#include "AliTrackReference.h" #include "AliLog.h" -#include -#include #include +#include +#include +#include +#include +#include #include #include -#include #include +#include "AliMUONVHitStore.h" + +/// \cond CLASSIMP ClassImp(AliMUONv1) +/// \endcond //___________________________________________ AliMUONv1::AliMUONv1() : AliMUON(), - fStepManagerVersionOld(kTRUE), - fStepManagerVersionDE(kTRUE), fAngleEffect(kTRUE), + fMagEffect(kTRUE), fStepMaxInActiveGas(0.6), fStepSum(0x0), fDestepSum(0x0), @@ -67,7 +72,8 @@ AliMUONv1::AliMUONv1() fTrackPosition(), fElossRatio(0x0), fAngleEffect10(0x0), - fAngleEffectNorma(0x0) + fAngleEffectNorma(0x0), + fMagAngleEffectNorma(0x0) { /// Default constructor @@ -75,13 +81,10 @@ AliMUONv1::AliMUONv1() } //___________________________________________ -AliMUONv1::AliMUONv1(const char *name, const char *title, - const char* sDigitizerClassName, - const char* digitizerClassName) -: AliMUON(name,title,sDigitizerClassName,digitizerClassName), - fStepManagerVersionOld(kTRUE), - fStepManagerVersionDE(kTRUE), +AliMUONv1::AliMUONv1(const char *name, const char* title) +: AliMUON(name, title), fAngleEffect(kTRUE), + fMagEffect(kTRUE), fStepMaxInActiveGas(0.6), fStepSum(0x0), fDestepSum(0x0), @@ -89,12 +92,18 @@ AliMUONv1::AliMUONv1(const char *name, const char *title, fTrackPosition(), fElossRatio(0x0), fAngleEffect10(0x0), - fAngleEffectNorma(0x0) + fAngleEffectNorma(0x0), + fMagAngleEffectNorma(0x0) { /// Standard onstructor AliDebug(1,Form("ctor this=%p",this)); + // Load mapping + if ( ! AliMpCDB::LoadMpSegmentation() ) { + AliFatal("Could not access mapping from OCDB !"); + } + // By default include all stations fStepSum = new Float_t [AliMUONConstants::NCh()]; @@ -123,15 +132,11 @@ AliMUONv1::AliMUONv1(const char *name, const char *title, fAngleEffectNorma->SetParameter(1,-6.809e-01); fAngleEffectNorma->SetParameter(2,5.151e-02); fAngleEffectNorma->SetParameter(3,-1.490e-03); -} - -//_____________________________________________________________________________ -AliMUONv1::AliMUONv1(const AliMUONv1& right) - : AliMUON(right) -{ -/// Copy constructor (not implemented) - AliFatal("Copy constructor not provided."); + // Magnetic field effect: Normalisation form theta=16 degres (eq. 10 degrees B=0) to theta between -20 and 20 (Lamia Benhabib jun 2006 ) + // Angle with respect to the wires assuming that chambers are perpendicular to the z axis. + fMagAngleEffectNorma = new TF2("MagAngleEffectNorma","121.24/(([1]+[2]*abs(y))+[3]*abs(x-[0]*y)+[4]*abs((x-[0]*y)*(x-[0]*y))+[5]*abs((x-[0]*y)*(x-[0]*y)*(x-[0]*y))+[6]*abs((x-[0]*y)*(x-[0]*y)*(x-[0]*y)*(x-[0]*y)))",-20.0,20.0,-1.,1.); + fMagAngleEffectNorma->SetParameters(8.6995, 25.4022, 13.8822, 2.4717, 1.1551, -0.0624, 0.0012); } //___________________________________________ @@ -145,21 +150,9 @@ AliMUONv1::~AliMUONv1() delete fElossRatio; delete fAngleEffect10; delete fAngleEffectNorma; + delete fMagAngleEffectNorma; } -//_____________________________________________________________________________ -AliMUONv1& AliMUONv1::operator=(const AliMUONv1& right) -{ -/// Assignement operator (not implemented) - - // check assignement to self - if (this == &right) return *this; - - AliFatal("Assignement operator not provided."); - - return *this; -} - //__________________________________________________ void AliMUONv1::CreateGeometry() { @@ -176,6 +169,28 @@ void AliMUONv1::CreateMaterials() fGeometryBuilder->CreateMaterials(); } +//________________________________________________________________ +void AliMUONv1::UpdateInternalGeometry() +{ +/// Update geometry after applying mis-alignment + + // Load mapping + if ( ! AliMpCDB::LoadMpSegmentation() ) { + AliFatal("Could not access mapping from OCDB !"); + } + + fGeometryBuilder->UpdateInternalGeometry(); +} + +//________________________________________________________________ +void AliMUONv1::AddAlignableVolumes() const +{ +/// Construct materials using geometry builder + + GetGeometryTransformer()->AddAlignableVolumes(); +} + + //___________________________________________ void AliMUONv1::Init() { @@ -187,58 +202,29 @@ void AliMUONv1::Init() AliDebug(1,"Finished Init for version 1 - CPC chamber type"); - std::string ftype(GetTitle()); - // Build segmentation // using geometry parametrisation // - AliMUONSegFactory segFactory(GetGeometryTransformer()); - fSegmentation = segFactory.CreateSegmentation(ftype); - - if (!fSegmentation) { - AliFatal(Form("Wrong factory type : %s",ftype.c_str())); - } - // Build response // - AliMUONResponseFactory respFactory("default"); + AliMUONResponseFactory respFactory("default", fIsTailEffect); respFactory.Build(this); - - // Initialize segmentation - // - fSegmentation->Init(); - - // Initialize trigger circuits - // - for (Int_t i=0; iAt(i)); - c->Init(i); - } - - AliMUONTriggerCrateStore store; - store.ReadFromFile(); - for (Int_t i=0; iAt(i)); - c->Init(i,store); - } - } //__________________________________________________________________ -Int_t AliMUONv1::GetChamberId(Int_t volId) const +Int_t AliMUONv1::GetGeomModuleId(Int_t volId) const { /// Check if the volume with specified volId is a sensitive volume (gas) -/// of some chamber and returns the chamber number; +/// of some chamber and return the chamber number; /// if not sensitive volume - return 0. - for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) { + for (Int_t i = 0; i < AliMUONConstants::NGeomModules(); i++) { if ( GetGeometry()->GetModule(i)->IsSensitiveVolume(volId) ) - return i+1; + return i; } - return 0; + return -1; } //_______________________________________________________________________________ @@ -269,13 +255,6 @@ TString AliMUONv1::CurrentVolumePath() const void AliMUONv1::StepManager() { /// Step manager for the chambers -/// TBR - - if (fStepManagerVersionDE) { - StepManager2(); - return; - } - // Only charged tracks if( !(gMC->TrackCharge()) ) return; @@ -283,190 +262,64 @@ void AliMUONv1::StepManager() // 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; + static Int_t idvol=-1, iEnter = 0; Int_t copy; const Float_t kBig = 1.e10; - + static Double_t xyzEnter[3]; // // 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 - } - - // AliDebug(1, - // Form("Active volume found %d chamber %d Z chamber is %f ",idvol,iChamber, - // ( (AliMUONChamber*)(*fChambers)[idvol])->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(AliDebugLevel()) { - // AliDebug(1, - // Form("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())); - // AliDebug(1, - // Form("Track Momentum %f %f %f", fTrackMomentum.X(), fTrackMomentum.Y(), - // fTrackMomentum.Z())); - // gMC->TrackPosition(fTrackPosition); - // AliDebug(1, - // Form("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 ); - // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(), - // fTrackPosition.Y(),fTrackPosition.Z())) ; - // AliDebug(1,Form("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) + Int_t id=gMC->CurrentVolID(copy); + Int_t iGeomModule = GetGeomModuleId(id); + if (iGeomModule == -1) return; + + // Detection elements id + const AliMUONGeometryModule* kGeometryModule + = GetGeometry()->GetModule(iGeomModule); + AliMUONGeometryDetElement* detElement + = kGeometryModule->FindBySensitiveVolume(CurrentVolumePath()); - 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 - const AliMUONGeometryModule* kGeometryModule - = GetGeometry()->GetModule(iChamber-1); - - AliMUONGeometryDetElement* detElement - = kGeometryModule->FindBySensitiveVolume(CurrentVolumePath()); + if (!detElement && iGeomModule < AliMUONConstants::NGeomModules()-2) { + iGeomModule++; + const AliMUONGeometryModule* kGeometryModule2 + = GetGeometry()->GetModule(iGeomModule); + detElement + = kGeometryModule2->FindBySensitiveVolume(CurrentVolumePath()); + } - Int_t detElemId = 0; - if (detElement) detElemId = detElement->GetUniqueID(); + 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; - AliWarning("DetElemId not identified."); - } - - // One hit per chamber - GetMUONData()->AddHit(fIshunt, - gAlice->GetMCApp()->GetCurrentTrackNumber(), - iChamber, 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 (AliDebugLevel()){ -// AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber)); -// AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol])); -// AliDebug(1,Form("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::StepManager2() -{ -/// Step manager for the chambers - - // Only charged tracks - if( !(gMC->TrackCharge()) ) return; - // Only charged tracks + if (!detElemId) { + AliErrorStream() + << "Geometry module id: " + << setw(3) << iGeomModule << " " + << "Current SV: " + << CurrentVolumePath() + << " detElemId: " + << setw(5) << detElemId + << endl; + Double_t x, y, z; + gMC->TrackPosition(x, y, z); + AliErrorStream() + << " global position: " + << x << ", " << y << ", " << z + << endl; + AliErrorStream() << "DetElemId not identified." << endl; + } - // Only gas gap inside chamber - // Tag chambers and record hits when track enters - static Int_t idvol=-1, iEnter = 0; - Int_t iChamber=0; - Int_t id=0; - Int_t copy; - const Float_t kBig = 1.e10; - static Double_t xyzEnter[3]; - - // - // Only gas gap inside chamber - // Tag chambers and record hits when track enters - id=gMC->CurrentVolID(copy); - iChamber = GetChamberId(id); + Int_t iChamber = AliMpDEManager::GetChamberId(detElemId) + 1; 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() || gMC->IsTrackExiting() ) ) { + AliTrackReference* trackReference + = AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kMUON); + trackReference->SetUserId(detElemId); + } - if( gMC->IsTrackEntering() ) { + 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 iEnter = 1; @@ -564,10 +417,13 @@ void AliMUONv1::StepManager2() 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 - + Float_t thetawires = TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) ;// We use Pi-theta because z is negative + Double_t bField[3] = {0}; + fTrackPosition.Vect().GetXYZ(tmp); + TGeoGlobalMagField::Instance()->Field(tmp,bField); - if (fAngleEffect){ + if (fAngleEffect && !fMagEffect){ + thetawires = TMath::Abs(thetawires); if ( (betaxGamma >3.2) && (thetawires*kRaddeg<=15.) ) { betaxGamma=TMath::Log(betaxGamma); eLossParticleELossMip = fElossRatio->Eval(betaxGamma); @@ -580,53 +436,37 @@ void AliMUONv1::StepManager2() yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm } } - - // Detection elements ids - const AliMUONGeometryModule* kGeometryModule - = GetGeometry()->GetModule(iChamber-1); - - AliMUONGeometryDetElement* detElement - = kGeometryModule->FindBySensitiveVolume(CurrentVolumePath()); + else if (fAngleEffect && fMagEffect) { + if ( (betaxGamma >3.2) && (TMath::Abs(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/fMagAngleEffectNorma->Eval(thetawires*kRaddeg,bField[0]/10.); // 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 + } + } - 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."); - } + AliMUONHit hit(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()); - // One hit per chamber - GetMUONData()->AddHit2(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()); - - // AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber)); - // AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol])); - // AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ; + fHitStore->Add(hit); fStepSum[idvol] =0; // Reset for the next event fDestepSum[idvol]=0; // Reset for the next event