6 std::vector<raw::RawDigit>
8 std::vector<std::pair <std::pair<unsigned int,unsigned int>,lbne::TpcNanoSlice::Header::nova_timestamp_t> > &DigitsIndexList,
9 lbne::TpcNanoSlice::Header::nova_timestamp_t& firstTimestamp,
13 DigitsIndexList.clear();
15 unsigned int numFragments = rawFragments.size();
16 bool TimestampSet =
false;
18 std::map < unsigned int, unsigned int > mapFragID;
20 for(
size_t fragIndex = 0; fragIndex < rawFragments.size(); fragIndex++){
22 const artdaq::Fragment &singleFragment = rawFragments[fragIndex];
24 unsigned int fragmentID = singleFragment.fragmentID();
26 mapFragID.insert(std::pair<unsigned int, unsigned int>(fragmentID,fragIndex));
31 std::cout << numFragments<<
" rawFragments" <<
std::endl;
34 std::vector<raw::RawDigit> rawDigitVector;
43 for(
size_t chan=0;chan < numChans;chan++){
51 std::cout <<
"channel: " << chan
52 <<
"\tfragment: " << fragmentID
54 <<
"\tsample: " << sample
61 if( mapFragID.find(fragmentID) == mapFragID.end() ){
63 if (debug) std::cout <<
"Fragment not found" <<
std::endl;
68 unsigned int fragIndex = mapFragID[fragmentID];
70 if (debug) std::cout <<
"fragIndex: " << fragIndex <<
std::endl;
72 std::vector<short> adcvec;
75 const artdaq::Fragment &singleFragment = rawFragments[fragIndex];
76 lbne::TpcMilliSliceFragment millisliceFragment(singleFragment);
79 auto numMicroSlices = millisliceFragment.microSliceCount();
80 bool FirstMicro =
false;
81 unsigned int FirstGoodIndex = 0;
82 unsigned int LastGoodIndex = 0;
83 bool PrevMicroRCE =
false;
84 lbne::TpcNanoSlice::Header::nova_timestamp_t ThisTimestamp = 0;
85 bool MadeList = DigitsIndexList.size();
86 for(
unsigned int i_micro=0;i_micro<numMicroSlices;i_micro++){
87 std::unique_ptr <const lbne::TpcMicroSlice> microSlice = millisliceFragment.microSlice(i_micro);
88 auto numNanoSlices = microSlice->nanoSliceCount();
91 for(
uint32_t i_nano=0; i_nano < numNanoSlices; i_nano++){
93 bool success = microSlice->nanosliceSampleValue(i_nano, sample, val);
94 if(success) adcvec.push_back(
short(val));
100 if (!FirstMicro && numNanoSlices) {
101 lbne::TpcNanoSlice::Header::nova_timestamp_t Timestamp = microSlice->nanoSlice(0)->nova_timestamp();
103 if (!TimestampSet || Timestamp < firstTimestamp) {
105 firstTimestamp = Timestamp;
112 LastGoodIndex = LastGoodIndex + numNanoSlices;
113 if (PrevMicroRCE ==
false)
114 ThisTimestamp = microSlice->nanoSlice(0)->nova_timestamp();
116 if (PrevMicroRCE ==
true && ( !numNanoSlices || i_micro==numMicroSlices-1 ) ) {
118 DigitsIndexList.push_back( std::make_pair( std::make_pair(FirstGoodIndex,LastGoodIndex-1), ThisTimestamp) );
119 FirstGoodIndex = LastGoodIndex;
121 PrevMicroRCE = (
bool)numNanoSlices;
126 if (DigitsIndexList.size() && !MadeList ) {
132 if (debug) std::cout <<
"adcvec->size(): " << adcvec.size() <<
std::endl;
133 unsigned int numTicks = adcvec.size();
135 int offlineChannel = -1;
136 if (useChannelMap) offlineChannel = channelMap->Offline(chan);
137 else offlineChannel = chan;
138 raw::RawDigit theRawDigit(offlineChannel, numTicks, adcvec, compression);
139 rawDigitVector.push_back(theRawDigit);
142 return rawDigitVector;
157 TTimeStamp time_of_event(20100101u,
161 seconds_since_nova_epoch);
enum raw::_compress Compress_t
static art::Timestamp fromNova(uint64_t tnova)
Collection of charge vs time digitized from a single readout channel.
unsigned int getNanoSliceSampleForChan(unsigned int channel)
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)
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
unsigned int getFragIDForChan(unsigned int channel)
art::Timestamp make_art_timestamp_from_nova_timestamp(lbne::TpcNanoSlice::Header::nova_timestamp_t this_nova_timestamp)
art::Timestamp old_make_art_timestamp_from_nova_timestamp(lbne::TpcNanoSlice::Header::nova_timestamp_t this_nova_timestamp)
static int max(int a, int b)
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
const lbne::TpcNanoSlice::Header::nova_timestamp_t nova_time_ticks_per_second
QTextStream & endl(QTextStream &s)