15 LOG(info) <<
"Loading SILICON Map from FILE: Period " << period <<
", Run " << run <<
"...";
23 for (
Int_t iSt = 0; iSt < kNStations; ++iSt) {
25 Int_t kNModules = st->GetNModules();
28 for (
Int_t iMod = 0; iMod < kNModules; ++iMod) {
29 auto* mod = st->GetModule(iMod);
33 for (
Int_t iLay = 0; iLay < kNLayers; ++iLay) {
48 LOGF(debug,
"Station: %d, Module: %2d, PseudoLayer: %2d, Strips: %3d", iSt, iMod, iLay,
54 histName.
Form(
"%s_%d_%d_%d",
fDetName.Data(), iSt, iMod, iLay);
55 fSigProf[iSt][iMod][iLay] =
new TH1F(histName, histName, kNStrips, 0, kNStrips);
56 fSigProf[iSt][iMod][iLay]->SetDirectory(0);
107 vector<string> channel_map;
108 vector<string> spec_thr;
115 po::options_description desc(
"Options");
116 desc.add_options()(
"CHANNEL_MAP.channels", po::value<vector<string>>(&channel_map)->multitoken(),
117 "ADC channel -> strip map")(
"SIGNAL_CONFIGURATION.spec_thr",
118 po::value<vector<string>>(&spec_thr)->multitoken(),
119 "ADC channel -> strip map")(
120 "SIGNAL_CONFIGURATION.Threshold", po::value<Double_t>(&final_thr)->default_value(150),
"ADC final threshold")(
121 "SIGNAL_CONFIGURATION.ThresholdDif", po::value<Double_t>(&thr_dif)->default_value(100),
"ADC threshold step")(
122 "SIGNAL_CONFIGURATION.NIterations", po::value<Int_t>(&n_iters)->default_value(6),
"ADC filter iterations")(
123 "SIGNAL_CONFIGURATION.CModCut", po::value<Double_t>(&cmod_cut)->default_value(100),
"ADC CModCut");
126 po::variables_map vm;
128 ifstream config_file(name.
Data(), ifstream::in);
129 if (!config_file.is_open()) {
130 LOG(error) <<
"Error opening map-file (" << name <<
")!";
133 po::store(po::parse_config_file(config_file, desc), vm);
143 for (
auto& str : spec_thr) {
144 istringstream ss(str);
145 ss >> std::hex >> ser >> std::dec >> ch >> thr;
147 LOGF(debug,
"Serial 0x%08X Channel %2d Threshold %3.3f", ser, ch, thr);
151 for (
auto& str : channel_map) {
152 istringstream ss(str);
153 ss >> std::hex >> ser >> std::dec >> ch_lo >> ch_hi >> mod_adc >> iMod >> iLay >> iStation;
157 record->
layer = iLay;
170 inner.insert(make_pair(record->
channel_low - 1,
nullptr));
172 fOuterMap.insert(make_pair(ser, move(inner)));
176 auto innerItLo = inner.find(record->
channel_low - 1);
177 if (innerItHi == inner.end()) {
180 if (innerItHi->second ==
nullptr) {
181 inner.erase(innerItHi);
184 fprintf(stderr,
"Wrong %s map! Overlapping intervals for %08X!\n",
fDetName.Data(), ser);
188 if (innerItLo == inner.end()) {
189 inner.insert(make_pair(record->
channel_low - 1,
nullptr));
197 auto* mod = st->GetModule(record->
module);
198 int32_t strip_min{INT32_MAX};
199 int32_t strip_max{0};
200 if (mod->GetNStripLayers() == 4) {
255 LOGF(info,
"Searching Noisy Channels in Silicon Strip Detectors");
256 LOGF(info,
"Window size: %3d, Threshold: %.2f, Correction: %3d", kNStripsInBunch, kNThresh,
257 (
int)
round(correction));
265 auto innerIt = inner.lower_bound(iCh);
266 if (innerIt == inner.end())
271 for (uint16_t iSmpl = 0; iSmpl <
GetNSamples(); ++iSmpl) {
274 if ((iStrip > rec->
strip_max) || (iStrip < rec->strip_min)) {
276 "fNoisyChannels strip outside range!\n\t"
277 " Station: %d, Module: %2d, Layer: %2d iStrip: %d set true",
292 for (
Int_t iMod = 0; iMod < st->GetNModules(); ++iMod) {
293 auto* mod = st->GetModule(iMod);
294 for (
Int_t iLay = 0; iLay < 2 ; ++iLay) {
312 bool newNoisyChannels =
true;
313 while (newNoisyChannels) {
316 newNoisyChannels =
false;
318 vector<int> noisyChannels;
319 for (
Int_t iStrip = 0; iStrip < kNStripsInBunch; ++iStrip) {
320 Int_t strip = iStrip;
337 if (curr > 0 && properStrips > 0) {
338 if (properStrips == 1
339 || (kNThresh * (sum - curr) / (properStrips - 1) < curr - correction))
341 LOGF(debug2,
"profile noise on iSt %d iMod %d iLay %d strip %d", iSt, iMod, iLay,
344 newNoisyChannels =
true;
345 noisyChannels.push_back(strip);
350 if (strip >= (kNStripsInBunch - 1) / 2
356 if (prof->
GetBinContent(strip - (kNStripsInBunch - 1) / 2 + 1) > 0)
365 if (prof->
GetBinContent(strip + (kNStripsInBunch / 2) + 1 + 1) > 0)
376 for (
auto strip : noisyChannels) {
395 auto innerIt = inner.lower_bound(iCh);
396 if (innerIt == inner.end())
401 for (uint16_t iSmpl = 0; iSmpl <
GetNSamples(); ++iSmpl) {
403 if ((iStrip > rec->
strip_max) || (iStrip < rec->strip_min)) {
405 "fNoisyChannels strip outside range!\n\t"
406 " Station: %d, Module: %2d, Layer: %2d iStrip: %d set true back",
427 auto innerIt = it->second.lower_bound(iCh);
428 if (innerIt == it->second.end())
437 SpecThr = itThr->second;
439 uint16_t station = rec->
station;
440 uint16_t module = rec->
module;
441 uint16_t layer = rec->
layer;
442 int32_t sampleShift =
446 for (uint16_t iSmpl = 0; iSmpl <
GetNSamples(); ++iSmpl) {
449 int32_t iStrip = sampleShift + iSmpl;
451 if ((iStrip > rec->
strip_max) || (iStrip < rec->strip_min)) {
453 "fNoisyChannels strip outside range!\n\t"
454 " Station: %d, Module: %2d, Layer: %2d iStrip: %d digi add",
474 fSigProf[station][module][layer]->Fill(iStrip);
map< int32_t, BmnSiliconMapInfo * > InChanMapSil
upper channel to map info (range map (C++20 is still unavailable, so we have to use crutches))