ProtoDUNEBeamEvent.h
Go to the documentation of this file.
1 #ifndef BEAMDATA_PROTODUNEBEAMEVENT_H
2 #define BEAMDATA_PROTODUNEBEAMEVENT_H
3 
4 #include <vector>
5 #include <bitset>
6 #include <iostream>
7 #include <map>
10 
11 namespace beam
12 {
13 
14 
16  public:
19 
20  const std::pair< double, double > & GetT0() const{ return t0;};
21  const double & GetT0Sec() const { return t0.first; };
22  const double & GetT0Nano() const { return t0.second; };
23  void SetT0(std::pair< double, double > theT0){ t0 = theT0;};
24 
25  const FBM & GetFBM(std::string) const;
27 
29  const short & GetFiberStatus(std::string, size_t) const;
30  const std::vector<short> & GetActiveFibers(std::string) const;
31  const double & GetFiberTime(std::string) const;
32 
33  std::bitset<32> toBinary(double num){return std::bitset<32>( (uint32_t(num)) );};
34 
35  void SetCKov0(CKov theCKov){ CKov0 = theCKov; };
36  void SetCKov1(CKov theCKov){ CKov1 = theCKov; };
37  const short & GetCKov0Status() const{ return CKov0.trigger; };
38  const short & GetCKov1Status() const{ return CKov1.trigger; };
39  const double & GetCKov0Time() const{ return CKov0.timeStamp; };
40  const double & GetCKov1Time() const{ return CKov1.timeStamp; };
41  const double & GetCKov0Pressure() const{ return CKov0.pressure; };
42  const double & GetCKov1Pressure() const{ return CKov1.pressure; };
43 
44  void SetCalibrations(double TOFCalAA, double TOFCalBA, double TOFCalAB, double TOFCalBB){
45  TOFCal.at(0) = TOFCalAA;
46  TOFCal.at(1) = TOFCalBA;
47  TOFCal.at(2) = TOFCalAB;
48  TOFCal.at(3) = TOFCalBB;
49  };
50 
51  const std::vector<double> & GetCalibrations() const{ return TOFCal; };
52 
53 
54  void CalibrateTOFs(){
55  for( size_t i = 0; i < MultipleTOFs.size(); ++i ){
56  if( MultipleTOFChans[i] < 0) continue;
58  }
59  };
60 
61  void DecodeTOF(){
62  theTOF = MultipleTOFs[0];
64  };
65 
66  const double & GetTOF() const { return theTOF; };
67  const int & GetTOFChan() const{ return TOFChan; };
68 
69  const std::vector< double > & GetTOFs() const { return MultipleTOFs; };
70  const std::vector< int > & GetTOFChans() const { return MultipleTOFChans; };
71  const std::vector< size_t > & GetUpstreamTriggers() const { return UpstreamTriggers; };
72  const std::vector< size_t > & GetDownstreamTriggers() const { return DownstreamTriggers; };
73 
74  void SetTOFs (std::vector< double > theContent ) { MultipleTOFs = theContent; };
75  void SetTOFChans (std::vector< int > theContent ) { MultipleTOFChans = theContent; };
76  void SetUpstreamTriggers (std::vector< size_t > theContent ) { UpstreamTriggers = theContent; };
77  void SetDownstreamTriggers(std::vector< size_t > theContent ) { DownstreamTriggers = theContent; };
78 
79  void AddBeamTrack(recob::Track theTrack){ Tracks.push_back(theTrack);};
80  const recob::Track & GetBeamTrack(size_t i) const{ return Tracks.at(i);};
81  size_t GetNBeamTracks() {return Tracks.size();}
82  const std::vector< recob::Track > & GetBeamTracks() const;
83  void ClearBeamTracks(){ Tracks.clear(); };
84 
85  void SetActiveTrigger(size_t theTrigger){ activeTrigger = theTrigger; isMatched = true; };
86  const bool & CheckIsMatched()const { return isMatched; };
87  void SetUnmatched(){ isMatched = false; };
88  const size_t & GetActiveTrigger() const{ return activeTrigger; };
89 
90  void AddRecoBeamMomentum( double theMomentum ){ RecoBeamMomenta.push_back( theMomentum ); };
91  const std::vector< double > & GetRecoBeamMomenta() const { return RecoBeamMomenta;};
92  size_t GetNRecoBeamMomenta() { return RecoBeamMomenta.size(); };
93  const double & GetRecoBeamMomentum( size_t i ) const { return RecoBeamMomenta.at(i); };
94  void ClearRecoBeamMomenta() { RecoBeamMomenta.clear(); };
95 
96  void SetBITrigger(int theTrigger){ BITrigger = theTrigger; };
97  const int & GetBITrigger() const{ return BITrigger; };
98 
99  void SetTimingTrigger(int theTrigger){ TimingTrigger = theTrigger; };
100  const int & GetTimingTrigger() const{ return TimingTrigger; };
101 
102  void SetSpillStart(double theSpillStart){ SpillStart = theSpillStart; };
103  const double & GetSpillStart() const{ return SpillStart; };
104 
105  void SetSpillOffset(double theSpillOffset){ SpillOffset = theSpillOffset; };
106  const double & GetSpillOffset() const{ return SpillOffset; };
107 
108  void SetCTBTimestamp(long long theCTBTimestamp){ CTBTimestamp = theCTBTimestamp; };
109  const long long & GetCTBTimestamp() const{ return CTBTimestamp; };
110 
111  void SetRDTimestamp(long long theRDTimestamp){ RDTimestamp = theRDTimestamp; };
112  const long long & GetRDTimestamp() const{ return RDTimestamp; };
113 
114  void SetMagnetCurrent(double theMagnetCurrent){ MagnetCurrent = theMagnetCurrent; };
115  const double & GetMagnetCurrent() const{ return MagnetCurrent; };
116 
117 
118 
119 
120  private:
121 
122  //Time of a coincidence between 2 TOFs
123  //Signalling a good particle
124  //Known as 'GeneralTrigger'
125  //
126  std::pair<double,double> t0;
127 
128  //Timestamp from the CTB signaling a
129  //Good particle signal was received
130  //
131  long long CTBTimestamp;
132  long long RDTimestamp;
133 
134  //Set of FBMs
135  //Indices: [Monitor in beam]
136  std::map<std::string, FBM > fiberMonitors;
137 
138  //Set of TOF detectors
139  //
140  int TOFChan;
141  double theTOF;
142 
143  std::vector< double > MultipleTOFs;
144  std::vector< int > MultipleTOFChans;
145  std::vector< size_t > UpstreamTriggers;
146  std::vector< size_t > DownstreamTriggers;
147 
148  std::vector<double> TOFCal = {0.,0.,0.,0.};
149 
150  //Set of Cerenkov detectors
151  //
154 
155  std::vector<recob::Track> Tracks;
156 
158  bool isMatched = false;
159 
160  std::vector< double > RecoBeamMomenta;
161 
164  double SpillStart;
165  double SpillOffset;
166 
168 
169  };
170 
172  : t0({0.,0.}), CTBTimestamp(0), RDTimestamp(0), TOFChan(0),
173  theTOF(0.), activeTrigger(0), BITrigger(0), TimingTrigger(0),
174  SpillStart(0.), SpillOffset(0.), MagnetCurrent(0.) {
175  /*
176  FBM dummy;
177  dummy.ID = -1;
178  dummy.fibers = {};
179  std::uninitialized_fill( std::begin(dummy.fiberData), std::end(dummy.fiberData), 0. );
180  std::uninitialized_fill( std::begin(dummy.timeData), std::end(dummy.timeData), 0. );
181  dummy.glitch_mask = {};
182  dummy.timeStamp = 0.;
183  dummy.decoded = false;
184  dummy.active = std::vector<short>();
185  */
186  FBM dummy(-1);
187  fiberMonitors["dummy"] = dummy;
188 
189  //add in default values for TOF and CKov, tracks, etc.?
190  }
191 
192  inline const std::vector< recob::Track > & ProtoDUNEBeamEvent::GetBeamTracks() const { return Tracks; }
193 
194 
195  ////////////Fiber Monitor Access
196  inline const FBM & ProtoDUNEBeamEvent::GetFBM(std::string FBMName) const{
197  if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
198 
199  std::cout << "Error FBM " << FBMName << " not found" << std::endl;
200 
201  for(auto itF = fiberMonitors.begin(); itF != fiberMonitors.end(); ++itF){
202  std::cout << "\t" << itF->first << std::endl;
203  }
204 
205  return fiberMonitors.at("dummy");
206  }
207 
208  return fiberMonitors.at(FBMName);
209  }
210 
211  inline void ProtoDUNEBeamEvent::SetFBMTrigger(std::string FBMName, FBM theFBM){
212  if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
213 // std::cout << "FBM not found" << std::endl;
214 // std::cout << "Setting New FBM " << FBMName << std::endl;
215  }
216 
217  fiberMonitors[FBMName] = theFBM;
218  }
219 
220 
221 
223  if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
224  std::cout << "FBM " << FBMName << " Not Found" << std::endl;
225  return;
226  }
227  //This always clears the currently active fibers in the FBM.
228  fiberMonitors[FBMName].active.clear();
229 
230  for(int iSet = 0; iSet < 6; ++iSet){
231 
232  std::bitset<32> theseFibers = toBinary( fiberMonitors[FBMName].fiberData[iSet] );
233 
234  for(int iFiber = 0; iFiber < 32; ++iFiber){
235  fiberMonitors[FBMName].fibers[iSet*32 + iFiber] = theseFibers[iFiber];
236  if(theseFibers[iFiber]) fiberMonitors[FBMName].active.push_back(iSet*32 + iFiber);
237  }
238  }
239 
240  fiberMonitors[FBMName].decoded = true;
241  }
242 
243 
244  inline const short & ProtoDUNEBeamEvent::GetFiberStatus(std::string FBMName, size_t iFiber) const{
245 /* if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
246  std::cout << "FBM " << FBMName << " not found in list" << std::endl;
247  return -1;
248  }
249  if( (iFiber > 191)){
250  std::cout << "Please input fiber in range [0,191]" << std::endl;
251  return -1;
252  }
253 */
254  return fiberMonitors.at(FBMName).fibers.at(iFiber);
255  }
256 
257  inline const std::vector<short> & ProtoDUNEBeamEvent::GetActiveFibers(std::string FBMName) const{
258 // std::vector<short> active;
259 
260  if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
261  std::cout << "FBM " << FBMName << " not found in list" << std::endl;
262  return fiberMonitors.at("dummy").active;
263  }
264 
265 /* for(size_t iF = 0; iF < 192; ++iF){
266  if(fiberMonitors[FBMName].fibers[iF]) active.push_back(iF);
267  }
268 */
269  return fiberMonitors.at(FBMName).active;
270  }
271 
272  inline const double & ProtoDUNEBeamEvent::GetFiberTime(std::string FBMName) const{
273 /* if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
274  std::cout << "FBM " << FBMName << " not found in list" << std::endl;
275  return -1;
276  }
277 */
278  return fiberMonitors.at(FBMName).timeStamp;
279  }
280 
281  /////////////////////////////////
282 
283 
284 }
285 
286 
287 #endif
code to link reconstructed objects back to the MC truth information
const FBM & GetFBM(std::string) const
std::vector< size_t > DownstreamTriggers
const double & GetT0Nano() const
const int & GetTimingTrigger() const
const recob::Track & GetBeamTrack(size_t i) const
void SetSpillStart(double theSpillStart)
const std::vector< double > & GetTOFs() const
const long long & GetCTBTimestamp() const
const std::vector< double > & GetCalibrations() const
std::string string
Definition: nybbler.cc:12
const double & GetCKov0Pressure() const
std::vector< double > TOFCal
void SetTimingTrigger(int theTrigger)
const short & GetCKov1Status() const
const long long & GetRDTimestamp() const
const double & GetSpillOffset() const
std::vector< int > MultipleTOFChans
std::vector< size_t > UpstreamTriggers
const double & GetCKov0Time() const
void SetBITrigger(int theTrigger)
void SetSpillOffset(double theSpillOffset)
void SetFBMTrigger(std::string, FBM)
void DecodeFibers(std::string)
void SetCKov0(CKov theCKov)
std::pair< double, double > t0
const std::vector< size_t > & GetDownstreamTriggers() const
void SetMagnetCurrent(double theMagnetCurrent)
const std::vector< short > & GetActiveFibers(std::string) const
const std::vector< double > & GetRecoBeamMomenta() const
std::bitset< 32 > toBinary(double num)
const double & GetTOF() const
const double & GetT0Sec() const
const double & GetSpillStart() const
const std::vector< size_t > & GetUpstreamTriggers() const
const double & GetFiberTime(std::string) const
void SetRDTimestamp(long long theRDTimestamp)
void SetCTBTimestamp(long long theCTBTimestamp)
void AddBeamTrack(recob::Track theTrack)
const std::pair< double, double > & GetT0() const
std::map< std::string, FBM > fiberMonitors
void AddRecoBeamMomentum(double theMomentum)
const size_t & GetActiveTrigger() const
const std::vector< int > & GetTOFChans() const
const double & GetCKov1Time() const
std::vector< recob::Track > Tracks
void SetDownstreamTriggers(std::vector< size_t > theContent)
Provides recob::Track data product.
std::vector< double > RecoBeamMomenta
void SetUpstreamTriggers(std::vector< size_t > theContent)
const short & GetFiberStatus(std::string, size_t) const
std::vector< double > MultipleTOFs
cet::LibraryManager dummy("noplugin")
const std::vector< recob::Track > & GetBeamTracks() const
const short & GetCKov0Status() const
void SetT0(std::pair< double, double > theT0)
const int & GetBITrigger() const
void SetCKov1(CKov theCKov)
const double & GetRecoBeamMomentum(size_t i) const
const double & GetMagnetCurrent() const
const bool & CheckIsMatched() const
void SetTOFs(std::vector< double > theContent)
const int & GetTOFChan() const
void SetCalibrations(double TOFCalAA, double TOFCalBA, double TOFCalAB, double TOFCalBB)
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
void SetTOFChans(std::vector< int > theContent)
QTextStream & endl(QTextStream &s)
const double & GetCKov1Pressure() const
void SetActiveTrigger(size_t theTrigger)