SND@LHC Software
Loading...
Searching...
No Matches
exitHadronAbsorber.cxx
Go to the documentation of this file.
2#include <math.h>
3#include "vetoPoint.h"
4
5#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN
6#include "FairVolume.h"
7#include "FairGeoVolume.h"
8#include "FairGeoNode.h"
9#include "FairRootManager.h"
10#include "FairGeoLoader.h"
11#include "FairGeoInterface.h"
12#include "FairGeoMedia.h"
13#include "FairGeoBuilder.h"
14#include "FairRun.h"
15#include "FairRuntimeDb.h"
16#include "ShipDetectorList.h"
17#include "ShipStack.h"
18
19#include "TClonesArray.h"
20#include "TVirtualMC.h"
21#include "TGeoManager.h"
22#include "TGeoBBox.h"
23#include "TGeoEltu.h"
24#include "TGeoBoolNode.h"
25#include "TGeoMaterial.h"
26#include "TParticle.h"
27#include "TROOT.h"
28#include "TH1D.h"
29#include "TH2D.h"
30#include "TDatabasePDG.h"
31
32#include <iostream>
33using std::cout;
34using std::endl;
35
36Double_t cm = 1; // cm
37Double_t m = 100*cm; // m
38Double_t mm = 0.1*cm; // mm
39
41 : FairDetector("exitHadronAbsorber", kTRUE, kVETO),
42 fTrackID(-1),
43 fVolumeID(-1),
44 fPos(),
45 fMom(),
46 fTime(-1.),
47 fLength(-1.),
48 fOnlyMuons(kFALSE),
49 fSkipNeutrinos(kFALSE),
50 fzPos(3E8),
51 withNtuple(kFALSE),
52 fexitHadronAbsorberPointCollection(new TClonesArray("vetoPoint"))
53{}
54
62
63Bool_t exitHadronAbsorber::ProcessHits(FairVolume* vol)
64{
66 if ( gMC->IsTrackEntering() ) {
67 fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
68 TParticle* p = gMC->GetStack()->GetCurrentTrack();
69 Int_t pdgCode = p->GetPdgCode();
70 gMC->TrackMomentum(fMom);
71 if (!(fOnlyMuons && TMath::Abs(pdgCode)!=13)){
72 fTime = gMC->TrackTime() * 1.0e09;
73 fLength = gMC->TrackLength();
74 gMC->TrackPosition(fPos);
75 if ( (fMom.E()-fMom.M() )>EMax) {
76 AddHit(fTrackID, 111, TVector3(fPos.X(),fPos.Y(),fPos.Z()),
77 TVector3(fMom.Px(), fMom.Py(), fMom.Pz()), fTime, fLength,
78 0,pdgCode,TVector3(p->Vx(), p->Vy(), p->Vz()),TVector3(p->Px(), p->Py(), p->Pz()) );
79 ShipStack* stack = (ShipStack*) gMC->GetStack();
80 stack->AddPoint(kVETO);
81 }
82 }
83 }
84 gMC->StopTrack();
85 return kTRUE;
86}
87
89{
90 FairDetector::Initialize();
91 TSeqCollection* fileList=gROOT->GetListOfFiles();
92 fout = ((TFile*)fileList->At(0));
93 // book hists for Genie neutrino momentum distribution
94 // add also leptons, and photon
95 // add pi0 111 eta 221 eta' 331 omega 223 for DM production
96 TDatabasePDG* PDG = TDatabasePDG::Instance();
97 for(Int_t idnu=11; idnu<26; idnu+=1){
98 // nu or anti-nu
99 for (Int_t idadd=-1; idadd<3; idadd+=2){
100 Int_t idw=idnu;
101 if (idnu==18){idw=22;}
102 if (idnu==19){idw=111;}
103 if (idnu==20){idw=221;}
104 if (idnu==21){idw=223;}
105 if (idnu==22){idw=331;}
106 if (idnu==23){idw=211;}
107 if (idnu==24){idw=321;}
108 if (idnu==25){idw=2212;}
109 Int_t idhnu=10000+idw;
110 if (idadd==-1){
111 if (idnu>17){continue;}
112 idhnu+=10000;
113 idw=-idnu;
114 }
115 TString name=PDG->GetParticle(idw)->GetName();
116 TString title = name;title+=" momentum (GeV)";
117 TString key = "";key+=idhnu;
118 TH1D* Hidhnu = new TH1D(key,title,400,0.,400.);
119 title = name;title+=" log10-p vs log10-pt";
120 key = "";key+=idhnu+1000;
121 TH2D* Hidhnu100 = new TH2D(key,title,100,-0.3,1.7,100,-2.,0.5);
122 title = name;title+=" log10-p vs log10-pt";
123 key = "";key+=idhnu+2000;
124 TH2D* Hidhnu200 = new TH2D(key,title,25,-0.3,1.7,100,-2.,0.5);
125 }
126 }
127 if(withNtuple) {
128 fNtuple = new TNtuple("4DP","4DP","id:px:py:pz:x:y:z");
129 }
130}
131
138
140 gMC->TrackMomentum(fMom);
141 if ( (fMom.E()-fMom.M() )<EMax){
142 gMC->StopTrack();
143 return;
144 }
145 TParticle* p = gMC->GetStack()->GetCurrentTrack();
146 Int_t pdgCode = p->GetPdgCode();
147// record statistics for neutrinos, electrons and photons
148// add pi0 111 eta 221 eta' 331 omega 223
149 Int_t idabs = TMath::Abs(pdgCode);
150 if (idabs<18 || idabs==22 || idabs==111 || idabs==221 || idabs==223 || idabs==331
151 || idabs==211 || idabs==321 || idabs==2212 ){
152 Double_t wspill = p->GetWeight();
153 Int_t idhnu=idabs+10000;
154 if (pdgCode<0){ idhnu+=10000;}
155 Double_t l10ptot = TMath::Min(TMath::Max(TMath::Log10(fMom.P()),-0.3),1.69999);
156 Double_t l10pt = TMath::Min(TMath::Max(TMath::Log10(fMom.Pt()),-2.),0.4999);
157 TString key; key+=idhnu;
158 TH1D* h1 = (TH1D*)fout->Get(key);
159 if (h1){h1->Fill(fMom.P(),wspill);}
160 key="";key+=idhnu+1000;
161 TH2D* h2 = (TH2D*)fout->Get(key);
162 if (h2){h2->Fill(l10ptot,l10pt,wspill);}
163 key="";key+=idhnu+2000;
164 h2 = (TH2D*)fout->Get(key);
165 if (h2){h2->Fill(l10ptot,l10pt,wspill);}
166 if(withNtuple){
167 fNtuple->Fill(pdgCode,fMom.Px(),fMom.Py(), fMom.Pz(),fPos.X(),fPos.Y(),fPos.Z());
168 }
169 if (fSkipNeutrinos && (idabs==12 or idabs==14 or idabs == 16 )){gMC->StopTrack();}
170 }
171}
172
174 for(Int_t idnu=11; idnu<23; idnu+=1){
175 // nu or anti-nu
176 for (Int_t idadd=-1; idadd<3; idadd+=2){
177 Int_t idw=idnu;
178 if (idnu==18){idw=22;}
179 if (idnu==19){idw=111;}
180 if (idnu==20){idw=221;}
181 if (idnu==21){idw=223;}
182 if (idnu==22){idw=331;}
183 Int_t idhnu=10000+idw;
184 if (idadd==-1){
185 if (idnu>17){continue;}
186 idhnu+=10000;
187 idw=-idnu;
188 }
189 TString key = "";key+=idhnu;
190 TSeqCollection* fileList=gROOT->GetListOfFiles();
191 ((TFile*)fileList->At(0))->cd();
192 TH1D* Hidhnu = (TH1D*)fout->Get(key);
193 Hidhnu->Write();
194 key="";key+=idhnu+1000;
195 TH2D* Hidhnu100 = (TH2D*)fout->Get(key);
196 Hidhnu100->Write();
197 key = "";key+=idhnu+2000;
198 TH2D* Hidhnu200 = (TH2D*)fout->Get(key);
199 Hidhnu200->Write();
200 }
201 }
202 if(withNtuple){fNtuple->Write();}
203}
204
206{
207 static FairGeoLoader *geoLoad=FairGeoLoader::Instance();
208 static FairGeoInterface *geoFace=geoLoad->getGeoInterface();
209 static FairGeoMedia *media=geoFace->getMedia();
210 static FairGeoBuilder *geoBuild=geoLoad->getGeoBuilder();
211
212 FairGeoMedium *ShipMedium=media->getMedium("vacuums");
213 TGeoMedium* vac=gGeoManager->GetMedium("vacuums");
214 if (vac==NULL)
215 geoBuild->createMedium(ShipMedium);
216 vac =gGeoManager->GetMedium("vacuums");
217 TGeoVolume *top=gGeoManager->GetTopVolume();
218 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
219 Double_t zLoc;
220 if (fzPos>1E8){
221 //Add thin sensitive plane after hadron absorber
222 Float_t distance = 1.;
223 Double_t local[3]= {0,0,0};
224 if (not nav->cd("/MuonShieldArea_1/CoatWall_1")) {
225 nav->cd("/MuonShieldArea_1/MagnAbsorb2_MagRetL_1");
226 distance = -1.;}
227 TGeoBBox* tmp = (TGeoBBox*)(nav->GetCurrentNode()->GetVolume()->GetShape());
228 local[2] = distance * tmp->GetDZ();
229 Double_t global[3] = {0,0,0};
230 nav->LocalToMaster(local,global);
231 zLoc = global[2] + distance * 1.*cm;
232 }else{zLoc = fzPos;} // use external input
233 TGeoVolume *sensPlane = gGeoManager->MakeBox("sensPlane",vac,10.*m-1.*mm,10.*m-1.*mm,1.*mm);
234 nav->cd("/MuonShieldArea_1/");
235 nav->GetCurrentNode()->GetVolume()->AddNode(sensPlane, 1, new TGeoTranslation(0, 0, zLoc));
236 AddSensitiveVolume(sensPlane);
237}
238
239vetoPoint* exitHadronAbsorber::AddHit(Int_t trackID, Int_t detID,
240 TVector3 pos, TVector3 mom,
241 Double_t time, Double_t length,
242 Double_t eLoss, Int_t pdgCode,TVector3 Lpos, TVector3 Lmom)
243{
244 TClonesArray& clref = *fexitHadronAbsorberPointCollection;
245 Int_t size = clref.GetEntriesFast();
246 return new(clref[size]) vetoPoint(trackID, detID, pos, mom,
247 time, length, eLoss, pdgCode,Lpos,Lmom);
248}
249
251{
252
253 FairRootManager::Instance()->Register("vetoPoint", "veto",
255}
256
257TClonesArray* exitHadronAbsorber::GetCollection(Int_t iColl) const
258{
259 if (iColl == 0) { return fexitHadronAbsorberPointCollection; }
260 else { return NULL; }
261}
266
Double_t cm
Double_t m
Double_t mm
@ kVETO
TClonesArray * fexitHadronAbsorberPointCollection
virtual TClonesArray * GetCollection(Int_t iColl) const
TLorentzVector fPos
volume id
vetoPoint * AddHit(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss, Int_t pdgcode, TVector3 Lpos, TVector3 Lmom)
Bool_t withNtuple
zPos, optional
TLorentzVector fMom
position at entrance
Double_t fTime
momentum at entrance
TFile * fout
flag if neutrinos should be ignored
TNtuple * fNtuple
special option for Dark Photon physics studies
Bool_t fSkipNeutrinos
flag if only muons should be stored
Bool_t fOnlyMuons
max energy to transport
virtual Bool_t ProcessHits(FairVolume *v=0)
ClassImp(ecalContFact) ecalContFact
Double_t cm
Double_t m
Double_t mm