All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
evgen::ldm::MeVPrtlTestRayTrace Class Reference
Inheritance diagram for evgen::ldm::MeVPrtlTestRayTrace:

Public Member Functions

 MeVPrtlTestRayTrace (fhicl::ParameterSet const &p)
 
 MeVPrtlTestRayTrace (MeVPrtlTestRayTrace const &)=delete
 
 MeVPrtlTestRayTrace (MeVPrtlTestRayTrace &&)=delete
 
MeVPrtlTestRayTraceoperator= (MeVPrtlTestRayTrace const &)=delete
 
MeVPrtlTestRayTraceoperator= (MeVPrtlTestRayTrace &&)=delete
 
void analyze (const art::Event &e) override
 
 ~MeVPrtlTestRayTrace () noexcept
 

Private Attributes

std::unique_ptr
< evgen::ldm::IMesonGen
fGenTool
 
std::unique_ptr
< evgen::ldm::IMeVPrtlFlux
fFluxTool
 
std::vector< std::unique_ptr
< evgen::ldm::IRayTrace > > 
fRayTools
 
unsigned fNCall
 
unsigned fNEvt
 
TTree * fTree
 
std::vector< double > fBranchWeights
 
MeVPrtlTruthfMeVPrtl
 

Detailed Description

Definition at line 60 of file MeVPrtlTestRayTrace_module.cc.

Constructor & Destructor Documentation

evgen::ldm::MeVPrtlTestRayTrace::MeVPrtlTestRayTrace ( fhicl::ParameterSet const &  p)
explicit

Definition at line 90 of file MeVPrtlTestRayTrace_module.cc.

91  : EDAnalyzer{p}
92 {
93  // bring in the tools
94  fGenTool = art::make_tool<IMesonGen>(p.get<fhicl::ParameterSet>("MesonGen"));
95  fFluxTool = art::make_tool<IMeVPrtlFlux>(p.get<fhicl::ParameterSet>("Flux"));
96 
97  for (auto const &rayconfig: p.get<std::vector<fhicl::ParameterSet>>("RayTraces")) {
98  fRayTools.push_back(art::make_tool<IRayTrace>(rayconfig));
99  fBranchWeights.push_back(0);
100  }
101 
102  fNCall = p.get<unsigned>("NCall", 10000);
103  fNEvt = 0;
104 
105  art::ServiceHandle<art::TFileService> tfs;
106  fTree = tfs->make<TTree>("testraytrace", "testraytrace");
108  fTree->Branch("mevprtl", &fMeVPrtl);
109  for (unsigned iray = 0; iray < fRayTools.size(); iray++) {
110  fTree->Branch((std::string(fRayTools[iray]->Name()) + "_wgt").c_str(), &fBranchWeights[iray]);
111  }
112 
113 }
pdgs p
Definition: selectors.fcl:22
std::vector< std::unique_ptr< evgen::ldm::IRayTrace > > fRayTools
std::unique_ptr< evgen::ldm::IMesonGen > fGenTool
BEGIN_PROLOG vertical distance to the surface Name
std::unique_ptr< evgen::ldm::IMeVPrtlFlux > fFluxTool
art::ServiceHandle< art::TFileService > tfs
evgen::ldm::MeVPrtlTestRayTrace::MeVPrtlTestRayTrace ( MeVPrtlTestRayTrace const &  )
delete
evgen::ldm::MeVPrtlTestRayTrace::MeVPrtlTestRayTrace ( MeVPrtlTestRayTrace &&  )
delete
evgen::ldm::MeVPrtlTestRayTrace::~MeVPrtlTestRayTrace ( )
inlinenoexcept

Definition at line 75 of file MeVPrtlTestRayTrace_module.cc.

75 {}

Member Function Documentation

void evgen::ldm::MeVPrtlTestRayTrace::analyze ( const art::Event &  e)
override

Definition at line 115 of file MeVPrtlTestRayTrace_module.cc.

116 {
117  // get the next MeVPrtl Truth
118  while (1) {
119  simb::MCFlux kaon = fGenTool->GetNext();
120 
121  evgen::ldm::KaonParent kaonp(kaon);
122  bool is_kaon = kaonp.kaon_pdg != 0;
123 
124  // (void) is_kaon;
125  if (is_kaon) {
126  std::cout << "Flux is kaon (" << is_kaon << "). Weight: " << kaonp.weight << ". Produced with energy: " << kaonp.mom.E()
127  << " M=" << kaonp.mom.M() << " P=(" << kaonp.mom.Px() << ", " << kaonp.mom.Py() << ", " << kaonp.mom.Pz() << ") At: ("
128  << kaonp.pos.X() << ", " << kaonp.pos.Y() << ", " << kaonp.pos.Z() << ")" << std::endl;
129  }
130 
131  bool success;
132 
134  double flux_weight;
135 
136  success = fFluxTool->MakeFlux(kaon, flux, flux_weight);
137  if (!success) continue;
138 
139  std::cout << "New flux. E=" << flux.mom.E() << " At: (" << flux.pos.X() << ", " << flux.pos.Y() << ", " << flux.pos.Z() << ")" << std::endl;
140  std::cout << "P=(" << flux.mom.Px() << ", " << flux.mom.Py() << ", " << flux.mom.Pz() << ")" << std::endl;
141  std::cout << "Flux weight: " << flux_weight << std::endl;
142 
143 
144  // See if an intersection is possible
145  double costh_crit = minKinematicCosTheta(flux.kmom.M(), flux.sec.M(), flux.mom.M(), flux.kmom.E());
146  TVector3 det(0., 0., 0.); // detector should be near origin
147  double costh = flux.kmom.Vect().Unit().Dot((det - flux.pos.Vect()).Unit());
148  std::cout << "COSTH CRIT: " << costh_crit << " DETECTOR COSTH: " << costh << std::endl;
149  if (costh < costh_crit) continue;
150 
151  std::cout << "CALLING RAY TOOLS\n";
152  fNEvt ++;
153  unsigned iray = 0;
154  std::vector<double> weightsum(fRayTools.size(), 0.);
155  std::vector<double> time(fRayTools.size(), 0.);
156  for (auto const &r: fRayTools) {
157  std::array<TVector3, 2> intersection;
158  double ray_weight;
159  std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
160 
161  for (unsigned icall = 0; icall < fNCall; icall++) {
162  success = r->IntersectDetector(flux, intersection, ray_weight);
163  if (!success) ray_weight = 0.;
164  weightsum[iray] += ray_weight;
165  }
166 
167  std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
168  std::chrono::duration<double, std::milli> duration = t2 - t1;
169  time[iray] = duration.count();
170 
171  iray ++;
172  }
173 
174  std::cout << "DONE CALLING RAY TOOLS\n";
175  for (unsigned iray = 0; iray < fRayTools.size(); iray++) {
176  std::cout << fRayTools[iray]->Name() << " " << (time[iray] / fNCall) << " " << (weightsum[iray] / fNCall) << std::endl;
177  }
178 
180  std::array<TVector3, 2> intersection;
181  *fMeVPrtl = evgen::ldm::MeVPrtlTruth(flux, decay, intersection, flux_weight, 1., 1., 0.);
182  for (unsigned iray = 0; iray < fRayTools.size(); iray++) {
183  fBranchWeights[iray] = weightsum[iray] / fNCall;
184  }
185 
186  fTree->Fill();
187 
188  break;
189  }
190 }
TLorentzVector mom
Definition: MeVPrtlFlux.h:14
std::vector< std::unique_ptr< evgen::ldm::IRayTrace > > fRayTools
std::unique_ptr< evgen::ldm::IMesonGen > fGenTool
TLorentzVector kmom
Definition: MeVPrtlFlux.h:13
std::unique_ptr< evgen::ldm::IMeVPrtlFlux > fFluxTool
double minKinematicCosTheta(double parentM, double secM, double prtlM, double parentE)
Definition: Constants.cpp:195
TLorentzVector pos
Definition: MeVPrtlFlux.h:11
esac echo uname r
BEGIN_PROLOG could also be cout
TLorentzVector sec
Definition: MeVPrtlFlux.h:16
MeVPrtlTestRayTrace& evgen::ldm::MeVPrtlTestRayTrace::operator= ( MeVPrtlTestRayTrace const &  )
delete
MeVPrtlTestRayTrace& evgen::ldm::MeVPrtlTestRayTrace::operator= ( MeVPrtlTestRayTrace &&  )
delete

Member Data Documentation

std::vector<double> evgen::ldm::MeVPrtlTestRayTrace::fBranchWeights
private

Definition at line 86 of file MeVPrtlTestRayTrace_module.cc.

std::unique_ptr<evgen::ldm::IMeVPrtlFlux> evgen::ldm::MeVPrtlTestRayTrace::fFluxTool
private

Definition at line 79 of file MeVPrtlTestRayTrace_module.cc.

std::unique_ptr<evgen::ldm::IMesonGen> evgen::ldm::MeVPrtlTestRayTrace::fGenTool
private

Definition at line 78 of file MeVPrtlTestRayTrace_module.cc.

MeVPrtlTruth* evgen::ldm::MeVPrtlTestRayTrace::fMeVPrtl
private

Definition at line 87 of file MeVPrtlTestRayTrace_module.cc.

unsigned evgen::ldm::MeVPrtlTestRayTrace::fNCall
private

Definition at line 82 of file MeVPrtlTestRayTrace_module.cc.

unsigned evgen::ldm::MeVPrtlTestRayTrace::fNEvt
private

Definition at line 83 of file MeVPrtlTestRayTrace_module.cc.

std::vector<std::unique_ptr<evgen::ldm::IRayTrace> > evgen::ldm::MeVPrtlTestRayTrace::fRayTools
private

Definition at line 80 of file MeVPrtlTestRayTrace_module.cc.

TTree* evgen::ldm::MeVPrtlTestRayTrace::fTree
private

Definition at line 85 of file MeVPrtlTestRayTrace_module.cc.


The documentation for this class was generated from the following file: