PCHitTransposer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: PCHitTransposer
3 // Plugin Type: producer (art v2_11_01)
4 // File: PCHitTransposer_module.cc
5 //
6 // Generated at Tue Jul 3 06:29:49 2018 by Kevin Mulder using cetskelgen
7 // from cetlib version v3_03_00.
8 ////////////////////////////////////////////////////////////////////////
9 
10 // C/C++ includes
11 #include <memory>
12 
13 //Framework includes
21 #include "fhiclcpp/ParameterSet.h"
23 
24 //NOvASoft includes
26 
27 //ROOT includes
28 
29 namespace calib {
30  class PCHitTransposer;
31 }
32 
34 public:
35  explicit PCHitTransposer(fhicl::ParameterSet const & p);
36 
37  // Plugins should not be copied or assigned.
38  PCHitTransposer(PCHitTransposer const &) = delete;
39  PCHitTransposer(PCHitTransposer &&) = delete;
40  PCHitTransposer & operator = (PCHitTransposer const &) = delete;
42 
43  // Required functions.
44  void produce(art::Event & e) override;
45 
46  // Selected optional functions.
47  void beginJob() override;
48  void reconfigure(const fhicl::ParameterSet& pset);
49 
50 private:
56  int fMinPlane;
57  int fMaxPlane;
58  int fMinCell;
59  int fMaxCell;
60 };
61 
63 {
64  fInputModuleLabel = pset.get<std::string>("InputModuleLabel");
65  fInputProductInstanceXY = pset.get<std::string>("InputProductInstanceXY");
66  fInputProductInstanceTraj = pset.get<std::string>("InputProductInstanceTraj");
67  fOutputMode = pset.get<std::string>("OutputMode");
68  fMinPlane = pset.get<int>("MinPlane");
69  fMaxPlane = pset.get<int>("MaxPlane");
70  fMinCell = pset.get<int>("MinCell");
71  fMaxCell = pset.get<int>("MaxCell");
72 }
73 
75 // :
76 // Initialize member data here.
77 {
78  // Call appropriate produces<>() functions here.
79  this->reconfigure(p);
80  std::string instancename_XY;
81  std::string instancename_Traj;
82  for(int i=fMinPlane; i<=fMaxPlane; i++){
83  if(fOutputMode=="Plane"){
84  instancename_XY = "XYpchitplane"+std::to_string(i);
85  instancename_Traj = "Trajpchitplane"+std::to_string(i);
86  produces< std::vector<caldp::PCHit> >(instancename_XY);
87  produces< std::vector<caldp::PCHit> >(instancename_Traj);
88  }
89  else if(fOutputMode=="Cell"){
90  for(int c=fMinCell; c<=fMaxCell; c++){
91  instancename_XY = "XYpchitplane"+std::to_string(i)+"cell"+std::to_string(c);
92  instancename_Traj = "Trajpchitplane"+std::to_string(i)+"cell"+std::to_string(c);
93  produces< std::vector<caldp::PCHit> >(instancename_XY);
94  produces< std::vector<caldp::PCHit> >(instancename_Traj);
95  }
96  }
97  }
98 }
99 
101 {
102  // Declarations
105  std::string instancename_XY;
106  std::string instancename_Traj;
107  std::vector< std::unique_ptr< std::vector<caldp::PCHit> > > outputvector_XY;
108  std::vector< std::unique_ptr< std::vector<caldp::PCHit> > > outputvector_Traj;
109 
110  // Create the outputvector, and fill it with unique pointers for every plane or cell
111  for(int i=fMinPlane; i<=fMaxPlane; i++){
112  if(fOutputMode=="Plane"){
113  std::unique_ptr< std::vector<caldp::PCHit> > Plane_XY (new std::vector<caldp::PCHit>);
114  std::unique_ptr< std::vector<caldp::PCHit> > Plane_Traj (new std::vector<caldp::PCHit>);
115  outputvector_XY.push_back(std::move(Plane_XY));
116  outputvector_Traj.push_back(std::move(Plane_Traj));
117  }
118  else if(fOutputMode=="Cell"){
119  for(int c=fMinCell; c<=fMaxCell; c++){
120  std::unique_ptr< std::vector<caldp::PCHit> > Cell_XY (new std::vector<caldp::PCHit>);
121  std::unique_ptr< std::vector<caldp::PCHit> > Cell_Traj (new std::vector<caldp::PCHit>);
122  outputvector_XY.push_back(std::move(Cell_XY));
123  outputvector_Traj.push_back(std::move(Cell_Traj));
124  }
125  }
126  }
127 
128  // Retrieve the PCHits from the event
131 
132  // Loop through every PCHit, sort it into the outputvector based on plane(& cell)
133  for(unsigned int n = 0; n < PCHits_XY->size(); ++n){
134  const caldp::PCHit& PCHit_XY = (*PCHits_XY)[n];
135  if(fOutputMode=="Plane"){
136  if(PCHit_XY.Plane() >= fMinPlane && PCHit_XY.Plane() <= fMaxPlane){
137  outputvector_XY[PCHit_XY.Plane()-fMinPlane]->push_back(PCHit_XY);
138  }
139  }
140  else if(fOutputMode=="Cell"){
141  if(PCHit_XY.Plane() >= fMinPlane && PCHit_XY.Plane() <= fMaxPlane){
142  if(PCHit_XY.Cell() >= fMinCell && PCHit_XY.Cell() <= fMaxCell){
143  outputvector_XY[(PCHit_XY.Plane()-fMinPlane)*(fMaxCell-fMinCell+1)+(PCHit_XY.Cell()-fMinCell)]->push_back(PCHit_XY);
144  }
145  }
146  }
147  }
148  for(unsigned int n = 0; n < PCHits_Traj->size(); ++n){
149  const caldp::PCHit& PCHit_Traj = (*PCHits_Traj)[n];
150  if(fOutputMode=="Plane"){
151  if(PCHit_Traj.Plane() >= fMinPlane && PCHit_Traj.Plane() <= fMaxPlane){
152  outputvector_Traj[PCHit_Traj.Plane()-fMinPlane]->push_back(PCHit_Traj);
153  }
154  }
155  else if(fOutputMode=="Cell"){
156  if(PCHit_Traj.Plane() >= fMinPlane && PCHit_Traj.Plane() <= fMaxPlane){
157  if(PCHit_Traj.Cell() >= fMinCell && PCHit_Traj.Cell() <= fMaxCell){
158  outputvector_Traj[(PCHit_Traj.Plane()-fMinPlane)*(fMaxCell-fMinCell+1)+(PCHit_Traj.Cell()-fMinCell)]->push_back(PCHit_Traj);
159  }
160  }
161  }
162  }
163 
164  // Store the transposed PCHits contained in the outputvector to the event
165  for(int i=fMinPlane; i<=fMaxPlane; i++){
166  if(fOutputMode=="Plane"){
167  instancename_XY = "XYpchitplane"+std::to_string(i);
168  instancename_Traj = "Trajpchitplane"+std::to_string(i);
169  e.put(std::move(outputvector_XY[i-fMinPlane]), instancename_XY);
170  e.put(std::move(outputvector_Traj[i-fMinPlane]), instancename_Traj);
171  }
172  else if(fOutputMode=="Cell"){
173  for(int c=fMinCell; c<=fMaxCell; c++){
174  instancename_XY = "XYpchitplane"+std::to_string(i)+"cell"+std::to_string(c);
175  instancename_Traj = "Trajpchitplane"+std::to_string(i)+"cell"+std::to_string(c);
176  e.put(std::move(outputvector_XY[(i-fMinPlane)*(fMaxCell-fMinCell+1)+(c-fMinCell)]), instancename_XY);
177  e.put(std::move(outputvector_Traj[(i-fMinPlane)*(fMaxCell-fMinCell+1)+(c-fMinCell)]), instancename_Traj);
178  }
179  }
180  }
181  return;
182 }
183 
185 {
186  // Implementation of optional member function here.
187  std::cout<<"BeginJob is starting"<<std::endl;
188 
189 }
190 
const char * p
Definition: xmltok.h:285
PCHitTransposer(fhicl::ParameterSet const &p)
void reconfigure(const fhicl::ParameterSet &pset)
int Cell() const
Return cell value.
Definition: PCHit.h:26
DEFINE_ART_MODULE(TestTMapFile)
"Pre-calibration hit". Common input to calibration procedures
Definition: PCHit.h:16
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void produce(art::Event &e) override
PCHitTransposer & operator=(PCHitTransposer const &)=delete
CDPStorage service.
T get(std::string const &key) const
Definition: ParameterSet.h:231
base_types push_back(int_type())
int Plane() const
Return plane value.
Definition: PCHit.h:24
OStream cout
Definition: OStream.cxx:6
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
Float_t e
Definition: plot.C:35
enum BeamMode string