Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
ifdb::TBSpillInfo Class Reference
Inheritance diagram for ifdb::TBSpillInfo:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 TBSpillInfo (fhicl::ParameterSet const &pset)
 
virtual ~TBSpillInfo ()
 
void produce (art::Event &evt)
 
void reconfigure (const fhicl::ParameterSet &pset)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

double fOffset
 
std::string pRawDataLabel
 
std::string pRawBLTrigLabel
 
art::ServiceHandle< ifbeam_ns::IFBeamifbeam_handle
 
std::unique_ptr< BeamFolderbfp
 
bool isMC
 

Detailed Description

Definition at line 48 of file TBSpillInfo_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

ifdb::TBSpillInfo::TBSpillInfo ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 76 of file TBSpillInfo_module.cc.

References bfp.

76  :
77  fOffset (pset.get< double >("Offset") ),
78  pRawDataLabel (pset.get< std::string >("RawDataLabel") ),
79  pRawBLTrigLabel (pset.get< std::string >("RawBLTrigLabel") ),
80  bfp( ifbeam_handle->getBeamFolder(pset.get< std::string >("Bundle"), pset.get< std::string >("URL"), pset.get< double >("TimeWindow"))),
81  isMC(false)
82  {
83  // how close in time does the spill time have to be from the DAQ tims [seconds]
84  // TB has one 4.2 second spill every minute.
85  bfp->set_epsilon(5);
86  // tell the module what it is making as this is a EDProducer
87  produces< sumdata::MCenterData >();
88  // Be noisy to demonstrate what's happening
89  mf::LogInfo("TBSpillInfo") << "In TBSpillInfo Constructor\n";
90 
91  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
art::ServiceHandle< ifbeam_ns::IFBeam > ifbeam_handle
std::string pRawBLTrigLabel
std::unique_ptr< BeamFolder > getBeamFolder(std::string bundle_name, std::string url="", double time_width=1200.0)
std::unique_ptr< BeamFolder > bfp
enum BeamMode string
ifdb::TBSpillInfo::~TBSpillInfo ( )
virtual

Definition at line 94 of file TBSpillInfo_module.cc.

95  {
96  }

Member Function Documentation

template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDProducer::currentContext ( ) const
protectedinherited
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

Referenced by skim::NueSkimmer::CopyMichelSlice(), and skim::NueSkimmer::CopyMichelTrack().

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID(), and string.

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void ifdb::TBSpillInfo::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 105 of file TBSpillInfo_module.cc.

References bfp, novadaq::timeutils::convertNovaTimeToUnixTime(), DEFINE_ART_MODULE(), release_diff::diff, fOffset, rawdata::RawTrigger::fTriggerMask_TriggerType, rawdata::RawTrigger::fTriggerTimingMarker_TimeStart, art::DataViewImpl::getByLabel(), makeTrainCVSamples::int, isMC, art::Event::isRealData(), pRawBLTrigLabel, pRawDataLabel, art::Event::put(), string, rawdata::RawBeamlineTrigger::TDUTime(), and msf_helper::timespec.

106  {
107  std::unique_ptr<sumdata::MCenterData> mcenterdata(new sumdata::MCenterData());
108 
109  if(!evt.isRealData()){
110  // remove empty spill info write from here, move to GENIEGen and fill
111  isMC = true;
112  // don't have any beam sim to put in here
113  return;
114  }
115 
116  //this will be the CORRECT UTC time we want ultimately
117  struct timespec unixTime;
118 
121 
122  // Case: use NOvA DAQ trigger
123  if (evt.getByLabel<std::vector<rawdata::RawTrigger> >(pRawDataLabel, trigv)) {
124 
125  const rawdata::RawTrigger& trig = (*trigv)[0];
126 
127  if( !(trig.fTriggerMask_TriggerType == 1 || trig.fTriggerMask_TriggerType == 43) ){
128  // This isn't a Beamline or TBSpill trigger. Don't try to get beam info
129  evt.put(std::move(mcenterdata));
130  return;
131  }
132 
134 
135  }
136 
137  // Case: use Beamline DAQ trigger
138  else if (evt.getByLabel<std::vector<rawdata::RawBeamlineTrigger> >(pRawBLTrigLabel, bltrigv)) {
139 
140  const rawdata::RawBeamlineTrigger& trig = (*bltrigv)[0];
142 
143  }
144 
145  else
146  throw cet::exception("TBSpillInfo") << "failed to get valid trigger handle";
147 
148  unsigned long int uevt_sec = unixTime.tv_sec; //utval >> 32 & 0xFFFFFFFFF;
149  unsigned long int uevt_nsec = unixTime.tv_nsec; //utval & 0xFFFFFFFFF;
150 
151  //DAQ event time
152  double DAQtime = (double)(uevt_sec + (0.000000001)*uevt_nsec);
153 
154  // beam parameters
155  double mcnrg=0.;
156  double mc6ic=0.;
157  double mc6ictime=0.;
158  double mc6cv=0.;
159  double mc7sc1=0.;
160  double mc7an1=0.;
161 
162  // NOvA scintillator counters
163  double novtsc01=0.;
164  double novtsc07=0.;
165 
166  // start with what was originally in bundle - split up the beam devices due to
167  // some issues querying around March 4th. Looks like devices that were added to the bundle
168  // later don't have data for some time on the 4th.
169  try{
170 
171  // Query the database to get post-spill sample device info. We are querying $36, so an offset
172  // is added to the event time to match the db time. Epsilon for the beam folder is large enough
173  // to encompass full spill
174 
175  bfp->GetNamedData(DAQtime+fOffset,"F:MC6IC@,F:MC7SC1", &mc6ic, &mc6ictime, &mc7sc1);
176 
177  //Check time close to DB time later
178 
179  // Epsilon provided on beam folder should already guarantee matching spill time (if one exists)
180 
181  unsigned long int spill_time_sec = (int) mc6ictime;
182  unsigned long int spill_time_nsec = (mc6ictime-spill_time_sec)*1e9;
183  double diff = DAQtime+fOffset-mc6ictime;
184 
185  mcenterdata->spilltimesec = spill_time_sec;
186  mcenterdata->spilltimensec = spill_time_nsec;
187  mcenterdata->deltaspilltimensec = diff*1e9;
188  mcenterdata->mc6int = mc6ic;
189  mcenterdata->mc7int = mc7sc1;
190 
191  }
192  catch (WebAPIException we){
193  std::string err(we.what());
194  // If the varialbe can't be found, it means there was no spill within epsilon of DAQtime+fOffset
195  // In this case, just enter zeros for all spill data.
196  // If it's a different error, force and abort and print out error
197  if (!err.find("variable not found")) {
198  mf::LogError("TBSpillInfo") << "Exception encountered: " << we.what();
199  std::abort();
200  }
201  } // end try/catch
202 
203  // Get other beam devices
204  try{
205 
206  bfp->GetNamedData(DAQtime+fOffset,"F:MCENRG,F:MC6CV,F:MC7AN1", &mcnrg, &mc6cv, &mc7an1);
207 
208  mcenterdata->mcenrg = mcnrg;
209  mcenterdata->mc6col = mc6cv;
210  mcenterdata->mc7magnet = mc7an1;
211 
212  }
213  catch (WebAPIException we){
214  std::string err(we.what());
215  // If the varialbe can't be found, it means there was no spill within epsilon of DAQtime+fOffset
216  // or there is no reading for the scintillator counters at this time
217  // In this case, just enter zeros for the counters
218  // If it's a different error, force and abort and print out error
219  if (!err.find("variable not found")) {
220  mf::LogError("TBSpillInfo") << "Exception encountered: " << we.what();
221  std::abort();
222  }
223  } // end try/catch
224 
225 
226  // Get NOvA scintillator counters
227  try{
228 
229  bfp->GetNamedData(DAQtime+fOffset,"Z:NOVTSC01,Z:NOVTSC07", &novtsc01, &novtsc07);
230 
231  mcenterdata->targetsc = novtsc01;
232  mcenterdata->daqtrigger = novtsc07;
233 
234  }
235  catch (WebAPIException we){
236  std::string err(we.what());
237  // If the varialbe can't be found, it means there was no spill within epsilon of DAQtime+fOffset
238  // or there is no reading for the scintillator counters at this time
239  // In this case, just enter zeros for the counters
240  // If it's a different error, force and abort and print out error
241  if (!err.find("variable not found")) {
242  mf::LogError("TBSpillInfo") << "Exception encountered: " << we.what();
243  std::abort();
244  }
245  } // end try/catch
246 
247 
248  evt.put(std::move(mcenterdata));
249 
250  } //end event loop
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool isRealData() const
Definition: Event.h:83
bool convertNovaTimeToUnixTime(uint64_t const &inputNovaTime, struct timespec &outputUnixTime)
uint8_t fTriggerMask_TriggerType
Definition: RawTrigger.h:43
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
std::string pRawBLTrigLabel
uint64_t TDUTime() const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
unsigned long long fTriggerTimingMarker_TimeStart
Definition: RawTrigger.h:38
std::unique_ptr< BeamFolder > bfp
enum BeamMode string
void ifdb::TBSpillInfo::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 99 of file TBSpillInfo_module.cc.

References fOffset, and fhicl::ParameterSet::get().

100  {
101  fOffset = pset.get< double >("Offset");
102  }
T get(std::string const &key) const
Definition: ParameterSet.h:231
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

std::unique_ptr<BeamFolder> ifdb::TBSpillInfo::bfp
private

Definition at line 65 of file TBSpillInfo_module.cc.

Referenced by produce(), and TBSpillInfo().

double ifdb::TBSpillInfo::fOffset
private

Definition at line 60 of file TBSpillInfo_module.cc.

Referenced by produce(), and reconfigure().

art::ServiceHandle<ifbeam_ns::IFBeam> ifdb::TBSpillInfo::ifbeam_handle
private

Definition at line 64 of file TBSpillInfo_module.cc.

bool ifdb::TBSpillInfo::isMC
private

Definition at line 66 of file TBSpillInfo_module.cc.

Referenced by produce().

std::string ifdb::TBSpillInfo::pRawBLTrigLabel
private

Definition at line 62 of file TBSpillInfo_module.cc.

Referenced by produce().

std::string ifdb::TBSpillInfo::pRawDataLabel
private

Definition at line 61 of file TBSpillInfo_module.cc.

Referenced by produce().


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