RawEVDDP_module.cc
Go to the documentation of this file.
1 //Use this module to create histograms for 10kt FD Dual-phase TPC
2 
3 #ifndef RawEVDDP_Module
4 #define RawEVDDP_Module
5 
6 // LArSoft includes
10 #include "lardataobj/RawData/raw.h"
18 #include "lardataobj/RawData/raw.h"
19 
20 // Framework includes
25 #include "art_root_io/TFileService.h"
27 #include "canvas/Persistency/Common/FindManyP.h"
29 #include "fhiclcpp/ParameterSet.h"
30 
31 // ROOT includes.
32 #include "TH1.h"
33 #include "TH2.h"
34 
35 // C++ Includes
36 #include <map>
37 #include <vector>
38 #include <algorithm>
39 #include <fstream>
40 #include <iostream>
41 #include <string>
42 #include <sstream>
43 #include <cmath>
44 
45 namespace AnalysisExample{
46 
47  class RawEVDDP : public art::EDAnalyzer{
48  public:
49 
50  explicit RawEVDDP(fhicl::ParameterSet const& pset);
51  virtual ~RawEVDDP();
52 
53  void beginJob();
54 
55  void beginRun(const art::Run& run);
56  void reconfigure(fhicl::ParameterSet const& pset);
57  void analyze(const art::Event& evt);
58 
59 
60  private:
61 
62  // the parameters we'll read from the .fcl
64  //unsigned int fEvent; // unused
65 
66  // number of time bins for histogram ranges
67  unsigned int fNticks;
68  unsigned int fChPerView; // total number of channels in given view
69 
70  // find channel boundaries for each view
71  //unsigned int fV0ChanMin; // unused
72  //unsigned int fV0ChanMax; // unused
73  //unsigned int fV1ChanMin; // unused
74  //unsigned int fV1ChanMax; // unused
75 
76  //unsigned int fNofAPA; // unused
77  //unsigned int fChansPerAPA; // unused
78  //unsigned int fUWireMax; // unused
79  //unsigned int fVWireMax; // unused
80  //unsigned int fZ0WireMax; // unused
81  //unsigned int fZ1WireMax; // unused
82 
83 
84 
85  // art handles
88 
89  std::vector<TH2I*> fTimeChanU; //data in view 0
90  std::vector<TH2I*> fTimeChanV; //data in view 1
91 
92  std::vector<TH2I*> fTimeChanThumbU;
93  std::vector<TH2I*> fTimeChanThumbV;
94 
95  std::vector<TH1I*> fADCMaxDistU; //max adc per channel per view
96  std::vector<TH1I*> fADCMaxDistV; //max adc per channel per view
97 
98  }; // class RawEVDDP
99 
100  //-----------------------------------------------------------------------
101 
102  // read in the parameters from the .fcl file
104  : EDAnalyzer(parameterSet)
105  {
106  this->reconfigure(parameterSet);
107  }
108 
109 
110  //-----------------------------------------------------------------------
111 
113  fDetProp = lar::providerFrom<detinfo::DetectorPropertiesService>();
114  fRawDigitLabel = p.get< std::string >("RawDigitLabel");
116  return;
117  }
118 
119 
120  //-----------------------------------------------------------------------
121 
123  }
124 
125  //-----------------------------------------------------------------------
126 
128  // Access ART's TFileService, which will handle creating and writing
129  // histograms and n-tuples for us.
131 
132  //Histogram names and titles
133  std::stringstream name, title;
134 
135  TH2I* TempHisto2;
136  TH1I* TempHisto1;
137 
138  //ofstream outfile;
139  //outfile.open("msglog.txt");
140 
141 
143  mf::LogInfo("RawEVDP")<< "Number of channels per view is "<<fChPerView;
144 
145  if(fGeom->Nviews() != 2 )
146  throw cet::exception("RawEVDDP") << "For DUNE DP expected to have only 2 views ";
147 
148 
149  //
150  unsigned int minT = 0;
151  unsigned int maxT = fNticks;
152  unsigned int binT = (maxT-minT);
153 
154  float minADC = 0.0;
155  float maxADC = 4096;
156  int nBins = (int)((maxADC - minADC)/2.0);
157 
158  for(unsigned int i=0;i<fGeom->NTPC();i++)
159  {
160 
161  name.str("");
162  name << "fTimeChanU";
163  name << i;
164  title.str("");
165  title << "Time vs Channel(Plane U, CRM";
166  title << i<<")";
167  TempHisto2 = tfs->make<TH2I>(name.str().c_str(),title.str().c_str(), fChPerView, 0, fChPerView, binT, minT, maxT);
168  fTimeChanU.push_back(TempHisto2);
169 
170  name.str("");
171  name << "fTimeChanThumbU";
172  name << i;
173  title.str("");
174  title << "Time vs Channel(Plane U, CRM";
175  title << i<<")";
176  TempHisto2 = tfs->make<TH2I>(name.str().c_str(),title.str().c_str(), 32, 0, fChPerView, 32, minT, maxT);
177  fTimeChanThumbU.push_back(TempHisto2);
178 
179  name.str("");
180  name << "fADCMaxU";
181  name << i;
182  title.str("");
183  title << "Max ADC per channel (Plane U, CRM";
184  title << i<<")";
185  TempHisto1 = tfs->make<TH1I>(name.str().c_str(),title.str().c_str(), nBins, minADC, maxADC);
186  fADCMaxDistU.push_back(TempHisto1);
187 
188  //
189  name.str("");
190  name << "fTimeChanV";
191  name << i;
192  title.str("");
193  title << "Time vs Channel(Plane V, CRM";
194  title << i<<")";
195  TempHisto2 = tfs->make<TH2I>(name.str().c_str(),title.str().c_str(), fChPerView, 0, fChPerView, binT, minT, maxT);
196  fTimeChanV.push_back(TempHisto2);
197 
198  name.str("");
199  name << "fTimeChanThumbV";
200  name << i;
201  title.str("");
202  title << "Time vs Channel(Plane V, CRM";
203  title << i<<")";
204  TempHisto2 = tfs->make<TH2I>(name.str().c_str(),title.str().c_str(), 32, 0, fChPerView, 32, minT, maxT);
205  fTimeChanThumbV.push_back(TempHisto2);
206 
207  name.str("");
208  name << "fADCMaxV";
209  name << i;
210  title.str("");
211  title << "Max ADC per channel (Plane V, CRM";
212  title << i<<")";
213  TempHisto1 = tfs->make<TH1I>(name.str().c_str(),title.str().c_str(), nBins, minADC, maxADC);
214  fADCMaxDistV.push_back(TempHisto1);
215  }
216 
217  }
218  //-----------------------------------------------------------------------
219 
220  void RawEVDDP::beginRun(const art::Run& /*run*/){
221 
222  }
223 
224 
225  //-----------------------------------------------------------------------
226 
228  {
229 
230  unsigned int tpcid;//, cryoid;
231  //std::stringstream thumbnameZ0, thumbnameZ1;
232 
233  // get the objects holding all of the raw data information
235  event.getByLabel(fRawDigitLabel, Raw);
236 
237  // put it in a more easily usable form
238  std::vector< art::Ptr<raw::RawDigit> > Digits;
239  art::fill_ptr_vector(Digits, Raw);
240 
241  //loop through all RawDigits (over entire channels)
242 
243  for(size_t d = 0; d < Digits.size(); d++)
244  {
246  digit=Digits.at(d);
247 
248  // get the channel number for this digit
249  uint32_t chan = digit->Channel();
250  tpcid = fGeom->ChannelToWire(chan)[0].TPC;
251  //cryoid = fGeom->ChannelToWire(chan)[0].Cryostat;
252 
253  // ok this loop does not really work for more than 1 cryostat
254 
255  std::vector<short> uncompressed(digit->Samples());
256  raw::Uncompress(digit->ADCs(), uncompressed, digit->Compression());
257 
258  short maxadc = 0;
259  if( fGeom->View(chan) == geo::kU )
260  {
261  for(unsigned int l=0;l<uncompressed.size();l++)
262  {
263  short adcval = uncompressed.at(l);
264  if(uncompressed.at(l) > maxadc)
265  maxadc = adcval;
266 
267  fTimeChanU[tpcid]->Fill(chan - 2*tpcid*fChPerView, l, adcval);
268  if(adcval>0)
269  fTimeChanThumbU[tpcid]->Fill(chan - 2*tpcid*fChPerView,l, adcval);
270  }
271  if(maxadc>0) fADCMaxDistU[tpcid]->Fill(maxadc);
272  }
273  else if( fGeom->View(chan) == geo::kV )
274  {
275  for(unsigned int l=0;l<uncompressed.size();l++)
276  {
277  short adcval = uncompressed.at(l);
278  if(uncompressed.at(l) > maxadc)
279  maxadc = adcval;
280 
281  fTimeChanV[tpcid]->Fill(chan - 2*tpcid*fChPerView-fChPerView, l, adcval);
282  if(adcval>0)
283  fTimeChanThumbV[tpcid]->Fill(chan - 2*tpcid*fChPerView-fChPerView,l, adcval);
284  }
285  if(maxadc > 0) fADCMaxDistV[tpcid]->Fill(maxadc);
286  }
287 
288  } // end RawDigit loop
289 
290  return;
291  }
292 
294 
295 } // namespace AnalysisExample
296 
297 #endif // RawEVDDP_Module
static QCString name
Definition: declinfo.cpp:673
Store parameters for running LArG4.
detinfo::DetectorProperties const * fDetProp
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
Definition: RawDigit.h:210
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
Definition: RawDigit.h:213
void beginRun(const art::Run &run)
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Planes which measure V.
Definition: geo_types.h:126
Declaration of signal hit object.
ChannelID_t Channel() const
DAQ channel this raw data was read from.
Definition: RawDigit.h:212
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
Definition of basic raw digits.
std::vector< TH2I * > fTimeChanU
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
Particle class.
static QStrList * l
Definition: config.cpp:1044
Definition: Run.h:21
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
std::vector< TH2I * > fTimeChanV
Planes which measure U.
Definition: geo_types.h:125
std::vector< TH2I * > fTimeChanThumbU
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:69
unsigned int uint32_t
Definition: stdint.h:126
Collect all the RawData header files together.
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::vector< TH1I * > fADCMaxDistU
virtual unsigned int NumberTimeSamples() const =0
Declaration of cluster object.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Definition of data types for geometry description.
RawEVDDP(fhicl::ParameterSet const &pset)
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
void reconfigure(fhicl::ParameterSet const &pset)
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
Definition: RawDigit.h:216
p
Definition: test.py:223
art::ServiceHandle< geo::Geometry > fGeom
object containing MC truth information necessary for making RawDigits and doing back tracking ...
unsigned int Nviews() const
Returns the number of views (different wire orientations)
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:291
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:755
void analyze(const art::Event &evt)
std::vector< TH2I * > fTimeChanThumbV
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Event finding and building.
unsigned int run
std::vector< TH1I * > fADCMaxDistV