ChanOcc_module.cc
Go to the documentation of this file.
1 ///
2 /// \file ChanOcc.cxx
3 /// \brief Make ntuples of channel occupancies
4 /// \version $Id: ChanOcc.cxx,v 1.7 2012-09-25 16:06:22 gsdavies Exp $
5 /// \author messier@indiana.edu
6 ///
12 
15 #include "Geometry/Geometry.h"
17 #include "RawData/RawDigit.h"
18 
19 #include "TNtuple.h"
20 
21 class TNtuple;
22 
23 namespace comi {
24  /// Module to produce ntuples of channel occupancies
25  class ChanOcc : public art::EDAnalyzer {
26  public:
27  explicit ChanOcc(fhicl::ParameterSet const& pset);
28  virtual ~ChanOcc();
29 
30  void beginJob();
31  void endSubRun(art::SubRun const& sr);
32 
33  void analyze(art::Event const& evt);
34  void reconfigure(const fhicl::ParameterSet& p);
35 
36  private:
37  static const int kPLANE_MAX = 2048;
38  static const int kCELL_MAX = 512;
39  double fNhit[kPLANE_MAX][kCELL_MAX]; ///< Number of hits by plane/cell
40  double fNevt; ///< Number of events seen
41 
42  TNtuple* fNt; ///< Ntuple summarizing channel occupancies
43  private:
44  float fADCThresh; ///< Filter hits below this ADC threshold
45  };
46 
47  //......................................................................
48 
50  : EDAnalyzer(p)
51  {
52  memset(fNhit, 0, kPLANE_MAX*kCELL_MAX*sizeof(float));
53  this->reconfigure(p);
54  }
55 
56  //......................................................................
57 
59  {
61  fNt = f->make<TNtuple>("occ",
62  "Channel Occupancies",
63  "run:subrun:view:ip:ic:occ");
64  }
65 
66  //......................................................................
67 
69 
70  //......................................................................
71 
73  {
74  unsigned int i;
75 
76  fNevt += 1.0;
77 
78  //
79  // Pull out the raw digits from the event
80  //
82  evt.getByLabel("daq",digidummy);
83 
84  //
85  // Shuffle the data into a vector we can manipulate
86  //
87  std::vector< art::Ptr<rawdata::RawDigit> > digi;
88  for (i=0; i<digidummy->size(); ++i) {
89  digi.push_back(art::Ptr<rawdata::RawDigit>(digidummy, i));
90  }
91 
92  //
93  // Record the number of hits
94  //
96  for (i=0; i<digi.size(); ++i) {
97  if (digi[i].get()->ADC()<fADCThresh) continue;
98 
99  int p = cmap->GetPlane(digi[i].get());
100  int c = cmap->GetCell(digi[i].get());
101 
102  if (p>=0 && p<kPLANE_MAX && c>=0 && c<kCELL_MAX) {
103  fNhit[p][c] += 1.0;
104  }
105  else abort();
106  }
107  }
108 
109  //......................................................................
110 
112  {
113  if (fNevt<=10000) return;
114 
115  int run = sr.run();
116  int subrun = sr.subRun();
117 
119  unsigned int i, j;
120  for (i=0; i<geom->NPlanes(); ++i) {
121  int view = geom->Plane(i)->View();
122  for (j=0; j<geom->Plane(i)->Ncells(); ++j) {
123  fNt->Fill(run, subrun, view, i, j, fNhit[i][j]/fNevt);
124  }
125  }
126  memset(fNhit, 0, kPLANE_MAX*kCELL_MAX*sizeof(float));
127  fNevt = 0;
128  }
129 
130  //......................................................................
131 
133  {
134  fADCThresh = p.get<float>("ADCThresh");
135  }
136 
137 } // end namespace comi
138 ////////////////////////////////////////////////////////////////////////
140 ////////////////////////////////////////////////////////////////////////
void reconfigure(const fhicl::ParameterSet &p)
SubRunNumber_t subRun() const
Definition: SubRun.h:44
float fADCThresh
Filter hits below this ADC threshold.
const char * p
Definition: xmltok.h:285
virtual ~ChanOcc()
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
const PlaneGeo * Plane(unsigned int i) const
DEFINE_ART_MODULE(TestTMapFile)
static const int kCELL_MAX
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:53
void endSubRun(art::SubRun const &sr)
Commissioning files to look at the quality of our data.
Definition: Cana_module.cc:39
T get(std::string const &key) const
Definition: ParameterSet.h:231
double fNhit[kPLANE_MAX][kCELL_MAX]
Number of hits by plane/cell.
int evt
unsigned short GetPlane(const rawdata::RawDigit *dig)
Definition: CMap.cxx:285
caf::StandardRecord * sr
const double j
Definition: BetheBloch.cxx:29
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
Module to produce ntuples of channel occupancies.
Definition: run.py:1
T * make(ARGS...args) const
ChanOcc(fhicl::ParameterSet const &pset)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void geom(int which=0)
Definition: geom.C:163
static const int kPLANE_MAX
double fNevt
Number of events seen.
unsigned short GetCell(const rawdata::RawDigit *dig)
Definition: CMap.cxx:327
unsigned int NPlanes() const
void analyze(art::Event const &evt)
Definition: fwd.h:28
Encapsulate the geometry of one entire detector (near, far, ndos)
RunNumber_t run() const
Definition: SubRun.h:49
TNtuple * fNt
Ntuple summarizing channel occupancies.