41 G4Exception(
"MicromegasSensitiveDetector::ProcessHits",
"MicromegasHitCollectionMissing", FatalException,
42 "Hit collection not initialized; did SetupEvent run?");
45 G4Track* currentTrack = aStep->GetTrack();
46 int charge=currentTrack->GetDefinition()->GetPDGCharge();
47 bool geantinoHit = (currentTrack->GetDefinition()==G4Geantino::GeantinoDefinition()) ||
48 (currentTrack->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition());
50 if (!
charge && (!geantinoHit))
return false;
52 G4StepPoint* postStep=aStep->GetPostStepPoint();
53 const G4Step* post_Step=aStep->GetTrack()->GetStep();
57 int pdgCode=currentTrack->GetDefinition()->GetPDGEncoding();
59 float globalTime=postStep->GetGlobalTime();
60 float eKin=postStep->GetKineticEnergy();
61 if (eKin<= 0. && (!geantinoHit))
return false;
64 float depositEnergy=post_Step->GetTotalEnergyDeposit();
66 if (depositEnergy<0.0001 && (!geantinoHit))
return false;
68 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
72 int nLayer=touchHist->GetVolume(0)->GetCopyNo();
73 std::string chName=touchHist->GetVolume(1)->GetLogicalVolume()->GetName();
74 std::string subType=chName.substr(chName.find(
'-')+1);
75 if (subType[0]!=
'M') G4cout <<
" something is wrong, this is no Micromegas!" << G4endl;
76 std::string temp(&subType[1]);
77 std::istringstream is(temp);
84 G4ThreeVector posH=postStep->GetPosition();
85 if (subType[2]==
'L') posH.rotateZ(
M_PI/8.);
86 double phiHit=posH.phi();
87 if(phiHit<=0) phiHit+=2.*
M_PI;
88 int iPhi=1+int(phiHit/(
M_PI/4.));
90 if (subType[2]==
'L') iPhi-=1;
93 if (position.z()<0) iSide=-1;
95 int mLayer= atoi((subType.substr(3,1)).c_str());
96 if (mLayer != 1 && mLayer !=2) G4cout <<
" something is wrong - multilayer index is " << mLayer << G4endl;
99 int MmId =
m_muonHelper->BuildMicromegasHitId(subType, iPhi, iRing, mLayer,nLayer, iSide);