DataProductSkimmer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: DataProductSkimmer
3 // Module Type: producer
4 // File: DataProductSkimmer_module.cc
5 //
6 // Generated at Mon Aug 3 10:52:56 2015 by Brian Rebel using artmod
7 // from cetpkgsupport v1_08_06.
8 ////////////////////////////////////////////////////////////////////////
9 
22 #include "fhiclcpp/ParameterSet.h"
24 
25 #include <memory>
26 #include <map>
27 
31 #include "CosRej/NueCosRej.h"
32 #include "CosRej/CosRejObj.h"
33 #include "CVN/func/Result.h"
34 #include "LEM/PIDDetails.h"
35 #include "MCReweight/FluxWeights.h"
36 #include "MEFinder/MEClusters.h"
37 #include "NueSandbox/NueSandObj.h"
39 #include "NumuEnergy/NumuE.h"
40 #include "Preselection/Veto.h"
41 #include "Preselection/PreselObj.h"
42 #include "QEEventFinder/QePId.h"
43 #include "RecoBase/Cluster.h"
44 #include "RecoBase/Prong.h"
45 #include "RecoBase/Track.h"
46 #include "RecoBase/Shower.h"
47 #include "RecoBase/Vertex.h"
48 #include "ReMId/ReMId.h"
49 #include "ShowerLID/ShowerLID.h"
50 #include "ShowerLID/EventLID.h"
51 #include "SummaryData/SubRunData.h"
52 #include "Utilities/AssociationUtil.h"
53 
57 
58 namespace skim {
59  class DataProductSkimmer;
60 }
61 
62 // this module is a producer because it is assumed to be after a path that
63 // contains the CellHitSkimmer, which has already removed events without
64 // interesting slices
66 public:
67 
68  explicit DataProductSkimmer(fhicl::ParameterSet const & p);
69  // The destructor generated by the compiler is fine for classes
70  // without bare pointers or other resource use.
71 
72  // Plugins should not be copied or assigned.
73  DataProductSkimmer(DataProductSkimmer const &) = delete;
77 
78  // Required functions.
79  void produce(art::Event & e) override;
80 
81  // Selected optional functions.
82  void reconfigure(fhicl::ParameterSet const & p);
83 
84  // void beginRun(art::Run & r) override;
85  // void beginJob() override;
86  // void beginSubRun(art::SubRun & sr) override;
87  // void endJob() override;
88  // void endRun(art::Run & r) override;
89  // void endSubRun(art::SubRun & sr) override;
90  // void respondToCloseInputFile(art::FileBlock const & fb) override;
91  // void respondToCloseOutputFiles(art::FileBlock const & fb) override;
92  void respondToOpenInputFile(art::FileBlock const &fb) override;
93  // void respondToOpenOutputFiles(art::FileBlock const & fb) override;
94 
95 private:
96 
97  std::vector<std::shared_ptr<skim::BaseSkimmer> > fSkimmers; ///< does the heavy lifting of skimming
98  int fCycle; ///< cycle number, default is 0
99 
100 };
101 
102 //------------------------------------------------------------------------------
104 : fCycle(0)
105 {
106  this->reconfigure(p);
107 
108  std::string instance;
109 
110  for(auto skimmer : fSkimmers){
111 
112  instance = skimmer->InstanceLabel();
113 
114  if(instance.find("fhc") != std::string::npos ||
115  instance.find("rhc") != std::string::npos){
116 
117  if( instance.find("nue2017") != std::string::npos ||
118  instance.find("nue2018") != std::string::npos){ // need 2017 or 2018 in instance name to avoid checking for lem
119  produces< std::vector<rb::Shower> >(instance);
120  produces< std::vector<rb::Prong> >(instance);
121  produces< std::vector<rb::Cluster> >(instance);
122  produces< std::vector<rb::Vertex> >(instance);
123  produces< std::vector<slid::EventLID> >(instance);
124  produces< std::vector<slid::ShowerLID> >(instance);
125  ///// produces< std::vector<lem::PIDDetails> >(instance);
126  produces< std::vector<cvn::Result> >(instance);
127  produces< std::vector<cosrej::NueCosRej> >(instance);
128  produces< std::vector<presel::Veto> >(instance);
129  produces< std::vector<me::SlcME> >(instance);
130  produces< std::vector<me::TrkME> >(instance);
131  produces< std::vector<rb::PID> >(instance); /// 2017
132  produces< art::Assns<rb::Cluster, rb::Shower> >(instance);
133  produces< art::Assns<rb::Cluster, rb::Prong> >(instance);
134  produces< art::Assns<rb::Cluster, rb::Vertex> >(instance);
135  produces< art::Assns<rb::Cluster, slid::EventLID> >(instance);
136  produces< art::Assns<rb::Cluster, slid::ShowerLID> >(instance);
137  produces< art::Assns<rb::Shower, slid::ShowerLID> >(instance);
138  /// produces< art::Assns<rb::Cluster, lem::PIDDetails> >(instance);
139  produces< art::Assns<rb::Cluster, cosrej::NueCosRej> >(instance);
140  produces< art::Assns<rb::Cluster, simb::MCTruth> >(instance);
141  produces< art::Assns<rb::Cluster, simb::MCFlux> >(instance);
142  produces< art::Assns<rb::Cluster, fxwgt::FluxWeights> >(instance);
143  produces< art::Assns<rb::Cluster, simb::GTruth> >(instance);
144  produces< art::Assns<rb::Cluster, cvn::Result> >(instance);
145  produces< art::Assns<rb::Cluster, presel::Veto> >(instance);
146  produces< art::Assns<rb::Cluster, me::SlcME> >(instance);
147  produces< art::Assns<rb::Cluster, me::TrkME> >(instance);
148  produces< art::Assns<rb::Cluster, rb::PID> >(instance); // 2017
149  produces< art::Assns<rb::Prong, rb::PID> >(instance); // 2017
150  produces< art::Assns<rb::Shower, rb::Prong> >(instance); // 2017
151 
152  } else if( instance.find("nue") != std::string::npos){
153  produces< std::vector<rb::Shower> >(instance);
154  produces< std::vector<rb::Prong> >(instance);
155  produces< std::vector<rb::Cluster> >(instance);
156  produces< std::vector<rb::Vertex> >(instance);
157  produces< std::vector<slid::EventLID> >(instance);
158  produces< std::vector<slid::ShowerLID> >(instance);
159  produces< std::vector<lem::PIDDetails> >(instance);
160  produces< std::vector<cvn::Result> >(instance);
161  produces< std::vector<cosrej::NueCosRej> >(instance);
162  produces< std::vector<presel::Veto> >(instance);
163  produces< std::vector<me::SlcME> >(instance);
164  produces< std::vector<me::TrkME> >(instance);
165  produces< std::vector<rb::PID> >(instance); /// 2017
166  produces< art::Assns<rb::Cluster, rb::Shower> >(instance);
167  produces< art::Assns<rb::Cluster, rb::Prong> >(instance);
168  produces< art::Assns<rb::Cluster, rb::Vertex> >(instance);
169  produces< art::Assns<rb::Cluster, slid::EventLID> >(instance);
170  produces< art::Assns<rb::Cluster, slid::ShowerLID> >(instance);
171  produces< art::Assns<rb::Shower, slid::ShowerLID> >(instance);
172  produces< art::Assns<rb::Cluster, lem::PIDDetails> >(instance);
173  produces< art::Assns<rb::Cluster, cosrej::NueCosRej> >(instance);
174  produces< art::Assns<rb::Cluster, simb::MCTruth> >(instance);
175  produces< art::Assns<rb::Cluster, simb::MCFlux> >(instance);
176  produces< art::Assns<rb::Cluster, fxwgt::FluxWeights> >(instance);
177  produces< art::Assns<rb::Cluster, cvn::Result> >(instance);
178  produces< art::Assns<rb::Cluster, presel::Veto> >(instance);
179  produces< art::Assns<rb::Cluster, me::SlcME> >(instance);
180  produces< art::Assns<rb::Cluster, me::TrkME> >(instance);
181  produces< art::Assns<rb::Cluster, rb::PID> >(instance); // 2017
182  produces< art::Assns<rb::Prong, rb::PID> >(instance); // 2017
183 
184  }
185 
186  if(instance.find("numu") != std::string::npos){
187  produces< std::vector<rb::Cluster> >(instance);
188  produces< std::vector<rb::Energy> >(instance);
189  produces< std::vector<rb::Track> >(instance);
190  produces< std::vector<cosrej::CosRejObj> >(instance);
191  produces< std::vector<cosrej::NueCosRej> >(instance); /// 2017
192  produces< std::vector<cvn::Result> >(instance); /// 2017
193  produces< std::vector<rb::Shower> >(instance); /// 2017
194  produces< std::vector<rb::Prong> >(instance); /// 2017
195  produces< std::vector<rb::Vertex> >(instance); /// 2017
196  produces< std::vector<slid::ShowerLID> >(instance); /// 2017
197  produces< std::vector<numusand::NumuSandObj> >(instance);
198  produces< std::vector<presel::Veto> >(instance);
199  produces< std::vector<qeef::QePId> >(instance);
200  produces< std::vector<remid::ReMId> >(instance);
201  produces< std::vector<numue::NumuE> >(instance);
202  produces< art::Assns<rb::Cluster, rb::Track> >(instance);
203  produces< art::Assns<rb::Cluster, cosrej::CosRejObj> >(instance);
204  produces< art::Assns<rb::Cluster, cosrej::NueCosRej> >(instance); /// 2017
205  produces< art::Assns<rb::Cluster, cvn::Result> >(instance); /// 2017
206  produces< art::Assns<rb::Cluster, rb::Shower> >(instance); /// 2017
207  produces< art::Assns<rb::Cluster, rb::Prong> >(instance); /// 2017
208  produces< art::Assns<rb::Cluster, rb::Vertex> >(instance); /// 2017
209  produces< art::Assns<rb::Cluster, slid::ShowerLID> >(instance); /// 2017
210  produces< art::Assns<rb::Shower, slid::ShowerLID> >(instance); /// 2017
211  produces< art::Assns<rb::Cluster, fxwgt::FluxWeights> >(instance); /// 2017
212  produces< art::Assns<rb::Cluster, simb::GTruth> >(instance); /// 2017
213 
214  produces< art::Assns<rb::Cluster, numusand::NumuSandObj> >(instance);
215  produces< art::Assns<rb::Cluster, presel::Veto> >(instance);
216  produces< art::Assns<rb::Cluster, qeef::QePId> >(instance);
217  produces< art::Assns<rb::Cluster, numue::NumuE> >(instance);
218  produces< art::Assns<rb::Track, remid::ReMId> >(instance);
219  produces< art::Assns<rb::Track, rb::Energy> >(instance);
220  produces< art::Assns<rb::Cluster, simb::MCTruth> >(instance);
221  produces< art::Assns<rb::Cluster, simb::MCFlux> >(instance);
222 
223  // cosmic ray tracks
224  produces< std::vector<rb::Track> >(instance + "Cosmics");
225  produces< art::Assns<rb::Cluster, rb::Track> >(instance + "Cosmics");
226  }
227  }
228  if(instance.compare("ccpi") == 0){
229  produces< std::vector<rb::Cluster> >(instance);
230  produces< std::vector<rb::Energy> >(instance);
231  produces< std::vector<rb::Track > >(instance);
232  produces< std::vector<cosrej::CosRejObj> >(instance);
233  produces< std::vector<numusand::NumuSandObj> >(instance);
234  produces< std::vector<presel::Veto> >(instance);
235  produces< std::vector<qeef::QePId> >(instance);
236  produces< std::vector<remid::ReMId> >(instance);
237  produces< std::vector<numue::NumuE> >(instance);
238  produces< art::Assns<rb::Cluster, rb::Track> >(instance);
239  produces< art::Assns<rb::Cluster, cosrej::CosRejObj> >(instance);
240  produces< art::Assns<rb::Cluster, numusand::NumuSandObj> >(instance);
241  produces< art::Assns<rb::Cluster, presel::Veto> >(instance);
242  produces< art::Assns<rb::Cluster, qeef::QePId> >(instance);
243  produces< art::Assns<rb::Cluster, numue::NumuE> >(instance);
244  produces< art::Assns<rb::Track, remid::ReMId> >(instance);
245  produces< art::Assns<rb::Track, rb::Energy> >(instance);
246  produces< art::Assns<rb::Cluster, simb::MCTruth> >(instance);
247  produces< art::Assns<rb::Cluster, simb::MCFlux> >(instance);
248  produces< art::Assns<rb::Cluster, fxwgt::FluxWeights> >(instance); /// 2017
249  }
250 
251  }
252 
253  // all uses of this module should create a sumdata::SubRunData
254  produces< sumdata::SubRunData >();
255 
256  return;
257 }
258 
259 //......................................................................
261 {
262  // get the name of the file to determine the cycle
263  auto fileName = fb.fileName();
264 
265  // look for the first instance of _c in the name, the next 3 characters are
266  // the cycle number
267  // real data files do not have cycle numbers so we default fCycle to 0
268  auto cycleStart = fileName.find("_c");
269  if(cycleStart != std::string::npos){
270  auto cycleStr = fileName.substr(cycleStart + 2, 3);
271  fCycle = std::atoi(cycleStr.c_str());
272  }
273  else fCycle = 0;
274 
275  return;
276 }
277 
278 
279 
280 ////------------------------------------------------------------------------------
281 //void skim::DataProductSkimmer::endSubRun(art::SubRun & sr)
282 //{
283 // return;
284 //}
285 
286 //------------------------------------------------------------------------------
288 {
289 
290  // all the work of skimming data products and putting them in the event
291  // is in the DataProductSkimmermer object
292  for(auto skimmer : fSkimmers) skimmer->Skim(e, *this);
293 
294  std::unique_ptr< sumdata::SubRunData > srd(new sumdata::SubRunData(fCycle));
295 
296  e.put(std::move(srd));
297 
298  return;
299 }
300 
301 //------------------------------------------------------------------------------
303 {
304 
305  auto skimmers = p.get< std::vector<fhicl::ParameterSet> >("SkimmerConfigs");
306 
307  std::string skimmerType;
308  for(auto itr : skimmers){
309  skimmerType = itr.get<std::string>("InstanceLabel");
310  if(skimmerType.find("nue" ) != std::string::npos) fSkimmers.push_back(std::make_shared<skim::NueSkimmer> (itr));
311  else if(skimmerType.find("numu") != std::string::npos) fSkimmers.push_back(std::make_shared<skim::NumuSkimmer> (itr));
312  else if(skimmerType.find("ccpi") != std::string::npos) fSkimmers.push_back(std::make_shared<skim::NumuCCpiSkimmer>(itr));
313  }
314 
315  if(fSkimmers.size() < 1)
316  throw cet::exception("DataProductSkimmer")
317  << "No skimmers were created, something is very wrong";
318 
319  return;
320 }
321 
322  // //------------------------------------------------------------------------------
323  // void skim::DataProductSkimmer::beginJob()
324  // {
325  // // Implementation of optional member function here.
326  // }
327 
328  // //------------------------------------------------------------------------------
329  // bool skim::DataProductSkimmer::beginSubRun(art::SubRun & sr)
330  // {
331  // // Implementation of optional member function here.
332  // }
333 
334  // //------------------------------------------------------------------------------
335  // void skim::DataProductSkimmer::endJob()
336  // {
337  // // Implementation of optional member function here.
338  // }
339 
340  // //------------------------------------------------------------------------------
341  // bool skim::DataProductSkimmer::endRun(art::Run & r)
342  // {
343  // // Implementation of optional member function here.
344  // }
345 
346  // void skim::DataProductSkimmer::respondToCloseInputFile(art::FileBlock const & fb)
347  // {
348  // // Implementation of optional member function here.
349  // }
350 
351  // void skim::DataProductSkimmer::respondToCloseOutputFiles(art::FileBlock const & fb)
352  // {
353  // // Implementation of optional member function here.
354  // }
355 
356  // void skim::DataProductSkimmer::respondToOpenInputFile(art::FileBlock const &fb)
357  // {
358  // // Implementation of optional member function here.
359  // }
360 
361  // void skim::DataProductSkimmer::respondToOpenOutputFiles(art::FileBlock const & fb)
362  // {
363  // // Implementation of optional member function here.
364  // }
365 
std::vector< std::shared_ptr< skim::BaseSkimmer > > fSkimmers
does the heavy lifting of skimming
fileName
Definition: plotROC.py:78
const char * p
Definition: xmltok.h:285
std::string const & fileName() const
Definition: FileBlock.h:38
void respondToOpenInputFile(art::FileBlock const &fb) override
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
DataProductSkimmer & operator=(DataProductSkimmer const &)=delete
DEFINE_ART_MODULE(TestTMapFile)
int fCycle
cycle number, default is 0
Module to create a summary of total POT seen in a job.
Definition: Evaluator.h:27
object containing MC flux information
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Result for CVN.
void produce(art::Event &e) override
T get(std::string const &key) const
Definition: ParameterSet.h:231
Vertex location in position and time.
void reconfigure(fhicl::ParameterSet const &p)
DataProductSkimmer(fhicl::ParameterSet const &p)
Object collecting Preselection variables.
Float_t e
Definition: plot.C:35
enum BeamMode string