G4RWExampleAnalyzer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: G4RWExampleAnalyzer
3 // Plugin Type: analyzer (art v3_05_00)
4 // File: G4RWExampleAnalyzer_module.cc
5 //
6 // Generated at Wed Apr 22 10:59:17 2020 by Jacob Calcutt using cetskelgen
7 // from cetlib version v3_10_00.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
20 #include "art_root_io/TFileService.h"
21 #include "TTree.h"
22 
23 #include "geant4reweight/src/ReweightBase/G4ReweighterFactory.hh"
24 #include "geant4reweight/src/ReweightBase/G4Reweighter.hh"
25 #include "geant4reweight/src/ReweightBase/G4ReweightTraj.hh"
26 #include "geant4reweight/src/PropBase/G4ReweightParameterMaker.hh"
27 #include "geant4reweight/src/ReweightBase/G4MultiReweighter.hh"
28 #include "geant4reweight/src/ReweightBase/G4ReweightManager.hh"
29 #include "G4ReweightUtils.h"
30 
35 
36 #include "cetlib/search_path.h"
37 #include "cetlib/filesystem.h"
38 
39 
40 namespace protoana {
41  class G4RWExampleAnalyzer;
42  TFile * OpenFile(const std::string filename) {
43  TFile * theFile = 0x0;
44  mf::LogInfo("pduneana::OpenFile") << "Searching for " << filename;
45  if (cet::file_exists(filename)) {
46  mf::LogInfo("pduneana::OpenFile") << "File exists. Opening " << filename;
47  theFile = new TFile(filename.c_str());
48  if (!theFile ||theFile->IsZombie() || !theFile->IsOpen()) {
49  delete theFile;
50  theFile = 0x0;
51  throw cet::exception("PDSPAnalyzer_module.cc") << "Could not open " << filename;
52  }
53  }
54  else {
55  mf::LogInfo("pduneana::OpenFile") << "File does not exist here. Searching FW_SEARCH_PATH";
56  cet::search_path sp{"FW_SEARCH_PATH"};
57  std::string found_filename;
58  auto found = sp.find_file(filename, found_filename);
59  if (!found) {
60  throw cet::exception("PDSPAnalyzer_module.cc") << "Could not find " << filename;
61  }
62 
63  mf::LogInfo("pduneana::OpenFile") << "Found file " << found_filename;
64  theFile = new TFile(found_filename.c_str());
65  if (!theFile ||theFile->IsZombie() || !theFile->IsOpen()) {
66  delete theFile;
67  theFile = 0x0;
68  throw cet::exception("PDSPAnalyzer_module.cc") << "Could not open " << found_filename;
69  }
70  }
71  return theFile;
72  }
73 }
74 
79 
81 public:
82  explicit G4RWExampleAnalyzer(fhicl::ParameterSet const& p);
83  // The compiler-generated destructor is fine for non-base
84  // classes without bare pointers or other resource use.
85 
86  // Plugins should not be copied or assigned.
91 
92  // Required functions.
93  void analyze(art::Event const& e) override;
94 
95  //Optional
96  void beginJob() override;
97  void reset();
98 
99 private:
100 
101  // Declare member data here.
102  TTree *fTree;
103  int run, subrun, event;
113  std::vector<std::string> true_beam_traj_procs;
114  std::vector<double> true_beam_dEdX;
115  std::vector<double> reco_beam_len,
124  std::vector<double> g4rw_primary_plus_sigma_weight;
125  std::vector<double> g4rw_primary_minus_sigma_weight;
126  std::vector<double> g4rw_primary_weights;
127  std::vector<std::string> g4rw_primary_var;
135  std::vector<double> g4rw_set_weights;
136 
137 
138  TFile * FracsFile;
140  G4MultiReweighter * MultiRW;
141 
143  //Geant4Reweight stuff
144  int RW_PDG;
145  std::vector<fhicl::ParameterSet> ParSet;
146  G4ReweightParameterMaker ParMaker;
147  G4ReweightManager RWManager;
148  bool fDoFull;
149  //G4MultiReweighter ProtMultiRW;
150  //G4ReweighterFactory RWFactory;
151  //G4Reweighter * theRW;
152 
153 };
154 
155 
157  fhicl::ParameterSet const& p)
158  : EDAnalyzer{p},
159  fGeneratorTag(p.get<std::string>("GeneratorTag")),
160  fPFParticleTag(p.get<std::string>("PFParticleTag")),
161  fTrackerTag(p.get<std::string>("TrackerTag")),
162  RW_PDG(p.get<int>("RW_PDG")),
163  ParSet(p.get<std::vector<fhicl::ParameterSet>>("ParameterSet")),
164  ParMaker(ParSet, false, RW_PDG),
165  RWManager({p.get<fhicl::ParameterSet>("Material")}),
166  fDoFull(p.get<bool>("DoFull")) {
167 
168  FracsFile = OpenFile(p.get< std::string >( "FracsFile" ));
169  MultiRW = new G4MultiReweighter(RW_PDG, *FracsFile, ParSet,
170  p.get<fhicl::ParameterSet>("Material"),
171  &RWManager);
172 }
173 
175 
176  reset();
177 
179  art::ServiceHandle < geo::Geometry > fGeometryService;
181  const sim::ParticleList & plist = pi_serv->ParticleList();
182 
183 
184  // This gets the true beam particle that generated the event
185  const simb::MCParticle* true_beam_particle = 0x0;
186  auto mcTruths = e.getValidHandle<std::vector<simb::MCTruth>>(fGeneratorTag);
187  true_beam_particle = truthUtil.GetGeantGoodParticle((*mcTruths)[0], e);
188  if (!true_beam_particle) {
189  MF_LOG_WARNING("PionAnalyzer") << "No true beam particle" << std::endl;
190  return;
191  }
192  ////////////////////////////
193 
194  true_beam_PDG = true_beam_particle->PdgCode();
195  true_beam_ID = true_beam_particle->TrackId();
196  true_beam_len = true_beam_particle->Trajectory().TotalLength();
197  true_beam_startX = true_beam_particle->Position(0).X();
198  true_beam_startY = true_beam_particle->Position(0).Y();
199  true_beam_startZ = true_beam_particle->Position(0).Z();
200  true_beam_endX = true_beam_particle->EndX();
201  true_beam_endY = true_beam_particle->EndY();
202  true_beam_endZ = true_beam_particle->EndZ();
203  true_beam_startP = true_beam_particle->P();
204  true_beam_endP = true_beam_particle->P(
205  (true_beam_particle->NumberTrajectoryPoints() - 2));
206  true_beam_endProcess = true_beam_particle->EndProcess();
207 
208  for (int i = 0; i < true_beam_particle->NumberDaughters(); ++i) {
209  int daughterID = true_beam_particle->Daughter(i);
210  auto part = plist[ daughterID ];
211  int pdg = part->PdgCode();
212 
213  if (part->Process().find("Inelastic") != std::string::npos) {
214  if (pdg == 211) {
216  }
217  else if (pdg == -211) {
219  }
220  else if (pdg == 111) {
222  }
223  else if (pdg == 2212) {
225  }
226  else if (pdg == 2112) {
228  }
229  }
230 
231  }
232 
234  auto view2_IDEs = bt_serv->TrackIdToSimIDEs_Ps(true_beam_ID, geo::View_t(2));
235  if (view2_IDEs.size() > 1) {
236  std::sort(view2_IDEs.begin(), view2_IDEs.end(),
237  [](const sim::IDE * i1, const sim::IDE * i2)
238  {return (i1->z < i2->z);});
239  for (size_t i = 0; i < view2_IDEs.size()-1; ++i) {
240  const sim::IDE * i1 = view2_IDEs[i];
241  const sim::IDE * i2 = view2_IDEs[i+1];
242 
243  double edep = i1->energy;
244  double len = sqrt(std::pow((i1->x - i2->x), 2) +
245  std::pow((i1->y - i2->y), 2) +
246  std::pow((i1->z - i2->z), 2));
247  if (len > 1.e-5)
248  true_beam_dEdX.push_back((edep/len));
249  }
250  }
251 
252  try {
254  auto pfpVec =
255  e.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleTag);
256  for (const recob::PFParticle & pfp : (*pfpVec)) {
257  const recob::Track * thisTrack =
259 
260  reco_beam_nDaughters.push_back(pfp.NumDaughters());
261  if (thisTrack) {
262  reco_beam_len.push_back(thisTrack->Length());
263  reco_beam_ID.push_back(thisTrack->ID());
264  reco_beam_startX.push_back(thisTrack->Start().X());
265  reco_beam_startY.push_back(thisTrack->Start().Y());
266  reco_beam_startZ.push_back(thisTrack->Start().Z());
267  reco_beam_endX.push_back(thisTrack->End().X());
268  reco_beam_endY.push_back(thisTrack->End().Y());
269  reco_beam_endZ.push_back(thisTrack->End().Z());
270  }
271  else {
272  reco_beam_len.push_back(-1.);
273  reco_beam_ID.push_back(-1);
274  reco_beam_startX.push_back(-1.);
275  reco_beam_startY.push_back(-1.);
276  reco_beam_startZ.push_back(-1.);
277  reco_beam_endX.push_back(-1.);
278  reco_beam_endY.push_back(-1.);
279  reco_beam_endZ.push_back(-1.);
280  }
281 
282  }
283  }
284  catch (const std::exception & e) {
285  std::cout << "No reco info. Moving on" << std::endl;
286  }
287 
288  const simb::MCTrajectory & true_beam_trajectory =
289  true_beam_particle->Trajectory();
290 
291  auto true_beam_proc_map = true_beam_trajectory.TrajectoryProcesses();
292  std::map<size_t, std::string> proc_map;
293  for (auto itProc = true_beam_proc_map.begin();
294  itProc != true_beam_proc_map.end(); ++itProc) {
295  //int index = itProc->first;
296  std::string process = true_beam_trajectory.KeyToProcess(itProc->second);
297  proc_map[itProc->first] = process;
298 
299  if (process == "hadElastic") {
301  }
302  }
303 
304  true_beam_nTrajPts = true_beam_trajectory.size();
305  true_beam_traj_X.push_back(true_beam_trajectory.X(0));
306  true_beam_traj_Y.push_back(true_beam_trajectory.Y(0));
307  true_beam_traj_Z.push_back(true_beam_trajectory.Z(0));
308  true_beam_traj_KE.push_back(
309  1.e3*(true_beam_trajectory.E(0) - true_beam_particle->Mass()));
310  double p_mag = sqrt(true_beam_trajectory.Px(0)*true_beam_trajectory.Px(0) +
311  true_beam_trajectory.Py(0)*true_beam_trajectory.Py(0) +
312  true_beam_trajectory.Pz(0)*true_beam_trajectory.Pz(0));
313  true_beam_traj_rx.push_back(true_beam_trajectory.Px(0)/p_mag);
314  true_beam_traj_ry.push_back(true_beam_trajectory.Py(0)/p_mag);
315  true_beam_traj_rz.push_back(true_beam_trajectory.Pz(0)/p_mag);
316  if (proc_map.find(0) != proc_map.end()) {
317  true_beam_traj_procs.push_back(proc_map.at(0));
318  }
319  else {
320  true_beam_traj_procs.push_back("");
321  }
322  for (int i = 1; i < true_beam_nTrajPts; ++i) {
323  double x0 = true_beam_trajectory.X(i-1);
324  double x1 = true_beam_trajectory.X(i);
325  double y0 = true_beam_trajectory.Y(i-1);
326  double y1 = true_beam_trajectory.Y(i);
327  double z0 = true_beam_trajectory.Z(i-1);
328  double z1 = true_beam_trajectory.Z(i);
329 
330  true_beam_traj_dx.push_back(sqrt((x1 - x0)*(x1 - x0) +
331  (y1 - y0)*(y1 - y0) +
332  (z1 - z0)*(z1 - z0)));
333  true_beam_traj_X.push_back(true_beam_trajectory.X(i));
334  true_beam_traj_Y.push_back(true_beam_trajectory.Y(i));
335  true_beam_traj_Z.push_back(true_beam_trajectory.Z(i));
336  true_beam_traj_KE.push_back(
337  1.e3*(true_beam_trajectory.E(i) - true_beam_particle->Mass()));
338  double p_mag = sqrt(true_beam_trajectory.Px(i)*true_beam_trajectory.Px(i) +
339  true_beam_trajectory.Py(i)*true_beam_trajectory.Py(i) +
340  true_beam_trajectory.Pz(i)*true_beam_trajectory.Pz(i));
341  true_beam_traj_rx.push_back(true_beam_trajectory.Px(i)/p_mag);
342  true_beam_traj_ry.push_back(true_beam_trajectory.Py(i)/p_mag);
343  true_beam_traj_rz.push_back(true_beam_trajectory.Pz(i)/p_mag);
344  if (proc_map.find(i) != proc_map.end()) {
345  true_beam_traj_procs.push_back(proc_map.at(i));
346  }
347  else {
348  true_beam_traj_procs.push_back("");
349  }
350  }
351 
352 
353  event = e.id().event();
354  run = e.run();
355  subrun = e.subRun();
356 
357  if (true_beam_PDG == RW_PDG) {
358  G4ReweightTraj theTraj(true_beam_ID, true_beam_PDG, 0, event, {0,0});
359  /*
360  bool created = CreateRWTraj(*true_beam_particle, plist,
361  fGeometryService, event, &theTraj);
362  if (created && theTraj.GetNSteps()) {
363 
364  g4rw_primary_singular_weight = MultiRW->GetWeightFromNominal(theTraj);
365  //the following method achieves the same result
366  //g4rw_primary_singular_weight = theRW->GetWeight(&theTraj);
367 
368  std::vector<double> weights_vec = MultiRW->GetWeightFromAll1DThrows(
369  theTraj);
370  g4rw_primary_weights.insert(g4rw_primary_weights.end(),
371  weights_vec.begin(), weights_vec.end());
372 
373  for (size_t i = 0; i < ParSet.size(); ++i) {
374  std::pair<double, double> pm_weights =
375  MultiRW->GetPlusMinusSigmaParWeight(theTraj, i);
376 
377  g4rw_primary_plus_sigma_weight.push_back(pm_weights.first);
378  g4rw_primary_minus_sigma_weight.push_back(pm_weights.second);
379  g4rw_primary_var.push_back(ParSet[i].get<std::string>("Name"));
380  }
381 
382  //For testing with Heng-Ye's parameters
383  if (ParSet.size() == 2) {
384  for (size_t i = 0; i < 20; ++i) {
385  for (size_t j = 0; j < 20; ++j) {
386  std::vector<double> input_values = {(.1 + i*.1), (.1 + j*.1)};
387  bool set_values = MultiRW->SetAllParameterValues(input_values);
388  if (!set_values) continue;
389 
390  g4rw_set_weights.push_back(
391  MultiRW->GetWeightFromSetParameters(theTraj));
392  }
393  }
394  }
395 
396 
397  }
398  */
399 
400  std::vector<G4ReweightTraj *> trajs = CreateNRWTrajs(
401  *true_beam_particle, plist,
402  fGeometryService, event, "LAr");
403  bool added = false;
404  for (size_t i = 0; i < trajs.size(); ++i) {
405  if (trajs[i]->GetNSteps() > 0) {
406  //std::cout << i << " " << trajs[i]->GetNSteps() << std::endl;
407  for (size_t j = 0; j < ParSet.size(); ++j) {
408  std::pair<double, double> pm_weights =
409  MultiRW->GetPlusMinusSigmaParWeight((*trajs[i]), j);
410  //std::cout << "got weights" << std::endl;
411  //std::cout << pm_weights.first << " " << pm_weights.second << std::endl;
412 
413  if (!added) {
414  g4rw_alt_primary_plus_sigma_weight.push_back(pm_weights.first);
415  g4rw_alt_primary_minus_sigma_weight.push_back(pm_weights.second);
416  }
417  else {
418  g4rw_alt_primary_plus_sigma_weight[j] *= pm_weights.first;
419  g4rw_alt_primary_minus_sigma_weight[j] *= pm_weights.second;
420  }
421  }
422  added = true;
423  }
424  }
425 
426  for (size_t i = 0; i < ParSet.size(); ++i) {
427  std::pair<double, double> temp_weights = GetNTrajPMSigmaWeights(trajs, *MultiRW, i);
428  g4rw_test_primary_plus_sigma_weight.push_back(temp_weights.first);
429  g4rw_test_primary_minus_sigma_weight.push_back(temp_weights.second);
430  }
431 
432  std::vector<double> input(ParSet.size(), 1.);
433  bool set_values = MultiRW->SetAllParameterValues(input);
434  if (set_values) {
435  }
436 
437  //Heng-Ye's weights
438  //for (ii reac loop)
439  //for (jj elast loop)
440  // bool set_values = MultiRW->SetAllParameterValues(input_values);
441  // if (!set_values) continue;
442  // double temp_w = GetNTrajWeightFromSetPars(trajs, MultiRW);
443  // g4rw_set_weights.push_back(temp_w);
444 
445  if (fDoFull) {
446  std::vector<int> to_create = {true_beam_ID};
447  std::vector<std::vector<G4ReweightTraj *>> created;
448  while (to_create.size()) {
449  auto part = plist[to_create[0]];
450  std::vector<G4ReweightTraj *> temp_trajs =
451  CreateNRWTrajs(*part, plist, fGeometryService,
452  event, "LAr");
453  if (temp_trajs.size()) {
454  auto last_traj = temp_trajs.back();
455  for (size_t i = 0; i < last_traj->GetNChilds(); ++i) {
456  if ((last_traj->GetChild(i)->GetPDG() == 2212) ||
457  (last_traj->GetChild(i)->GetPDG() == 2112) ||
458  (abs(last_traj->GetChild(i)->GetPDG()) == 211) ) {
459  to_create.push_back(last_traj->GetChild(i)->GetTrackID());
460  }
461  }
462 
463  if (temp_trajs[0]->GetPDG() == RW_PDG) {
464  created.push_back(temp_trajs);
465  }
466  }
467  to_create.erase(to_create.begin());
468  }
469 
470 
471  bool new_added = false;
472  for (size_t i = 0; i < created.size(); ++i) {
473  std::vector<G4ReweightTraj *> temp_trajs = created[i];
474  for (size_t j = 0; j < temp_trajs.size(); ++j) {
475  G4ReweightTraj * this_traj = temp_trajs[j];
476  if (this_traj->GetNSteps() > 0) {
477  for (size_t k = 0; k < ParSet.size(); ++k) {
478  std::pair<double, double> pm_weights =
479  MultiRW->GetPlusMinusSigmaParWeight((*this_traj), k);
480 
481  if (!new_added) {
482  g4rw_full_primary_plus_sigma_weight.push_back(pm_weights.first);
483  g4rw_full_primary_minus_sigma_weight.push_back(pm_weights.second);
484  }
485  else {
486  g4rw_full_primary_plus_sigma_weight[k] *= pm_weights.first;
487  g4rw_full_primary_minus_sigma_weight[k] *= pm_weights.second;
488  }
489  }
490  new_added = true;
491  }
492  }
493  }
494  }
495  }
496 
497  fTree->Fill();
498 }
499 
502  fTree = tfs->make<TTree>("tree","output tree");
503 
504  fTree->Branch("run", &run);
505  fTree->Branch("subrun", &subrun);
506  fTree->Branch("event", &event);
507  fTree->Branch("true_beam_ID", &true_beam_ID);
508  fTree->Branch("true_beam_PDG", &true_beam_PDG);
509  fTree->Branch("true_beam_len", &true_beam_len);
510  fTree->Branch("true_beam_nTrajPts", &true_beam_nTrajPts);
511  fTree->Branch("true_beam_traj_dx", &true_beam_traj_dx);
512  fTree->Branch("true_beam_traj_X", &true_beam_traj_X);
513  fTree->Branch("true_beam_traj_Y", &true_beam_traj_Y);
514  fTree->Branch("true_beam_traj_Z", &true_beam_traj_Z);
515  fTree->Branch("true_beam_traj_rx", &true_beam_traj_rx);
516  fTree->Branch("true_beam_traj_ry", &true_beam_traj_ry);
517  fTree->Branch("true_beam_traj_rz", &true_beam_traj_rz);
518  fTree->Branch("true_beam_traj_KE", &true_beam_traj_KE);
519  fTree->Branch("true_beam_traj_procs", &true_beam_traj_procs);
520  fTree->Branch("true_beam_startP", &true_beam_startP);
521  fTree->Branch("true_beam_startX", &true_beam_startX);
522  fTree->Branch("true_beam_startY", &true_beam_startY);
523  fTree->Branch("true_beam_startZ", &true_beam_startZ);
524  fTree->Branch("true_beam_endX", &true_beam_endX);
525  fTree->Branch("true_beam_endY", &true_beam_endY);
526  fTree->Branch("true_beam_endZ", &true_beam_endZ);
527  fTree->Branch("true_beam_endP", &true_beam_endP);
528  fTree->Branch("true_beam_dEdX", &true_beam_dEdX);
529  fTree->Branch("true_beam_nPi0_daughter", &true_beam_nPi0_daughter);
530  fTree->Branch("true_beam_nPiPlus_daughter", &true_beam_nPiPlus_daughter);
531  fTree->Branch("true_beam_nPiMinus_daughter", &true_beam_nPiMinus_daughter);
532  fTree->Branch("true_beam_nProton_daughter", &true_beam_nProton_daughter);
533  fTree->Branch("true_beam_nNeutron_daughter", &true_beam_nNeutron_daughter);
534  fTree->Branch("true_beam_endProcess", &true_beam_endProcess);
535  fTree->Branch("true_beam_nElasticScatters", &true_beam_nElasticScatters);
536 
537  fTree->Branch("reco_beam_len", &reco_beam_len);
538  fTree->Branch("reco_beam_startX", &reco_beam_startX);
539  fTree->Branch("reco_beam_startY", &reco_beam_startY);
540  fTree->Branch("reco_beam_startZ", &reco_beam_startZ);
541  fTree->Branch("reco_beam_endX", &reco_beam_endX);
542  fTree->Branch("reco_beam_endY", &reco_beam_endY);
543  fTree->Branch("reco_beam_endZ", &reco_beam_endZ);
544  fTree->Branch("reco_beam_ID", &reco_beam_ID);
545  fTree->Branch("reco_beam_nDaughters", &reco_beam_nDaughters);
546 
547  fTree->Branch("g4rw_primary_weights", &g4rw_primary_weights);
548  fTree->Branch("g4rw_primary_singular_weight", &g4rw_primary_singular_weight);
549  fTree->Branch("g4rw_primary_plus_sigma_weight", &g4rw_primary_plus_sigma_weight);
550  fTree->Branch("g4rw_primary_minus_sigma_weight", &g4rw_primary_minus_sigma_weight);
551  fTree->Branch("g4rw_primary_var", &g4rw_primary_var);
552  fTree->Branch("g4rw_alt_primary_plus_sigma_weight",
554  fTree->Branch("g4rw_alt_primary_minus_sigma_weight",
556  fTree->Branch("g4rw_test_primary_plus_sigma_weight",
558  fTree->Branch("g4rw_test_primary_minus_sigma_weight",
560 
561  fTree->Branch("g4rw_full_primary_plus_sigma_weight",
563  fTree->Branch("g4rw_full_primary_minus_sigma_weight",
565  fTree->Branch("g4rw_set_weights", &g4rw_set_weights);
566 }
567 
569  true_beam_PDG = -1;
570  true_beam_ID = -1;
571  true_beam_len = -1.;
572  true_beam_nTrajPts = -1;
573  true_beam_traj_dx.clear();
574  true_beam_traj_X.clear();
575  true_beam_traj_Y.clear();
576  true_beam_traj_Z.clear();
577  true_beam_traj_KE.clear();
578  true_beam_traj_procs.clear();
579  true_beam_traj_rx.clear();
580  true_beam_traj_ry.clear();
581  true_beam_traj_rz.clear();
582  true_beam_startP = -1.;
583  true_beam_startX = -1.;
584  true_beam_startY = -1.;
585  true_beam_startZ = -1.;
586  true_beam_endX = -1.;
587  true_beam_endY = -1.;
588  true_beam_endZ = -1.;
589  true_beam_endP = -1.;
597  true_beam_dEdX.clear();
598 
599  reco_beam_len.clear();
600  reco_beam_ID.clear();
601  reco_beam_nDaughters.clear();
602  reco_beam_startX.clear();
603  reco_beam_startY.clear();
604  reco_beam_startZ.clear();
605  reco_beam_endX.clear();
606  reco_beam_endY.clear();
607  reco_beam_endZ.clear();
608 
609  g4rw_primary_weights.clear();
613  g4rw_primary_var.clear();
620  g4rw_set_weights.clear();
621 }
622 
double Z(const size_type i) const
Definition: MCTrajectory.h:151
double X(const size_type i) const
Definition: MCTrajectory.h:149
std::vector< std::string > g4rw_primary_var
std::vector< double > g4rw_full_primary_minus_sigma_weight
float z
z position of ionization [cm]
Definition: SimChannel.h:117
G4RWExampleAnalyzer & operator=(G4RWExampleAnalyzer const &)=delete
const simb::MCParticle * GetGeantGoodParticle(const simb::MCTruth &genTruth, const art::Event &evt) const
G4RWExampleAnalyzer(fhicl::ParameterSet const &p)
double E(const size_type i) const
Definition: MCTrajectory.h:156
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
double Pz(const size_type i) const
Definition: MCTrajectory.h:155
constexpr T pow(T x)
Definition: pow.h:72
std::string KeyToProcess(unsigned char const &key) const
std::vector< const sim::IDE * > TrackIdToSimIDEs_Ps(int const &id) const
double GetNTrajWeightFromSetPars(const std::vector< G4ReweightTraj * > &trajs, G4MultiReweighter &rw)
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::vector< fhicl::ParameterSet > ParSet
string filename
Definition: train.py:213
float x
x position of ionization [cm]
Definition: SimChannel.h:115
std::vector< double > g4rw_alt_primary_minus_sigma_weight
def process(f, kind)
Definition: search.py:254
T abs(T value)
const double e
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:167
double Y(const size_type i) const
Definition: MCTrajectory.h:150
static int input(void)
Definition: code.cpp:15695
std::vector< double > g4rw_full_primary_plus_sigma_weight
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
std::vector< double > g4rw_primary_plus_sigma_weight
Point_t const & Start() const
Access to track position at different points.
Definition: Track.h:123
Ionization at a point of the TPC sensitive volume.
Definition: SimChannel.h:84
const recob::Track * GetPFParticleTrack(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Get the track associated to this particle. Returns a null pointer if not found.
float energy
energy deposited by ionization by this track ID and time [MeV]
Definition: SimChannel.h:114
std::vector< double > g4rw_primary_minus_sigma_weight
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
p
Definition: test.py:223
bool CreateRWTraj(const simb::MCParticle &part, const sim::ParticleList &plist, art::ServiceHandle< geo::Geometry > geo_serv, int event, G4ReweightTraj *theTraj)
ProcessMap const & TrajectoryProcesses() const
Definition: MCTrajectory.h:188
std::vector< double > g4rw_test_primary_minus_sigma_weight
const sim::ParticleList & ParticleList() const
float y
y position of ionization [cm]
Definition: SimChannel.h:116
int ID() const
Definition: Track.h:198
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
size_type size() const
Definition: MCTrajectory.h:166
void analyze(art::Event const &e) override
std::vector< std::string > true_beam_traj_procs
Point_t const & End() const
Definition: Track.h:125
std::vector< double > g4rw_alt_primary_plus_sigma_weight
double Px(const size_type i) const
Definition: MCTrajectory.h:153
bool file_exists(std::string const &qualified_filename)
Definition: filesystem.cc:14
#define MF_LOG_WARNING(category)
std::vector< G4ReweightTraj * > CreateNRWTrajs(const simb::MCParticle &part, const sim::ParticleList &plist, art::ServiceHandle< geo::Geometry > geo_serv, int event, std::string material_name="LAr", bool fVerbose=false)
TFile * OpenFile(const std::string filename)
double Py(const size_type i) const
Definition: MCTrajectory.h:154
std::vector< double > g4rw_test_primary_plus_sigma_weight
std::pair< double, double > GetNTrajPMSigmaWeights(const std::vector< G4ReweightTraj * > &trajs, G4MultiReweighter &rw, size_t iPar)
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
Event finding and building.