SMMEff_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: SMMEff
3 // Module Type: analyzer
4 // File: SMMEff_module.cc
5 //
6 // Generated at Thu Sep 28 15:31:46 2013 by Zukai Wang using artmod
7 // from art v1_02_06.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "RecoBase/CellHit.h"
11 #include "Simulation/Particle.h"
13 #include "MCCheater/BackTracker.h"
14 
20 
21 #include <fstream>
22 #include <string>
23 #include <vector>
24 
25 
26 class TTree;
27 
28 namespace ddt {
29  class SMMEff;
30  struct ZukHit;
31  struct Zuk_CompareHit;
32 }
33 
34 class ddt::SMMEff : public art::EDAnalyzer {
35 public:
36  explicit SMMEff(fhicl::ParameterSet const & p);
37  virtual ~SMMEff();
38 
39  void analyze(art::Event const & e) override;
40 
41 private:
43 
44  float beta;
45  int nhits;
46 
47 };
48 
49 
51  EDAnalyzer(p),
52  fCellHitInput(p.get<std::string>("CellHitInput"))
53 {
54 }
55 
57 {
58 }
59 
61 {
62  std::ofstream ofs;
63  ofs.open ("SMM_MC.dat", std::ofstream::out | std::ofstream::app);
65  const sim::ParticleNavigator& pnav = bt->ParticleNavigator();
66  for (sim::ParticleNavigator::const_iterator i = pnav.begin(); i != pnav.end(); ++i){
67  const sim::Particle *p = (*i).second;
68  if (p->PdgCode() == 42) {
69  beta = sqrt((p->P())*(p->P())/((p->P())*(p->P())+ (p->Mass())*(p->Mass())) );
70  const std::vector<sim::FLSHit>& flshits = bt->ParticleToFLSHit(p->TrackId());
71  nhits = flshits.size();
72  break;
73  }
74  }
75 
76  ofs<<beta<<" "<<nhits<<std::endl;
77 
78  return;
79 }
80 
81 
back track the reconstruction to the simulation
int PdgCode() const
Definition: MCParticle.h:211
const sim::ParticleNavigator & ParticleNavigator() const
Get a reference to the ParticleNavigator.
Definition: BackTracker.h:744
const char * p
Definition: xmltok.h:285
T sqrt(T number)
Definition: d0nt_math.hpp:156
std::vector< sim::FLSHit > ParticleToFLSHit(const int &trackID) const
All the FLSHits that were created by the track id trackID, sorted from most to least light...
double Mass() const
Definition: MCParticle.h:238
list_type::const_iterator const_iterator
DEFINE_ART_MODULE(TestTMapFile)
SMMEff(fhicl::ParameterSet const &p)
int TrackId() const
Definition: MCParticle.h:209
std::string fCellHitInput
double P(const int i=0) const
Definition: MCParticle.h:233
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
app
Definition: demo.py:189
Float_t e
Definition: plot.C:35
virtual ~SMMEff()
void analyze(art::Event const &e) override
enum BeamMode string