All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRTTrueHitProducer_module.cc
Go to the documentation of this file.
1 // icaruscode includes
4 
5 // Framework includes
6 #include "art/Framework/Core/ModuleMacros.h"
7 #include "art/Framework/Core/EDProducer.h"
8 #include "art/Framework/Principal/Handle.h"
9 #include "art/Framework/Principal/Event.h"
10 #include "canvas/Persistency/Common/Ptr.h"
11 #include "canvas/Persistency/Common/PtrVector.h"
12 #include "art/Framework/Services/Registry/ServiceHandle.h"
13 #include "art/Persistency/Common/PtrMaker.h"
14 #include "canvas/Utilities/InputTag.h"
15 #include "fhiclcpp/ParameterSet.h"
16 #include "messagefacility/MessageLogger/MessageLogger.h"
17 
18 // C++ includes
19 #include <memory>
20 #include <iostream>
21 #include <map>
22 #include <iterator>
23 #include <algorithm>
24 #include <vector>
25 #include <utility>
26 
27 // LArSoft
35 
36 using std::vector;
37 using sim::AuxDetIDE;
38 
39 namespace icarus {
40  namespace crt {
41  class CRTTrueHitProducer;
42  }
43 }
44 
45 class icarus::crt::CRTTrueHitProducer : public art::EDProducer {
46 public:
47 
49 
50  explicit CRTTrueHitProducer(fhicl::ParameterSet const & p);
51 
52  // The destructor generated by the compiler is fine for classes
53  // without bare pointers or other resource use.
54 
55  // Plugins should not be copied or assigned.
56  CRTTrueHitProducer(CRTTrueHitProducer const &) = delete;
60 
61  // Required functions.
62  void produce(art::Event & e) override;
63 
64  // Selected optional functions.
65  void reconfigure(fhicl::ParameterSet const & p);
66 
67 private:
68 
69  // Params from fcl file.......
70  art::InputTag fCrtModuleLabel; ///< name of crt producer
71 
73 
74 }; // class CRTTrueHitProducer
75 
76 //constructor
78  : EDProducer{p}, hitAlg(p.get<fhicl::ParameterSet>("HitAlg"))
79  // Initialize member data here, if know don't want to reconfigure on the fly
80 {
81  this->reconfigure(p);
82 
83  // Call appropriate produces<>() functions here.
84  produces< vector<CRTHit> >();
85  produces< vector<AuxDetIDE> >();
86  produces< art::Assns<CRTHit , AuxDetIDE> >();
87 
88 } // CRTTrueHitProducer()
89 
90 void icarus::crt::CRTTrueHitProducer::reconfigure(fhicl::ParameterSet const & p)
91 {
92  fCrtModuleLabel = (p.get<art::InputTag> ("CrtModuleLabel"));
93 } // CRTTrueHitProducer::reconfigure()
94 
96 {
97  std::unique_ptr< vector<CRTHit> > CRTHitcol( new vector<CRTHit>);
98  std::unique_ptr< vector<AuxDetIDE> > IDEcol( new vector<AuxDetIDE>);
99  std::unique_ptr< art::Assns<CRTHit, AuxDetIDE> > Hitassn( new art::Assns<CRTHit,AuxDetIDE>);
100  art::PtrMaker<CRTHit> makeHitPtr(event);
101  art::PtrMaker<AuxDetIDE> makeAdPtr(event);
102 
103  int nHits = 0;
104 
105  // Retrieve list of CRT hits
106  art::Handle< vector<sim::AuxDetSimChannel>> adscListHandle;
107  vector<art::Ptr<sim::AuxDetSimChannel> > adscList;
108 
109  if (event.getByLabel(fCrtModuleLabel, adscListHandle))
110  art::fill_ptr_vector(adscList, adscListHandle);
111 
112  mf::LogInfo("CRTTrueHitProducer")
113  <<"Number of AuxDetSimChannels = "<<adscList.size();
114 
115  vector<std::pair<CRTHit, vector<AuxDetIDE>>> crtHitPairs = hitAlg.CreateCRTHits(adscList);
116 
117  for(auto const& crtHitPair : crtHitPairs){
118 
119  CRTHitcol->push_back(crtHitPair.first);
120  art::Ptr<CRTHit> hitPtr = makeHitPtr(CRTHitcol->size()-1);
121  nHits++;
122 
123  for(auto const& ide : crtHitPair.second){
124 
125  IDEcol->push_back(ide);
126  art::Ptr<AuxDetIDE> idePtr = makeAdPtr(IDEcol->size()-1);
127  Hitassn->addSingle(hitPtr, idePtr);
128  }
129  }
130 
131  event.put(std::move(CRTHitcol));
132  event.put(std::move(IDEcol));
133  event.put(std::move(Hitassn));
134 
135  mf::LogInfo("CRTTrueHitProducer")
136  <<"Number of CRT hits produced = "<<nHits;
137 
138 } // CRTTrueHitProducer::produce()
139 
140 DEFINE_ART_MODULE(icarus::crt::CRTTrueHitProducer)
art::InputTag fCrtModuleLabel
name of crt producer
CRTTrueHitProducer(fhicl::ParameterSet const &p)
pdgs p
Definition: selectors.fcl:22
for pfile in ack l reconfigure(.*) override"` do echo "checking $
CRTTrueHitProducer & operator=(CRTTrueHitProducer const &)=delete
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
Access the description of detector geometry.
object containing MC truth information necessary for making RawDigits and doing back tracking ...
art framework interface to geometry description for auxiliary detectors
Definition of data types for geometry description.
void reconfigure(fhicl::ParameterSet const &p)
Encapsulate the construction of a single detector plane.
MC truth information to make RawDigits and do back tracking.
do i e
void produce(art::Event &e) override
process_name crt
art framework interface to geometry description