11 #include "art_root_io/TFileService.h" 15 #include "artdaq-core/Data/Fragment.hh" 16 #include "artdaq-core/Data/ContainerFragment.hh" 59 const artdaq::Fragment& frag,
60 RawDigits& raw_digits);
117 _h_nticks = file_srv->make<TH1D>(
"rce_NTicks",
"TPC: Number of ticks", 100, 0, 20000);
119 _h_all_adc_values = file_srv->make<TH1I>(
"rce_All_ADC_values",
"TPC: All_ADC_values", 5000, 0, 5000);
121 _h_crate_numbers = file_srv->make<TH1I>(
"rce_All_crate_numbers",
"TPC: Crate Numbers", 6, 0, 6);
123 _h_slot_IDs = file_srv->make<TH1I>(
"rce_All_slot_IDs",
"TPC: Slot IDs", 30, 0, 30);
125 _h_fiber_IDs = file_srv->make<TH1I>(
"rce_All_fiber_IDs",
"TPC: Fiber IDs", 120, 0, 120);
127 _h_online_channels = file_srv->make<TH1I>(
"rce_Online_Channels",
"TPC: Online Channel ID", 5000, 0, 5000);
128 _h_offline_channels = file_srv->make<TH1I>(
"rce_Offline_Channels",
"TPC: Offline Channel ID", 5000, 0, 5000);
129 for(
int i=0;i<30;i++) {
130 _h_mean_slot_channels.push_back(file_srv->make<TH2F>(Form(
"Slot%d_Mean", i), Form(
"Slot%d:Mean_vs_SlotChannel", i), 512, 0, 512, 5000, .0, 5000));
131 _h_rms_slot_channels.push_back(file_srv->make<TH2F>(Form(
"Slot%d_RMS", i), Form(
"Slot%d:RMS_vs_SlotChannel", i), 512, 0, 512, 5000, .0, 5000));
132 _h_mean_slot_channels_pfx.push_back(file_srv->make<TProfile>(Form(
"Slot%d_Mean_pfx", i), Form(
"Slot%d:Mean_vs_SlotChannel_pfx", i), 512, 0, 512));
133 _h_rms_slot_channels_pfx.push_back(file_srv->make<TProfile>(Form(
"Slot%d_RMS_pfx", i), Form(
"Slot%d:RMS_vs_SlotChannel_pfx", i), 512, 0, 512));
140 for(
int i=0;i<120;i++) {
141 _h_fiber_persistent_wav.push_back(file_srv->make<TH2I>(Form(
"Persistent_Waveform_Fiber#%d", i), Form(
"Persistent_Waveform_Fiber#%d", i), 10000, 0, 10000, 500, 0, 5000));
151 <<
"-------------------- RCE RawDecoder -------------------";
154 unsigned int n_rce_frags = 0;
162 try { cont_frags->size(); }
164 std::cout <<
"WARNING: Container TPC/RCE data not found in event " << eventNumber <<
std::endl;
165 std::vector<raw::RawDigit> digits;
172 <<
"Run: " << evt.
run()
173 <<
", SubRun: " << evt.
subRun()
174 <<
", Event: " << evt.
event()
175 <<
" Container Fragments is NOT VALID";
178 for (
auto const& cont : *cont_frags)
180 artdaq::ContainerFragment cont_frag(cont);
181 for (
size_t ii = 0; ii < cont_frag.block_count(); ++ii)
187 if (
_process(*cont_frag[ii], raw_digits)) ++n_rce_frags;
199 try { frags->size(); }
201 std::cout <<
"WARNING: Raw TPC/RCE data not found in event " << eventNumber <<
std::endl;
202 std::vector<raw::RawDigit> digits;
208 if(!frags.isValid()){
210 <<
"Run: " << evt.
run()
211 <<
", SubRun: " << evt.
subRun()
212 <<
", Event: " << evt.
event()
213 <<
" Fragments is NOT VALID";
216 for(
auto const& frag: *frags)
218 if (
_process(frag, raw_digits)) ++n_rce_frags;
223 <<
" Processed " << n_rce_frags
224 <<
" RCE Fragments, " 228 evt.
put(std::make_unique<decltype(raw_digits)>(
std::move(raw_digits)),
233 const artdaq::Fragment& frag,
238 if((
unsigned)frag.type() != 2)
return false;
241 <<
" SequenceID = " << frag.sequenceID()
242 <<
" fragmentID = " << frag.fragmentID()
243 <<
" fragmentType = " << (unsigned)frag.type()
244 <<
" Timestamp = " << frag.timestamp();
248 uint32_t ch_counter = 0;
249 for (
int i = 0; i < rce.
size(); ++i)
252 int n_ch = rce_stream->getNChannels();
253 int n_ticks = rce_stream->getNTicks();
254 auto const identifier = rce_stream->getIdentifier();
255 uint32_t crateNumber = identifier.getCrate();
256 uint32_t slotNumber = identifier.getSlot();
257 uint32_t fiberNumber = identifier.getFiber();
258 std::cout<<
"crate, slot, fiber = "<<crateNumber<<
", "<<slotNumber<<
", "<<fiberNumber<<
std::endl;
259 uint32_t fiberID = (crateNumber*5+slotNumber)*4 + fiberNumber;
262 <<
"RceFragment timestamp: " << rce_stream->getTimeStamp()
263 <<
", NChannels: " << n_ch
264 <<
", NTicks: " << n_ticks;
268 size_t buffer_size = n_ch * n_ticks;
269 if (
_buffer.capacity() < buffer_size)
272 <<
"Increase buffer size from " <<
_buffer.capacity()
273 <<
" to " << buffer_size;
278 int16_t* adcs =
_buffer.data();
279 rce_stream->getMultiChannelData(adcs);
282 for (
int i_ch = 0; i_ch < n_ch; i_ch++)
284 if(i==0 && i_ch ==0) std::cout<<
" ADCs for the the 100 ticks in the 1st channel of the 1st RCE "<<
std::endl;
286 for (
int i_tick = 0; i_tick < n_ticks; i_tick++)
289 if(i==0 && i_ch==0 && i_tick<100) {
290 std::cout<<adcs[i_tick]<<
"\t";
293 v_adc.push_back(adcs[i_tick]);
301 int offlineChannel = -1;
305 raw_digits.push_back(raw_digit);
308 uint32_t slotID = crateNumber*5 + slotNumber;
310 uint32_t slotchannel = 0;
311 slotchannel = fiberNumber*128 + i_ch;
333 for(
int i = 0; i <
n; i++){
334 if(wav[i]!=0) sum += wav[i];
336 float mean = sum /
n;
338 for(
int i = 0; i <
n; i++)
340 if (wav[i]!=0) sum += (wav[i]-
mean)*(wav[i]-mean);
342 return sqrt(sum / n);
351 for(
int i = 0; i <
n; i++)
353 if (wav[i]!=0) sum +=
abs(wav[i]);
bool _expect_container_fragments
std::vector< int16_t > _buffer
EventNumber_t event() const
Collection of charge vs time digitized from a single readout channel.
TpcStreamUnpack const * get_stream(int i) const
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
void reconfigure(const fhicl::ParameterSet &pset)
Handle< PROD > getHandle(SelectorBase const &) const
EDProducer(fhicl::ParameterSet const &pset)
std::vector< TProfile * > _h_mean_slot_channels_pfx
bool _process(const artdaq::Fragment &frag, RawDigits &raw_digits)
TH1I * _h_online_channels
static constexpr double fs
#define MF_LOG_ERROR(category)
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
RceRawDecoder(fhicl::ParameterSet const &p)
std::vector< TH2F * > _h_rms_slot_channels
unsigned int GetOfflineNumberFromDetectorElements(unsigned int crate, unsigned int slot, unsigned int fiber, unsigned int fembchannel, FelixOrRCE frswitch)
#define DEFINE_ART_MODULE(klass)
float meanADC(raw::RawDigit::ADCvector_t &wav)
T get(std::string const &key) const
SubRunNumber_t subRun() const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
TH1I * _h_offline_channels
#define MF_LOG_INFO(category)
float rmsADC(raw::RawDigit::ADCvector_t &wav)
std::vector< raw::RawDigit > RawDigits
std::vector< TH2F * > _h_mean_slot_channels
IDNumber_t< Level::Event > EventNumber_t
std::string _output_label
std::vector< TProfile * > _h_rms_slot_channels_pfx
std::vector< TH2I * > _h_fiber_persistent_wav
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
std::vector< Fragment > Fragments
cet::coded_exception< error, detail::translate > exception
void produce(art::Event &e) override
QTextStream & endl(QTextStream &s)
RceRawDecoder & operator=(RceRawDecoder const &)=delete