Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
DAQToOffline::Splitter Class Reference

Public Member Functions

 Splitter (fhicl::ParameterSet const &ps, art::ProductRegistryHelper &prh, art::SourceHelper const &sh)
 
bool readFile (string const &filename, art::FileBlock *&fb)
 
bool readNext (art::RunPrincipal *const &inR, art::SubRunPrincipal *const &inSR, art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
 
void closeCurrentFile ()
 

Private Types

using rawDigits_t = vector< RawDigit >
 
using SSPWaveforms_t = vector< OpDetWaveform >
 
using OpHits_t = vector< recob::OpHit >
 
using PennCounters_t = vector< ExternalTrigger >
 
using MCPart_t = vector< simb::MCParticle >
 
using MCTruth_t = vector< simb::MCTruth >
 
using MCSimChan_t = vector< sim::SimChannel >
 

Private Member Functions

bool eventIsFull_ (rawDigits_t const &v)
 
bool loadEvents_ (size_t &InputTree)
 
bool LoadPTBInformation (size_t LoadTree)
 
void LoadSSPInformation (size_t LoadTree)
 
void LoadRCEInformation (size_t LoadTree)
 
void makeEventAndPutDigits_ (art::EventPrincipal *&outE, art::Timestamp art_timestamp=0)
 
void Reset ()
 
void CheckTimestamps (bool &JumpEvent, size_t &JumpNADC)
 
bool NoRCEsCase (art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
 
void Triggering (std::map< int, int > &PrevChanADC, std::vector< short > ADCdigits, bool NewTree)
 
void CheckTrigger ()
 
bool TicklerTrigger (std::map< int, int > &PrevChanADC, std::vector< short > ADCdigits)
 

Private Attributes

string sourceName_
 
string lastFileName_
 
std::unique_ptr< TFile > file_
 
bool doneWithFiles_
 
art::InputTag TPCinputTag_
 
art::InputTag SparseinputTag_
 
art::InputTag SSPinputTag_
 
art::InputTag OpHitinputTag_
 
art::InputTag PenninputTag_
 
art::InputTag MCPartinputTag_
 
art::InputTag MCTruthinputTag_
 
art::InputTag MCSimChaninputTag_
 
string TPCinputDataProduct_
 
string SSPinputDataProduct_
 
string OpHitinputDataProduct_
 
string PenninputDataProduct_
 
string MCPartinputDataProduct_
 
string MCTruthinputDataProduct_
 
string MCSimChaninputDataProduct_
 
SSPReformatterAlgs sspReform
 
string fPTBMapFile
 
string fPTBMapDir
 
art::SourceHelper const & sh_
 
TBranch * TPCinputBranch_
 
TBranch * SparseinputBranch_
 
TBranch * SSPinputBranch_
 
TBranch * OpHitinputBranch_
 
TBranch * PenninputBranch_
 
TBranch * MCPartinputBranch_
 
TBranch * MCTruthinputBranch_
 
TBranch * MCSimChaninputBranch_
 
TBranch * EventAuxBranch_
 
LoadedDigits loadedDigits_
 
LoadedWaveforms loadedWaveforms_
 
LoadedOpHits loadedOpHits_
 
LoadedCounters loadedCounters_
 
MonteCarlo MonteCarlo_
 
size_t nInputEvts_
 
size_t EventIndex_
 
art::RunNumber_t runNumber_
 
art::SubRunNumber_t subRunNumber_
 
art::EventNumber_t eventNumber_
 
art::RunNumber_t cachedRunNumber_
 
art::SubRunNumber_t cachedSubRunNumber_
 
art::RunNumber_t inputRunNumber_
 
art::SubRunNumber_t inputSubRunNumber_
 
art::EventNumber_t inputEventNumber_
 
art::Timestamp inputEventTime_
 
size_t ticksPerEvent_
 
rawDigits_t bufferedDigits_
 
std::vector< RawDigit::ADCvector_t > dbuf_
 
SSPWaveforms_t wbuf_
 
OpHits_t hbuf_
 
PennCounters_t cbuf_
 
MCPart_t mcbuf_
 
MCTruth_t mctruth_
 
MCSimChan_t simchanbuf_
 
unsigned short fTicksAccumulated
 
unsigned int fChansPresent = 0
 
bool fTrigger = false
 
bool fCheatPTBTrig = false
 
bool fCheatSSPTrig = false
 
size_t fLastTriggerIndex = 0
 
size_t fLastEventIndex = 0
 
size_t fLastEvent = 0
 
int fDiffFromLastTrig = 0
 
lbne::TpcNanoSlice::Header::nova_timestamp_t fLastTimeStamp = 0
 
lbne::TpcNanoSlice::Header::nova_timestamp_t first_timestamp =0
 
lbne::TpcNanoSlice::Header::nova_timestamp_t Event_timestamp =0
 
lbne::TpcNanoSlice::Header::nova_timestamp_t last_timestamp =0
 
lbne::TpcNanoSlice::Header::nova_timestamp_t this_timestamp =0
 
lbne::TpcNanoSlice::Header::nova_timestamp_t prev_timestamp =0
 
std::map< uint64_t, size_t > EventTreeMap
 
TTree * fTree
 
int AttemptedEvents
 
int VoidedEvents
 
int GoodEvents
 
int GivenRunNum [ArraySize]
 
int GivenSubRunNum [ArraySize]
 
int GivenEventNum [ArraySize]
 
int TreeIndexStart [ArraySize]
 
int ChansAtStartOfEvent [ArraySize]
 
int ChansAtEndOfEvent [ArraySize]
 
std::function< rawDigits_t(artdaq::Fragments const &, std::vector< std::pair< std::pair< unsigned int, unsigned int >, lbne::TpcNanoSlice::Header::nova_timestamp_t > > &, lbne::TpcNanoSlice::Header::nova_timestamp_t &, art::ServiceHandle< lbne::ChannelMapService > const &)> fragmentsToDigits_
 
art::EventAuxiliary evAux_
 
art::EventAuxiliarypevaux_
 
bool fRequireRCE
 
bool fRequireSSP
 
bool fRequireOpHit
 
bool fRequirePTB
 
bool fMonteCarlo
 
size_t fPostTriggerTicks
 
size_t fPreTriggerTicks
 
double fNovaTicksPerTPCTick
 
double fNovaTicksPerSSPTick
 
double fNovaTicksPerCountTick
 
double fNanoSecondsPerNovaTick
 
int fDebugLevel
 
double fTimeStampThreshold
 
int fMCTrigLevel
 
std::vector< unsigned int > fWhichTrigger
 
std::vector< unsigned int > fPTBTrigs
 
int fTrigSeparation
 
double fWaveformADCWidth
 
double fWaveformADCThreshold
 
int fWaveformADCsOverThreshold
 
double fOpHitADCWidth
 
double fOpHitADCThreshold
 
int fOpHitADCsOverThreshold
 
int fADCdiffThreshold
 
int fADCsOverThreshold
 
bool fUsePedestalDefault
 
bool fUsePedestalFile
 
bool fUsePedestalFileSearchPath
 
std::string fPedestalFile
 
std::string fPedestalFileSearchPath
 
int fSkipNInputEvents
 
int fSkipNOutputEvents
 
bool RCEsPresent = true
 
int gSkippedOuputEvents = 0
 
std::vector< std::pair< std::pair< unsigned int, unsigned int >, lbne::TpcNanoSlice::Header::nova_timestamp_t > > DigitsIndexList
 
std::map< uint16_t, std::map< size_t, std::pair< float, float > > > AllPedMap
 
std::map< int, int > fPTBMap
 

Detailed Description

Definition at line 607 of file SplitterInput_source.cc.

Member Typedef Documentation

Definition at line 631 of file SplitterInput_source.cc.

Definition at line 633 of file SplitterInput_source.cc.

Definition at line 632 of file SplitterInput_source.cc.

Definition at line 628 of file SplitterInput_source.cc.

Definition at line 629 of file SplitterInput_source.cc.

Definition at line 626 of file SplitterInput_source.cc.

Definition at line 627 of file SplitterInput_source.cc.

Constructor & Destructor Documentation

DAQToOffline::Splitter::Splitter ( fhicl::ParameterSet const &  ps,
art::ProductRegistryHelper prh,
art::SourceHelper const &  sh 
)

Definition at line 794 of file SplitterInput_source.cc.

796  :
797  sourceName_("SplitterInput"),
798  lastFileName_(ps.get<vector<string>>("fileNames",{}).back()),
799  file_(),
800  doneWithFiles_(false),
801  // TPCinputTag_("daq:TPC:DAQ"), // "moduleLabel:instance:processName"
802  TPCinputTag_ (ps.get<string>("TPCInputTag")),
803  SparseinputTag_ (ps.get<string>("SparseInputTag")),
804  SSPinputTag_ (ps.get<string>("SSPInputTag")),
805  OpHitinputTag_ (ps.get<string>("OpHitInputTag")),
806  PenninputTag_ (ps.get<string>("PennInputTag")),
807  MCPartinputTag_ (ps.get<string>("MCPartInputTag")),
808  MCTruthinputTag_ (ps.get<string>("MCTruthInputTag")),
809  MCSimChaninputTag_ (ps.get<string>("MCSimChanInputTag")),
810  TPCinputDataProduct_ (ps.get<string>("TPCInputDataProduct")),
811  SSPinputDataProduct_ (ps.get<string>("SSPInputDataProduct")),
812  OpHitinputDataProduct_(ps.get<string>("OpHitInputDataProduct")),
813  PenninputDataProduct_ (ps.get<string>("PennInputDataProduct")),
814  MCPartinputDataProduct_(ps.get<string>("MCPartInputDataProduct")),
815  MCTruthinputDataProduct_(ps.get<string>("MCTruthInputDataProduct")),
816  MCSimChaninputDataProduct_(ps.get<string>("MCSimChanInputDataProduct")),
817  sspReform (ps.get<fhicl::ParameterSet>("SSPReformatter")),
818  fPTBMapFile (ps.get<std::string>("PTBMapFile")),
819  fPTBMapDir (ps.get<std::string>("PTBMapDir")),
820  sh_(sh),
821  TPCinputBranch_(nullptr),
822  SSPinputBranch_(nullptr),
823  OpHitinputBranch_(nullptr),
824  PenninputBranch_(nullptr),
825  EventAuxBranch_(nullptr),
826  nInputEvts_(),
827  runNumber_(1), // Defaults
828  subRunNumber_(0),
829  eventNumber_(),
830  cachedRunNumber_(-1),
832  inputRunNumber_(1),
833  inputSubRunNumber_(1),
835  bufferedDigits_(),
836  dbuf_(),
837  wbuf_(),
838  hbuf_(),
839  cbuf_(),
842  std::placeholders::_1, // artdaq::Fragments
843  std::placeholders::_2, // std::vector< std::pair< std::pair<int,int>, lbne::TpcNanoSlice::Header::nova_timestamp_t > > DigitsIndexList
844  std::placeholders::_3, // lbne::TpcNanoSlice::Header::nova_timestamp_t& firstTimestamp
845  std::placeholders::_4, // the channel map
846  ps.get<bool>("UseRCEChanMap",true), // use the channel map
847  ps.get<bool>("debug",false),
848  ps.get<raw::Compress_t>("compression",raw::kNone),
849  ps.get<unsigned>("zeroThreshold",0) ) ),
850  fRequireRCE (ps.get<bool> ("RequireRCE")),
851  fRequireSSP (ps.get<bool> ("RequireSSP")),
852  fRequireOpHit (ps.get<bool> ("RequireOpHit")),
853  fRequirePTB (ps.get<bool> ("RequirePTB")),
854  fMonteCarlo (ps.get<bool> ("MonteCarlo")),
855  fPostTriggerTicks (ps.get<size_t>("PostTriggerTicks")),
856  fPreTriggerTicks (ps.get<size_t>("PreTriggerTicks")),
857  fNovaTicksPerTPCTick (ps.get<double>("NovaTicksPerTPCTick")),
858  fNovaTicksPerSSPTick (ps.get<double>("NovaTicksPerSSPTick")),
859  fNovaTicksPerCountTick (ps.get<double>("NovaTicksPerCountTick")),
860  fNanoSecondsPerNovaTick(ps.get<double>("NanoSecondsPerNovaTick")),
861  fDebugLevel (ps.get<int> ("DebugLevel")),
862  fTimeStampThreshold (ps.get<double>("TimeStampThreshold")),
863  fMCTrigLevel (ps.get<int> ("MCTrigLevel")),
864  fWhichTrigger (ps.get<std::vector<unsigned int> >("WhichTrigger")),
865  fPTBTrigs (ps.get<std::vector<unsigned int> >("PTBTrigs")),
866  fTrigSeparation (ps.get<int> ("TrigSeparation")),
867  fWaveformADCWidth (ps.get<double>("WaveformADCWidth")),
868  fWaveformADCThreshold (ps.get<double>("WaveformADCThreshold")),
869  fWaveformADCsOverThreshold(ps.get<double>("WaveformADCsOverThreshold")),
870  fOpHitADCWidth (ps.get<double>("OpHitADCWidth")),
871  fOpHitADCThreshold (ps.get<double>("OpHitADCThreshold")),
872  fOpHitADCsOverThreshold(ps.get<double>("OpHitADCsOverThreshold")),
873  fADCdiffThreshold (ps.get<int> ("ADCdiffThreshold")),
874  fADCsOverThreshold (ps.get<int> ("ADCsOverThreshold")),
875  fUsePedestalDefault (ps.get<bool> ("UsePedestalDefault")),
876  fUsePedestalFile (ps.get<bool> ("UsePedestalFile")),
877  fUsePedestalFileSearchPath(ps.get<bool> ("UsePedestalFileSearchPath",false)),
878  fPedestalFile (ps.get<std::string>("PedestalFile")),
879  fPedestalFileSearchPath(ps.get<std::string>("PedestalFileSearchPath", "")),
880  fSkipNInputEvents (ps.get<int> ("SkipNInputEvents")),
881  fSkipNOutputEvents (ps.get<int> ("SkipNOutputEvents"))
882 {
884  // Will use same instance names for the outgoing products as for the
885  // incoming ones.
890  // If looking at Monte Carlo, also want to copy the truth information to the split event.
891  if (fMonteCarlo) {
895  //prh.produces< art::Assns< simb::MCParticle, simb::MCTruth> >( MCPartinputTag_.instance() );
896  }
897  //std::cout << "Built TPC Channel Map" << std::endl;
899 }
enum raw::_compress Compress_t
art::SubRunNumber_t inputSubRunNumber_
static const double ps
Definition: Units.h:103
std::string string
Definition: nybbler.cc:12
std::unique_ptr< TFile > file_
void BuildPTBChannelMap(std::string MapDir, std::string MapFile, std::map< int, int > &channelMap)
art::SubRunNumber_t subRunNumber_
vector< sim::SimChannel > MCSimChan_t
vector< simb::MCParticle > MCPart_t
std::string const & instance() const noexcept
Definition: InputTag.cc:82
vector< ExternalTrigger > PennCounters_t
art::SourceHelper const & sh_
art::EventNumber_t inputEventNumber_
art::SubRunNumber_t cachedSubRunNumber_
no compression
Definition: RawTypes.h:9
std::vector< unsigned int > fPTBTrigs
art::EventNumber_t eventNumber_
std::vector< raw::RawDigit > tpcFragmentToRawDigits(artdaq::Fragments const &rawFragments, std::vector< std::pair< std::pair< unsigned int, unsigned int >, lbne::TpcNanoSlice::Header::nova_timestamp_t > > &DigitsIndexList, lbne::TpcNanoSlice::Header::nova_timestamp_t &firstTimestamp, art::ServiceHandle< lbne::ChannelMapService > const &channelMap, bool useChannelMap, bool debug, raw::Compress_t compression, unsigned int zeroThreshold)
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
SSPReformatterAlgs sspReform
vector< RawDigit > rawDigits_t
art::RunNumber_t inputRunNumber_
vector< recob::OpHit > OpHits_t
art::RunNumber_t cachedRunNumber_
vector< simb::MCTruth > MCTruth_t
std::map< int, int > fPTBMap
std::vector< RawDigit::ADCvector_t > dbuf_
std::vector< unsigned int > fWhichTrigger
std::function< rawDigits_t(artdaq::Fragments const &, std::vector< std::pair< std::pair< unsigned int, unsigned int >, lbne::TpcNanoSlice::Header::nova_timestamp_t > > &, lbne::TpcNanoSlice::Header::nova_timestamp_t &, art::ServiceHandle< lbne::ChannelMapService > const &)> fragmentsToDigits_
vector< OpDetWaveform > SSPWaveforms_t

Member Function Documentation

void DAQToOffline::Splitter::CheckTimestamps ( bool JumpEvent,
size_t &  JumpNADC 
)
private

Definition at line 1552 of file SplitterInput_source.cc.

1552  {
1553  int StampDiff = loadedDigits_.getTimeStampAtIndex(loadedDigits_.index, fNovaTicksPerTPCTick) - prev_timestamp;
1554  if (fDebugLevel) std::cout << "\n" << StampDiff << " = " << loadedDigits_.getTimeStampAtIndex(loadedDigits_.index, fNovaTicksPerTPCTick) << " - " << prev_timestamp << std::endl;
1555  if ( fabs(StampDiff) > fTimeStampThreshold ) { // Timestamps of old and new file too far apart. So want to clear all previously loaded event.
1556  if (fDebugLevel) std::cout << "\nThe absolute gap between timestamps is " << fabs(StampDiff) << " which is more than the threshold " << fTimeStampThreshold << std::endl;
1557  bool fixed = false;
1558  if ( StampDiff < 0 ) { // got overlapping timestamps.
1559  if (fDebugLevel) std::cout << "Stamp diff is negative...need to figure out how to try and fix..." << std::endl;
1560  //fixed = true;
1561  } else {
1562  if (fDebugLevel) std::cout << "Stamp diff is positive...need to figure out how to try and fix..." << std::endl;
1563  //fixed=true;
1564  }
1565  if (!fixed) {
1566  if (fDebugLevel) std::cout << "\nCan't reconcile the timestamps, so voiding this trigger :( \n" << std::endl;
1567  Reset();
1569  if (fPreTriggerTicks > loadedDigits_.digits[0].NADC() ) {
1570  JumpEvent = true;
1571  JumpNADC = loadedDigits_.digits[0].NADC();
1572  }
1574  this_timestamp = loadedDigits_.getTimeStampAtIndex(loadedDigits_.index, fNovaTicksPerTPCTick);
1575  fLastTriggerIndex = 0;
1576  } else {
1577  if (fDebugLevel) std::cout << "\nRectified the timestamps, carry on building event :D\n" << std::endl;
1578  }
1579  } else {
1580  if (fDebugLevel) std::cout << "\nTimestamps lead on from each other, carry on :)" << std::endl;
1581  }
1582 } // Check Timestamps
lbne::TpcNanoSlice::Header::nova_timestamp_t this_timestamp
lbne::TpcNanoSlice::Header::nova_timestamp_t prev_timestamp
QTextStream & endl(QTextStream &s)
void DAQToOffline::Splitter::CheckTrigger ( )
private

Definition at line 1643 of file SplitterInput_source.cc.

1643  {
1644  size_t TempEventIndex = EventIndex_ -1;
1645  art::EventNumber_t TempEventNumber = inputEventNumber_;
1646  size_t TempTriggerIndex = loadedDigits_.index;
1647  lbne::TpcNanoSlice::Header::nova_timestamp_t TempTimeStamp = this_timestamp;
1648  size_t TempNADCs = loadedDigits_.digits[0].NADC();
1649 
1650  if (fDebugLevel) std::cout << "\nTrying to Trigger on timestamp " << this_timestamp << std::endl;
1651 
1652  //******** Now to sort out the prebuffer!!! ***********
1653  int BufferResidual = loadedDigits_.index - fPreTriggerTicks;
1654  if ( BufferResidual > 0 ) {
1655  if (fDebugLevel) {
1656  std::cout << "I have enough previous digits in this event for the prebuffer (" << BufferResidual << " = " << loadedDigits_.index << " - " << fPreTriggerTicks
1657  << ")! Moving loadedDigits_.index to " << BufferResidual << std::endl;
1658  }
1659  loadedDigits_.index = BufferResidual;
1660  }
1661  else { // Don't have enough ticks in the event for the prebuffer :( so need to load previous events!
1662  BufferResidual = -BufferResidual;
1663  lbne::TpcNanoSlice::Header::nova_timestamp_t TrigEvStart = loadedDigits_.getTimeStampAtIndex(loadedDigits_.index, fNovaTicksPerTPCTick);
1664  if (fDebugLevel) {
1665  std::cout << "I don't have enough previous digits :(, I need an extra " << BufferResidual << " ticks from previous events. TrigEvStart = " << TrigEvStart
1666  << ". I'm going to have to load the previous event to try and find these ticks..."
1667  << std::endl;
1668  }
1669  // ASSUMPTION! Only worth loading the previous event, as won't want more than one readout of pretrigger window.
1670  if (EventIndex_ < 3) {
1671  std::cout << "No previous event to load, so can't get a good event. Voiding the trigger." << std::endl;
1672  } else {
1673  loadedDigits_.index = 0; // Clear loadedDigits
1674  loadedDigits_.clear(fDebugLevel); // Clear loadedDigits
1677  this_timestamp = loadedDigits_.getTimeStampAtIndex(loadedDigits_.index, fNovaTicksPerTPCTick);
1678  if ( BufferResidual - (int)loadedDigits_.digits[0].NADC() < 0 ) {
1679  loadedDigits_.index = loadedDigits_.digits[0].NADC() - BufferResidual;
1680  if (fDebugLevel)
1681  std::cout << "I have satisfied the pretrigger conditions, on the previous EventIndex " << EventIndex_-1 << " corresponding to event " << inputEventNumber_ << ". It has " << loadedDigits_.digits[0].NADC()
1682  << " ADCs, so switching the index to " << loadedDigits_.index << std::endl;
1683  } else { // ^ If enough ticks in previous event to satisfy pre-trigger ^
1684  if (fDebugLevel)
1685  std::cout << "I can't satisfy the pretrigger conditions, on the previous event. So loading old event :(" << std::endl;
1686  loadedDigits_.index = 0; // Clear loadedDigits
1687  loadedDigits_.clear(fDebugLevel); // Clear loadedDigits
1688  EventIndex_ = TempEventIndex;
1690  loadedDigits_.index = TempTriggerIndex;
1691  fTrigger = false;
1692  std::cout << "Have I reloaded everything properly?"
1693  << "\nEventIndex " << TempEventIndex << ", Event " << TempEventNumber << ", Index " << TempTriggerIndex << ", NADCs " << TempNADCs
1694  << "\nEventIndex " << EventIndex_-1 << ", Event " << inputEventNumber_ << ", Index " << loadedDigits_.index << ", NADCs " << loadedDigits_.digits[0].NADC()
1695  << std::endl;
1696  } // ^ If NOT enough ticks in previous event to satisfy pre-trigger ^
1697  } // If can load previous event
1698  } // If need to load previous event for pre-trigger
1699  this_timestamp = loadedDigits_.getTimeStampAtIndex(loadedDigits_.index, fNovaTicksPerTPCTick); // Set this_timestamp to whatever it now is....
1700 
1701  if ( fTrigger ) { // If trigger is still good!
1702  fLastTriggerIndex = TempTriggerIndex;
1703  fLastEventIndex = TempEventIndex;
1704  fLastEvent = TempEventNumber;
1705  fLastTimeStamp = TempTimeStamp;
1706  }
1707  else {
1708  loadedDigits_.index = TempTriggerIndex + BufferResidual; // Jump to where the trigger was plus buffer residual
1709  if (fDebugLevel) {
1710  std::cout << "Trigger isn't good so I'm going back to where I triggered..."
1711  << "Attempted trigger was in EventIndex " << TempEventIndex << ", event " << TempEventNumber << " at index " << TempTriggerIndex
1712  << " at timestamp " << TempTimeStamp << ", it had " << TempNADCs << " ADCs."
1713  << "\nI'm now at event " << inputEventNumber_ << " index " << loadedDigits_.index
1714  << " and timestamp " << loadedDigits_.getTimeStampAtIndex(loadedDigits_.index, fNovaTicksPerTPCTick)
1715  << " and " << loadedDigits_.digits[0].NADC() << " ADCs, loadedDigits empty? " << loadedDigits_.empty(fDebugLevel) << "\n"
1716  << std::endl;
1717  }
1718  }
1719 }
bool loadEvents_(size_t &InputTree)
art::EventNumber_t inputEventNumber_
lbne::TpcNanoSlice::Header::nova_timestamp_t fLastTimeStamp
lbne::TpcNanoSlice::Header::nova_timestamp_t this_timestamp
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
QTextStream & endl(QTextStream &s)
void DAQToOffline::Splitter::closeCurrentFile ( )

Definition at line 1290 of file SplitterInput_source.cc.

1290  {
1291  file_.reset(nullptr);
1292  fTree->Fill();
1293 }
std::unique_ptr< TFile > file_
bool DAQToOffline::Splitter::eventIsFull_ ( rawDigits_t const &  v)
private

Definition at line 1296 of file SplitterInput_source.cc.

1296  {
1297  return v.size() == ticksPerEvent_;
1298 }
bool DAQToOffline::Splitter::loadEvents_ ( size_t &  InputTree)
private

Definition at line 1301 of file SplitterInput_source.cc.

1301  {
1302  //std::cout << "At the start of loadEvents..." << std::endl;
1303  if ( LoadEventIndex != nInputEvts_ ) {
1304  if ( !loadedDigits_.empty(fDebugLevel) && fRequireRCE ) return false;
1305 
1306  // I want to look through my map to find correct tree for this event, whilst ensuring I skip the neccessary number of events....
1307  bool GoodTree = false;
1308  size_t LoadTree = 0;
1309  while (!GoodTree) {
1310  int LookingAtIndex = 0;
1311  for (std::map<uint64_t,size_t>::iterator it=EventTreeMap.begin(); it!=EventTreeMap.end(); ++it ) {
1312  ++LookingAtIndex;
1313  if ( LookingAtIndex == (int)LoadEventIndex ) {
1314  // Is this index high enough?
1315  if (LookingAtIndex > fSkipNInputEvents ) {
1316  LoadTree = it->second;
1317  GoodTree = true;
1318  }
1319  break;
1320  }
1321  } // For Loop
1322  if (fDebugLevel > 2)
1323  std::cout << "Looking for event " << LoadEventIndex << ", it was found at TreeIndex " << LookingAtIndex << " but I want to skip " << fSkipNInputEvents << ". Do I load this tree? " << GoodTree << std::endl;
1324  if (!GoodTree) ++LoadEventIndex;
1325  } // While Loop
1326  // I want to look through my map to find correct tree for this event!
1327 
1328  EventAuxBranch_->GetEntry(LoadTree);
1333  if (fDebugLevel > 1)
1334  std::cout << "\nLoading event " << inputEventNumber_ << " at EventIndex " << LoadEventIndex << " on TreeIndex " << LoadTree << std::endl;
1335 
1336  bool PTBTrigPresent = false;
1337  if (fRequirePTB) {
1338  PTBTrigPresent= LoadPTBInformation( LoadTree );
1339  }
1340 
1341  if ( fWhichTrigger.size() == 1 && fWhichTrigger[0] == 3 ) { // If looking for only looking for triggers from the PTB
1342  if ( PTBTrigPresent || fTrigger ) { // Only load RCEs and SSPs if a trigger is present.
1343  if (fRequireSSP) LoadSSPInformation( LoadTree );
1344  if (fRequireRCE) LoadRCEInformation( LoadTree );
1345  } else { // If no PTB trigger is present make sure to clear Digits and Waveforms.
1349  }
1350  } else { // If either not looking for PTB triggers at all, or looking for additional triggers too, then always load RCE/SSP.
1351  if (fRequireSSP) LoadSSPInformation( LoadTree );
1352  if (fRequireRCE) LoadRCEInformation( LoadTree );
1353  }
1354  // If Looking at MonteCarlo, also want to load in some other stuff....
1355  if (fMonteCarlo) {
1356  auto *particles = getMCParticles(MCPartinputBranch_, LoadTree);
1357  MonteCarlo_.loadMCParts(*particles);
1358  auto *truths = getMCTruths(MCTruthinputBranch_, LoadTree);
1359  mctruth_ = *truths;
1360  auto *simchans = getMCSimChans(MCSimChaninputBranch_, LoadTree);
1361  MonteCarlo_.loadSimChans(*simchans);
1362  }
1363 
1364  LoadEventIndex++;
1365  return true;
1366  }
1367  else return false;
1368 } // load digits
SubRunNumber_t subRun() const noexcept
intermediate_table::iterator iterator
art::SubRunNumber_t inputSubRunNumber_
EventNumber_t event() const noexcept
void LoadRCEInformation(size_t LoadTree)
art::EventAuxiliary evAux_
art::EventNumber_t inputEventNumber_
std::map< uint64_t, size_t > EventTreeMap
RunNumber_t run() const noexcept
void LoadSSPInformation(size_t LoadTree)
art::RunNumber_t inputRunNumber_
bool LoadPTBInformation(size_t LoadTree)
std::vector< unsigned int > fWhichTrigger
Timestamp const & time() const noexcept
QTextStream & endl(QTextStream &s)
bool DAQToOffline::Splitter::LoadPTBInformation ( size_t  LoadTree)
private

Definition at line 1370 of file SplitterInput_source.cc.

1370  {
1371  bool TrigPresent = false;
1372  if (PenninputDataProduct_.find("Fragment") != std::string::npos) {
1373  auto* PennFragments = getFragments ( PenninputBranch_, LoadTree );
1374  lbne::PennMicroSlice::Payload_Timestamp *FirstPTBTimestamp = nullptr;
1375  std::vector<raw::ExternalTrigger> counters = DAQToOffline::PennFragmentToExternalTrigger( *PennFragments, fPTBMap, FirstPTBTimestamp );
1376  loadedCounters_.load( counters, fDebugLevel );
1377  if (fDebugLevel > 1) std::cout << "Counters has size " << counters.size() << std::endl;
1378 
1379  for (size_t CountLoop = 0; CountLoop < counters.size(); ++CountLoop) {
1380  if (fDebugLevel > 3 )
1381  std::cout << "Looking at counters[" << CountLoop << "] has CounterID " << counters[CountLoop].GetTrigID() << " and Timestamp " << counters[CountLoop].GetTrigTime() << std::endl;
1382  for (size_t PTB = 0; PTB < fPTBTrigs.size(); ++PTB) {
1383  if ( counters[CountLoop].GetTrigID() == fPTBTrigs[PTB] ) {
1384  if (fDebugLevel) std::cout << "\nThere is a trigger on channel " << counters[CountLoop].GetTrigID() << " at time " << counters[CountLoop].GetTrigTime() << " in event " << inputEventNumber_ << std::endl;
1385  TrigPresent = true;
1386  }
1387  }
1388  }
1389  } else {
1390  auto *counters = getRawExternalTriggers(PenninputBranch_, LoadTree );
1391  loadedCounters_.load( *counters, fDebugLevel );
1392  if (fDebugLevel > 1) {
1393  std::cout << "Counters has size" << counters->size() << std::endl;
1394  }
1395 
1396  for (auto count: *counters) {
1397  if (fDebugLevel > 3 )
1398  std::cout << "Looking at a counter which has CounterID " << count.GetTrigID() << " and Timestamp " << count.GetTrigTime() << std::endl;
1399  for (size_t PTB = 0; PTB < fPTBTrigs.size(); ++PTB) {
1400  if ( count.GetTrigID() == fPTBTrigs[PTB] ) {
1401  if (fDebugLevel) std::cout << "Looking at event " << inputEventNumber_ << ", there is a trigger here on channel " << count.GetTrigID() << std::endl;
1402  TrigPresent = true;
1403  }
1404  }
1405  }
1406  }
1407  return TrigPresent;
1408 }
art::EventNumber_t inputEventNumber_
std::vector< unsigned int > fPTBTrigs
std::map< int, int > fPTBMap
std::vector< raw::ExternalTrigger > PennFragmentToExternalTrigger(artdaq::Fragments const &Fragments, std::map< int, int > &channelMap, lbne::PennMicroSlice::Payload_Timestamp *&FirstPTBTimestamp)
QTextStream & endl(QTextStream &s)
void DAQToOffline::Splitter::LoadRCEInformation ( size_t  LoadTree)
private

Definition at line 1451 of file SplitterInput_source.cc.

1451  {
1452  if (TPCinputDataProduct_.find("Fragment") != std::string::npos) {
1453  //RCEsPresent = true;
1454  lbne::TpcNanoSlice::Header::nova_timestamp_t firstTimestamp = 0;
1455  auto* fragments = getFragments( TPCinputBranch_, LoadTree );
1457  rawDigits_t const digits = fragmentsToDigits_( *fragments, DigitsIndexList, firstTimestamp, TPCChannelMap );
1458  if (!digits.size() && EventIndex_ == 0) {
1459  RCEsPresent = false;
1460  fRequireRCE = false;
1461  }
1462  loadedDigits_.load( digits, fDebugLevel );
1463  loadedDigits_.loadTimestamp( firstTimestamp );
1464  if (fDebugLevel > 1) std::cout << "Loaded RCE information with timestamp " << firstTimestamp << std::endl;
1465  }
1466  else {
1467  auto* digits = getRawDigits(TPCinputBranch_, LoadTree );
1468  loadedDigits_.load( *digits, fDebugLevel);
1469  loadedDigits_.loadTimestamp(0); // MC timestamp is zero (? assume?)
1470  if (fDebugLevel > 1) std::cout << "Loaded MC RCE's with timestamp 0" << std::endl;
1471  }
1472 }
vector< RawDigit > rawDigits_t
std::vector< std::pair< std::pair< unsigned int, unsigned int >, lbne::TpcNanoSlice::Header::nova_timestamp_t > > DigitsIndexList
std::function< rawDigits_t(artdaq::Fragments const &, std::vector< std::pair< std::pair< unsigned int, unsigned int >, lbne::TpcNanoSlice::Header::nova_timestamp_t > > &, lbne::TpcNanoSlice::Header::nova_timestamp_t &, art::ServiceHandle< lbne::ChannelMapService > const &)> fragmentsToDigits_
QTextStream & endl(QTextStream &s)
void DAQToOffline::Splitter::LoadSSPInformation ( size_t  LoadTree)
private

Definition at line 1410 of file SplitterInput_source.cc.

1410  {
1411  if (SSPinputDataProduct_.find("Fragment") != std::string::npos) {
1412  auto* SSPfragments = getFragments( SSPinputBranch_, LoadTree );
1413  std::vector<raw::OpDetWaveform> waveforms;
1414  std::vector<recob::OpHit> hits;
1415  sspReform.SSPFragmentToWaveformsAndHits(*SSPfragments, waveforms, hits);
1416  if (fDebugLevel > 3 ) {
1417  for ( size_t WaveLoop=0; WaveLoop < waveforms.size(); ++WaveLoop ) {
1418  int64_t SSPTime = waveforms[WaveLoop].TimeStamp()*fNovaTicksPerSSPTick;
1419  std::cout << "Looking at waveform[" << WaveLoop << "] it has channel number " << waveforms[WaveLoop].ChannelNumber()
1420  << " and timestamp " << SSPTime << ", and size " << waveforms[WaveLoop].size() << std::endl;
1421  }
1422  for ( size_t HitLoop=0; HitLoop < hits.size(); ++HitLoop ) {
1423  int64_t OpHitTime = hits[HitLoop].PeakTime()*fNovaTicksPerSSPTick;
1424  std::cout << "Looking at waveform[" << HitLoop << "] it is on channel number " << hits[HitLoop].OpChannel() << " at timestamp " << OpHitTime << std::endl;
1425  }
1426  }
1427 
1428  if (fDebugLevel > 1)
1429  std::cout << "Loaded waveforms has size " << waveforms.size() << ", and OpHits has size " << hits.size() << std::endl;
1430  if (waveforms.size() && hits.size()) std::cout << "\n They Both have non-zero size!!!!\n\n\n" << std::endl;
1431  loadedWaveforms_.load( waveforms, fDebugLevel );
1432  loadedOpHits_.load ( hits , fDebugLevel );
1433  }
1434  else {
1435  auto* waveforms = getSSPWaveforms(SSPinputBranch_, LoadTree );
1436  if (fDebugLevel > 1) std::cout << "Loaded waveforms has size " << waveforms->size() << std::endl;
1437  loadedWaveforms_.load( *waveforms, fDebugLevel );
1438  if ( evAux_.isRealData() ) {
1439  auto* hits = getOpHits(OpHitinputBranch_, LoadTree );
1440  if (fDebugLevel > 1) std::cout << "Loaded OpHits has size " << hits->size() << std::endl;
1441  loadedOpHits_.load( *hits, fDebugLevel );
1442  } else {
1443  std::vector<recob::OpHit> hits;
1444  hits.clear();
1445  loadedOpHits_.load( hits, fDebugLevel );
1446  }
1447  }
1448  return;
1449 }
void SSPFragmentToWaveformsAndHits(artdaq::Fragments const &rawFragments, std::vector< raw::OpDetWaveform > &opDetWaveformVector, std::vector< recob::OpHit > &opHitVector)
art::EventAuxiliary evAux_
SSPReformatterAlgs sspReform
signed __int64 int64_t
Definition: stdint.h:135
bool isRealData() const noexcept
QTextStream & endl(QTextStream &s)
void DAQToOffline::Splitter::makeEventAndPutDigits_ ( art::EventPrincipal *&  outE,
art::Timestamp  art_timestamp = 0 
)
private

Definition at line 1474 of file SplitterInput_source.cc.

1474  {
1475  // just keep incrementing the event number as we split along
1476  ++eventNumber_;
1477 
1478  for (size_t TrigSize = 0; TrigSize < fWhichTrigger.size(); ++TrigSize) {
1479  if ( fWhichTrigger[TrigSize] == 0 && fDebugLevel) {
1480  std::cout << "\n\n\nI hope you know that you are triggering on a random number of ticks and not any sort of data! Check that fwhichTrigger is set correctly.\n\n\n" << std::endl;
1481  }
1482  }
1483  std::cout << "\nMaking an event with RunNumber " << runNumber_ << ", subRunNumber " << subRunNumber_ << ", EventNumber " << eventNumber_ << " and art_timestamp " << art_timestamp.value() << std::endl;
1484 
1486  art::put_product_in_principal( std::make_unique<rawDigits_t>(bufferedDigits_),
1487  *outE,
1488  sourceName_,
1489  TPCinputTag_.instance() );
1490  art::put_product_in_principal( std::make_unique<SSPWaveforms_t>(wbuf_),
1491  *outE,
1492  sourceName_,
1493  SSPinputTag_.instance() );
1494  art::put_product_in_principal( std::make_unique<OpHits_t>(hbuf_),
1495  *outE,
1496  sourceName_,
1498  art::put_product_in_principal( std::make_unique<PennCounters_t>(cbuf_),
1499  *outE,
1500  sourceName_,
1501  PenninputTag_.instance() );
1502 
1503  if (fMonteCarlo) {
1504  art::put_product_in_principal( std::make_unique<MCPart_t>(mcbuf_),
1505  *outE,
1506  sourceName_,
1508  art::put_product_in_principal( std::make_unique<MCTruth_t>(mctruth_),
1509  *outE,
1510  sourceName_,
1512  art::put_product_in_principal( std::make_unique<MCSimChan_t>(simchanbuf_),
1513  *outE,
1514  sourceName_,
1516  //std::unique_ptr< art::Assns< simb::MCParticle, simb::MCTruth> > assn( new art::Assns<simb::MCParticle, simb::MCTruth> );
1517  //util::CreateAssn(*this, eventNumber_, mcbuf_, mctruth_, *assn);
1518  //art::put_product_in_principal( std::make_unique_ptr<art::Assns< simb::MCParticle, simb::MCTruth> >(assn),
1519  // *outE,
1520  // sourceName_,
1521  // MCPartinputTag_.instance() );
1522  }
1529  ++AttemptedEvents;
1530  ++GoodEvents;
1531 
1532  mf::LogDebug("SplitterFunc") << "Producing event: " << outE->eventID() << " with " << bufferedDigits_.size() << " RCE digits and " <<
1533  wbuf_.size() << " SSP waveforms, " << hbuf_.size() << " OpHits and " << cbuf_.size() << " External Triggers (muon counters)";
1534  Reset();
1535 }
EventID const & eventID() const
Definition: Principal.cc:1121
art::SubRunNumber_t subRunNumber_
std::string const & instance() const noexcept
Definition: InputTag.cc:82
art::SourceHelper const & sh_
art::EventAuxiliary evAux_
constexpr TimeValue_t value() const
Definition: Timestamp.h:23
art::EventNumber_t eventNumber_
EventAuxiliary::ExperimentType experimentType() const noexcept
size_t size
Definition: lodepng.cpp:55
std::enable_if_t<!detail::range_sets_supported(P::branch_type)> put_product_in_principal(std::unique_ptr< T > &&product, P &principal, std::string const &module_label, std::string const &instance_name={})
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::unique_ptr< History > &&history) const
bool isRealData() const noexcept
std::vector< unsigned int > fWhichTrigger
QTextStream & endl(QTextStream &s)
bool DAQToOffline::Splitter::NoRCEsCase ( art::RunPrincipal *&  outR,
art::SubRunPrincipal *&  outSR,
art::EventPrincipal *&  outE 
)
private

Definition at line 1584 of file SplitterInput_source.cc.

1584  {
1585  fCheatPTBTrig = fCheatSSPTrig = true; // Want to 'cheat' SSP and PTB trigs in this case. Cheat means look over whole event time, not a small range of ticks.
1586  while (!fTrigger) {
1587  bool NewTree = false;
1588  // Whilst LoadedWaveforms and LoadedCounters are empty, load a new event...
1589  while (!NewTree) {
1590  if( loadedWaveforms_.empty() && loadedOpHits_.empty() ) {
1591  bool rc = loadEvents_(EventIndex_);
1592  if (!rc) {
1593  doneWithFiles_ = (file_->GetName() == lastFileName_);
1594  return false;
1595  }
1596  } else NewTree = true;
1597  } // while not NewTree ( Waveforms and OpHits are empty )
1598  std::map<int,int> PrevChanADC;
1599  std::vector<short> ADCdigits;
1600  Triggering(PrevChanADC, ADCdigits, NewTree);
1601  }
1602  wbuf_ = loadedWaveforms_.TakeAll();
1603  hbuf_ = loadedOpHits_.TakeAll();
1604  cbuf_ = loadedCounters_.TakeAll();
1605  if (fDebugLevel) std::cout << "After looking at EventIndex_ " << EventIndex_-1 << ", event " << inputEventNumber_ << " wbuf, hbuf cbuf have sizes " << wbuf_.size() << ", " << hbuf_.size() << ", " << cbuf_.size() << std::endl;
1606 
1607  // ******** Now Build the event *********
1610  //art::Timestamp ts; // LBNE should decide how to initialize this -- use first_timestamp converted into an art::Timestamp
1611  //FIXME - This is a first attempt at interpreting the novatimestamp from the tpc data to create an art event timestamp
1612  if (cbuf_.size()) {
1613  Event_timestamp = cbuf_[0].GetTrigTime();
1614  if (wbuf_.size() && wbuf_[0].TimeStamp() < Event_timestamp) Event_timestamp = wbuf_[0].TimeStamp();
1615  if (hbuf_.size() && hbuf_[0].PeakTime() < Event_timestamp) Event_timestamp = hbuf_[0].PeakTime();
1616  } else {
1617  if (wbuf_.size()) {
1618  Event_timestamp = wbuf_[0].TimeStamp();
1619  if (hbuf_.size() && hbuf_[0].PeakTime() < Event_timestamp) Event_timestamp = hbuf_[0].PeakTime();
1620  } else Event_timestamp = hbuf_[0].PeakTime();
1621  }
1622 
1624  if ( runNumber_ != cachedRunNumber_ ) {
1625  outR = sh_.makeRunPrincipal(runNumber_,this_art_event_timestamp);
1627  eventNumber_ = 0ul;
1628  }
1630  outSR = sh_.makeSubRunPrincipal(runNumber_,subRunNumber_,this_art_event_timestamp);
1632  eventNumber_ = 0ul;
1633  }
1634  //inputEventTime_ is the art::Timestamp() of the online art::Event() used to create the offline art::Event()
1635  makeEventAndPutDigits_( outE, this_art_event_timestamp );
1636  Reset();
1638  loadedOpHits_.clear(fDebugLevel);
1640  return true;
1641 }
void Triggering(std::map< int, int > &PrevChanADC, std::vector< short > ADCdigits, bool NewTree)
art::SubRunNumber_t inputSubRunNumber_
bool loadEvents_(size_t &InputTree)
std::unique_ptr< TFile > file_
art::SubRunNumber_t subRunNumber_
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
art::SourceHelper const & sh_
art::EventNumber_t inputEventNumber_
art::SubRunNumber_t cachedSubRunNumber_
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:94
art::EventNumber_t eventNumber_
lbne::TpcNanoSlice::Header::nova_timestamp_t Event_timestamp
void makeEventAndPutDigits_(art::EventPrincipal *&outE, art::Timestamp art_timestamp=0)
art::Timestamp make_art_timestamp_from_nova_timestamp(lbne::TpcNanoSlice::Header::nova_timestamp_t this_nova_timestamp)
art::RunNumber_t inputRunNumber_
art::RunNumber_t cachedRunNumber_
QTextStream & endl(QTextStream &s)
bool DAQToOffline::Splitter::readFile ( string const &  filename,
art::FileBlock *&  fb 
)

Definition at line 902 of file SplitterInput_source.cc.

902  {
903  //std::cout << "At the top of readFile" << std::endl;
904  // Get fragments branches
905  file_.reset( new TFile(filename.data()) );
906  TTree* evtree = reinterpret_cast<TTree*>(file_->Get(art::rootNames::eventTreeName().c_str()));
907 
908  TPCinputBranch_ = evtree->GetBranch( getBranchName(TPCinputTag_ , TPCinputDataProduct_ ) ); // get branch for TPC input tag
909  SparseinputBranch_ = evtree->GetBranch( getBranchName(SparseinputTag_, SSPinputDataProduct_ ) ); // get branch for Sparsified input tag
910  SSPinputBranch_ = evtree->GetBranch( getBranchName(SSPinputTag_ , SSPinputDataProduct_ ) ); // get branch for SSP input tag
911  OpHitinputBranch_ = evtree->GetBranch( getBranchName(OpHitinputTag_ , OpHitinputDataProduct_ ) ); // get branch for OpHit input tag
912  PenninputBranch_ = evtree->GetBranch( getBranchName(PenninputTag_ , PenninputDataProduct_ ) ); // get branch for Penn Board input tag
913 
914  MCPartinputBranch_ = evtree->GetBranch( getBranchName(MCPartinputTag_ , MCPartinputDataProduct_ ) ); // MCParticle input tag
915  MCTruthinputBranch_ = evtree->GetBranch( getBranchName(MCTruthinputTag_ , MCTruthinputDataProduct_ ) ); // MCTruth input tag
916  MCSimChaninputBranch_ = evtree->GetBranch( getBranchName(MCSimChaninputTag_, MCSimChaninputDataProduct_ ) ); // SimChannel input tag
917 
918  if (TPCinputBranch_) nInputEvts_ = static_cast<size_t>( TPCinputBranch_->GetEntries() );
919  size_t nevt_ssp = 0;
920  if (SparseinputBranch_)
921  nevt_ssp = static_cast<size_t>( SparseinputBranch_->GetEntries() );
922  if (nevt_ssp) {
924  if (fDebugLevel) std::cout << "There is data on the Sparsified branch, so using that." << std::endl;
925  }
926  if (!nevt_ssp)
927  if (SSPinputBranch_)
928  nevt_ssp = static_cast<size_t>( SSPinputBranch_->GetEntries() );
929  size_t nevt_penn = 0;
930  if (PenninputBranch_) nevt_penn = static_cast<size_t>( PenninputBranch_->GetEntries());
931 
932  if (nevt_ssp != nInputEvts_&& nevt_ssp) throw cet::exception("35-ton SplitterInput: Different numbers of RCE and SSP input events in file");
933  if (nevt_penn != nInputEvts_&& nevt_penn) throw cet::exception("35-ton SplitterInput: Different numbers of RCE and Penn input events in file");
934  EventIndex_ = 0ul;
935 
936  EventAuxBranch_ = evtree->GetBranch( "EventAuxiliary" );
937  pevaux_ = &evAux_;
938  EventAuxBranch_->SetAddress(&pevaux_);
939 
940  // ------------ Make my sorted event branch --------------------
941  EventTreeMap.clear();
942  art::RunNumber_t TreeRunNumber; uint16_t IntRunNumber;
943  art::SubRunNumber_t TreeSubRunNumber; uint16_t IntSubRunNumber;
944  art::EventNumber_t TreeEventNumber; uint32_t IntEventNumber;
945  uint64_t CombinedInt;
946 
947  std::cout << "\nfDebugLevel is " << fDebugLevel << ", PedestalDefault is " << fUsePedestalDefault << " fUsePedestalFile is " << fUsePedestalFile << std::endl;
948 
949  art::RunNumber_t PrevRunNumber = -1;
950  for (size_t Tree=1; Tree < nInputEvts_; ++Tree) {
951  EventAuxBranch_->GetEntry(Tree); TreeRunNumber = evAux_.run(); //Get the run number
952  IntRunNumber = (int)TreeRunNumber; TreeSubRunNumber = evAux_.subRun(); IntSubRunNumber = (int)TreeSubRunNumber; //Get the subrun number
953  TreeEventNumber = evAux_.event(); IntEventNumber = (int)TreeEventNumber; //Get the event number
954  CombinedInt = (uint64_t) IntRunNumber << 16 | IntSubRunNumber << 16 | IntEventNumber; // Combine them as a 64 bit int.
955  if (fDebugLevel > 4 )
956  std::cout << "Looking at Tree " << Tree << ", RunNumber " << IntRunNumber << ", SubRunNumber " << IntSubRunNumber << ", EventNumber " << IntEventNumber << ", CrazyNumber " << CombinedInt << std::endl;
957  EventTreeMap[CombinedInt] = Tree; // Add that to a tree - use the fact that this will sort them by Run, Subrun, Event.
958 
959  art::RunNumber_t ThisNumber = evAux_.run();;
960  if (ThisNumber != PrevRunNumber ) {
961  if ( evAux_.isRealData() ) { // If real data subtract pedestal conditions
962  dune::DetPedestalDUNE pedestals("dune35t");
963  pedestals.SetDetName("dune35t");
964  pedestals.SetUseDefaults(fUsePedestalDefault);
965  if ( fUsePedestalFile ) {
966  std::string fullname;
968  if( fPedestalFileSearchPath != "" ){
969  std::cout << "SplitterStitcher: fPedestalFileSearchPath: " << fPedestalFileSearchPath << " fPedestalFile: " << fPedestalFile << std::endl;
971  if(fPedestalFile != "" ) sp.find_file(fPedestalFile, fullname);
972  else fullname = cet::getenv(fPedestalFileSearchPath);
973  }//fPedestalFileSearchPath != ""
974  else{
975  std::cout << "SplitterStitcher: fPedestalFileSearchPath: " << fPedestalFileSearchPath << " fPedestalFile: " << fPedestalFile << std::endl;
976  fullname = fPedestalFile;
977  }
978  }//fUsePedestalFileSearchPath
979  else fullname = fPedestalFile;
980 
981  std::cout << "SplitterStitcher: Setting CSVFileName to " << fullname << std::endl;
982  pedestals.SetCSVFileName(fullname);
983  } else {
984  pedestals.SetUseDB(true);
985  }
986  pedestals.Update(ThisNumber);
987  for (size_t ichan=0;ichan<2048;ichan++) {
988  AllPedMap[ThisNumber][ichan].first = pedestals.PedMean(ichan);
989  AllPedMap[ThisNumber][ichan].second = pedestals.PedMeanErr(ichan);
990  if (fDebugLevel > 2) {
991  std::cout << "AllPedMap["<<ThisNumber<<"]["<<ichan<<"] has mean " << pedestals.PedMean(ichan) << " (" << AllPedMap[ThisNumber][ichan].first << ")"
992  << "and error " << pedestals.PedMeanErr(ichan) << " (" << AllPedMap[ThisNumber][ichan].second << "). " << std::endl;
993  }
994  }
995  PrevRunNumber = ThisNumber;
996  }
997  }
998  }
999 
1000  // New fileblock
1002  if ( fb == nullptr ) {
1004  << "Unable to open file " << filename << ".\n";
1005  }
1006 
1008  fTree = tfs->make<TTree>("EventInfo","Split event information");
1009  fTree->Branch("AttemptedEvents",&AttemptedEvents,"AttemptedEvents/I");
1010  fTree->Branch("VoidedEvents" ,&VoidedEvents ,"VoidedEvents/I" );
1011  fTree->Branch("GoodEvents" ,&GoodEvents ,"GoodEvents/I" );
1012  fTree->Branch("GivenRunNum" ,&GivenRunNum ,"GivenRunNum[AttemptedEvents]/I" );
1013  fTree->Branch("GivenSubRunNum" ,&GivenSubRunNum ,"GivenSubRunNum[AttemptedEvents]/I" );
1014  fTree->Branch("GivenEventNum" ,&GivenEventNum ,"GivenEventNum[AttemptedEvents]/I" );
1015  fTree->Branch("TreeIndexStart" ,&TreeIndexStart ,"TreeIndexStart[AttemptedEvents]/I" );
1016  fTree->Branch("ChansAtStartOfEvent",&ChansAtStartOfEvent,"ChansAtStartOfEvent[AttemptedEvents]/I");
1017  fTree->Branch("ChansAtEndOfEvent" ,&ChansAtEndOfEvent ,"ChansAtEndOfEvent[AttemptedEvents]/I" );
1018 
1020  for (size_t q=0; q<ArraySize; ++q)
1022 
1023  return true;
1024 }
SubRunNumber_t subRun() const noexcept
std::string string
Definition: nybbler.cc:12
EventNumber_t event() const noexcept
std::unique_ptr< TFile > file_
unsigned short uint16_t
Definition: stdint.h:125
art::EventAuxiliary evAux_
string filename
Definition: train.py:213
std::map< uint64_t, size_t > EventTreeMap
RunNumber_t run() const noexcept
art::EventAuxiliary * pevaux_
unsigned int uint32_t
Definition: stdint.h:126
std::string getenv(std::string const &name)
Definition: getenv.cc:15
unsigned __int64 uint64_t
Definition: stdint.h:136
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::map< uint16_t, std::map< size_t, std::pair< float, float > > > AllPedMap
const int ArraySize
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
std::string const & eventTreeName()
Definition: rootNames.cc:67
bool isRealData() const noexcept
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120
bool DAQToOffline::Splitter::readNext ( art::RunPrincipal *const &  inR,
art::SubRunPrincipal *const &  inSR,
art::RunPrincipal *&  outR,
art::SubRunPrincipal *&  outSR,
art::EventPrincipal *&  outE 
)

Definition at line 1027 of file SplitterInput_source.cc.

1031  {
1032  //std::cout << "At the start of readNext..." << std::endl;
1033  if (!fRequireRCE) {
1034  std::cout << "Entering NoRCEsCase" << std::endl;
1035  bool Return = NoRCEsCase(outR, outSR, outE);
1036  std::cout << "Left NoRCEsCase" << std::endl;
1037  return Return;
1038  }
1039 
1040  if ( doneWithFiles_ ) {
1041  return false;
1042  }
1044  size_t FirstDigIndex;
1045  size_t FirstDigEventIndex;
1046  size_t FirstDigEvent;
1047  bool first_tick = true; // The earliest time in this new split event, so want to calculate time of this for use with first_timestamp variable only!
1048  bool NewTree;
1049  bool JumpEvent = false;
1050  size_t JumpNADC = 0;
1051 
1052  std::map<int,int> PrevChanADC;
1053  if (fDebugLevel > 3 ) {
1054  std::cout << "\nAt the top of readNext....what do I increment here? " << fTicksAccumulated << " " << ticksPerEvent_ << " " << loadedDigits_.empty(fDebugLevel)
1055  << " " << wbuf_.size() << " " << cbuf_.size() << " " << hbuf_.size() << std::endl;
1056  }
1057  while ( fTicksAccumulated < ticksPerEvent_ ) {
1059  NewTree = false;
1060  prev_timestamp = this_timestamp; // set prev_timestamp to old timestamp
1061 
1062  // ************* Check if loadedDigits is empty... ************************
1063  while (loadedDigits_.empty(fDebugLevel)) {
1064  if (fDebugLevel > 3 ) std::cout << "\nLoaded digits is empty..." << std::endl;
1065  if ( fTrigger ) { // Want to load wbuf with end of last event, before loading new data.
1069  if (fDebugLevel > 2 ) {
1070  std::cout << "Loaded digits was empty, will be refilled..."
1071  << "\nwbuf_ has size " << wbuf_.size() << " at " << first_timestamp << " " << last_timestamp << " " << fNovaTicksPerSSPTick
1072  << "\nhbuf_ has size " << hbuf_.size() << " at " << first_timestamp << " " << last_timestamp << " " << fNovaTicksPerSSPTick
1073  << "\ncbuf_ has size " << cbuf_.size() << " at " << first_timestamp << " " << last_timestamp << " " << fNovaTicksPerCountTick
1074  << std::endl;
1075  }
1076  }
1077  bool rc = loadEvents_(EventIndex_);
1078  //std::cout << "Loaded a new event..." << EventIndex_ << " " << loadedDigits_.empty(fDebugLevel) << " " << loadedWaveforms_.empty()
1079  // << " " << loadedCounters_.empty() << " " << loadedOpHits_.empty() << " " << RCEsPresent << std::endl;
1080  if (!RCEsPresent && (!loadedWaveforms_.empty() || !loadedOpHits_.empty())) {
1081  if (fDebugLevel) std::cout << "\nThe RCEs aren't present, so switching to the don't require RCEs case...." << std::endl;
1082  bool Return = NoRCEsCase(outR, outSR, outE);
1083  return Return;
1084  } // RCEsPresent
1085  if (fDebugLevel > 2) std::cout << "There are a total of " << loadedDigits_.digits[0].NADC() << " ADC's " << std::endl;
1086  if (!rc) {
1087  doneWithFiles_ = (file_->GetName() == lastFileName_);
1088  //std::cout << "Loaded the final file..." << std::endl;
1089  return false;
1090  }
1091  NewTree = true;
1092  first_tick = true; // Just loaded in new event, so want to reset first_timestamp...doesn't effect previous loaded event.
1093  first_timestamp=0, last_timestamp=0; // Want to reset the timestamps.
1094  // ******* Check that the time stamps lead on from one another!! ***********
1095  if ( loadedDigits_.digits.size() != 0 && loadedDigits_.digits[0].NADC() ) {
1096  if (fTrigger ) {
1097  if (loadedDigits_.size() != fChansPresent) {
1098  if (fDebugLevel)
1099  std::cout << "\nThere are inconsistent numbers of digits between this millislice and the previous millislice: "
1100  << loadedDigits_.size() << " not " << fChansPresent << ". This means data is corrupted. Voiding this trigger."
1101  << std::endl;
1108  ++AttemptedEvents;
1109  ++VoidedEvents;
1110  Reset();
1111  } else {
1112  CheckTimestamps( JumpEvent, JumpNADC ); // Check that the time stamps lead on from one another!!
1113  } // If triggered and good digit consistency, check timestamps.
1114  } // If triggered check digit consistency, and timestamps
1115  } // If digits has size
1116  } // loadedDigits_.empty()
1117 
1118  if (NewTree) {
1119  if (JumpEvent) {
1120  loadedDigits_.index = fPreTriggerTicks - JumpNADC;
1121  JumpEvent = false;
1122  JumpNADC = 0;
1123  }
1124  if (fDebugLevel) std::cout << "\nLooking at EventIndex " << EventIndex_-1 << ", index " << loadedDigits_.index << std::endl;
1125  }
1126 
1127  std::vector<short> nextdigits = loadedDigits_.next();
1128  // Check if I am straddling over a readout boundary within this microslice....
1129  if (DigitsIndexList.size() > 1) {
1130  for (unsigned int IndexListLoop = 1; IndexListLoop<DigitsIndexList.size(); ++IndexListLoop ) {
1131  if (loadedDigits_.index-1 == DigitsIndexList[IndexListLoop].first.first) {
1132  if (fDebugLevel) std::cout << "\nI am looking at loadedDigitsIndex " << loadedDigits_.index << ". This is the index where the jump occurs so I want to reset stuff." << std::endl;
1133  Reset();
1134  NewTree = true;
1135  lbne::TpcNanoSlice::Header::nova_timestamp_t NewStamp = DigitsIndexList[IndexListLoop].second - (DigitsIndexList[IndexListLoop].first.first*fNovaTicksPerTPCTick);
1136  loadedDigits_.loadTimestamp(NewStamp);
1137  if (fDebugLevel) std::cout << "I have reset the event... and loaded a new timestamp " << NewStamp << " as opposed to " << DigitsIndexList[IndexListLoop].second << std::endl;
1138  }
1139  }
1140  }
1141  // Get the timestamp for this index.
1142  this_timestamp = loadedDigits_.getTimeStampAtIndex(loadedDigits_.index, fNovaTicksPerTPCTick);
1143  if (fTrigger && fDebugLevel > 4) {
1144  std::cout << "Index " << loadedDigits_.index << " " << fTicksAccumulated << " " << prev_timestamp << " " << this_timestamp << std::endl;
1145  }
1146  // ******* See if can trigger on this tick...only want to do this if haven't already triggered. We also don't want two triggers too close together!... *****************
1148  Triggering (PrevChanADC, nextdigits, NewTree);
1149  } // if TickAccumulated == 0
1150 
1151  // ******* What do we want to do for every tick we have triggered on? *****************
1152  if ( fTrigger ) {
1153  if (fTicksAccumulated == 0 ) { // Have only just triggered!
1154  FirstDigIndex = loadedDigits_.index;
1155  FirstDigEventIndex = EventIndex_ - 1;
1156  FirstDigEvent = inputEventNumber_;
1158  fChansPresent = nextdigits.size();
1159  if (fDebugLevel) {
1160  std::cout << "\nThe trigger is good so triggering on, EventIndex " << fLastEventIndex << " corresponding to event " << fLastEvent
1161  << ", loadedDigits_.index() " << fLastTriggerIndex << ", with timestamp " << fLastTimeStamp << ", there are " << fChansPresent << " digits in this event."
1162  << "\nThe first tick in this event is in EventIndex " << FirstDigEventIndex << ", event " << FirstDigEvent << ", loadedDigits index " << loadedDigits_.index
1163  << ". It has timestamp " << this_timestamp
1164  << std::endl;
1165  }
1166  }
1167  if (first_tick) { // First tick in split event and/or first tick in newly loaded event.
1169  first_tick = false;
1170  }
1172 
1173  // ************* Now want to load the RCE information into dbuf_ ************************
1174  if (dbuf_.size() == 0) {
1175  RawDigit::ADCvector_t emptyvector;
1176  for (size_t ichan=0;ichan<nextdigits.size();ichan++) dbuf_.push_back(emptyvector);
1177  }
1178  for (size_t ichan=0;ichan<nextdigits.size();ichan++) {
1179  dbuf_[ichan].push_back(nextdigits[ichan]);
1180  }
1181  fTicksAccumulated ++;
1182  } // If triggered on this tick!
1183  // ************* Now Done for this tick ************************
1184 
1185  // If I want to skip N Output events, I want to delete the event now that I have made it...
1187  if (fDebugLevel) std::cout << "I have skipped " << gSkippedOuputEvents << " events of a desired " << fSkipNOutputEvents << ". I am now voiding another...\n" << std::endl;
1189  Reset();
1190  }
1191  } // while ticks accumulated < ticksperEvent
1192 
1193  if (fDebugLevel > 1)
1194  std::cout << "\nGot enough ticks now start building the events...Start/End time for Waveforms/Counters are " << first_timestamp << " " << last_timestamp << std::endl;
1195  // ************* Fill wbuf_ with the SSP information within time range ************************
1196  if (fDebugLevel > 1)
1197  std::cout << "Loading the Waveforms...wbuf_ has size " << wbuf_.size() << " " << fNovaTicksPerSSPTick << std::endl;
1199  if (fDebugLevel > 1)
1200  std::cout << "wbuf_ now has size " << wbuf_.size() << std::endl;
1201 
1202  // ************* Fill hbuf_ with the OpHit information within time range ************************
1203  if (fDebugLevel > 1)
1204  std::cout << "Loading the Waveforms...hbuf_ has size " << hbuf_.size() << " " << fNovaTicksPerSSPTick << std::endl;
1206  if (fDebugLevel > 1)
1207  std::cout << "hbuf_ now has size " << hbuf_.size() << std::endl;
1208 
1209  // ************* Fill cbuf_ with the PTB information within time range ************************
1210  if (fDebugLevel > 1)
1211  std::cout << "Loading the Counters! cbuf size " << cbuf_.size() << " counterticks " << fNovaTicksPerCountTick << std::endl;
1213  if (fDebugLevel > 1)
1214  std::cout << "Now cbuf has size " << cbuf_.size() << std::endl;
1215 
1216  // ******** Now Build the event *********
1220  if ( runNumber_ != cachedRunNumber_ ) {
1221  outR = sh_.makeRunPrincipal(runNumber_,this_art_event_timestamp);
1223  eventNumber_ = 0ul;
1224  }
1226  outSR = sh_.makeSubRunPrincipal(runNumber_,subRunNumber_,this_art_event_timestamp);
1228  eventNumber_ = 0ul;
1229  }
1230 
1231  // ************* Now fill dbuf_ with TPC information collected ************************
1232  if (fDebugLevel > 1) std::cout << "Just about to fill d " << fTicksAccumulated << " " << dbuf_.size() << std::endl;
1233  for (size_t ichan=0;ichan<dbuf_.size();ichan++) {
1234  RawDigit d(loadedDigits_.digits[ichan].Channel(), fTicksAccumulated, dbuf_[ichan] //,loadedDigits_.digits[ichan].Compression()
1235  );
1236  if (evAux_.isRealData() ) { //If looking at real data!
1237  d.SetPedestal(AllPedMap[runNumber_][loadedDigits_.digits[ichan].Channel()].first,
1238  AllPedMap[runNumber_][loadedDigits_.digits[ichan].Channel()].second );
1239  if (fDebugLevel > 3) {
1240  std::cout << "digit[0] corresponding to channel " << d.Channel() << " ("<<ichan<<") has ADC value " << d.ADC(0)
1241  << ", pedestal "<<d.GetPedestal()<<" ["<<AllPedMap[runNumber_][loadedDigits_.digits[ichan].Channel()].first <<"],"
1242  << " and sigma "<<d.GetSigma() <<" ["<<AllPedMap[runNumber_][loadedDigits_.digits[ichan].Channel()].second<<"]."
1243  << std::endl;
1244  }
1245  } else { //If looking at Truth
1246  d.SetPedestal(loadedDigits_.digits[ichan].GetPedestal(),
1247  loadedDigits_.digits[ichan].GetSigma() );
1248  if (fDebugLevel > 3)
1249  std::cout << "Looking at Monte Carlo, so using pedestals loaded from event, channel " << ichan
1250  << ", pedestal " << d.GetPedestal() << " ("<<loadedDigits_.digits[ichan].GetPedestal()<<")"
1251  << ", sigma " << d.GetSigma() << " ("<<loadedDigits_.digits[ichan].GetSigma()<<")." << std::endl;
1252  }
1253  bufferedDigits_.emplace_back(d);
1254  }
1255 
1256  // If looking at Monte Carlo, now want to add the Truth stuff
1257  if (fMonteCarlo) {
1259  if (fDebugLevel) std::cout << "Have now returned from TakeMCParts, it has size " << mcbuf_.size() << std::endl;
1261  if (fDebugLevel) std::cout << "Have now returned from TakeMCSimChans, it has size " << simchanbuf_.size() << std::endl;
1262  }
1263 
1264  // Create event using the time from the data.
1265  makeEventAndPutDigits_( outE, this_art_event_timestamp);
1266 
1267  // ******** Reset loadedDigits_.index and TreeIndex_ to where the trigger was *********
1268  if (fDebugLevel) {
1269  std::cout << "The event triggered on Event Index " << fLastEventIndex << ", event " << fLastEvent << ", tick " << fLastTriggerIndex << ".\n"
1270  << "It went from EventIndex " << FirstDigEventIndex << ", event " << FirstDigEvent << ", tick " << FirstDigIndex
1271  << " to Tree index " << EventIndex_-1 << ", event " << inputEventNumber_ << ", tick " << loadedDigits_.index << ".\n"
1272  << "I want to reset the tick value for sure, but do I need to reload the digits because EventIndex is different?" << std::endl;
1273  }
1274  if ( EventIndex_-1 != fLastEventIndex ) {
1275  if (fDebugLevel) std::cout << "Yes I do! Changing EventIndex_ to fLastEventIndex...Also want to clear loadedDigits." << std::endl;
1277  loadedDigits_.index = 0;
1278  loadedDigits_.clear(fDebugLevel);
1280  } else {
1281  if (fDebugLevel) std::cout << "No, I'm still looking at the same tree!\n" << std::endl;
1282  }
1285 
1286  return true;
1287 } // read next
void Triggering(std::map< int, int > &PrevChanADC, std::vector< short > ADCdigits, bool NewTree)
lbne::TpcNanoSlice::Header::nova_timestamp_t last_timestamp
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
art::SubRunNumber_t inputSubRunNumber_
bool loadEvents_(size_t &InputTree)
std::unique_ptr< TFile > file_
art::SubRunNumber_t subRunNumber_
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
art::SourceHelper const & sh_
art::EventAuxiliary evAux_
art::EventNumber_t inputEventNumber_
art::SubRunNumber_t cachedSubRunNumber_
bool NoRCEsCase(art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:94
art::EventNumber_t eventNumber_
lbne::TpcNanoSlice::Header::nova_timestamp_t Event_timestamp
std::vector< std::pair< std::pair< unsigned int, unsigned int >, lbne::TpcNanoSlice::Header::nova_timestamp_t > > DigitsIndexList
void makeEventAndPutDigits_(art::EventPrincipal *&outE, art::Timestamp art_timestamp=0)
lbne::TpcNanoSlice::Header::nova_timestamp_t first_timestamp
art::Timestamp make_art_timestamp_from_nova_timestamp(lbne::TpcNanoSlice::Header::nova_timestamp_t this_nova_timestamp)
lbne::TpcNanoSlice::Header::nova_timestamp_t fLastTimeStamp
art::RunNumber_t inputRunNumber_
lbne::TpcNanoSlice::Header::nova_timestamp_t this_timestamp
std::map< uint16_t, std::map< size_t, std::pair< float, float > > > AllPedMap
void CheckTimestamps(bool &JumpEvent, size_t &JumpNADC)
lbne::TpcNanoSlice::Header::nova_timestamp_t prev_timestamp
art::RunNumber_t cachedRunNumber_
std::vector< RawDigit::ADCvector_t > dbuf_
bool isRealData() const noexcept
QTextStream & endl(QTextStream &s)
void DAQToOffline::Splitter::Reset ( )
private

Definition at line 1537 of file SplitterInput_source.cc.

1537  {
1538  bufferedDigits_.clear();
1539  for (size_t ichan=0;ichan<dbuf_.size();ichan++) { dbuf_[ichan].clear(); }
1540  dbuf_.clear();
1541  wbuf_.clear();
1542  hbuf_.clear();
1543  cbuf_.clear();
1544  Event_timestamp = 0;
1545  fTicksAccumulated = 0; // No longer have any RCE data...
1546  fTrigger = false; // Need to re-decide where to trigger
1547  fDiffFromLastTrig = 0; // Reset trigger counter.
1548  fChansPresent = 0;
1549  if (fDebugLevel > 1) std::cout << "Resetting everything (dbuf, cbuf, wbuf, hbuf, Trigger, etc)" << std::endl;
1550 }
lbne::TpcNanoSlice::Header::nova_timestamp_t Event_timestamp
std::vector< RawDigit::ADCvector_t > dbuf_
QTextStream & endl(QTextStream &s)
bool DAQToOffline::Splitter::TicklerTrigger ( std::map< int, int > &  PrevChanADC,
std::vector< short >  ADCdigits 
)
private

Definition at line 1751 of file SplitterInput_source.cc.

1751  {
1752  int HitsOverThreshold = 0;
1753  if (PrevChanADC.size() != 0) {
1754  for (unsigned int achan=0; achan<ADCdigits.size(); ++achan)
1755  if ( fabs( ADCdigits[achan] - PrevChanADC[achan] ) > fADCdiffThreshold ) {
1756  ++HitsOverThreshold;
1757  if (fDebugLevel > 3) {
1758  std::cout << "Looking at index " << loadedDigits_.index << " channel " << achan << "..." << ADCdigits[achan] << " - "
1759  << PrevChanADC[achan] << " = " << fabs( ADCdigits[achan] - PrevChanADC[achan] ) << " > " << fADCdiffThreshold
1760  << std::endl;
1761  }
1762  }
1763  if ( HitsOverThreshold != 0 )
1764  if (fDebugLevel > 2) std::cout << " after looking through all the channels ("<<ADCdigits.size()<<") I had " << HitsOverThreshold << " ticks with diff more than " << fADCdiffThreshold << std::endl;
1765  if ( HitsOverThreshold > fADCsOverThreshold ) {
1766  if (fDebugLevel > 2) std::cout << "Looking at index " << loadedDigits_.index << ", which had " << HitsOverThreshold << " hits over diff threshold. Trigger threshold is " << fADCsOverThreshold << std::endl;
1767  return true;
1768  }
1769  } // if PrevChanADC not empty.
1770  for (unsigned int bchan=0; bchan<ADCdigits.size(); ++bchan)
1771  PrevChanADC[bchan] = ADCdigits[bchan];
1772  return false;
1773 }
QTextStream & endl(QTextStream &s)
void DAQToOffline::Splitter::Triggering ( std::map< int, int > &  PrevChanADC,
std::vector< short >  ADCdigits,
bool  NewTree 
)
private

Definition at line 1721 of file SplitterInput_source.cc.

1721  {
1722  if ( EventIndex_-1 != fLastEventIndex ) fLastTimeStamp = 0; // No longer looking at same treeIndex as previous trigger, so reset lastTimeStamp
1723 
1724  for (size_t TrigSize = 0; TrigSize < fWhichTrigger.size(); ++TrigSize) {
1725  // Trigger on Monte Carlo whichTrigger == 0
1726  if ( fWhichTrigger[TrigSize] == 0 ) {
1727  if ( fDiffFromLastTrig > fMCTrigLevel ) fTrigger = true;
1728  }
1729  // Trigger on new files
1730  else if ( fWhichTrigger[TrigSize] == 1 && NewTree ) {
1731  fTrigger = true;
1732  }
1733  // Trigger on Photon Detectors
1734  else if ( fWhichTrigger[TrigSize] == 2 ) {
1736  }
1737  // Trigger using the user defined PTB Trigger vector
1738  else if ( fWhichTrigger[TrigSize] == 3 ) {
1740  }
1741  // Trigger on "Tickler" / TPC information
1742  else if ( fWhichTrigger[TrigSize] == 4 ) {
1743  fTrigger = TicklerTrigger( PrevChanADC, ADCdigits);
1744  }
1745 
1747  if (fTrigger) break;
1748  }
1749 }
std::vector< unsigned int > fPTBTrigs
lbne::TpcNanoSlice::Header::nova_timestamp_t fLastTimeStamp
lbne::TpcNanoSlice::Header::nova_timestamp_t this_timestamp
bool TicklerTrigger(std::map< int, int > &PrevChanADC, std::vector< short > ADCdigits)
std::vector< unsigned int > fWhichTrigger

Member Data Documentation

std::map<uint16_t, std::map <size_t, std::pair<float,float> > > DAQToOffline::Splitter::AllPedMap
private

Definition at line 788 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::AttemptedEvents
private

Definition at line 712 of file SplitterInput_source.cc.

rawDigits_t DAQToOffline::Splitter::bufferedDigits_
private

Definition at line 684 of file SplitterInput_source.cc.

art::RunNumber_t DAQToOffline::Splitter::cachedRunNumber_
private

Definition at line 677 of file SplitterInput_source.cc.

art::SubRunNumber_t DAQToOffline::Splitter::cachedSubRunNumber_
private

Definition at line 678 of file SplitterInput_source.cc.

PennCounters_t DAQToOffline::Splitter::cbuf_
private

Definition at line 688 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::ChansAtEndOfEvent[ArraySize]
private

Definition at line 720 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::ChansAtStartOfEvent[ArraySize]
private

Definition at line 719 of file SplitterInput_source.cc.

std::vector<RawDigit::ADCvector_t> DAQToOffline::Splitter::dbuf_
private

Definition at line 685 of file SplitterInput_source.cc.

std::vector<std::pair<std::pair<unsigned int,unsigned int>, lbne::TpcNanoSlice::Header::nova_timestamp_t > > DAQToOffline::Splitter::DigitsIndexList
private

Definition at line 786 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::doneWithFiles_
private

Definition at line 638 of file SplitterInput_source.cc.

art::EventAuxiliary DAQToOffline::Splitter::evAux_
private

Definition at line 748 of file SplitterInput_source.cc.

lbne::TpcNanoSlice::Header::nova_timestamp_t DAQToOffline::Splitter::Event_timestamp =0
private

Definition at line 704 of file SplitterInput_source.cc.

TBranch* DAQToOffline::Splitter::EventAuxBranch_
private

Definition at line 666 of file SplitterInput_source.cc.

size_t DAQToOffline::Splitter::EventIndex_
private

Definition at line 673 of file SplitterInput_source.cc.

art::EventNumber_t DAQToOffline::Splitter::eventNumber_
private

Definition at line 676 of file SplitterInput_source.cc.

std::map<uint64_t,size_t> DAQToOffline::Splitter::EventTreeMap
private

Definition at line 709 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::fADCdiffThreshold
private

Definition at line 774 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::fADCsOverThreshold
private

Definition at line 775 of file SplitterInput_source.cc.

unsigned int DAQToOffline::Splitter::fChansPresent = 0
private

Definition at line 693 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fCheatPTBTrig = false
private

Definition at line 696 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fCheatSSPTrig = false
private

Definition at line 697 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::fDebugLevel
private

Definition at line 762 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::fDiffFromLastTrig = 0
private

Definition at line 701 of file SplitterInput_source.cc.

std::unique_ptr<TFile> DAQToOffline::Splitter::file_
private

Definition at line 637 of file SplitterInput_source.cc.

lbne::TpcNanoSlice::Header::nova_timestamp_t DAQToOffline::Splitter::first_timestamp =0
private

Definition at line 703 of file SplitterInput_source.cc.

size_t DAQToOffline::Splitter::fLastEvent = 0
private

Definition at line 700 of file SplitterInput_source.cc.

size_t DAQToOffline::Splitter::fLastEventIndex = 0
private

Definition at line 699 of file SplitterInput_source.cc.

lbne::TpcNanoSlice::Header::nova_timestamp_t DAQToOffline::Splitter::fLastTimeStamp = 0
private

Definition at line 702 of file SplitterInput_source.cc.

size_t DAQToOffline::Splitter::fLastTriggerIndex = 0
private

Definition at line 698 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::fMCTrigLevel
private

Definition at line 764 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fMonteCarlo
private

Definition at line 755 of file SplitterInput_source.cc.

double DAQToOffline::Splitter::fNanoSecondsPerNovaTick
private

Definition at line 761 of file SplitterInput_source.cc.

double DAQToOffline::Splitter::fNovaTicksPerCountTick
private

Definition at line 760 of file SplitterInput_source.cc.

double DAQToOffline::Splitter::fNovaTicksPerSSPTick
private

Definition at line 759 of file SplitterInput_source.cc.

double DAQToOffline::Splitter::fNovaTicksPerTPCTick
private

Definition at line 758 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::fOpHitADCsOverThreshold
private

Definition at line 773 of file SplitterInput_source.cc.

double DAQToOffline::Splitter::fOpHitADCThreshold
private

Definition at line 772 of file SplitterInput_source.cc.

double DAQToOffline::Splitter::fOpHitADCWidth
private

Definition at line 771 of file SplitterInput_source.cc.

std::string DAQToOffline::Splitter::fPedestalFile
private

Definition at line 779 of file SplitterInput_source.cc.

std::string DAQToOffline::Splitter::fPedestalFileSearchPath
private

Definition at line 780 of file SplitterInput_source.cc.

size_t DAQToOffline::Splitter::fPostTriggerTicks
private

Definition at line 756 of file SplitterInput_source.cc.

size_t DAQToOffline::Splitter::fPreTriggerTicks
private

Definition at line 757 of file SplitterInput_source.cc.

std::map<int,int> DAQToOffline::Splitter::fPTBMap
private

Definition at line 789 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::fPTBMapDir
private

Definition at line 656 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::fPTBMapFile
private

Definition at line 655 of file SplitterInput_source.cc.

std::vector<unsigned int> DAQToOffline::Splitter::fPTBTrigs
private

Definition at line 766 of file SplitterInput_source.cc.

std::function<rawDigits_t(artdaq::Fragments const&, std::vector<std::pair< std::pair<unsigned int,unsigned int>, lbne::TpcNanoSlice::Header::nova_timestamp_t > > &, lbne::TpcNanoSlice::Header::nova_timestamp_t&, art::ServiceHandle<lbne::ChannelMapService> const&)> DAQToOffline::Splitter::fragmentsToDigits_
private

Definition at line 725 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fRequireOpHit
private

Definition at line 753 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fRequirePTB
private

Definition at line 754 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fRequireRCE
private

Definition at line 751 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fRequireSSP
private

Definition at line 752 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::fSkipNInputEvents
private

Definition at line 781 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::fSkipNOutputEvents
private

Definition at line 782 of file SplitterInput_source.cc.

unsigned short DAQToOffline::Splitter::fTicksAccumulated
private

Definition at line 692 of file SplitterInput_source.cc.

double DAQToOffline::Splitter::fTimeStampThreshold
private

Definition at line 763 of file SplitterInput_source.cc.

TTree* DAQToOffline::Splitter::fTree
private

Definition at line 711 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fTrigger = false
private

Definition at line 695 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::fTrigSeparation
private

Definition at line 767 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fUsePedestalDefault
private

Definition at line 776 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fUsePedestalFile
private

Definition at line 777 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::fUsePedestalFileSearchPath
private

Definition at line 778 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::fWaveformADCsOverThreshold
private

Definition at line 770 of file SplitterInput_source.cc.

double DAQToOffline::Splitter::fWaveformADCThreshold
private

Definition at line 769 of file SplitterInput_source.cc.

double DAQToOffline::Splitter::fWaveformADCWidth
private

Definition at line 768 of file SplitterInput_source.cc.

std::vector<unsigned int> DAQToOffline::Splitter::fWhichTrigger
private

Definition at line 765 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::GivenEventNum[ArraySize]
private

Definition at line 717 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::GivenRunNum[ArraySize]
private

Definition at line 715 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::GivenSubRunNum[ArraySize]
private

Definition at line 716 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::GoodEvents
private

Definition at line 714 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::gSkippedOuputEvents = 0
private

Definition at line 785 of file SplitterInput_source.cc.

OpHits_t DAQToOffline::Splitter::hbuf_
private

Definition at line 687 of file SplitterInput_source.cc.

art::EventNumber_t DAQToOffline::Splitter::inputEventNumber_
private

Definition at line 681 of file SplitterInput_source.cc.

art::Timestamp DAQToOffline::Splitter::inputEventTime_
private

Definition at line 682 of file SplitterInput_source.cc.

art::RunNumber_t DAQToOffline::Splitter::inputRunNumber_
private

Definition at line 679 of file SplitterInput_source.cc.

art::SubRunNumber_t DAQToOffline::Splitter::inputSubRunNumber_
private

Definition at line 680 of file SplitterInput_source.cc.

lbne::TpcNanoSlice::Header::nova_timestamp_t DAQToOffline::Splitter::last_timestamp =0
private

Definition at line 705 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::lastFileName_
private

Definition at line 636 of file SplitterInput_source.cc.

LoadedCounters DAQToOffline::Splitter::loadedCounters_
private

Definition at line 670 of file SplitterInput_source.cc.

LoadedDigits DAQToOffline::Splitter::loadedDigits_
private

Definition at line 667 of file SplitterInput_source.cc.

LoadedOpHits DAQToOffline::Splitter::loadedOpHits_
private

Definition at line 669 of file SplitterInput_source.cc.

LoadedWaveforms DAQToOffline::Splitter::loadedWaveforms_
private

Definition at line 668 of file SplitterInput_source.cc.

MCPart_t DAQToOffline::Splitter::mcbuf_
private

Definition at line 689 of file SplitterInput_source.cc.

TBranch* DAQToOffline::Splitter::MCPartinputBranch_
private

Definition at line 663 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::MCPartinputDataProduct_
private

Definition at line 651 of file SplitterInput_source.cc.

art::InputTag DAQToOffline::Splitter::MCPartinputTag_
private

Definition at line 644 of file SplitterInput_source.cc.

TBranch* DAQToOffline::Splitter::MCSimChaninputBranch_
private

Definition at line 665 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::MCSimChaninputDataProduct_
private

Definition at line 653 of file SplitterInput_source.cc.

art::InputTag DAQToOffline::Splitter::MCSimChaninputTag_
private

Definition at line 646 of file SplitterInput_source.cc.

MCTruth_t DAQToOffline::Splitter::mctruth_
private

Definition at line 690 of file SplitterInput_source.cc.

TBranch* DAQToOffline::Splitter::MCTruthinputBranch_
private

Definition at line 664 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::MCTruthinputDataProduct_
private

Definition at line 652 of file SplitterInput_source.cc.

art::InputTag DAQToOffline::Splitter::MCTruthinputTag_
private

Definition at line 645 of file SplitterInput_source.cc.

MonteCarlo DAQToOffline::Splitter::MonteCarlo_
private

Definition at line 671 of file SplitterInput_source.cc.

size_t DAQToOffline::Splitter::nInputEvts_
private

Definition at line 672 of file SplitterInput_source.cc.

TBranch* DAQToOffline::Splitter::OpHitinputBranch_
private

Definition at line 661 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::OpHitinputDataProduct_
private

Definition at line 649 of file SplitterInput_source.cc.

art::InputTag DAQToOffline::Splitter::OpHitinputTag_
private

Definition at line 642 of file SplitterInput_source.cc.

TBranch* DAQToOffline::Splitter::PenninputBranch_
private

Definition at line 662 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::PenninputDataProduct_
private

Definition at line 650 of file SplitterInput_source.cc.

art::InputTag DAQToOffline::Splitter::PenninputTag_
private

Definition at line 643 of file SplitterInput_source.cc.

art::EventAuxiliary* DAQToOffline::Splitter::pevaux_
private

Definition at line 749 of file SplitterInput_source.cc.

lbne::TpcNanoSlice::Header::nova_timestamp_t DAQToOffline::Splitter::prev_timestamp =0
private

Definition at line 707 of file SplitterInput_source.cc.

bool DAQToOffline::Splitter::RCEsPresent = true
private

Definition at line 784 of file SplitterInput_source.cc.

art::RunNumber_t DAQToOffline::Splitter::runNumber_
private

Definition at line 674 of file SplitterInput_source.cc.

art::SourceHelper const& DAQToOffline::Splitter::sh_
private

Definition at line 657 of file SplitterInput_source.cc.

MCSimChan_t DAQToOffline::Splitter::simchanbuf_
private

Definition at line 691 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::sourceName_
private

Definition at line 635 of file SplitterInput_source.cc.

TBranch* DAQToOffline::Splitter::SparseinputBranch_
private

Definition at line 659 of file SplitterInput_source.cc.

art::InputTag DAQToOffline::Splitter::SparseinputTag_
private

Definition at line 640 of file SplitterInput_source.cc.

TBranch* DAQToOffline::Splitter::SSPinputBranch_
private

Definition at line 660 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::SSPinputDataProduct_
private

Definition at line 648 of file SplitterInput_source.cc.

art::InputTag DAQToOffline::Splitter::SSPinputTag_
private

Definition at line 641 of file SplitterInput_source.cc.

SSPReformatterAlgs DAQToOffline::Splitter::sspReform
private

Definition at line 654 of file SplitterInput_source.cc.

art::SubRunNumber_t DAQToOffline::Splitter::subRunNumber_
private

Definition at line 675 of file SplitterInput_source.cc.

lbne::TpcNanoSlice::Header::nova_timestamp_t DAQToOffline::Splitter::this_timestamp =0
private

Definition at line 706 of file SplitterInput_source.cc.

size_t DAQToOffline::Splitter::ticksPerEvent_
private

Definition at line 683 of file SplitterInput_source.cc.

TBranch* DAQToOffline::Splitter::TPCinputBranch_
private

Definition at line 658 of file SplitterInput_source.cc.

string DAQToOffline::Splitter::TPCinputDataProduct_
private

Definition at line 647 of file SplitterInput_source.cc.

art::InputTag DAQToOffline::Splitter::TPCinputTag_
private

Definition at line 639 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::TreeIndexStart[ArraySize]
private

Definition at line 718 of file SplitterInput_source.cc.

int DAQToOffline::Splitter::VoidedEvents
private

Definition at line 713 of file SplitterInput_source.cc.

SSPWaveforms_t DAQToOffline::Splitter::wbuf_
private

Definition at line 686 of file SplitterInput_source.cc.


The documentation for this class was generated from the following file: