SMMADC_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: SMMADC
3 // Module Type: analyzer
4 // File: SMMADC_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 #include "Simulation/FLSHit.h"
15 #include "Simulation/FLSHitList.h"
16 
22 
23 #include <fstream>
24 #include <string>
25 #include <vector>
26 #include "TTree.h"
27 
28 class TTree;
29 
30 namespace ddt {
31  class SMMADC;
32 }
33 
34 
35 class ddt::SMMADC : public art::EDAnalyzer {
36 public:
37  explicit SMMADC(fhicl::ParameterSet const & p);
38  virtual ~SMMADC();
39 
40  void beginJob();
41  void analyze(art::Event const & e) override;
42 
43 private:
45  TTree* SMtree;
46 
47  float beta,plc,edep;
48  int ADC;
49 };
50 
51 
53  EDAnalyzer(p),
54  fCellHitInput(p.get<std::string>("CellHitInput"))
55 {
56 }
57 
59 {
60 }
61 
63 {
64 
66  SMtree = tfs->make<TTree>("SMHitsTree","");
67 
68  SMtree->Branch("beta",&beta,"beta/F");
69  SMtree->Branch("ADC",&ADC,"ADC/I");
70  SMtree->Branch("plc",&plc,"plc/F");
71  SMtree->Branch("edep",&edep,"edep/F");
72 }
73 
75 {
77  e.getByLabel(fCellHitInput, hitcol);
78 
80 
81  const sim::ParticleNavigator& pnav = bt->ParticleNavigator();
82  for (sim::ParticleNavigator::const_iterator i = pnav.begin(); i != pnav.end(); ++i){
83  const sim::Particle *p = (*i).second;
84  if (p->PdgCode() == 42) {
85  beta = sqrt((p->P())*(p->P())/((p->P())*(p->P())+ (p->Mass())*(p->Mass())) );
86  break;
87  }
88  }
89 
90 
91  for (unsigned int i = 0; i < hitcol->size(); ++i) {
92  art::Ptr<rb::CellHit> hit(hitcol, i);
93  if (!bt->IsNoise(hit)) {
94  ADC = hit->ADC();
95  const std::vector<sim::FLSHit >& flshits = bt->HitToFLSHit(hit);
96  plc = flshits[0].GetTotalPathLength();
97  edep = flshits[0].GetEdep();
98 
99  SMtree->Fill();
100  }
101  }
102 
103  return;
104 }
105 
106 
107 
back track the reconstruction to the simulation
int PdgCode() const
Definition: MCParticle.h:211
std::string fCellHitInput
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
double Mass() const
Definition: MCParticle.h:238
list_type::const_iterator const_iterator
void analyze(art::Event const &e) override
DEFINE_ART_MODULE(TestTMapFile)
bool IsNoise(const art::Ptr< rb::CellHit > &hit) const
Is this hit not associated with any particles?
virtual ~SMMADC()
std::vector< sim::FLSHit > HitToFLSHit(const rb::CellHit &hit) const
All the FLSHits that contributed to this hit, sorted from most to least light.
double P(const int i=0) const
Definition: MCParticle.h:233
SMMADC(fhicl::ParameterSet const &p)
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
T * make(ARGS...args) const
int16_t ADC(uint32_t i) const
Definition: RawDigit.cxx:58
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
void beginJob()
TTree * SMtree
Float_t e
Definition: plot.C:35
enum BeamMode string