ActivityTriggerProd_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ActivityTriggerProd
3 // Module Type: producer
4 // File: ActivityTriggerProd_module.cc
5 //
6 // Generated at Tuesday March 29 2016 by Michael Baird using the old
7 // copy and paste method...
8 //
9 // Modified by Karl Warburton May 9th 2017 to reflect the move away
10 // services (for better or worse...)
11 // --- contact information --- karlwarb@iastate.edu
12 //
13 ////////////////////////////////////////////////////////////////////////
14 
15 // C++ includes
16 
17 // ROOT includes
18 #include "TH1F.h"
19 #include "TTree.h"
20 
21 // Framework includes
26 //#include "art/Framework/Principal/Run.h"
27 //#include "art/Framework/Principal/SubRun.h"
30 #include "fhiclcpp/ParameterSet.h"
37 
38 // DUNETPC specific includes
41 
42 // The trigger classes which you're including
44 
45 namespace triggersim { // Declare that we are working in the triggersim namespace
46 
48 
49  public:
50 
51  explicit ActivityTriggerProd(fhicl::ParameterSet const & pset);
52 
53  // Plugins should not be copied or assigned.
54  ActivityTriggerProd(ActivityTriggerProd const &) = delete;
58 
59  // The main guts...
60  void produce(art::Event& event) override;
61 
62  void reconfigure(fhicl::ParameterSet const & pset);
63 
64  // If you want to another function...
65  // void YourFunction();
66 
67  // Declare our classes as data members...
69 
70  private:
71 
72  // --- We want to use backtracker later backtracker.
74 
75  // declare fcl input variables here
79  // Your fcl params to send to the trigger functions...
80  };
81 
82  //......................................................
84  TempTrig()
85  {
86  // --- Declare what this module is puttting in the art event.
87  produces< std::vector<triggersim::BasicTrigger> >();
88  // --- Configure my trigger module.
89  this->reconfigure(pset);
90  // --- Configure my trigger class.
91  TempTrig.Configure( pset );
92  }
93 
94 
95 
96  //......................................................
98  {
99  // --- Pull the variables from the fcl file.
100  fAString = pset.get<std::string> ("AString");
101  fRawDigitLabel = pset.get<std::string> ("RawDigitLabel");
102  fOpDetWaveLabel = pset.get<std::string> ("OpDetWaveLabel");
103 
104  // To convince ourselves that they have been set, print them out...
105  std::cout << "\n------In my Activity Trigger module------\nThe fcl params have been set to :"
106  << "\n fAString: " << fAString
107  << "\n fRawDigitLabel: " << fRawDigitLabel
108  << "\n fOpDetWaveLabel: " << fOpDetWaveLabel
109  << "\n-------------------------------\n"
110  << std::endl;
111  }
112 
113  //......................................................
115  {
116  // --- Make the vector of BasicTrigger objects:
117  std::unique_ptr< std::vector<triggersim::BasicTrigger> > triggers(new std::vector<triggersim::BasicTrigger>);
118 
119  // --- Lift out the TPC raw digits:
120  auto rawdigits = event.getValidHandle<std::vector<raw::RawDigit> >(fRawDigitLabel);
121  if ( rawdigits.failedToGet() )
122  mf::LogError("ActivityTrigger_Producer") << "The raw::RawDigit you gave me " << fRawDigitLabel << " is not in the event..." << std::endl;
123 
124  // --- Lift out the Photon Detector OpDetWaveforms:
125  auto waveforms = event.getValidHandle<std::vector<raw::OpDetWaveform> >(fOpDetWaveLabel);
126  if ( rawdigits.failedToGet() )
127  mf::LogError("ActivityTrigger_Producer") << "The raw::OpDetWaveform you gave me " << fOpDetWaveLabel << " is not in the event..." << std::endl;
128 
129  // --- Lets get the MCTruth information out of the event using the backtracker we defined earlier...
130  const sim::ParticleList& plist = pi_serv->ParticleList();
131  // --- Now loop through the particle list.
132  for ( sim::ParticleList::const_iterator ipar = plist.begin(); ipar!=plist.end(); ++ipar) {
133  // --- Grab this particle.
134  simb::MCParticle *particle = ipar->second;
135  // Let's just write out what our primary particles are...
136  if (particle->Process() != "primary") continue; // Can also check that particle->Mother() != 0.
137  std::cout << "-- Particle with TrackID " << particle->TrackId() << ", which was a " << particle->PdgCode() << " was a primary and had initial energy " << particle->E()
138  << ", " << particle->NumberTrajectoryPoints() << " trajectory points, and " << particle->NumberDaughters() << " daughters. Process - " << particle->Process()
139  << std::endl;
140  }
141 
142  // **************************************************
143  // *********** Trigger on the whole event ***********
144  // **************************************************
145  std::cout << "\nLet's trigger on the whole event...." << std::endl;
146 
147  // --- Now call the class...
148  bool EvTrigDec = TempTrig.TriggerOnWholeEvent( event );
149 
150  // --- Make my basic trigger and push it back
152  triggers->push_back( my_ev_trig );
153 
154  std::cout << "I have now left my trigger, it's decision was " << EvTrigDec << ".\n" << std::endl;
155 
156  // **************************************************
157  // ************* Trigger on the TPC info ************
158  // **************************************************
159  std::cout << "\nLet's trigger on the TPC info...." << std::endl;
160 
161  // --- Now call the class...
162  bool TPCTrigDec = TempTrig.TriggerOnTPC( *rawdigits );
163 
164  // --- Make my basic trigger and push it back
166  triggers->push_back( my_tpc_trig );
167 
168  std::cout << "I have now left my trigger, it's decision was " << TPCTrigDec << ".\n" << std::endl;
169 
170  // **************************************************
171  // ******** Trigger on the OpDetWaveform info *******
172  // **************************************************
173  std::cout << "\nLet's trigger on the OpDetWaveform info...." << std::endl;
174 
175  // --- Now call the class...
176  bool PDTrigDec = TempTrig.TriggerOnPD( *waveforms );
177 
178  // --- Make my basic trigger and push it back
180  triggers->push_back( my_pd_trig );
181 
182  std::cout << "I have now left my trigger, it's decision was " << PDTrigDec << ".\n" << std::endl;
183 
184 
185  // **************************************************
186  // *** Trigger on the OpDetWaveform and TPC info ****
187  // **************************************************
188  std::cout << "\nLet's trigger on the TPC and OpDetWaveform info...." << std::endl;
189 
190  // --- Now call the class...
191  bool TPC_PD_TrigDec = TempTrig.TriggerOnTPC_PD( *rawdigits, *waveforms );
192 
193  // --- Make my basic trigger and push it back
194  triggersim::BasicTrigger my_tpc_pd_trig( TPC_PD_TrigDec , triggersim::kNu, triggersim::kNuBeam);
195  triggers->push_back( my_tpc_pd_trig );
196 
197  std::cout << "I have now left my trigger, it's decision was " << TPC_PD_TrigDec << ".\n" << std::endl;
198 
199 
200  // **************************************************
201  // **** Trigger some of the triggers we've made *****
202  // **************************************************
203  std::cout << "\nLet's trigger on the triggers I've just made...." << std::endl;
204 
205  // --- Now call the class...
206  bool Trig_TrigDec = TempTrig.TriggerOnTriggers( *triggers );
207 
208  // --- Make my basic trigger and push it back
209  triggersim::BasicTrigger my_trig_trig( Trig_TrigDec , triggersim::kNu, triggersim::kNuBeam);
210  triggers->push_back( my_trig_trig );
211 
212  std::cout << "I have now left my trigger, it's decision was " << Trig_TrigDec << ".\n" << std::endl;
213 
214  // **************************************************
215  // ******* Now put all of that into the event *******
216  // **************************************************
217  event.put(std::move(triggers));
218 
219  } // ActivityTriggerProd::produce()
220  //......................................................
221  // If you want to another function...
222 
223  //......................................................
225 } // namespace triggersim
double E(const int i=0) const
Definition: MCParticle.h:233
unsigned int NumberTrajectoryPoints() const
Definition: MCParticle.h:218
int PdgCode() const
Definition: MCParticle.h:212
bool TriggerOnTPC(std::vector< raw::RawDigit > rawTPC)
ActivityTriggerProd & operator=(ActivityTriggerProd const &)=delete
std::string string
Definition: nybbler.cc:12
void Configure(fhicl::ParameterSet const &pset)
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
intermediate_table::const_iterator const_iterator
const unsigned int kNu
Definition: TriggerTypes.h:17
std::string Process() const
Definition: MCParticle.h:215
Particle class.
int NumberDaughters() const
Definition: MCParticle.h:217
int TrackId() const
Definition: MCParticle.h:210
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
void produce(art::Event &event) override
def move(depos, offset)
Definition: depos.py:107
T get(std::string const &key) const
Definition: ParameterSet.h:271
bool TriggerOnPD(std::vector< raw::OpDetWaveform > rawPD)
bool TriggerOnTPC_PD(std::vector< raw::RawDigit > rawTPC, std::vector< raw::OpDetWaveform > rawPD)
const sim::ParticleList & ParticleList() const
void reconfigure(fhicl::ParameterSet const &pset)
bool TriggerOnWholeEvent(art::Event &event)
bool TriggerOnTriggers(std::vector< triggersim::BasicTrigger > triggerVec)
ActivityTriggerProd(fhicl::ParameterSet const &pset)
QTextStream & endl(QTextStream &s)
Event finding and building.
const unsigned int kNuBeam
Definition: TriggerTypes.h:45
art::ServiceHandle< cheat::ParticleInventoryService > pi_serv