29 #include "DAQChannelMap/DAQChannelMap.h" 32 #include "NovaDAQConventions/DAQConventions.h" 49 return std::make_tuple(view, x, y) < std::make_tuple(rhs.
view, rhs.
x, rhs.
y);
63 const std::vector<rb::CellHit>& chits)
const;
65 const std::vector<rb::Cluster>& slices,
66 const std::vector<rb::Track>& tracks)
const;
71 std::set<DCMId>& pop)
const;
74 const std::set<DCMId>& pop,
75 int& nedge,
int& nmatch)
const;
97 fTrackSyncMetric = pset.
get<
bool >(
"TrackSyncMetric");
98 fTimeLow = pset.
get<
double >(
"TimeLow");
99 fTimeHigh = pset.
get<
double >(
"TimeHigh");
100 fNoisyHitMin = pset.
get<
int >(
"NoisyHitMin");
102 produces< sumdata::EventQuality >();
127 FillRawVars(spillqual.get(),*daqheader);
129 FillCountVars(spillqual.get(), *chits);
133 evt.
put(std::move(spillqual));
139 if(fTrackSyncMetric) evt.
getByLabel(fTrackLabel, tracks);
142 FillSyncVars(spillqual.get(), *slices, *tracks);
144 FillSyncVars(spillqual.get(), *slices, {});
148 evt.
put(std::move(spillqual));
154 const std::vector<rb::CellHit>& chits)
const 160 unsigned int horizhits = 0;
161 unsigned int ndcm3hits = 0;
163 unsigned int ncells_outtime = 0;
176 std::vector<std::vector<unsigned int> > ndcmhits(totdb);
177 for(
auto & itr : ndcmhits) itr.resize(totdcm, 0);
179 std::map<
unsigned int,
180 std::map<unsigned int, unsigned int> > dbapdmap;
184 const unsigned int dcm = cmap->
getDCM(chit.DaqChannel());
185 const unsigned int db = cmap->
getDiBlock(chit.DaqChannel());
186 const unsigned int apd = cmap->
getFEB(chit.DaqChannel());
188 ++ndcmhits[db-1][dcm-1];
191 if(chit.TNS() < fTimeLow || chit.TNS() > fTimeHigh ){
200 int cell = chit.Cell();
201 if(cell == 95 || cell == 87 || cell == 79 || cell == 71)
210 unsigned int ndeaddcms = 0;
213 for(
unsigned int dbIdx = 0; dbIdx < totdb; ++dbIdx){
215 for(
unsigned int dcmIdx = 0; dcmIdx < totdcm; ++dcmIdx){
216 if(ndcmhits[dbIdx][dcmIdx] == 0) ndeaddcms++;
220 for(
unsigned int dcmIdx = 0; dcmIdx < totdcm; ++dcmIdx){
221 if(ndcmhits[dbIdx][dcmIdx] == 0) ++ndeaddcms;
227 for(
unsigned int dcmIdx = 0; dcmIdx < 2; ++dcmIdx){
228 if(ndcmhits[totdb-1][dcmIdx] == 0) ++ndeaddcms;
234 float filter_lightson = 0.;
235 if(horizhits > 0) filter_lightson =
float(ndcm3hits)/horizhits;
241 int napd_hitmin_tot = 0;
244 for(
const auto dbItr : dbapdmap){
245 for(
const auto apdItr : dbItr.second){
246 if(apdItr.second > fNoisyHitMin) napd_hitmin_tot++;
261 const std::vector<rb::Cluster>& slices,
262 const std::vector<rb::Track>& tracks)
const 268 for(
const rb::Cluster& slice: slices) FillPopulatedDCMs(slice, pop);
275 if(fTrackSyncMetric){
277 AccumulateSyncMetric(
track, pop, nedge, nmatch);
281 if(!slice.IsNoise()) AccumulateSyncMetric(slice, pop, nedge, nmatch);
297 case kDown:
return kUp;
298 default:
assert(0 &&
"Not reached");
309 case kDown:
return DCMId(dcm.
view, dcm.
x, dcm.
y-1);
310 default:
assert(0 &&
"Not reached");
322 std::set<DCMId>& pop)
const 324 for(
unsigned int chitIdx = 0; chitIdx < clust.
NCell(); ++chitIdx){
327 const int dcmx = chit->
Plane() / 64;
328 const int dcmy = chit->
Cell() / 64;
330 pop.insert(
DCMId(chit->
View(), dcmx, dcmy));
336 const std::set<DCMId>& pop,
337 int& nedge,
int& nmatch)
const 339 std::map<DCMId, Edges> edges;
341 for(
unsigned int chitIdx = 0; chitIdx < clust.
NCell(); ++chitIdx){
344 const int modplane = chit->
Plane() % 64;
345 const int modcell = chit->
Cell() % 64;
347 const int dcmx = chit->
Plane() / 64;
348 const int dcmy = chit->
Cell() / 64;
352 if(modplane == 0 || modplane == 1) edges[
key].flag[
kLeft] =
true;
353 if(modplane == 62 || modplane == 63) edges[
key].flag[
kRight] =
true;
354 if(modcell == 0) edges[
key].flag[
kDown] =
true;
355 if(modcell == 63) edges[
key].flag[
kUp] =
true;
360 std::map<DCMId, Edges> edges_it = edges;
362 for(
auto it: edges_it){
371 if(!pop.count(nei))
continue;
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
int nouttimehits
of out-beam-window hits
virtual unsigned int getNumberOfDCM(DiBlock_TYPE dbt) const =0
How many DCMs does this diblock have?
std::string fTrackLabel
Label for tracks.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
unsigned short Plane() const
std::string fSliceLabel
Label for slices.
std::string fRawDataLabel
Label for raw data.
A collection of associated CellHits.
double fTimeHigh
Hit time of beam trigger window high end.
DCMId(geo::View_t v, int _x, int _y)
A rb::Prong with full reconstructed trajectory.
DQSpillFlags(fhicl::ParameterSet const &pset)
DEFINE_ART_MODULE(TestTMapFile)
int nmissingdcms
of missing DCMs
Horizontal planes which measure Y.
int nmicroslices
of micro slices
ProductID put(std::unique_ptr< PROD > &&product)
unsigned short Cell() const
void FillPopulatedDCMs(const rb::Cluster &clust, std::set< DCMId > &pop) const
void FillRawVars(sumdata::EventQuality *spillqual, const rawdata::DAQHeader &daqheader)
double fracdcm3hits
fraction of DCM3 hits in horizontal modules
float dcmedgematchfrac
Low values mean out-of-sync detector.
T get(std::string const &key) const
virtual unsigned int getTotalNumberOfDiblocks() const =0
How many diblocks does the detector have?
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Near Detector in the NuMI cavern.
bool operator<(const DCMId rhs) const
void FillCountVars(sumdata::EventQuality *spillqual, const std::vector< rb::CellHit > &chits) const
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
A rawdata::RawDigit with channel information decoded.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
void AccumulateSyncMetric(const rb::Cluster &clust, const std::set< DCMId > &pop, int &nedge, int &nmatch) const
DCMId Move(DCMId dcm, Dir d)
assert(nhit_max >=nhit_nbins)
cmap::CMap class source code
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
DiBlock_TYPE
Types of Diblock.
Calculate the spill level data quality flags and save to sumdata::EventQuality.
uint32_t dchan
< DAQ Channel Map Package
bool fTrackSyncMetric
Use track hits rather than all hits.
unsigned int fNoisyHitMin
Miniumum number of hits to be considered a noisy APD.
double fTimeLow
Hit time of beam trigger window low end.
int nnoisyapds
of noisy APDs
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
virtual DiBlock_TYPE getDiBlockType(dchan chan) const =0
What format is the diblock? Only relevant in NDOS.
Encapsulate the geometry of one entire detector (near, far, ndos)
std::string fCellHitLabel
Label for cell hits.
void FillSyncVars(sumdata::EventQuality *spillqual, const std::vector< rb::Cluster > &slices, const std::vector< rb::Track > &tracks) const
void produce(art::Event &evt)
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.
const unsigned int FirstPlaneInMuonCatcher() const
Returns the index of the first plane contained in the muon catcher.