sliceAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: sliceAna
3 // Module Type: analyzer
4 // File: sliceAna_module.cc
5 //
6 // Generated at Sun Oct 30 01:06:14 2016 by Andrew S. Hirsch using artmod
7 // from cetpkgsupport v1_10_02.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
24 #include <memory>
25 
27 #include "TTree.h"
28 
29 namespace supernova {
30  class sliceAna;
31 }
32 
34 public:
35  explicit sliceAna(fhicl::ParameterSet const & p);
36  // The destructor generated by the compiler is fine for classes
37  // without bare pointers or other resource use.
38 
39  // Plugins should not be copied or assigned.
40  sliceAna(sliceAna const &) = delete;
41  sliceAna(sliceAna &&) = delete;
42  sliceAna & operator = (sliceAna const &) = delete;
43  sliceAna & operator = (sliceAna &&) = delete;
44 
45  // Required functions.
46  void analyze(art::Event const & e) override;
47 
48  void CalculateDT (const novaddt::HitList& slice);
49  void CalculatePCorr(const novaddt::HitList& slice, const clusterInfo& c);
50  double CalcDT0(const novaddt::HitList& slice);
51  double CalcDTC(const novaddt::HitList& slice);
52 private:
53 
54  // Declare member data here.
56 
59 
60  TTree* fTree = 0;
62  uint64_t fEventNum = 0;
63  std::vector<uint64_t> fTime;
64  std::vector<uint64_t> fADC_x, fADC_y, fADC_c;
65  std::vector<uint16_t> fX,fY,fZ;
66  std::vector<uint16_t> fNx,fNy;
67  std::vector<double> fDT0,fDTC;
68  std::vector<double> fPCor_x,fPCor_y;
69 
70  void clearVector();
71  void addToVector(clusterInfo&);
72 };
73 
75  fTime.clear();
76  fADC_x.clear();
77  fADC_y.clear();
78  fADC_c.clear();
79  fX.clear();
80  fY.clear();
81  fZ.clear();
82  fNx.clear();
83  fNy.clear();
84  fDT0.clear();
85  fDTC.clear();
86  fPCor_x.clear();
87  fPCor_y.clear();
88 }
89 
91  fTime.push_back(c.t);
92  fADC_x.push_back(c.ADC_x());
93  fADC_y.push_back(c.ADC_y());
94  fADC_c.push_back(c.ADC_corr());
95  fX.push_back(c.crd[0]);
96  fY.push_back(c.crd[1]);
97  fZ.push_back(c.crd[2]);
98  fNx.push_back(c.Nx());
99  fNy.push_back(c.Ny());
100 }
101 
103  :
104  EDAnalyzer(p),
105  fDetUtils("fd"),
106  fSlicesTag (p.get< std::string >("slices_tag" )),
107  fSelector (p.get<fhicl::ParameterSet>("slice_cuts"))
108 {
110  fTree=tfs->make<TTree>("Slices","Slices analysis tree");
111  fTree->Branch("event",&fEventNum,"num/l");
112  fTree->Branch("tdc",&fTime);
113  fTree->Branch("adc_x",&fADC_x);
114  fTree->Branch("adc_y",&fADC_y);
115  fTree->Branch("Pcor_x",&fPCor_x);
116  fTree->Branch("Pcor_y",&fPCor_y);
117  fTree->Branch("nx",&fNx);
118  fTree->Branch("ny",&fNy);
119  fTree->Branch("x",&fX);
120  fTree->Branch("y",&fY);
121  fTree->Branch("z",&fZ);
122  fTree->Branch("dt0",&fDT0);
123  fTree->Branch("dtC",&fDTC);
124 }
125 
126 double DT(const novaddt::TDC& t1,const novaddt::TDC& t2){
127  // std::cout<<"t1 = "<<t1.val<<" + "<<t1.fraction()<<std::endl;
128  // std::cout<<"t2 = "<<t2.val<<" + "<<t2.fraction()<<std::endl;
129  return double(t2.val-t1.val)+(t2.fraction()-t1.fraction());
130 }
132  auto h0=slice.front();
133  auto h1=slice.back();
134  return DT(h0.TDC(),h1.TDC())*fDetUtils.TDC_to_ns();
135 };
136 
138  auto h1=slice.front();
139  auto h2=slice.back();
140  if(h1.View()==h2.View()) return 0;
141  double dist1 = fDetUtils.GetReadoutDistance(h1,h2.Cell());
142  double dist2 = fDetUtils.GetReadoutDistance(h2,h1.Cell());
143  //double dt1 = fDetUtils.TimeOffsetFull(h0,dist1);
144  //double dt2 = fDetUtils.TimeOffsetFull(h1,dist2);
145  double dt1 = fDetUtils.DistTimeOffset(dist1);
146  double dt2 = fDetUtils.DistTimeOffset(dist2);
147  double dpt1 = fDetUtils.PigTimeOffset(h1);
148  double dpt2 = fDetUtils.PigTimeOffset(h2);
149 /*
150  std::cout<<"h1.Cell="<<h1.Cell().val<<" dist="<<dist1
151  <<" dt="<<dt1<<" pt="<<dpt1<<std::endl;
152  std::cout<<"h2.Cell="<<h2.Cell().val<<" dist="<<dist2
153  <<" dt="<<dt2<<" pt="<<dpt2<<std::endl;
154 */
155  dt1+=dpt1;
156  dt2+=dpt2;
157  return DT(h1.TDC(),h2.TDC())*fDetUtils.TDC_to_ns()-dt2+dt1;
158 };
159 
161  double dt0=CalcDT0(slice);
162  double dtC=CalcDTC(slice);
163  fDT0.push_back(dt0);
164  fDTC.push_back(dtC);
165 }
166 
168  const clusterInfo& cluster){
169  //calculate PCorr
170  double pe[2] = {0,0};
171 
172  for(const auto & hit: slice){
173  // get the coordinate in the other view than this hit
174  uint16_t view = hit.View().val-1;
175  novaddt::Cell crd = cluster.crd[!view];
176 
177  double dist = fDetUtils.GetReadoutDistance(hit,crd);
178  double attFactor = fDetUtils.AttenFactor(hit,dist);
179  pe[view]+= hit.ADC().val/attFactor;
180 /* std::cout<<"Hit.v = "<< view << " crd=["
181  <<cluster.crd[0]<<","<<cluster.crd[1]
182  <<"]"<<std::endl;
183  std::cout<<"cell = "<<crd.val<<" -> dist = "<<dist<<" attF = "<<attFactor<<std::endl;
184  */
185  }
186 
187  fPCor_x.push_back(pe[0]);
188  fPCor_y.push_back(pe[1]);
189 }
190 
192 {
193  fEventNum++;
194  auto slices=e.getValidHandle<std::vector<novaddt::HitList>>(fSlicesTag);
195  clearVector();
196  for(const auto& slice: *slices){
197  auto c=CalcCluster(slice);
199  //calculate times
200  CalculateDT(slice);
201  CalculatePCorr(slice,c);
202 
203  //std::cout<<"DT: "<<dt0<<" -> "<<dtC<<std::endl;
204  }
205  fTree->Fill();
206 }
207 
uint64_t ADC_y() const
Definition: clusterInfo.h:12
void CalculatePCorr(const novaddt::HitList &slice, const clusterInfo &c)
value_type val
Definition: BaseProducts.h:34
std::vector< uint64_t > fADC_c
std::vector< uint64_t > fADC_y
std::vector< DAQHit > HitList
Definition: HitList.h:15
std::vector< double > fPCor_x
void addToVector(clusterInfo &)
const char * p
Definition: xmltok.h:285
double AttenFactor(const DAQHit &hit, double dist) const
uint64_t ADC_x() const
Definition: clusterInfo.h:11
DEFINE_ART_MODULE(TestTMapFile)
clusterInfo CalcCluster(const novaddt::HitList &slice)
Definition: clusterInfo.h:26
std::vector< uint64_t > fTime
double DistTimeOffset(double dist) const
uint64_t Nx() const
Definition: clusterInfo.h:8
double dist
Definition: runWimpSim.h:113
sliceAna(fhicl::ParameterSet const &p)
std::vector< uint16_t > fX
novaddt::SliceSelector fSelector
double CalcDT0(const novaddt::HitList &slice)
double DT(const novaddt::TDC &t1, const novaddt::TDC &t2)
std::vector< uint64_t > fADC_x
uint64_t t
Definition: clusterInfo.h:18
std::vector< uint16_t > fY
sliceAna & operator=(sliceAna const &)=delete
double ADC_corr() const
Definition: clusterInfo.h:13
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
double t2
double PigTimeOffset(const DAQHit &hit) const
Definition: DetectorUtils.h:69
double GetReadoutDistance(const DAQHit &hit, const novaddt::Cell &cell) const
double fraction() const
Definition: BaseProducts.h:37
TH1F * h2
Definition: plot.C:45
std::vector< uint16_t > fNy
uint64_t Ny() const
Definition: clusterInfo.h:9
TH1F * h1
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
T * make(ARGS...args) const
void CalculateDT(const novaddt::HitList &slice)
std::vector< uint16_t > fZ
Definition: structs.h:12
An ART module for generating supernova events via GENIE.
std::vector< double > fPCor_y
std::vector< double > fDT0
std::vector< double > fDTC
std::vector< uint16_t > fNx
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Float_t e
Definition: plot.C:35
double CalcDTC(const novaddt::HitList &slice)
bool checkCluster(const clusterInfo &c)
Definition: SliceSelector.h:68
uint64_t crd[3]
Definition: clusterInfo.h:19
novaddt::utils::DetectorUtils fDetUtils
void analyze(art::Event const &e) override