9 #include "TClonesArray.h" 10 #include "TParticle.h" 11 #include "TVirtualMC.h" 14 #include "FairRootManager.h" 16 #include "FairRunSim.h" 17 #include "FairRuntimeDb.h" 18 #include "FairLogger.h" 20 #include "ERBeamDet.h" 27 flGeoPar =
new TList();
28 flGeoPar->SetName( GetName());
36 flGeoPar =
new TList();
37 flGeoPar->SetName( GetName());
38 fVerboseLevel = verbose;
51 FairDetector::Initialize();
55 if (fVerboseLevel > 0)
61 FairRootManager* ioman = FairRootManager::Instance();
63 Fatal(
"Init",
"IO manager is not set");
64 fToFPoints =
new TClonesArray(
"ERBeamDetTOFPoint");
65 fMWPCPoints =
new TClonesArray(
"ERBeamDetMWPCPoint");
66 if (fSensitiveTargetIsSet) {
69 ioman->Register(
"BeamDetToFPoint",
"BeamDet",
fToFPoints, kTRUE);
70 ioman->Register(
"BeamDetMWPCPoint",
"BeamDet",
fMWPCPoints, kTRUE);
71 if (fSensitiveTargetIsSet) {
72 ioman->Register(
"BeamDetTargetPoint",
"BeamDet",
fTargetPoints, kTRUE);
81 if (fSensitiveTargetIsSet) {
91 for (Int_t iPoint = 0; iPoint <
fToFPoints->GetEntriesFast(); iPoint++){
97 for (Int_t iPoint = 0; iPoint <
fMWPCPoints->GetEntriesFast(); iPoint++){
102 if(fSensitiveTargetIsSet &&
fTargetPoints->GetEntriesFast() > 0) {
103 for (Int_t iPoint = 0; iPoint <
fTargetPoints->GetEntriesFast(); iPoint++) {
118 Int_t nEntries = cl1->GetEntriesFast();
119 LOG(FATAL) <<
"BeamDet: " << nEntries <<
" entries to add" << FairLogger::endl;
120 TClonesArray& clref = *cl2;
122 for (Int_t i=0; i<nEntries; i++) {
124 Int_t index = oldpoint->GetTrackID() + offset;
125 oldpoint->SetTrackID(index);
128 LOG(FATAL) <<
"BeamDet: " << cl2->GetEntriesFast() <<
" merged entries" << FairLogger::endl;
135 Int_t size = clref.GetEntriesFast();
146 Int_t size = clref.GetEntriesFast();
158 Int_t size = clref.GetEntriesFast();
168 TString volName = name;
169 if(volName.Contains(
"gasStrip")) {
172 if(volName.Contains(
"plastic")) {
175 if(fSensitiveTargetIsSet && volName.Contains(
"targetBodyH2")) {
182 fSetup->ConstructGeometry();
183 SetGeometryFileName(
"beamdet.temp.root");
184 ConstructRootGeometry();
185 fSensitiveTargetIsSet = fSetup->CheckIfTargetIsSet();
190 static const Double_t dP = 1.032 ;
191 static const Double_t BirkC1 = 0.013/dP;
192 static const Double_t BirkC2 = 9.6e-6/(dP * dP);
194 if ( gMC->IsTrackEntering() ) {
198 gMC->TrackPosition(
fPosIn);
199 gMC->TrackMomentum(
fMomIn);
200 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
201 fTime = gMC->TrackTime() * 1.0e09;
203 fMot0TrackID = gMC->GetStack()->GetCurrentTrack()->GetMother(0);
204 fPID = gMC->TrackPid();
205 TString volName = gMC->CurrentVolName();
207 const Double_t stepEloss = gMC->Edep() * 1000;
209 Double_t stepLightYield = 0;
211 if (gMC->TrackCharge()!=0) {
212 Double_t BirkC1Mod = 0;
214 if (TMath::Abs(gMC->TrackCharge())>=2)
215 BirkC1Mod=BirkC1*7.2/12.6;
219 if (gMC->TrackStep()>0) {
220 Double_t dedxcm = stepEloss / gMC->TrackStep();
221 stepLightYield= stepEloss / (1.+BirkC1Mod*dedxcm+BirkC2*dedxcm*dedxcm);
225 if (gMC->IsTrackExiting() ||
226 gMC->IsTrackStop() ||
227 gMC->IsTrackDisappeared())
231 TString volName = gMC->CurrentVolName();
233 if(volName.Contains(
"plastic")) {
234 gMC->CurrentVolID(
fToFNb);
240 if(volName.Contains(
"gasStrip")) {
243 gMC->CurrentVolOffID(3,
fMWPCNb);
246 if (fSensitiveTargetIsSet) {
247 if(volName.Contains(
"targetBodyH2")) {
ERBeamDetTOFPoint * AddTOFPoint()
Adds a ERBeamDetToFPoint to the ToFPoints Collection.
Class for the MC transport of the BeamDet.
virtual ~ERBeamDet()
Destructor.
virtual Bool_t ProcessHits(FairVolume *vol=0)
Defines the action to be taken when a step is inside the active volume. Creates a ERBeamDetPoint and ...
ERBeamDet()
Default constructor.
TClonesArray * fTargetPoints
The TargetPoint collection.
virtual void Reset()
Clears the point collection. Virtual from FairDetector.
virtual TClonesArray * GetCollection(Int_t iColl) const
Accessor to the point collection . Abstract from FairDetector.
Int_t fEventID
event index
virtual void EndOfEvent()
If verbosity level is set, print point collection at the end of the event. Virtual from FairDetector...
TClonesArray * fMWPCPoints
The MWPCPoint collection.
virtual void Print(const Option_t *opt=0) const
ERBeamDetMWPCPoint * AddMWPCPoint()
Adds a ERBeamDetMWPCPoint to the MWPCPoints Collection.
ERBeamDetTargetPoint * AddTargetPoint()
Adds a ERBeamDetTargetPoint to the TargetPoints Collection.
TClonesArray * fToFPoints
The ToFPoint collection.
virtual void Initialize()
Initialize ERBeamDet data. Abstract from FairDetector.
Int_t fMWPCNb
MWPC station number.
virtual void Register()
Registers the point collection in the ROOT manager. Virtual from FairDetector.
virtual void ConstructGeometry()
Builds geometry and writes it to temporary file trough parameters from ERBeamDetSetup class object...
TLorentzVector fMomOut
point finish momentum
Int_t fMWPCWireNb
wire number in gas strip array
Double32_t fTime
point start time
Int_t fMot0TrackID
0th mother track index
TLorentzVector fMomIn
point start momentum
virtual void Print(const Option_t *opt=0) const
virtual Bool_t CheckIfSensitive(std::string name)
Check whether a volume is sensitive.
TLorentzVector fPosOut
point finish position
Double32_t fLightYield
light yield
virtual void Print(Option_t *option="") const
Screen output of hit collection. Virtual from TObject.
TLorentzVector fPosIn
point start position
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
Copies the hit collection with a given track index offset.
virtual void Print(const Option_t *opt=0) const
Int_t fToFNb
ToF plastic number.
The base class for detector simulation in er sim.
Double32_t fELoss
energy loss
Int_t fTrackID
track index
Int_t fMWPCPlaneNb
gas strip array number in MWPC station