Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
CRT::CRTRawDecoder Class Reference
Inheritance diagram for CRT::CRTRawDecoder:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  PerModule
 

Public Member Functions

 CRTRawDecoder (fhicl::ParameterSet const &p)
 
 CRTRawDecoder (CRTRawDecoder const &)=delete
 
 CRTRawDecoder (CRTRawDecoder &&)=delete
 
CRTRawDecoderoperator= (CRTRawDecoder const &)=delete
 
CRTRawDecoderoperator= (CRTRawDecoder &&)=delete
 
void produce (art::Event &e) override
 
void beginJob () override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void FragmentToTriggers (const artdaq::Fragment &artFrag, std::unique_ptr< std::vector< CRT::Trigger >> &triggers)
 
void SetEarliestTime (const artdaq::Fragment &frag)
 
void createSyncPlots ()
 

Private Attributes

const art::InputTag fFragTag
 
const bool fLookForContainer
 
const bool fMatchOfflineMapping
 
std::vector< size_t > fChannelMap
 
std::vector< PerModulefSyncPlots
 
uint64_t fEarliestTime
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 48 of file CRTRawDecoder_module.cc.

Constructor & Destructor Documentation

CRT::CRTRawDecoder::CRTRawDecoder ( fhicl::ParameterSet const &  p)
explicit

Definition at line 115 of file CRTRawDecoder_module.cc.

115  : EDProducer{p}, fFragTag(p.get<std::string>("RawDataTag")),
116  fLookForContainer(p.get<bool>("LookForContainer", false)),
117  fMatchOfflineMapping(p.get<bool>("MatchOfflineMapping", true)),
118  fEarliestTime(std::numeric_limits<decltype(fEarliestTime)>::max())
119  {
120  // Call appropriate produces<>() functions here.
121  produces<std::vector<CRT::Trigger>>();
122  consumes<std::vector<artdaq::Fragment>>(fFragTag);
123 
124  //Register callback to make new plots on every file
126  tfs->registerFileSwitchCallback(this, &CRTRawDecoder::createSyncPlots);
127  }
const art::InputTag fFragTag
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
p
Definition: test.py:223
static int max(int a, int b)
CRT::CRTRawDecoder::CRTRawDecoder ( CRTRawDecoder const &  )
delete
CRT::CRTRawDecoder::CRTRawDecoder ( CRTRawDecoder &&  )
delete

Member Function Documentation

void CRT::CRTRawDecoder::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 277 of file CRTRawDecoder_module.cc.

278  {
279  createSyncPlots();
280 
281  //Set up channel mapping base on user configuration
283  const auto nModules = geom->NAuxDets();
285  {
286 // std::vector<const geo::AuxDetGeo*> auxDets; //The function to retrieve this vector seems to have been made protected
287 // for(size_t auxDet = 0; auxDet < nModules; ++auxDet) auxDets.push_back(&geom->AuxDet(auxDet));
288 //
289 // fChannelMap = CRTSorter::Mapping(auxDets); //Match whatever the current AuxDet sorter does.
290  //Based on v6 geometry (TY)
291  fChannelMap.push_back(24);
292  fChannelMap.push_back(25);
293  fChannelMap.push_back(30);
294  fChannelMap.push_back(18);
295  fChannelMap.push_back(15);
296  fChannelMap.push_back(7);
297  fChannelMap.push_back(13);
298  fChannelMap.push_back(12);
299  fChannelMap.push_back(11);
300  fChannelMap.push_back(10);
301  fChannelMap.push_back(6);
302  fChannelMap.push_back(14);
303  fChannelMap.push_back(19);
304  fChannelMap.push_back(31);
305  fChannelMap.push_back(26);
306  fChannelMap.push_back(27);
307  fChannelMap.push_back(22);
308  fChannelMap.push_back(23);
309  fChannelMap.push_back(29);
310  fChannelMap.push_back(17);
311  fChannelMap.push_back(8);
312  fChannelMap.push_back(0);
313  fChannelMap.push_back(3);
314  fChannelMap.push_back(2);
315  fChannelMap.push_back(5);
316  fChannelMap.push_back(4);
317  fChannelMap.push_back(1);
318  fChannelMap.push_back(9);
319  fChannelMap.push_back(16);
320  fChannelMap.push_back(28);
321  fChannelMap.push_back(20);
322  fChannelMap.push_back(21);
323  }
324  else
325  {
326  for(size_t module = 0; module < nModules; ++module) fChannelMap.push_back(module); //Map each index to itself
327  }
328  }
std::vector< size_t > fChannelMap
unsigned int NAuxDets() const
Returns the number of auxiliary detectors.
void CRT::CRTRawDecoder::createSyncPlots ( )
private

Definition at line 330 of file CRTRawDecoder_module.cc.

331  {
332  const auto nModules = art::ServiceHandle<geo::Geometry>()->NAuxDets();
334  fSyncPlots.clear(); //Clear any previous pointers to histograms. Some TFile owned them.
335  for(size_t module = 0; module < nModules; ++module) fSyncPlots.emplace_back(*tfs, module); //32 modules in the ProtoDUNE-SP CRT
336  }
std::vector< PerModule > fSyncPlots
void CRT::CRTRawDecoder::FragmentToTriggers ( const artdaq::Fragment &  artFrag,
std::unique_ptr< std::vector< CRT::Trigger >> &  triggers 
)
private

Definition at line 129 of file CRTRawDecoder_module.cc.

130  {
131  CRT::Fragment frag(artFrag);
132 
133  MF_LOG_DEBUG("CRTGoodEvent") << "Is this Fragment good? " << ((frag.good_event())?"true":"false") << "\n";
134  /*frag.print_header();
135  frag.print_hits();*/
136 
137  std::vector<CRT::Hit> hits;
138 
139  //Make a CRT::Hit from each non-zero ADC value in this Fragment
140  for(size_t hitNum = 0; hitNum < frag.num_hits(); ++hitNum)
141  {
142  const auto hit = *(frag.hit(hitNum));
143  MF_LOG_DEBUG("CRTRaw") << "Channel: " << (int)(hit.channel) << "\n"
144  << "ADC: " << hit.adc << "\n";
145  //Determine the offline channel number for each strip
146  size_t offline_channel = hit.channel;
147  if (frag.module_num() == 14 ||
148  frag.module_num() == 15 ||
149  frag.module_num() == 8 ||
150  frag.module_num() == 9 ||
151  frag.module_num() == 10 ||
152  frag.module_num() == 11 ||
153  frag.module_num() == 4 ||
154  frag.module_num() == 5 ||
155  frag.module_num() == 30 ||
156  frag.module_num() == 31 ||
157  frag.module_num() == 24 ||
158  frag.module_num() == 25 ||
159  frag.module_num() == 26 ||
160  frag.module_num() == 27 ||
161  frag.module_num() == 20 ||
162  frag.module_num() == 21){ //Strips need to be flipped (TY)
163  if (hit.channel<32){
164  offline_channel = (31-hit.channel)*2;
165  }
166  else{
167  offline_channel = (63-hit.channel)*2+1;
168  }
169  }
170  else{//Strips do not need to be flipped
171  if (hit.channel<32){
172  offline_channel = hit.channel*2;
173  }
174  else{
175  offline_channel = (hit.channel-32)*2+1;
176  }
177  }
178  //Flip the two layers
179  if (offline_channel%2==0) ++offline_channel;
180  else --offline_channel;
181  hits.emplace_back(offline_channel, hit.adc);
182  //MF_LOG_DEBUG("CRT Hits") CRT::operator << hits.back() << "\n"; //TODO: Some function template from the message service interferes with my
183  // function template from namespace CRT. using namespace CRT seems like
184  // it should solve this, but it doesn't seem to.
185  }
186 
187  MF_LOG_DEBUG("CRTFragments") << "Module: " << frag.module_num() << "\n"
188  << "Number of hits: " << frag.num_hits() << "\n"
189  << "Fifty MHz time: " << frag.fifty_mhz_time() << "\n";
190 
191  try
192  {
193  triggers->emplace_back(fChannelMap.at(frag.module_num()), frag.fifty_mhz_time(), std::move(hits));
194  }
195  catch(const std::out_of_range& e)
196  {
197  mf::LogWarning("Bad CRT Channel") << "Got CRT channel number " << frag.module_num() << " that is greater than the number of boards"
198  << " in the channel map: " << fChannelMap.size() << ". Throwing out this Trigger.\n";
199  }
200 
201  //Make diagnostic plots for sync pulses
202  const auto& plots = fSyncPlots[frag.module_num()];
203  const double deltaT = (frag.fifty_mhz_time() - fEarliestTime)*1.6e-8; //TODO: Get size of clock ticks from a service
204  if(deltaT > 0 && deltaT < 1e6) //Ignore time differences less than 1s and greater than 1 day
205  //TODO: Understand why these cases come up
206  {
207  plots.fLowerTimeVersusTime->SetPoint(plots.fLowerTimeVersusTime->GetN(), deltaT, frag.raw_backend_time());
208  }
209  else
210  {
211  mf::LogWarning("SyncPlots") << "Got time difference " << deltaT << " that was not included in sync plots.\n"
212  << "lhs is " << frag.fifty_mhz_time() << ", and rhs is " << fEarliestTime << ".\n"
213  << "Hardware raw time is " << frag.raw_backend_time() << ".\n";
214  }
215  }
std::vector< PerModule > fSyncPlots
const double e
def move(depos, offset)
Definition: depos.py:107
std::vector< size_t > fChannelMap
Detector simulation of raw signals on wires.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
#define MF_LOG_DEBUG(id)
CRTRawDecoder& CRT::CRTRawDecoder::operator= ( CRTRawDecoder const &  )
delete
CRTRawDecoder& CRT::CRTRawDecoder::operator= ( CRTRawDecoder &&  )
delete
void CRT::CRTRawDecoder::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 224 of file CRTRawDecoder_module.cc.

225  {
226  //Create an empty container of CRT::Triggers. Any Triggers in this container will be put into the
227  //event at the end of produce. I will try to fill this container, but just not produce any CRT::Triggers
228  //if there are no input artdaq::Fragments.
229  auto triggers = std::make_unique<std::vector<CRT::Trigger>>();
230 
231  try
232  {
233  //Try to get artdaq::Fragments produced from CRT data. The following line is the reason for
234  //this try-catch block. I don't expect anything else to throw a cet::Exception.
235  const auto& fragHandle = e.getValidHandle<std::vector<artdaq::Fragment>>(fFragTag);
236 
238  {
239  //If this is the first event, set fEarliestTime
240  if(fEarliestTime == std::numeric_limits<decltype(fEarliestTime)>::max())
241  {
242  for(const auto& frag: *fragHandle)
243  {
244  artdaq::ContainerFragment container(frag);
245  for(size_t pos = 0; pos < container.block_count(); ++pos) SetEarliestTime(*container[pos]);
246  }
247  }
248 
249  for(const auto& artFrag: *fragHandle)
250  {
251  artdaq::ContainerFragment container(artFrag);
252  for(size_t pos = 0; pos < container.block_count(); ++pos) FragmentToTriggers(*container[pos], triggers);
253  }
254  }
255  else
256  {
257  //If this is the first event, set fEarliestTime
258  if(fEarliestTime == std::numeric_limits<decltype(fEarliestTime)>::max())
259  {
260  for(const auto& frag: *fragHandle) SetEarliestTime(frag);
261  }
262 
263  //Convert each fragment into a CRT::Trigger.
264  for(const auto& artFrag: *fragHandle) FragmentToTriggers(artFrag, triggers);
265  }
266  }
267  catch(const cet::exception& exc) //If there are no artdaq::Fragments in this Event, just add an empty container of CRT::Triggers.
268  {
269  mf::LogWarning("MissingData") << "No artdaq::Fragments produced by " << fFragTag << " in this event, so "
270  << "not doing anything.\n";
271  }
272 
273  //Put a vector of CRT::Triggers into this Event for other modules to read.
274  e.put(std::move(triggers));
275  }
const art::InputTag fFragTag
void SetEarliestTime(const artdaq::Fragment &frag)
def move(depos, offset)
Definition: depos.py:107
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
void FragmentToTriggers(const artdaq::Fragment &artFrag, std::unique_ptr< std::vector< CRT::Trigger >> &triggers)
static int max(int a, int b)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void CRT::CRTRawDecoder::SetEarliestTime ( const artdaq::Fragment &  frag)
private

Definition at line 217 of file CRTRawDecoder_module.cc.

218  {
219  CRT::Fragment crt(frag);
220  if(crt.fifty_mhz_time() < fEarliestTime) fEarliestTime = crt.fifty_mhz_time();
221  }

Member Data Documentation

std::vector<size_t> CRT::CRTRawDecoder::fChannelMap
private

Definition at line 86 of file CRTRawDecoder_module.cc.

uint64_t CRT::CRTRawDecoder::fEarliestTime
private

Definition at line 111 of file CRTRawDecoder_module.cc.

const art::InputTag CRT::CRTRawDecoder::fFragTag
private

Definition at line 72 of file CRTRawDecoder_module.cc.

const bool CRT::CRTRawDecoder::fLookForContainer
private

Definition at line 75 of file CRTRawDecoder_module.cc.

const bool CRT::CRTRawDecoder::fMatchOfflineMapping
private

Definition at line 83 of file CRTRawDecoder_module.cc.

std::vector<PerModule> CRT::CRTRawDecoder::fSyncPlots
private

Definition at line 110 of file CRTRawDecoder_module.cc.


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