7 cout <<
"Loading Profilometer Map: Period " << period <<
", Run " <<
run <<
"..." << endl;
8 string dir = string(getenv(
"VMCWORKDIR")) +
"/input/";
9 fLocalMapFileName = dir + string(Form(
"Prof_map_run_%d.json", period));
10 fGlobalMapFileName = dir + string(Form(
"Prof_map_run_%d_global.txt", period));
11 ReadLocalMapFile(fLocalMapFileName);
12 ReadGlobalMapFile(fGlobalMapFileName);
32 TString gPathConfig = getenv(
"VMCWORKDIR");
33 TString xmlConfFileName;
36 xmlConfFileName =
"ProfRun8.xml";
39 printf(
"Error! Unknown config!\n");
43 TString gPathSiliconConfig = gPathConfig +
"/parameters/profilometer/XMLConfigs/";
44 return std::make_unique<BmnSiProfStationSet>(gPathSiliconConfig + xmlConfFileName);
47BmnStatus BmnProfRaw2Digit::ReadGlobalMapFile(
string name)
55 ifstream inFile(name);
56 if (!inFile.is_open())
57 cout <<
"Error opening map-file (" << name <<
")!" << endl;
58 for (Int_t
i = 0;
i < 2; ++
i)
59 getline(inFile, dummy);
60 while (!inFile.eof()) {
61 inFile >> std::hex >> ser >> std::dec >> ch >> station >> mod >> layer;
64 auto it = fChannelMaps.find(mod);
65 if (it == fChannelMaps.end())
67 auto itLayer = it->second.find(layer);
68 if (itLayer == it->second.end())
72 auto itGlobal = fGlobalMap.find(make_pair(ser, ch));
73 if (itGlobal == fGlobalMap.end()) {
74 auto pair = fGlobalMap.insert(make_pair(make_pair(ser, ch),
ProfiInfo{station, mod, &LayerInfo}));
76 itGlobal = pair.first;
79 cout <<
"ser: " << std::hex << ser << std::dec <<
" ch: " << ch << endl;
84BmnStatus BmnProfRaw2Digit::ReadLocalMapFile(
string name)
88 pt::read_json(name, conf);
89 pt::ptree pads = conf.get_child(
"modules");
90 for (
auto v = pads.begin();
v != pads.end();
v++) {
93 uint8_t mod = (*v).second.get<uint8_t>(
"moduleNumber");
94 pt::ptree maps = (*v).second.get_child(
"channelMapping");
95 for (
auto m = maps.begin();
m != maps.end();
m++) {
97 auto modIter = fChannelMaps.find(mod);
98 if (modIter == fChannelMaps.end()) {
100 printf(
"adding %d to the map\n", mod);
102 modIter = pair.first;
104 auto& localMap = modIter->second;
106 .LayerType = (*m).second.get<
char>(
"layerType")};
107 loc.LayerId = (loc.LayerType ==
'p') ? 0 : 1;
108 auto locPair = localMap.insert(make_pair(loc.LayerId, loc));
110 printf(
"adding %d : %d to the map\n", mod, loc.LayerId);
111 auto& stripArray = locPair.first->second.StripMap;
112 pt::ptree strips = (*m).second.get_child(
"stripsMapping");
113 for (
auto stripNode = strips.begin(); stripNode != strips.end(); stripNode++) {
114 auto it = (*stripNode).second.begin();
117 int stripId = (it)->second.get_value<int16_t>();
118 int chanlId = (++it)->second.get_value<int16_t>();
119 stripArray[chanlId] = stripId;
123 }
catch (boost::exception& e) {
124 cerr << boost::diagnostic_information(e);
125 cout <<
"Unable to parse the channel map!\n" << endl;
139 ProcessAdc(adc, csc, kFALSE);
151 ProcessAdc(adc,
nullptr, kTRUE);
156void BmnProfRaw2Digit::MapStrip(
ProfiInfo& info,
175 const Int_t kNThresh = 3;
179 auto it = fGlobalMap.find(make_pair(
GetSerials()[iCr], iCh));
180 if (it == fGlobalMap.end())
183 for (Int_t iSmpl = 0; iSmpl <
GetNSamples(); ++iSmpl)
185 uint16_t station = 0;
189 MapStrip(info, iCh, iSmpl, station, module, layer, strip);
195 for (Int_t iSt = 0; iSt < fSiProfStationSet->GetNStations(); ++iSt) {
196 auto* st = fSiProfStationSet->GetStation(iSt);
197 for (Int_t iMod = 0; iMod < st->GetNModules(); ++iMod) {
198 auto* mod = st->GetModule(iMod);
199 for (Int_t iLay = 0; iLay < mod->GetNStripLayers(); ++iLay) {
200 auto& lay = mod->GetStripLayer(iLay);
201 TH1F* prof =
fSigProf[iSt][iMod][iLay];
203 for (Int_t iStrip = 0; iStrip < lay.GetNStrips(); ++iStrip) {
207 Double_t next = prof->GetBinContent(iStrip + 1);
211 mean /= lay.GetNStrips();
212 for (Int_t iStrip = 0; iStrip < lay.GetNStrips(); ++iStrip) {
216 Double_t next = prof->GetBinContent(iStrip + 1);
218 if (kNThresh * mean < Abs(next - mean))
226 auto it = fGlobalMap.find(make_pair(
GetSerials()[iCr], iCh));
227 if (it == fGlobalMap.end())
230 for (Int_t iSmpl = 0; iSmpl <
GetNSamples(); ++iSmpl)
232 uint16_t station = 0;
236 MapStrip(info, iCh, iSmpl, station, module, layer, strip);
247void BmnProfRaw2Digit::ProcessAdc(TClonesArray* adc, TClonesArray* arr, Bool_t doFill)
250 for (Int_t iCr = 0; iCr <
fNSerials; ++iCr) {
251 for (Int_t iCh = 0; iCh <
fNChannels; ++iCh) {
252 auto it = fGlobalMap.find(make_pair(
GetSerials()[iCr], iCh));
253 if (it == fGlobalMap.end())
257 for (Int_t iSmpl = 0; iSmpl <
GetNSamples(); ++iSmpl) {
260 uint16_t station = 0;
264 MapStrip(info, iCh, iSmpl, station, module, layer, strip);
282 Double_t sig =
fAdc[iCr][iCh][iSmpl];
288 fSigProf[station][module][layer]->Fill(strip);
map< uint16_t, ProfiLocal > LayerIdProfiMap
Double_t *** GetPedestalsRMS()
void CalcEventMods_simd()
vector< UInt_t > & GetSerials()
Bool_t **** fNoisyChannels
void GrabNewSerial(UInt_t serial)
void InitNoiseArrays(SST &ss)
Bool_t *** GetNoisyChipChannels()
void DeleteNoiseArrays(SST &ss)
void(BmnAdcProcessor::* PrecalcEventModsImp)(TClonesArray *adc)
BmnStatus FillNoisyChannels()
static unique_ptr< BmnSiProfStationSet > GetProfStationSet(Int_t period)
BmnStatus FillProfiles(TClonesArray *adc)
BmnProfRaw2Digit(Int_t period, Int_t run)
BmnStatus FillEvent(TClonesArray *adc, TClonesArray *csc)
void SetIsGoodDigit(Bool_t tmp)
#define ADC_PROF_N_CHANNELS
int16_t StripMap[BmnProfRawTools::ChannelCnt()]