170 const string myname =
"test::HitNormCheck::analyze: ";
179 cout<<myname<<
"The event contains "<<
Hits->
size() <<
" hits\n";
197 auto wireIt = Wires->begin();
200 std::vector< hitinfo_t > hitInfoVec;
203 for(
size_t hitIter = 0; hitIter <
Hits->
size(); hitIter++ ){
208 cout<<myname<<
"Hit "<<hitIter<<*
hit;
214 hInfo.chan =
hit->Channel();
215 hInfo.hitid = hitIter;
216 hInfo.start =
hit->StartTick();
217 hInfo.end =
hit->EndTick();
218 hInfo.multiplicity =
hit->Multiplicity();
219 hInfo.adcsum =
hit->SummedADC();
220 hInfo.hitint =
hit->Integral();
221 hInfo.peak =
hit->PeakAmplitude();
223 if( hInfo.multiplicity > 1 ){
225 cout<<myname<<
"Process multi hit group"<<
endl;
228 while( hitIdx < (
unsigned)hInfo.multiplicity ){
231 if( multiHit->LocalIndex() != (
int)hitIdx ){
232 cerr<<myname<<
"Hit index is wrong: "<<multiHit->LocalIndex() <<
" != "<<hitIdx <<
endl;
233 cout<<hitIter<<
" "<<hitIdx<<
" "<<hInfo.multiplicity<<
" "<<multiHit->LocalIndex()<<
" "<<multiHit->Channel()<<
" "<<
hit->Channel()<<
" "<<hInfo.chan<<
endl;
236 hInfo.hitint += multiHit->Integral();
244 if(
hit->LocalIndex() > 0 ) {
245 cout<<myname<<
"This should not happen"<<
endl;
251 auto wire = HitToWires.at(hitIter);
254 auto signal = wire->Signal();
256 if( wire_start < 0 ) wire_start = 0;
258 if( wire_end > (
int)signal.size() ) wire_end = (
int)signal.size() - 1;
259 hInfo.adcsumpad = std::accumulate( signal.begin() + wire_start,
260 signal.begin() + wire_end, 0. );
267 if( wireChannel !=
hit->Channel() ){
268 cerr<<myname<<
"ERROR mismatch in hit and wire channel"<<
endl;
273 for( ;wireIt != Wires->end(); ++wireIt )
275 if( wireIt->Channel() == wireChannel ){
281 if (wireIt == Wires->end()){
282 cerr<<myname<<
"Could not find recob::Wire for channel for the hit"<<wireChannel<<
endl;
286 auto digit = WireToDigits.at(
std::distance(Wires->begin(), wireIt) );
287 if( digit->Channel() != wireChannel ) {
288 cout<<myname<<
"There is a channel mismatch with the RawDigit "<<wireChannel
289 <<
" "<<digit->Channel()<<
endl;
294 cerr<<myname<<
"ERROR: compression flag is set on raw data"<<
endl;
299 auto adc = digit->ADCs();
302 if( curChannel != wireChannel ){
303 curChannel = wireChannel;
315 if( hInfo.rawped < 0 ){
317 cout<<myname<<
"Could not calculate pedestal for the hit group "<<
endl;
322 cout<<myname<<
"Pedestal for this hit group in channel " 323 <<curChannel<<
" : "<<hInfo.rawped<<
" ADC"<<
endl;
326 int pstart =
hit->StartTick();
328 if( pend > (
int)digit->NADC() ) {
330 cout<<myname<<
"Skipping hit group at the end of the readout window"<<
endl;
336 hInfo.rawsum =
PulseSum(
adc, pstart, pend, hInfo.rawped );
338 cout<<myname<<
"Raw pulse sum "<<
fRawSum <<
" ADC"<<
endl;
341 if( dumped <
fDump ){
343 if( hInfo.rawped > 0 ){
345 DumpRoi<decltype(signal.begin())>(
"wire", hInfo.evenum,
346 hInfo.chan, hInfo.hitid,
348 signal.begin() + pstart,
349 signal.begin() +
hit->EndTick() );
351 DumpRoi<decltype(
adc.begin())>(
"digi", hInfo.evenum,
352 hInfo.chan, hInfo.hitid,
353 pstart, hInfo.rawped,
354 adc.begin() + pstart,
355 adc.begin() + pend );
360 hitInfoVec.push_back( hInfo );
372 for(
auto it = hitInfoVec.begin(); it!=hitInfoVec.end(); ++it )
374 auto nx = std::next( it, 1 );
377 if( nx != hitInfoVec.end() )
379 if( it->chan == nx->chan ){
380 dt = nx->start - it->start;
385 cout<<myname<<
"Skip hits that are separated "<<dt<<
" ticks"<<
endl;
391 if( it->rawped < 0 ) {
416 cout<<myname<<
"Processed "<<
Hits->
size()<<
" hits and skipped "<<iSkip<<
endl;
struct test::HitNormCheck::hitinfo_t hitinfo_t
std::string fHitModuleLabel
void PedestalProperties(const raw::RawDigit::ADCvector_t &digi, const std::vector< float > &wire, int this_hitstart, hitinfo_t &hinfo)
std::string fWireModuleLabel
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
float PulseSum(const raw::RawDigit::ADCvector_t &digi, int pstart, int pend, float pedestal)
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
Detector simulation of raw signals on wires.
void DumpRoi(const std::string roi_type, unsigned eve, unsigned chan, unsigned hit, int roi_start, float ped, Iterator begin, Iterator end)
art::PtrVector< recob::Hit > Hits
unsigned int ChannelID_t
Type representing the ID of a readout channel.
QTextStream & endl(QTextStream &s)