ResizeDetector_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ResizeDetector
3 // Module Type: producer
4 // File: ResizeDetector_module.cc
5 //
6 // Generated at Mon Jan 6 16:42:53 2014 by Brian_Rebel using artmod
7 // from cetpkgsupport v1_04_02.
8 // Module to create a RawDigit list for only those diblocks that are instrumented
9 ////////////////////////////////////////////////////////////////////////
10 
19 #include "fhiclcpp/ParameterSet.h"
20 
21 #include <memory>
22 #include <string>
23 
24 #include "DAQChannelMap/DAQChannelMap.h"
25 #include "RawData/RawDigit.h"
26 #include "Geometry/Geometry.h"
27 
28 #include "TH1.h"
29 
30 namespace calib {
31  class ResizeDetector;
32 }
33 
35 public:
36  explicit ResizeDetector(fhicl::ParameterSet const & p);
37  virtual ~ResizeDetector();
38 
39  void produce(art::Event & e) override;
40 
41  void beginJob() override;
42 
43  void reconfigure(fhicl::ParameterSet const & p);
44 
45 private:
46 
47  std::string fRawDigitLabel; ///< module producing raw digits
48  uint32_t fMaxDiBlock; ///< maximum diblock from which to use digits
49 
50  TH1F* fDiBlocks; ///< diblocks of the digits put into the vector
51  TH1F* fPlanes; ///< planes of the digits put into the vector
52 
53 };
54 
55 //------------------------------------------------------------------
57 {
58  this->reconfigure(p);
59 
60  produces< std::vector<rawdata::RawDigit> >();
61 }
62 
63 //------------------------------------------------------------------
65 {
66  // Clean up dynamic memory and other resources here.
67 }
68 
69 //------------------------------------------------------------------
71 {
73 
74  fDiBlocks = tfs->make<TH1F>("diblocks", ";DiBlock;Digits", 14, 1., 15.);
75  fPlanes = tfs->make<TH1F>("planes", ";Plane;Digits", 1000, 0, 1000);
76 
77  return;
78 }
79 
80 //------------------------------------------------------------------
82 {
83 
84  std::unique_ptr< std::vector<rawdata::RawDigit> > resizedDetDigits(new std::vector<rawdata::RawDigit>);
85 
87  e.getByLabel(fRawDigitLabel, inputDigits);
88 
89  // Create geometry service handle to pass detector type to getInstance
90  // to grab correct daqchannelmap class instance.
92 
94 
95  uint32_t diBlock(UINT_MAX);
96  uint32_t plane(UINT_MAX);
97 
98  for(size_t d = 0; d < inputDigits->size(); ++d){
99  rawdata::RawDigit const& rd = inputDigits->at(d);
100  diBlock = cm->getDiBlock(cm->encodeDChan(rd.Channel()));
101  plane = cm->getPlane(rd.Channel());
102 
103  if(diBlock <= fMaxDiBlock){
104  resizedDetDigits->push_back(inputDigits->at(d));
105  fDiBlocks->Fill(diBlock);
106  fPlanes->Fill(plane);
107  }
108  }
109 
110  e.put(std::move(resizedDetDigits));
111 
112 }
113 
114 //------------------------------------------------------------------
116 {
117  fRawDigitLabel = p.get< std::string >("RawDigitLabel", "daq");
118  fMaxDiBlock = p.get< uint32_t >("MaxDiBlock", 2);
119 }
120 
ResizeDetector(fhicl::ParameterSet const &p)
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
CDPStorage service.
static DAQChannelMap * getInstance(int detID)
T get(std::string const &key) const
Definition: ParameterSet.h:231
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
Float_t d
Definition: plot.C:236
uint32_t fMaxDiBlock
maximum diblock from which to use digits
void produce(art::Event &e) override
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
T * make(ARGS...args) const
TH1F * fDiBlocks
diblocks of the digits put into the vector
TH1F * fPlanes
planes of the digits put into the vector
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void reconfigure(fhicl::ParameterSet const &p)
uint32_t Channel() const
Definition: RawDigit.h:84
plane_t getPlane(lchan logicalchan) const
Decode the plane number from an lchan.
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
Float_t e
Definition: plot.C:35
Helper for AttenCurve.
Definition: Path.h:10
static constexpr Double_t cm
Definition: Munits.h:140
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
Encapsulate the geometry of one entire detector (near, far, ndos)
std::string fRawDigitLabel
module producing raw digits