RecordNoiseSpectrumFile_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief TODO
3 /// \author Christopher Backhouse - bckhouse@caltech.edu
4 ////////////////////////////////////////////////////////////////////////
5 
6 // Framework includes
14 #include "fhiclcpp/ParameterSet.h"
15 
16 // NOvA includes
18 #include "Geometry/Geometry.h"
19 #include "RecoBase/CellHit.h"
20 #include "RecoBase/Cluster.h"
22 
23 #include "TH3.h"
24 
25 namespace rsim
26 {
28  {
29  public:
30  explicit RecordNoiseSpectrumFile(const fhicl::ParameterSet& pset);
31  virtual ~RecordNoiseSpectrumFile();
32 
33  virtual void beginJob();
34  virtual void analyze(const art::Event& evt);
35  virtual void endSubRun(const art::SubRun& sr);
36  virtual void endJob();
37 
38  protected:
39  int fSubrunCount; ///< We can only handle input of precisely one subrun
40  TH3* fNoiseMap;
41  };
42 
43  //----------------------------------------------------------------------
45  EDAnalyzer(pset),
46  fSubrunCount(0)
47  {
48  }
49 
50  //----------------------------------------------------------------------
52  {
53  }
54 
55  //----------------------------------------------------------------------
57  {
59 
60  fNoiseMap = tfs->make<TH3D>("h3_adc0adc1adc2", ";ADC0;ADC1;ADC2",
61  150, 0, 150,
62  150, 0, 150,
63  150, 0, 150);
64  }
65 
66  //----------------------------------------------------------------------
68  {
70  evt.getByLabel("slicer", slices);
71 
72  const unsigned int slcMax = slices->size();
73  for(unsigned int slcIdx = 0; slcIdx < slcMax; ++slcIdx){
74  art::Ptr<rb::Cluster> slice(slices, slcIdx);
75 
76  if(!slice->IsNoise()) continue;
77 
78  const unsigned int cellMax = slice->NCell();
79  for(unsigned int cellIdx = 0; cellIdx < cellMax; ++cellIdx){
80  art::Ptr<rb::CellHit> chit = slice->Cell(cellIdx);
81 
82  fNoiseMap->Fill(chit->ADC(0)+0.5, 0.0, 0.0);
83  } // end for cellIdx
84  } // end for slcIdx
85  }
86 
87  //----------------------------------------------------------------------
89  {
90  ++fSubrunCount;
91 
93  sr.getByLabel("expo", ce);
94 
95  mf::LogInfo("RecordNoiseSpectrumFile") << "Total live time is " << 1e9*ce->totlivetime << " ns";
96 
99 
100  unsigned int nLiveChans = 0;
101 
102  const std::set<unsigned int>& planes = geom->GetPlanesByView(geo::kXorY);
103  for(std::set<unsigned int>::const_iterator it = planes.begin();
104  it != planes.end(); ++it){
105  const unsigned int plane = *it;
106  const unsigned int maxCell = geom->Plane(plane)->Ncells();
107  for(unsigned int cell = 0; cell < maxCell; ++cell){
108  if(!badChans->IsBad(plane, cell)) ++nLiveChans;
109  } // end for cell
110  } // end for it
111  mf::LogInfo("RecordNoiseSpectrumFile") << "There are " << nLiveChans << " live channels";
112 
113  // Normalization of noise map is probability /cell /ns
114  fNoiseMap->Scale(1.0/(nLiveChans*1e9*ce->totlivetime));
115  }
116 
117  //----------------------------------------------------------------------
119  {
120  assert(fSubrunCount == 1 && "Must run over precisely one subrun. "
121  "We're not smart enough to do the normalization in other cases");
122  }
123 
125 
126 }//namespace
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
set< int >::iterator it
X or Y views.
Definition: PlaneGeo.h:30
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
unsigned int Ncells() const
Number of cells in this plane.
Definition: PlaneGeo.h:43
RecordNoiseSpectrumFile(const fhicl::ParameterSet &pset)
const PlaneGeo * Plane(unsigned int i) const
DEFINE_ART_MODULE(TestTMapFile)
Common configuration params for SimpleReadout, FPGAAlgorithms, NoiseMaker.
virtual void analyze(const art::Event &evt)
int evt
virtual void endSubRun(const art::SubRun &sr)
caf::StandardRecord * sr
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
int fSubrunCount
We can only handle input of precisely one subrun.
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
const int cellMax
const std::set< unsigned int > & GetPlanesByView(View_t v=kXorY) const
void geom(int which=0)
Definition: geom.C:163
assert(nhit_max >=nhit_nbins)
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163
bool IsBad(int plane, int cell)
Encapsulate the geometry of one entire detector (near, far, ndos)