ClusterConvert_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ClusterConvert
3 // Module Type: filter
4 // File: ClusterConvert_module.cc
5 //
6 // Takes an offline rb::Cluster and turns it into a ddt HitList
7 //
8 // Generated at Wed Sep 24 06:29:23 2014 by Alec Habig using artmod
9 // from cetpkgsupport v1_07_00.
10 ////////////////////////////////////////////////////////////////////////
11 
16 // #include "art/Framework/Principal/Run.h"
17 // #include "art/Framework/Principal/SubRun.h"
18 // #include "art/Utilities/InputTag.h"
19 #include "fhiclcpp/ParameterSet.h"
21 
22 #include "RecoBase/CellHit.h"
23 #include "RecoBase/Cluster.h"
25 #include "NovaDAQConventions/DAQConventions.h"
28 
29 #include <memory>
30 
31 namespace novaddt {
32  class ClusterConvert;
33 }
34 
36 public:
37  explicit ClusterConvert(fhicl::ParameterSet const & p);
38  // The destructor generated by the compiler is fine for classes
39  // without bare pointers or other resource use.
40 
41  // Plugins should not be copied or assigned.
42  ClusterConvert(ClusterConvert const &) = delete;
43  ClusterConvert(ClusterConvert &&) = delete;
44  ClusterConvert & operator = (ClusterConvert const &) = delete;
46 
47  // Required functions.
48  bool filter(art::Event & e) override;
49 
50 
51 private:
52 
53  // Declare member data here.
56  int fDetector;
57  bool fVerbose;
58 };
59 
60 
62  fInputLabel (p.get< std::string >("InputLabel" )),
63  fInputInstance (p.get< std::string >("InputInstance")),
64  fDetector (p.get< int >("Detector")),
65  fVerbose (p.get< bool >("Verbose"))
66 {
67  std::cout << "--- novaddt::ClusterConvert begin" << std::endl;
68  std::cout << "\t Input hitlists label: " << fInputLabel << std::endl;
69  std::cout << "\t Input hitlists instance " << fInputInstance << std::endl;
70  std::cout << "\t Detector ID " << fDetector << std::endl;
71  std::cout << "\t Verbose " << fVerbose << std::endl;
72 
73  // Call appropriate produces<>() functions here.
74  produces<std::vector<HitList>>("ConvertedClusters");
75 }
76 
78 {
80  event.getByLabel(fInputLabel, fInputInstance, clusters);
81 
82  //make a grouped hitlist out of hits after slicing
83  std::unique_ptr< std::vector<HitList> >product(new std::vector<HitList>);
84 
85  // Loop over clusters
86  if (fVerbose) std::cout << "ClusterConvert " << clusters->size()<<" clusters" << std::endl;
87  for(unsigned int i = 0; i < clusters->size(); ++i) {
88  // Treat each cluster as a slice.
89  // Make a slice
90  novaddt::HitList slice;
91  // loop over hits, copy into slice
92  if (fVerbose) std::cout << "ClusterConvert " << clusters->at(i).NCell()<<" cells" << std::endl;
93  for(unsigned int j = 0; j < clusters->at(i).NCell(); ++j) {
94  // manually transfer elements
95  art::Ptr<rb::CellHit> hit(clusters->at(i).Cell(j));
96  novaddt::DAQHit Dhit(fDetector,hit->DaqChannel(),hit->ADC(),hit->TDC());
97  slice.push_back(Dhit);
98  }
99  // sort the slice by TDC
100  if (slice.size() > 0)
101  std::sort(slice.begin(), slice.end(), CompareDAQHit<TDC>());
102 
103  if (fVerbose) for (auto const& Dhit : slice) {
104  std::cout << "Channel:" << Dhit.Chan() ;
105  std::cout << " ADC:"<< Dhit.ADC().val << " TDC:" << Dhit.TDC().val << " Plane:" << Dhit.Plane().val << " Cell:" << Dhit.Cell().val << std::endl;
106  }
107  // store slice in product
108  product->emplace_back(slice);
109  }
110 
111  event.put(std::move(product),"ConvertedClusters");
112 
113  return true;
114 }
115 
std::vector< DAQHit > HitList
Definition: HitList.h:15
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
ClusterConvert(fhicl::ParameterSet const &p)
const double j
Definition: BetheBloch.cxx:29
bool filter(art::Event &e) override
OStream cout
Definition: OStream.cxx:6
T product(std::vector< T > dims)
Definition: structs.h:12
ClusterConvert & operator=(ClusterConvert const &)=delete
Float_t e
Definition: plot.C:35
enum BeamMode string