UpMuProb_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: UpMuProb
3 // Module Type: producer
4 // File: UpMuProb_module.cc
5 //
6 // Generated at Mon Jun 13 14:37:49 2016 by Aristeidis Tsaris using artmod
7 // from cetpkgsupport v1_10_02.
8 ////////////////////////////////////////////////////////////////////////
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
20 // Framework includes
24 #include "Utilities/AssociationUtil.h"
26 #include "cetlib/search_path.h"
27 
28 #include <memory>
29 
30 // NOVA includes
31 #include "RecoBase/Track.h"
32 #include "RecoBase/RecoHit.h"
33 #include "Eval/LlrUpmu.h"
34 
35 namespace upmuana {
36  class UpMuProb;
37 
38  bool recoHitComp (rb::RecoHit lhs, rb::RecoHit rhs) {
39  if (lhs.Y() == rhs.Y()) {
40  if (lhs.Z() == rhs.Z()) {
41  return lhs.T() < rhs.T();
42  }
43  else return lhs.Z() < rhs.Z();
44  }
45  else return lhs.Y() < rhs.Y();
46  }
47 
48  bool pairHitComp (std::pair<rb::CellHit, rb::RecoHit> lhp,
49  std::pair<rb::CellHit, rb::RecoHit> rhp) {
50  return recoHitComp(lhp.second, rhp.second);
51  }
52 
53 }
54 
56 public:
57  explicit UpMuProb(fhicl::ParameterSet const & p);
58  // The destructor generated by the compiler is fine for classes
59  // without bare pointers or other resource use.
60 
61  // Plugins should not be copied or assigned.
62  UpMuProb(UpMuProb const &) = delete;
63  UpMuProb(UpMuProb &&) = delete;
64  UpMuProb & operator = (UpMuProb const &) = delete;
65  UpMuProb & operator = (UpMuProb &&) = delete;
66 
67  // Required functions.
68  void produce(art::Event & e) override;
69 
70  // Selected optional functions.
71  void beginJob() override;
72  void endJob() override;
73 
74  void reconfigure(const fhicl::ParameterSet& p);
75 
76 private:
77 
78  // Declare member data here.
81 
82 };
83 
84 
86 // :
87 // Initialize member data here.
88 {
89  // Call appropriate produces<>() functions here.
90  reconfigure(p);
91 }
92 
94 {
95  fTrackLabel = p.get<std::string>("trackInputTag");
96  fSliceLabel = p.get<std::string>("sliceInputTag");
97 
98  produces<std::vector<upmuana::LlrUpmu> >();
99  produces< art::Assns<upmuana::LlrUpmu,rb::Track> >();
100 
101 }
102 
104 {
105  // Implementation of required member function here.
106 
107  std::unique_ptr<std::vector<upmuana::LlrUpmu> > upmucol(new std::vector<upmuana::LlrUpmu>);
108  std::unique_ptr< art::Assns<upmuana::LlrUpmu,rb::Track> > assncol(new art::Assns<upmuana::LlrUpmu,rb::Track>);
109 
111  e.getByLabel(fSliceLabel,slicecol);
112  art::PtrVector<rb::Cluster> slicelist;
113  for(unsigned int i = 0; i<slicecol->size();++i){
114  art::Ptr<rb::Cluster>slice(slicecol,i);
115  slicelist.push_back(slice);
116  }
117 
120  e.getByLabel(fTrackLabel, tracks);
121 
122  // loop over all of the slices
123  for(unsigned int iSlice = 0; iSlice<slicelist.size(); ++iSlice){
124  // get all of the tracks in this slice
125  const std::vector< art::Ptr<rb::Track> > slicetrks = fmt.at(iSlice);
126  for(unsigned int i_track = 0;i_track<slicetrks.size(); ++i_track){
127  //for (size_t i_track=0; i_track < tracks->size(); ++i_track){
128 
129  art::Ptr<rb::Track> track = slicetrks[i_track];
130 
131  art::PtrVector<rb::CellHit> trackHits = track->AllCells();
132  std::set< std::pair<rb::CellHit,rb::RecoHit>,
133  bool(*)(std::pair<rb::CellHit,rb::RecoHit>,
134  std::pair<rb::CellHit,rb::RecoHit>)>
135  sortedTrackHits (pairHitComp);
136 
137  for (size_t i_hit=0; i_hit < trackHits.size(); ++i_hit) {
138  art::Ptr<rb::CellHit> theHit = trackHits.at(i_hit);
139  if (!theHit->GoodTiming()) continue;
140  rb::RecoHit theRecoHit = track->RecoHit(theHit);
141  if (!theRecoHit.IsCalibrated()) continue;
142  sortedTrackHits.insert(std::make_pair(*theHit,theRecoHit));
143  }
144 
146  tmp.setLLR(sortedTrackHits);
147  upmucol->push_back(tmp);
148  util::CreateAssn(*this, e, *(upmucol.get()), track, *(assncol.get()));
149  }
150  }
151  e.put(std::move(upmucol));
152  e.put(std::move(assncol));
153 }
155 {
156  // Implementation of optional member function here.
157 }
158 
160 {
161  // Implementation of optional member function here.
162 }
163 
float T() const
Definition: RecoHit.h:39
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
void endJob() override
const char * p
Definition: xmltok.h:285
void setLLR(std::set< std::pair< rb::CellHit, rb::RecoHit >, bool(*)(std::pair< rb::CellHit, rb::RecoHit >, std::pair< rb::CellHit, rb::RecoHit >)>)
Definition: LlrUpmu.cxx:30
float Z() const
Definition: RecoHit.h:38
Definition: event.h:19
Float_t tmp
Definition: plot.C:36
void reconfigure(const fhicl::ParameterSet &p)
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
DEFINE_ART_MODULE(TestTMapFile)
std::string fSliceLabel
art::PtrVector< rb::CellHit > AllCells() const
Get all cells from both views.
Definition: Cluster.cxx:180
Calibrated quantities relying on position in the orthogonal view. To generate a rb::CellHit from a rb...
Definition: RecoHit.h:19
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
UpMuProb(fhicl::ParameterSet const &p)
UpMuProb & operator=(UpMuProb const &)=delete
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
std::string fTrackLabel
bool recoHitComp(rb::RecoHit lhs, rb::RecoHit rhs)
T get(std::string const &key) const
Definition: ParameterSet.h:231
rb::RecoHit RecoHit(const art::Ptr< rb::CellHit > &chit) const
Return calibrated hit based on assumed W coordinate.
Definition: Cluster.cxx:259
void beginJob() override
bool IsCalibrated() const
You MUST check here before accessing PECorr, MIP or GeV.
Definition: RecoHit.cxx:35
reference at(size_type n)
Definition: PtrVector.h:365
size_type size() const
Definition: PtrVector.h:308
bool pairHitComp(std::pair< rb::CellHit, rb::RecoHit > lhp, std::pair< rb::CellHit, rb::RecoHit > rhp)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
float Y() const
Definition: RecoHit.h:37
bool GoodTiming() const
Definition: CellHit.h:48
Float_t e
Definition: plot.C:35
void produce(art::Event &e) override