OpDetDivRec.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // File: OpDetDivRec..cxx
4 // Author: Jason Stock (jason.stock@mines.sdsmt.edu)
5 // This file is a set of classes for writeout of data relative to
6 // OpticalChannels in the DUNE detectors.
7 //
8 ////////////////////////////////////////////////////////////////////////
9 
10 //includes
11 #include <vector>
12 #include <TObject.h>
13 #include "OpDetDivRec.h"
14 #include <algorithm>
15 
16 namespace sim {
18  fOpDetNum(-1)
19  { }
21  fOpDetNum(det)
22  { }
23 
24  //int OpDetDivRec::OpDetNum() const { return fOpDetNum; }
27  if(itr == time_chans.end() || itr->time!=time){
28  std::vector<Chan_Phot> cfl;
29  cfl.emplace_back(opchan, tid);
30  time_chans.emplace(itr, time, std::move(cfl));
31  if(! std::is_sorted(time_chans.begin(), time_chans.end(), CompareByPdTime() ) ) //Just to guarantee no funny buisiness in the ordering. This shold generally not be an issue because we should always pass this check. After I convince myself it is always filled correctly, I will remove this check.
32  std::sort(time_chans.begin(), time_chans.end(), CompareByPdTime());
33  }else{
34  for(auto cfp = itr->phots.begin(); cfp!= itr->phots.end(); ++cfp){
35  if(cfp!= itr->phots.end() && cfp->opChan != opchan && cfp->trackID!=tid){
36  continue;
37  }else if(cfp == itr->phots.end()){
38  itr->phots.emplace_back(opchan, tid);
39  }else{
40  cfp->AddPhoton();
41  break;
42  }
43  }
44  }
45  }//End AddPhoton
46 
47  std::vector<std::pair<int, double>> OpDetDivRec::GetFracs(OpDet_Time_Chans::stored_time_t time){
48  std::vector<std::pair<int, double>> ret;
49  auto itr = priv_FindClosestTimeChan(time);
50  if( itr != time_chans.end() || itr->time==time ){
51  ret = itr->GetFracs();
52  }
53  return ret;
54  }
55 
56  std::vector<std::pair<int, double>> OpDetDivRec::GetFracs(OpDet_Time_Chans::stored_time_t time, int tid){
57  std::vector<std::pair<int, double>> ret;
58  auto itr = priv_FindClosestTimeChan(time);
59  if( itr != time_chans.end() || itr->time==time ){
60  ret = itr->GetFracs(tid);
61  }
62  return ret;
63  }
64 
66  return std::lower_bound
67  (time_chans.begin(), time_chans.end(), pdTime, CompareByPdTime() );
68  }
70  return std::lower_bound
71  (time_chans.begin(), time_chans.end(), pdTime, CompareByPdTime() );
72  }
73  std::pair<OpDetDivRec::Time_Chans_t::const_iterator , bool> OpDetDivRec::FindClosestTimeChan(OpDet_Time_Chans::stored_time_t pdTime) const{
74  auto ret = priv_FindClosestTimeChan(pdTime);
75  bool found=false;
76  if(ret!=time_chans.end()){
77  found=true;
78  }
79  return std::make_pair(ret, found);
80  }
81 
84  ret.lower = priv_FindClosestTimeChan(low_time);
85  ret.upper = priv_FindClosestTimeChan(high_time);
86  if(ret.lower!=ret.upper && ret.upper < time_chans.end()){
87  return ret;
88  }else{
89  ret.lower=time_chans.end();
90  ret.upper=time_chans.end();
91  return ret;
92  }
93  }
94 
96  time(timeIn)
97  {}
98  OpDet_Time_Chans::OpDet_Time_Chans(stored_time_t& timeIn, std::vector<Chan_Phot> inVec):
99  time(timeIn),
100  phots(inVec)
101  {}
102 }
intermediate_table::iterator iterator
Time_Chans_t::const_iterator lower
Definition: OpDetDivRec.h:91
time_slice GetSlice(OpDet_Time_Chans::stored_time_t low_time, OpDet_Time_Chans::stored_time_t high_time)
Definition: OpDetDivRec.cxx:82
std::vector< Chan_Phot > phots
Definition: OpDetDivRec.h:47
intermediate_table::const_iterator const_iterator
Time_Chans_t::iterator priv_FindClosestTimeChan(OpDet_Time_Chans::stored_time_t pdTime)
Definition: OpDetDivRec.cxx:65
std::vector< std::pair< int, double > > GetFracs(OpDet_Time_Chans::stored_time_t time)
Definition: OpDetDivRec.cxx:47
def move(depos, offset)
Definition: depos.py:107
Code to link reconstructed objects back to the MC truth information.
Time_Chans_t time_chans
Definition: OpDetDivRec.h:97
Time_Chans_t::const_iterator upper
Definition: OpDetDivRec.h:92
void AddPhoton(int opchan, int tid, OpDet_Time_Chans::stored_time_t pdTime)
Definition: OpDetDivRec.cxx:25
std::pair< OpDetDivRec::Time_Chans_t::const_iterator, bool > FindClosestTimeChan(OpDet_Time_Chans::stored_time_t pdTime) const
Definition: OpDetDivRec.cxx:73