96 auto const mcHandles = evt.
getMany<std::vector<simb::MCTruth>>();
97 std::vector< std::pair<int, std::string>> track_id_to_label;
99 for(
auto const& mcHandle : mcHandles ){
100 const std::string& sModuleLabel = mcHandle.provenance()->moduleLabel();
101 art::FindManyP<simb::MCParticle> findMCParts(mcHandle, evt,
"largeant");
102 std::vector<art::Ptr<simb::MCParticle> > mcParts = findMCParts.at(0);
104 int track_id = ptr->TrackId();
105 gf->
add(track_id, sModuleLabel);
109 std::vector<art::Ptr<recob::Hit>> hitList;
113 std::vector<art::Ptr<recob::OpHit>> opHitList;
130 unsigned int hitCounter=0;
131 for (
auto const&
hit : hitList){
134 mf::LogDebug(__FUNCTION__)<<
"Hit "<<hitCounter<<
" failed to add to the record. Is this hit caused by noise?";
139 for (
auto const&
hit : opHitList ){
142 mf::LogDebug(__FUNCTION__)<<
"OpHit "<<hitCounter<<
" failed to add to the record. Is this hit caused by noise?";
171 for(
auto part : eve.particles){
173 int partial_hit_pos=0;
174 for(
auto partial_hit : part.partial_hits){
175 int ind = partial_hit.index;
183 hc_pos->locations.emplace_back(eve_pos,part_pos,partial_hit_pos);
189 int partial_ophit_pos=0;
190 for(
auto partial_ophit : part.partial_ophits){
191 int ind = partial_ophit.index;
199 hc_pos->locations.emplace_back(eve_pos,part_pos,partial_ophit_pos);
219 for(
size_t part_num=0; part_num<eve.particles.size(); ++part_num ){
220 auto part = eve.particles.at(part_num);
222 npart.partial_hits.clear();
223 npart.partial_ophits.clear();
225 std::map<int64_t, CalibTreeRecord::PartialHit> bunched_hits;
226 std::map<int64_t, std::list<Double_t>> remembered_energies;
227 for(
auto partialhit : part.partial_hits){
228 auto emp_h = bunched_hits.emplace(std::make_pair(partialhit.index,partialhit));
229 std::list<Double_t>
dummy;
230 auto emp_e = remembered_energies.emplace(std::make_pair(partialhit.index, dummy));
231 if(emp_h.second==
true){
232 emp_e.first->second.emplace_back(partialhit.energy);
233 emp_h.first->second=partialhit;
235 if(emp_h.first->second.time != partialhit.time){
throw cet::exception(
"CalibrationTreeBuilder")<<
"Buncher failed. Trying to merge two of the same hit at different times?\n";}
236 emp_e.first->second.emplace_back(partialhit.energy);
237 emp_h.first->second.charge+=partialhit.charge;
238 emp_h.first->second.split+=partialhit.split;
239 emp_h.first->second.num_electrons+=partialhit.num_electrons;
241 emp_e.first->second.unique();
243 for(
auto en : emp_e.first->second){
246 emp_h.first->second.energy=
energy;
248 remembered_energies.clear();
249 std::map<int64_t, CalibTreeRecord::PartialOpHit> bunched_ophits;
250 for(
auto partialop : part.partial_ophits){
251 auto emp_o = bunched_ophits.emplace(std::make_pair(partialop.index,partialop));
252 std::list<Double_t>
dummy;
253 auto emp_e = remembered_energies.emplace(std::make_pair(partialop.index, dummy));
254 if(emp_o.second==
true){
255 emp_e.first->second.emplace_back(partialop.energy);
256 emp_o.first->second=partialop;
258 if(emp_o.first->second.time != partialop.time){
throw cet::exception(
"CalibrationTreeBuilder")<<
"Buncher failed. Trying to merge two of the same ophit at different times?\n";}
259 emp_e.first->second.emplace_back(partialop.energy);
260 emp_o.first->second.pes+=partialop.pes;
261 emp_o.first->second.split+=partialop.split;
262 emp_o.first->second.num_photons+=partialop.num_photons;
265 emp_e.first->second.unique();
267 for(
auto en : emp_e.first->second ){
270 emp_o.first->second.energy=
energy;
272 for(
auto entry : bunched_hits){
273 npart.partial_hits.push_back(
entry.second);
275 for(
auto entry : bunched_ophits){
278 npart.partial_ophits.push_back(
entry.second);
302 for(
auto part : eve.particles){
319 int partial_hit_pos=0;
320 for(
auto partial_hit : part.partial_hits){
331 int ind = partial_hit.index;
339 hc_pos->locations.emplace_back(eve_pos,part_pos,partial_hit_pos);
352 int partial_ophit_pos=0;
353 for(
auto partial_ophit : part.partial_ophits){
354 int ind = partial_ophit.index;
372 hc_pos->locations.emplace_back(eve_pos,part_pos,partial_ophit_pos);
void PrepDivRec(const art::Event &evt)
std::vector< HitContributor > hits
TTree * private_CalibrationTree
Handle< PROD > getHandle(SelectorBase const &) const
art::InputTag private_OpHitLabel
art::InputTag private_HitLabel
CalibTreeRecord::CalibTreeRecord private_eventBuffer
void add(const int &track_id, const std::string &gname)
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
std::vector< HitContributor > ophits
Detector simulation of raw signals on wires.
std::vector< art::Ptr< sim::OpDetDivRec > > priv_DivRecs
bool AddHit(detinfo::DetectorClocksData const &clockData, const art::Ptr< recob::Hit > hit, unsigned int &counter)
CalibTreeRecord::CalibTreeRecord private_eventPrep
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
std::vector< EveRecord > eves
cet::LibraryManager dummy("noplugin")
EventNumber_t event() const
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
SubRunNumber_t subRun() const
TTree * private_FlatCalibrationTree
cet::coded_exception< error, detail::translate > exception