1 #ifndef BEAMDATA_PROTODUNEBEAMSPILL_H 2 #define BEAMDATA_PROTODUNEBEAMSPILL_H 23 active = std::vector<short>();
34 active = std::vector<short>();
42 std::array<short,192>
fibers;
80 void InitFBMs(std::vector<std::string>);
81 std::pair< double, double > GetT0(
size_t);
82 double GetT0Sec(
size_t);
83 double GetT0Nano(
size_t);
85 void AddT0(std::pair< double, double >);
91 double DecodeFiberTime(
std::string,
size_t,
double);
94 std::array<double,4> ReturnTriggerAndTime(
std::string,
size_t);
96 std::vector<short> GetActiveFibers(
std::string,
size_t);
97 std::vector<short> GetMaskedFibers(
std::string,
size_t);
100 std::bitset<32> toBinary(
double);
123 std::pair< double, double > GetTOF0(
size_t);
124 double GetTOF0Sec(
size_t);
125 double GetTOF0Nano(
size_t);
126 std::pair< double, double > GetTOF1(
size_t);
127 double GetTOF1Sec(
size_t);
128 double GetTOF1Nano(
size_t);
129 double GetTOF(
size_t );
130 int GetTOFChan(
size_t);
141 void AddUpstreamTriggers( std::vector< size_t > theTriggers ){ UpstreamTriggers.push_back( theTriggers ); };
147 const std::vector< recob::Track > & GetBeamTracks()
const;
173 double GetMagnetCurrent(){
return MagnetCurrent; };
181 std::vector<std::pair<double,double>>
t0;
196 std::vector< std::pair< double, double > >
TOF0;
197 std::vector< std::pair< double, double > >
TOF1;
201 std::vector< std::vector< double > >
TOFs;
214 bool isMatched =
false;
228 if( trigger >
t0.size() - 1 ){
229 std::cout <<
"Error. Trigger out of bunds" <<
std::endl;
230 return std::make_pair(-1.,-1.);
237 if( trigger >
t0.size() - 1 ){
238 std::cout <<
"Error. Trigger out of bunds" <<
std::endl;
242 return t0[trigger].first;
246 if( trigger >
t0.size() - 1 ){
247 std::cout <<
"Error. Trigger out of bunds" <<
std::endl;
251 return t0[trigger].second;
263 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
264 std::cout <<
"Error FBM not found" <<
std::endl;
267 for(
auto itF = fiberMonitors.begin(); itF != fiberMonitors.end(); ++itF){
268 std::cout <<
"\t" << itF->first <<
std::endl;
273 if(theTrigger >
t0.size()){
274 std::cout <<
"Error, trigger out of range" <<
std::endl;
277 return fiberMonitors[FBMName].at(theTrigger);
282 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
283 std::cout <<
"Error FBM not found" <<
std::endl;
286 for(
auto itF = fiberMonitors.begin(); itF != fiberMonitors.end(); ++itF){
287 std::cout <<
"\t" << itF->first <<
std::endl;
293 if(fiberMonitors[FBMName][0].
ID == -1){
294 std::cout <<
"Replacing dummy FBM" <<
std::endl;
296 fiberMonitors[FBMName].insert(theIt,theFBM);
297 fiberMonitors[FBMName].pop_back();
300 fiberMonitors[FBMName].push_back(theFBM);
305 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
306 std::cout <<
"Error FBM not found" <<
std::endl;
308 for(
auto itF = fiberMonitors.begin(); itF != fiberMonitors.end(); ++itF){
309 std::cout <<
"\t" << itF->first <<
std::endl;
315 if( theTrigger >
t0.size() - 1 ){
316 std::cout <<
"Trigger out of range of good particles." <<
std::endl;
321 fiberMonitors[FBMName].at(theTrigger) = theFBM;
326 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
327 std::cout <<
"Please input monitor in range [0," << fiberMonitors.size() - 1 <<
"]" <<
std::endl;
330 if( (nTrigger > fiberMonitors[FBMName].
size()) ){
331 std::cout <<
"Please input trigger in range [0," << fiberMonitors[FBMName].size() - 1 <<
"]" <<
std::endl;
336 fiberMonitors[FBMName][nTrigger].active.clear();
338 for(
int iSet = 0; iSet < 6; ++iSet){
340 std::bitset<32> theseFibers = toBinary( fiberMonitors[FBMName][nTrigger].
fiberData[iSet] );
342 for(
int iFiber = 0; iFiber < 32; ++iFiber){
343 fiberMonitors[FBMName][nTrigger].fibers[iSet*32 + iFiber] = theseFibers[iFiber];
344 if(theseFibers[iFiber]) fiberMonitors[FBMName][nTrigger].active.push_back(iSet*32 + iFiber);
348 fiberMonitors[FBMName][nTrigger].decoded =
true;
352 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
353 std::cout <<
"FBM not found in list" <<
std::endl;
356 if( (nTrigger > fiberMonitors[FBMName].
size()) ){
357 std::cout <<
"Please input trigger in range [0," << fiberMonitors[FBMName].size() - 1 <<
"]" <<
std::endl;
365 return fiberMonitors[FBMName][nTrigger].timeData[3] - OffsetTAI + fiberMonitors[FBMName][nTrigger].timeData[2]*8.e-9;
369 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
370 std::cout <<
"FBM not found in list" <<
std::endl;
371 return {{-1.,-1.,-1.,-1.}};
373 if( (nTrigger > fiberMonitors[FBMName].
size()) ){
374 std::cout <<
"Please input trigger in range [0," << fiberMonitors[FBMName].size() - 1 <<
"]" <<
std::endl;
375 return {{-1.,-1.,-1.,-1.}};
378 return {{fiberMonitors[FBMName][nTrigger].timeData[0], fiberMonitors[FBMName][nTrigger].timeData[1], fiberMonitors[FBMName][nTrigger].timeData[2], fiberMonitors[FBMName][nTrigger].timeData[3]}};
382 std::bitset<64> mybits( (
long(num)) );
383 std::bitset<32> upper, lower;
384 for(
int i = 0; i < 32; ++i){
385 lower[i] = mybits[i];
386 upper[i] = mybits[i + 32];
388 if(upper.any()) std::cout <<
"WARNING: NONZERO HALF" <<
std::endl;
400 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
401 std::cout <<
"Please input monitor in range [0," << fiberMonitors.size() - 1 <<
"]" <<
std::endl;
405 std::cout <<
"Please input fiber in range [0,191]" <<
std::endl;
408 if( (nTrigger > fiberMonitors[FBMName].
size()) ){
409 std::cout <<
"Please input trigger in range [0," << fiberMonitors[FBMName].size() - 1 <<
"]" <<
std::endl;
412 return fiberMonitors[FBMName][nTrigger].fibers[iFiber];
416 std::vector<short>
active;
418 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
419 std::cout <<
"Please input monitor in range [0," << fiberMonitors.size() - 1 <<
"]" <<
std::endl;
422 if( (nTrigger > fiberMonitors[FBMName].
size()) ){
423 std::cout <<
"Please input trigger in range [0," << fiberMonitors[FBMName].size() - 1 <<
"]" <<
std::endl;
427 for(
size_t iF = 0; iF < 192; ++iF){
428 if(fiberMonitors[FBMName][nTrigger].
fibers[iF]) active.push_back(iF);
435 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
436 std::cout <<
"Please input monitor in range [0," << fiberMonitors.size() - 1 <<
"]" <<
std::endl;
439 if( (nTrigger > fiberMonitors[FBMName].
size()) ){
440 std::cout <<
"Please input trigger in range [0," << fiberMonitors[FBMName].size() - 1 <<
"]" <<
std::endl;
443 return fiberMonitors[FBMName][nTrigger].timeStamp;
447 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
448 std::cout <<
"Please input monitor in range [0," << fiberMonitors.size() - 1 <<
"]" <<
std::endl;
451 return fiberMonitors[FBMName].size();
457 if( (nTrigger >= TOF0.size()) ){
458 std::cout <<
"Please input index in range [0," << TOF0.size() - 1 <<
"]" <<
std::endl;
459 return std::make_pair(-1.,-1.);
462 return TOF0[nTrigger];
466 if( (nTrigger >= TOF0.size()) ){
467 std::cout <<
"Please input index in range [0," << TOF0.size() - 1 <<
"]" <<
std::endl;
471 return TOF0[nTrigger].first;
475 if( (nTrigger >= TOF0.size()) ){
476 std::cout <<
"Please input index in range [0," << TOF0.size() - 1 <<
"]" <<
std::endl;
480 return TOF0[nTrigger].second;
484 if( (nTrigger >=
TOF1.size()) ){
485 std::cout <<
"Please input index in range [0," <<
TOF1.size() - 1 <<
"]" <<
std::endl;
486 return std::make_pair(-1.,-1.);
489 return TOF1[nTrigger];
493 if( (nTrigger >=
TOF1.size()) ){
494 std::cout <<
"Please input index in range [0," <<
TOF1.size() - 1 <<
"]" <<
std::endl;
498 return TOF1[nTrigger].first;
502 if( (nTrigger >=
TOF1.size()) ){
503 std::cout <<
"Please input index in range [0," <<
TOF1.size() - 1 <<
"]" <<
std::endl;
507 return TOF1[nTrigger].second;
511 if( (nTrigger >=
TOF1.size()) ){
512 std::cout <<
"Please input index in range [0," <<
TOF1.size() - 1 <<
"]" <<
std::endl;
516 return TOFChan[nTrigger];
520 if( (nTrigger >=
TOF1.size()) ){
521 std::cout <<
"Please input index in range [0," <<
TOF1.size() - 1 <<
"]" <<
std::endl;
525 return (
TOF1[nTrigger].first - TOF0[nTrigger].first + 1.
e-9*(
TOF1[nTrigger].
second - TOF0[nTrigger].
second));
531 if( fiberMonitors.find(FBMName) == fiberMonitors.end() ){
532 std::cout <<
"Please input monitor with correct name" <<
std::endl;
538 if( fiberMonitors[FBMName].
size() < 2 ){
return; }
540 for(
size_t i = 1; i < fiberMonitors[FBMName].size(); ++i ){
541 std::vector<short> previous_active = fiberMonitors[FBMName][i-1].active;
542 std::vector<short> current_active = fiberMonitors[FBMName][i].active;
544 for(
size_t j = 0; j < current_active.size(); ++j ){
547 if( current_active[j] < 128 ){
continue; }
550 if( std::find( previous_active.begin(), previous_active.end(), current_active[j] ) != previous_active.end() ){
552 fiberMonitors[FBMName][i].glitch_mask[ current_active[j] ] = 1;
std::vector< std::vector< double > > TOFs
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::pair< double, double > GetTOF1(size_t)
code to link reconstructed objects back to the MC truth information
void AddFBMTrigger(std::string, FBM)
double GetCKov0Pressure(size_t i)
std::pair< double, double > GetTOF0(size_t)
size_t GetNRecoBeamMomenta()
void ClearRecoBeamMomenta()
std::vector< int > TOFChan
void AddTOF1Trigger(std::pair< double, double > theT)
std::pair< double, double > GetT0(size_t)
std::vector< short > GetActiveFibers(std::string, size_t)
void AddRecoBeamMomentum(double theMomentum)
double DecodeFiberTime(std::string, size_t, double)
std::vector< double > GetMultipleTOFs(size_t i)
double GetTOF1Sec(size_t)
void AddTOFChan(int theChan)
std::map< std::string, std::vector< FBM > > fiberMonitors
void ReplaceFBMTrigger(std::string, FBM, size_t)
std::vector< std::vector< size_t > > UpstreamTriggers
FBM GetFBM(std::string name, size_t theTrigger)
double GetFiberTime(std::string, size_t)
std::vector< double > RecoBeamMomenta
std::vector< short > active
void AddBeamTrack(recob::Track theTrack)
void AddCKov1(CKov theCKov)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
std::array< double, 4 > ReturnTriggerAndTime(std::string, size_t)
double GetCKov0Time(size_t i)
std::vector< CKov > CKov1
std::vector< size_t > GetUpstreamTriggers(size_t i)
void DecodeFibers(std::string, size_t)
std::vector< size_t > GetDownstreamTriggers(size_t i)
void SetSpillOffset(double theSpillOffset)
double GetCKov1Pressure(size_t i)
void AddT0(std::pair< double, double >)
std::vector< std::vector< int > > TOFChans
void AddUpstreamTriggers(std::vector< size_t > theTriggers)
std::vector< CKov > CKov1
void SetActiveTrigger(size_t theTrigger)
recob::Track GetBeamTrack(size_t i)
std::vector< int > GetMultipleTOFChans(size_t i)
double GetTOF1Nano(size_t)
void SetCTBTimestamp(double theCTBTimestamp)
std::vector< std::pair< double, double > > TOF0
const std::vector< recob::Track > & GetBeamTracks() const
void SetBITrigger(int theTrigger)
void AddMultipleTOFs(std::vector< double > theTOFs)
std::vector< std::vector< size_t > > DownstreamTriggers
void FixFiberGlitch(std::string)
size_t GetNFBMTriggers(std::string)
std::vector< std::pair< double, double > > TOF1
std::array< short, 192 > fibers
short GetCKov0Status(size_t i)
std::vector< CKov > CKov0
void AddMultipleTOFChans(std::vector< int > theChans)
void AddTOF0Trigger(std::pair< double, double > theT)
void SetSpillStart(double theSpillStart)
size_t GetActiveTrigger()
void SetMagnetCurrent(double theMagnetCurrent)
Provides recob::Track data product.
std::array< short, 192 > glitch_mask
cet::LibraryManager dummy("noplugin")
double GetCKov1Time(size_t i)
short GetCKov1Status(size_t i)
std::vector< recob::Track > Tracks
double GetTOF0Sec(size_t)
void AddCKov0(CKov theCKov)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
short GetFiberStatus(std::string, size_t, size_t)
double GetRecoBeamMomentum(size_t i)
second_as<> second
Type of time stored in seconds, in double precision.
std::vector< long long int > TOF1
double GetTOF0Nano(size_t)
std::bitset< 32 > toBinary(double)
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
std::vector< std::pair< double, double > > t0
void AddDownstreamTriggers(std::vector< size_t > theTriggers)
QTextStream & endl(QTextStream &s)