ShowerProducer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: ShowerProducer
3 // Plugin Type: producer (art v2_12_00)
4 // File: ShowerProducer_module.cc
5 //
6 // Generated at Mon Mar 18 09:24:15 2019 by Dung Phan using cetskelgen
7 // from cetlib version v3_06_00.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
21 
22 #include <memory>
23 #include <vector>
24 
25 #include "NNbarUtilities.h"
26 #include "Utilities/AssociationUtil.h"
27 
28 namespace nnbar {
29 class ShowerProducer;
30 }
31 
33 public:
34  explicit ShowerProducer(fhicl::ParameterSet const &p);
35 
36  void reconfigure(const fhicl::ParameterSet &p);
37  void beginJob() override;
38  void endJob() override;
39  void produce(art::Event &e) override;
40 
41 private:
43 
45 
47 
54 
55  unsigned int _TotalNumberOfEvents;
56  unsigned int _TotalNumberOfShowers;
57 };
58 
60  produces< std::vector<rb::Cluster> >("showers");
61  produces< std::vector<rb::Cluster> >("cosmics");
62 
63  reconfigure(p);
64 }
65 
69 }
70 
72  _InputDataLabel = p.get<art::InputTag> ("InputDataLabel");
73  _IsSimulation = p.get<bool> ("IsSimulation");
74  _NumberOfCHitsThreshold = p.get<unsigned int> ("NumberOfCHitsThreshold");
75 
76  _ContainmentMinX = p.get<double> ("ContainmentMinX");
77  _ContainmentMaxX = p.get<double> ("ContainmentMaxX");
78  _ContainmentMinY = p.get<double> ("ContainmentMinY");
79  _ContainmentMaxY = p.get<double> ("ContainmentMaxY");
80  _ContainmentMinZ = p.get<double> ("ContainmentMinZ");
81  _ContainmentMaxZ = p.get<double> ("ContainmentMaxZ");
82 }
83 
85  std::unique_ptr< std::vector<rb::Cluster> > showerClusters(new std::vector<rb::Cluster>);
86  std::unique_ptr< std::vector<rb::Cluster> > cosmicClusters(new std::vector<rb::Cluster>);
87 
89  std::vector<art::Ptr<rb::Cluster> > clusters;
90  if (e.getByLabel(_InputDataLabel, clusterHandle)) art::fill_ptr_vector(clusters, clusterHandle);
92 
93  for (std::vector<art::Ptr<rb::Cluster> >::const_iterator clusterItr = clusters.begin(); clusterItr != clusters.end(); ++clusterItr) {
94  auto cluster = *clusterItr;
95  if (_IsSimulation) {
96  if (cluster->IsNoise()) continue;
97  if (cluster->AllCells().size() > _NumberOfCHitsThreshold) continue;
98  showerClusters->push_back(*cluster);
100  } else {
101  if (cluster->IsNoise()) continue;
102  if (cluster->AllCells().size() > _NumberOfCHitsThreshold) continue;
103 
104  // Actually no containment cuts (see values of the containment cuts above)
105  bool isShower = NNbarUtilities::isShowerCluster(*cluster,
109  if (isShower) {
110  showerClusters->push_back(*cluster);
112  } else {
113  cosmicClusters->push_back(*cluster);
114  }
115  }
116  }
117 
118  e.put(std::move(showerClusters), "showers");
119  e.put(std::move(cosmicClusters), "cosmics");
120 }
121 
123  std::cout << "_TotalNumberOfEvents: " << _TotalNumberOfEvents << std::endl;
124  std::cout << "_TotalNumberOfShowers: " << _TotalNumberOfShowers << std::endl;
125 }
126 
ShowerProducer(fhicl::ParameterSet const &p)
void reconfigure(const fhicl::ParameterSet &p)
const char * p
Definition: xmltok.h:285
void produce(art::Event &e) override
DEFINE_ART_MODULE(TestTMapFile)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
T get(std::string const &key) const
Definition: ParameterSet.h:231
static bool isShowerCluster(rb::Cluster cluster, int containXmin, int containXmax, int containYmin, int containYmax, int containZmin, int containZmax)
OStream cout
Definition: OStream.cxx:6
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Float_t e
Definition: plot.C:35