Project
Loading...
Searching...
No Matches
DCSParserSpec.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13
15
16#ifdef WITH_OPENMP
17#include <omp.h>
18#endif
19
20namespace o2
21{
22namespace its
23{
24
26// Default constructor
28{
29 this->mSelfName = o2::utils::Str::concat_string(ChipMappingITS::getName(), "ITSDCSParser");
30}
31
34{
35 LOGF(info, "ITSDCSParser init...", mSelfName);
36
37 this->mCcdbUrl = ic.options().get<std::string>("ccdb-url");
38
39 this->mCcdbUrlRct = ic.options().get<std::string>("ccdb-url-rct");
40
41 this->mVerboseOutput = ic.options().get<bool>("verbose");
42
43 return;
44}
45
47// Main running function
48// Get DCSconfigObject_t from EPNs and aggregate them in 1 object
50{
51 // check O2/Detectors/DCS/testWorkflow/src/dcs-config-proxy.cxx for input format
52
53 // Retrieve string from inputs
54 const auto inString = pc.inputs().get<gsl::span<char>>("inString");
55 std::string inStringConv;
56 std::copy(inString.begin(), inString.end(), std::back_inserter(inStringConv));
57
58 // Check for DOS vs. Unix line ending
59 std::string line_ending = "\n";
60 size_t newline_pos = inStringConv.find(line_ending);
61 if (newline_pos && newline_pos != std::string::npos &&
62 inStringConv[newline_pos - 1] == '\r') {
63 line_ending = "\r\n";
64 }
65
66 // Initialize Dead Chips map
67 this->mDeadMap = o2::itsmft::NoiseMap(mp.getNChips());
68
69 // Loop over lines in the input file
70 for (const std::string& line : this->vectorizeStringList(inStringConv, line_ending)) {
71 if (!line.length()) {
72 continue;
73 }
74 this->updateMemoryFromInputString(line);
75 this->appendDeadChipObj();
76 this->saveToOutput();
77 this->resetMemory();
78 }
79
80 this->saveMissingToOutput();
81
82 if (this->mConfigDCS.size() && this->mDeadMap.size()) {
83 LOG(info) << "Pushing to CCDB...\n";
84 this->pushToCCDB(pc);
85 this->mConfigDCS.clear();
86 }
87
88 // Reset saved information for the next EOR file
89 this->mRunNumber = UNSET_INT;
90 this->mConfigVersion = UNSET_INT;
91 this->mRunType = UNSET_SHORT;
92
93 return;
94}
95
97void ITSDCSParser::updateMemoryFromInputString(const std::string& inString)
98{
99
100 // Print the entire string if verbose mode is requested
101 if (this->mVerboseOutput) {
102 LOG(info) << "Parsing string: " << inString;
103 }
104
105 // Parse the individual parts of the string
106 const std::string delimiter = "|";
107 const std::string terminator = "!";
108 size_t pos = 0;
109 size_t npos = inString.find(delimiter);
110 if (npos == std::string::npos) {
111 LOG(error) << "Delimiter not found, possibly corrupted data!";
112 return;
113 }
114
115 // First is the stave name
116 this->mStaveName = inString.substr(pos, npos);
117 this->mSavedStaves.push_back(this->mStaveName);
118
119 // Control the integrity of the string
120 this->mTerminationString = true;
121 if (inString.back() != '!') {
122 this->mTerminationString = false;
123 LOG(warning) << "Terminator not found, possibly incomplete data for stave " << this->mStaveName << " !";
124 }
125
126 // Next is the run number
127 if (!this->updatePosition(pos, npos, delimiter, "RUN", inString)) {
128 return;
129 }
130 this->updateAndCheck(this->mRunNumber, std::stoi(inString.substr(pos, npos)));
131
132 // Next is the config
133 if (!this->updatePosition(pos, npos, delimiter, "CONFIG", inString)) {
134 return;
135 }
136 this->updateAndCheck(this->mConfigVersion, std::stoi(inString.substr(pos, npos)));
137
138 // Then it's the run type
139 if (!this->updatePosition(pos, npos, delimiter, "RUNTYPE", inString)) {
140 return;
141 }
142 this->updateAndCheck(this->mRunType, std::stoi(inString.substr(pos, npos)));
143
144 // Then there is a semicolon-delineated list of disabled chips
145 if (!this->updatePosition(pos, npos, delimiter, "DISABLED_CHIPS", inString)) {
146 return;
147 }
148 std::string disabledChipsStr = inString.substr(pos, npos);
149 if (disabledChipsStr.length()) {
150 this->mDisabledChips = this->vectorizeStringListInt(disabledChipsStr, ";");
151 }
152
153 // Then there is a 2D list of masked double-columns
154 if (!this->updatePosition(pos, npos, delimiter, "MASKED_DCOLS", inString)) {
155 return;
156 }
157 std::string maskedDoubleColsStr = inString.substr(pos, npos);
158 if (maskedDoubleColsStr.length()) {
159 std::vector<std::string> chipVect = this->vectorizeStringList(maskedDoubleColsStr, ";");
160 for (const std::string& str : chipVect) {
161 // Element 0 in each subvector is chip ID, rest are double column numbers
162 this->mMaskedDoubleCols.push_back(this->vectorizeStringListInt(str, ":"));
163 }
164 }
165
166 // Finally, there are double columns which are disabled at EOR
167 if (!this->updatePosition(pos, npos, delimiter, "DCOLS_EOR", inString, true)) {
168 return;
169 }
170 std::string doubleColsEORstr = inString.substr(pos);
171
172 // In this case the terminator is missing and the DCOLS_EOR field is empty:
173 // the stave is passed whitout meaningful infos
174 if (doubleColsEORstr == "|") {
175 this->writeChipInfo(this->mStaveName, -1);
176 o2::dcs::addConfigItem(this->mConfigDCS, "String_OK", this->mTerminationString);
177 }
178 // Eliminate all the chars after the last ";":
179 // If the string is complete this has no effect on the saved object
180 // If the string is incomplete this avoids saving wrong data
181 size_t pos_del = doubleColsEORstr.rfind(';');
182 if (pos_del != std::string::npos) {
183 doubleColsEORstr = doubleColsEORstr.erase(pos_del);
184 }
185
186 if (doubleColsEORstr.length()) {
187 std::vector<std::string> bigVect = this->vectorizeStringList(doubleColsEORstr, "&");
188 for (const std::string& bigStr : bigVect) {
189 std::vector<std::string> bigVectSplit = this->vectorizeStringList(bigStr, "|");
190 if (!bigVectSplit.size()) {
191 continue;
192 }
193
194 // First, update map of disabled double columns at EOR
195 std::vector<std::string> doubleColDisable = this->vectorizeStringList(bigVectSplit[0], ";");
196 for (const std::string& str : doubleColDisable) {
197 if (str == '!') {
198 continue; // protection needed to avoid to pass '!' to std::stoi() in vectorizeStringListInt()
199 }
200 std::vector<unsigned short int> doubleColDisableVector = this->vectorizeStringListInt(str, ":");
201 this->mDoubleColsDisableEOR[doubleColDisableVector[0]].push_back(doubleColDisableVector[1]);
202 }
203 // Second, update map of flagged pixels at EOR
204 if (bigVectSplit.size() > 1) {
205 std::vector<std::string> pixelFlagsEOR = this->vectorizeStringList(bigVectSplit[1], ";");
206 for (const std::string& str : pixelFlagsEOR) {
207 std::vector<unsigned short int> pixelFlagsVector = this->vectorizeStringListInt(str, ":");
208 this->mPixelFlagsEOR[pixelFlagsVector[0]].push_back(pixelFlagsVector[1]);
209 }
210 }
211 }
212 }
213
214 return;
215}
216
218// Update pos and npos and check for validity. Return false if there is error
219bool ITSDCSParser::updatePosition(size_t& pos, size_t& npos,
220 const std::string& delimiter, const char* word,
221 const std::string& inString, bool ignoreNpos /*=false*/)
222{
223 pos += npos + delimiter.length() + std::string(word).length();
224 if (!ignoreNpos) {
225 npos = inString.find(delimiter, pos);
226
227 // Check that npos does not go out-of-bounds
228 if (npos == std::string::npos) {
229 LOG(error) << "Delimiter not found, possibly corrupted data for stave " << this->mStaveName << " !";
230 // If the last word is not complete and the terminator is missing the stave is saved as a stave
231 this->writeChipInfo(this->mStaveName, -1);
232 o2::dcs::addConfigItem(this->mConfigDCS, "String_OK", this->mTerminationString);
233
234 return false;
235 }
236
237 npos -= pos;
238 }
239
240 return true;
241}
242
244// Update memValue using newValue if memValue is not yet set
245void ITSDCSParser::updateAndCheck(int& memValue, const int newValue)
246{
247 // Check if value in memory is nonsense, meaning it has never been updated
248 if (memValue == UNSET_INT) {
249 // Save value in memory for the first time (should always be the same)
250 memValue = newValue;
251 } else if (memValue != newValue) {
252 // Different value received than the one saved in memory -- throw error
253 throw std::runtime_error(fmt::format("New value {} differs from old value {}", newValue, memValue));
254 }
255
256 return;
257}
258
260void ITSDCSParser::updateAndCheck(short int& memValue, const short int newValue)
261{
262 // Check if value in memory is nonsense, meaning it has never been updated
263 if (memValue == UNSET_SHORT) {
264 // Save value in memory for the first time (should always be the same)
265 memValue = newValue;
266 } else if (memValue != newValue) {
267 // Different value received than the one saved in memory -- throw error
268 throw std::runtime_error(fmt::format("New value {} differs from old value {}", newValue, memValue));
269 }
270
271 return;
272}
273
275// Take string delimited by delimiter and parse into vector of objects
276std::vector<std::string> ITSDCSParser::vectorizeStringList(
277 const std::string& str, const std::string& delimiter)
278{
279 std::vector<std::string> str_vect;
280 size_t prev_pos = 0, pos = 0;
281 while ((pos = str.find(delimiter, pos)) != std::string::npos) {
282 std::string substr = str.substr(prev_pos, pos - prev_pos);
283 if (substr.length()) {
284 str_vect.push_back(substr);
285 }
286 pos += delimiter.length();
287 prev_pos = pos;
288 }
289 std::string substr = str.substr(prev_pos, pos - prev_pos);
290 if (substr.length()) {
291 str_vect.push_back(substr);
292 }
293 return str_vect;
294}
295
297std::vector<unsigned short int> ITSDCSParser::vectorizeStringListInt(
298 const std::string& str, const std::string& delimiter)
299{
300 std::vector<unsigned short int> int_vect;
301 size_t prev_pos = 0, pos = 0;
302 while ((pos = str.find(delimiter, pos)) != std::string::npos) {
303 unsigned short int substr = std::stoi(str.substr(prev_pos, pos - prev_pos));
304 int_vect.push_back(substr);
305 pos += delimiter.length();
306 prev_pos = pos;
307 }
308 int_vect.push_back(std::stoi(str.substr(prev_pos, pos - prev_pos)));
309 return int_vect;
310}
311
313void ITSDCSParser::saveToOutput()
314{
315 // First loop through the disabled chips to write these to the string
316 for (const unsigned short int& chipID : this->mDisabledChips) {
317 // Write basic chip info
318 this->writeChipInfo(this->mStaveName, chipID);
319
320 // Mark chip as disabled
321 o2::dcs::addConfigItem(this->mConfigDCS, "Disabled", "1");
322
323 // Mark other information with nonsense value
324 o2::dcs::addConfigItem(this->mConfigDCS, "Dcol_masked", "-1");
325 o2::dcs::addConfigItem(this->mConfigDCS, "Dcol_masked_eor", "-1");
326 o2::dcs::addConfigItem(this->mConfigDCS, "Pixel_flags", "-1");
327 o2::dcs::addConfigItem(this->mConfigDCS, "String_OK", this->mTerminationString);
328
329 // Ensure that chips are removed from the maps
330 mDoubleColsDisableEOR.erase(chipID);
331 mPixelFlagsEOR.erase(chipID);
332 }
333
334 // Second, loop through all the chips with disabled double columns
335 for (std::vector<unsigned short int> maskedDoubleCols : this->mMaskedDoubleCols) {
336 unsigned short int chipID = maskedDoubleCols[0];
337 maskedDoubleCols.erase(maskedDoubleCols.begin());
338
339 // Write basic chip info
340 this->writeChipInfo(this->mStaveName, chipID);
341 o2::dcs::addConfigItem(this->mConfigDCS, "Disabled", "0");
342
343 // Write information for disabled double columns
344 o2::dcs::addConfigItem(this->mConfigDCS, "Dcol_masked", this->intVecToStr(maskedDoubleCols, "|"));
345
346 // Retrieve information from maps, if any, and then erase
348 this->mConfigDCS, "Dcol_masked_eor", this->intVecToStr(this->mDoubleColsDisableEOR[chipID], "|"));
349 this->mDoubleColsDisableEOR.erase(chipID);
351 this->mConfigDCS, "Pixel_flags", this->intVecToStr(this->mPixelFlagsEOR[chipID], "|"));
352 this->mPixelFlagsEOR.erase(chipID);
353 o2::dcs::addConfigItem(this->mConfigDCS, "String_OK", this->mTerminationString);
354 }
355
356 // Finally, loop through any remaining chips
357 for (const auto& [chipID, v] : this->mDoubleColsDisableEOR) {
358 std::string s = this->intVecToStr(v, "|");
359 if (s != "-1") { // Ensure no meaningless entries
360 this->writeChipInfo(this->mStaveName, chipID);
361 o2::dcs::addConfigItem(this->mConfigDCS, "Disabled", "0");
362 o2::dcs::addConfigItem(this->mConfigDCS, "Dcol_masked", "-1");
363 o2::dcs::addConfigItem(this->mConfigDCS, "Dcol_masked_eor", this->intVecToStr(v, "|"));
365 this->mConfigDCS, "Pixel_flags", this->intVecToStr(this->mPixelFlagsEOR[chipID], "|"));
366 this->mPixelFlagsEOR.erase(chipID);
367 o2::dcs::addConfigItem(this->mConfigDCS, "String_OK", this->mTerminationString);
368 }
369 }
370
371 for (const auto& [chipID, v] : this->mPixelFlagsEOR) {
372 std::string s = this->intVecToStr(v, "|");
373 if (s != "-1") { // Ensure no meaningless entries
374 this->writeChipInfo(this->mStaveName, chipID);
375 o2::dcs::addConfigItem(this->mConfigDCS, "Disabled", "0");
376 o2::dcs::addConfigItem(this->mConfigDCS, "Dcol_masked", "-1");
377 o2::dcs::addConfigItem(this->mConfigDCS, "Dcol_masked_eor", "-1");
378 o2::dcs::addConfigItem(this->mConfigDCS, "Pixel_flags", this->intVecToStr(v, "|"));
379 o2::dcs::addConfigItem(this->mConfigDCS, "String_OK", this->mTerminationString);
380 }
381 }
382 return;
383}
384
386void ITSDCSParser::saveMissingToOutput()
387{
388 // Loop on the missing staves
389 std::vector<string> missingStaves;
390 std::vector<string> listStaves = this->listStaves();
391 std::vector<string> savedStaves = this->mSavedStaves;
392 std::sort(savedStaves.begin(), savedStaves.end());
393 std::set_difference(listStaves.begin(), listStaves.end(), savedStaves.begin(), savedStaves.end(),
394 std::inserter(missingStaves, missingStaves.begin()));
395
396 for (std::string stave : missingStaves) {
397 this->writeChipInfo(stave, -1);
398 o2::dcs::addConfigItem(this->mConfigDCS, "String_OK", "-1");
399 }
400
401 return;
402}
403
405// Reset memory for reading another line from input string
406void ITSDCSParser::resetMemory()
407{
408 mStaveName = "";
409 mDisabledChips.clear();
410 mMaskedDoubleCols.clear();
411 mDoubleColsDisableEOR.clear();
412 mPixelFlagsEOR.clear();
413 return;
414}
415
417// Convert vector of integers to one single string, delineated by delin
418std::string ITSDCSParser::intVecToStr(
419 const std::vector<unsigned short int>& v, const std::string& delin)
420{
421 // Return nonsense value if there are no entries
422 if (v.empty()) {
423 return "-1";
424 }
425
426 std::string bigStr = std::to_string(v[0]);
427 for (int i = 1; i < v.size(); i++) {
428 bigStr += delin + std::to_string(v[i]);
429 }
430
431 return bigStr;
432}
433
435// Write the Stave, Hs_pos, Hic_pos, and ChipID to the config object
436void ITSDCSParser::writeChipInfo(
437 const std::string& staveName, const short int chipID)
438{
439 // Stave present in the EOR data and all the "worlds" correctly read
440 if (chipID != -1) {
441 // First save the Stave to the string
442 o2::dcs::addConfigItem(this->mConfigDCS, "Stave", staveName);
443 unsigned short int hicPos = getModule(chipID);
444 bool hsPos = getHS(chipID);
445 o2::dcs::addConfigItem(this->mConfigDCS, "Hs_pos", std::to_string(hsPos));
446 o2::dcs::addConfigItem(this->mConfigDCS, "Hic_pos", std::to_string(hicPos));
447
448 // Chip ID inside the module
449 o2::dcs::addConfigItem(this->mConfigDCS, "ChipID", std::to_string(chipID % 16));
450 }
451
452 // Stave missing in the EOR data or "word" non cottectly read
453 else {
454 o2::dcs::addConfigItem(this->mConfigDCS, "Stave", staveName);
455 o2::dcs::addConfigItem(this->mConfigDCS, "Hs_pos", "-1");
456 o2::dcs::addConfigItem(this->mConfigDCS, "Hic_pos", "-1");
457 o2::dcs::addConfigItem(this->mConfigDCS, "ChipID", "-1");
458 o2::dcs::addConfigItem(this->mConfigDCS, "Disabled", "-1");
459 o2::dcs::addConfigItem(this->mConfigDCS, "Dcol_masked", "-1");
460 o2::dcs::addConfigItem(this->mConfigDCS, "Dcol_masked_eor", "-1");
461 o2::dcs::addConfigItem(this->mConfigDCS, "Pixel_flags", "-1");
462 }
463
464 return;
465}
466
468void ITSDCSParser::pushToCCDB(ProcessingContext& pc)
469{
470 // Timestamps for CCDB entry
471 long tstart = 0, tend = 0;
472 // retireve run start/stop times from CCDB
474 cdbman.setURL(mCcdbUrlRct);
475 cdbman.setFatalWhenNull(false);
476 auto ts = o2::ccdb::BasicCCDBManager::instance().getRunDuration(mRunNumber, false);
477 if (ts.first < 0 || ts.second < 0) {
478 LOGP(info, "Failed to retrieve headers from CCDB with run number {}, << this->mRunNumber, will default to using the current time for timestamp information", mRunNumber);
480 tend = tstart + 365L * 24 * 3600 * 1000;
481 } else {
482 tstart = ts.first;
483 tend = ts.second;
484 }
485
486 auto class_name = o2::utils::MemFileHelper::getClassName(mConfigDCS);
487 auto class_name_deadMap = o2::utils::MemFileHelper::getClassName(mDeadMap);
488
489 // Create metadata for database object
490 std::map<std::string, std::string> metadata{{"runtype", std::to_string(mRunType)}, {"confDBversion", std::to_string(mConfigVersion)}, {"runNumber", std::to_string(mRunNumber)}};
491 std::string path("ITS/Calib/DCS_CONFIG");
492 std::string path_deadMap("ITS/Calib/DeadMap");
493 const char* filename = "dcs_config.root";
494 long current_time = o2::ccdb::getCurrentTimestamp();
495 std::string filename_deadMap = "o2-itsmft-NoiseMap_" + std::to_string(current_time) + ".root";
496 o2::ccdb::CcdbObjectInfo info(path, "dcs_config", filename, metadata, tstart - 2 * o2::ccdb::CcdbObjectInfo::MINUTE, tend + 2 * o2::ccdb::CcdbObjectInfo::MINUTE);
497 o2::ccdb::CcdbObjectInfo info_deadMap(path_deadMap, "noise_map", filename_deadMap, metadata, tstart - 2 * o2::ccdb::CcdbObjectInfo::MINUTE, tend + 2 * o2::ccdb::CcdbObjectInfo::MINUTE);
498 auto image = o2::ccdb::CcdbApi::createObjectImage(&mConfigDCS, &info);
499 auto image_deadMap = o2::ccdb::CcdbApi::createObjectImage(&mDeadMap, &info_deadMap);
500 info.setFileName(filename);
501 info_deadMap.setFileName(filename_deadMap);
502
503 // Send to ccdb-populator wf
504 LOG(info) << "Class Name: " << class_name << " | File Name: " << filename
505 << "\nSending to ccdb-populator the object " << info.getPath() << "/" << info.getFileName()
506 << " of size " << image->size() << " bytes, valid for "
507 << info.getStartValidityTimestamp() << " : "
508 << info.getEndValidityTimestamp();
509
510 if (mCcdbUrl.empty()) {
511
514
515 } else { // if url is specified, send object to ccdb from THIS wf
516
517 LOG(info) << "Sending object " << info.getFileName() << " to " << mCcdbUrl << "/browse/"
518 << info.getPath() << " from the ITS string parser workflow";
520 mApi.init(mCcdbUrl);
522 &image->at(0), image->size(), info.getFileName(), info.getObjectType(), info.getPath(),
523 info.getMetaData(), info.getStartValidityTimestamp(), info.getEndValidityTimestamp());
524 }
525
526 // Send dead chips map to ccdb-populator wf
527 LOG(info) << "Class Name: " << class_name_deadMap << " | File Name: " << filename_deadMap
528 << "\nSending to ccdb-populator the object " << info_deadMap.getPath() << "/" << info_deadMap.getFileName()
529 << " of size " << image_deadMap->size() << " bytes, valid for "
530 << info_deadMap.getStartValidityTimestamp() << " : "
531 << info_deadMap.getEndValidityTimestamp();
532
533 if (mCcdbUrl.empty()) {
534
535 pc.outputs().snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "DCS_CONFIG", 1}, *image_deadMap);
536 pc.outputs().snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "DCS_CONFIG", 1}, info_deadMap);
537
538 } else { // if url is specified, send object to ccdb from THIS wf
539
540 LOG(info) << "Sending object " << info_deadMap.getFileName() << " to " << mCcdbUrl << "/browse/"
541 << info_deadMap.getPath() << " from the ITS string parser workflow";
543 mApi.init(mCcdbUrl);
545 &image_deadMap->at(0), image_deadMap->size(), info_deadMap.getFileName(), info_deadMap.getObjectType(), info_deadMap.getPath(),
546 info_deadMap.getMetaData(), info_deadMap.getStartValidityTimestamp(), info_deadMap.getEndValidityTimestamp());
547 }
548
549 return;
550}
551
553std::vector<std::string> ITSDCSParser::listStaves()
554{
555 std::vector<std::string> vecStaves = {};
556 int stavesPerLayer[] = {12, 16, 20, 24, 30, 42, 48};
557 std::string stavenum = "";
558 for (int i = 0; i < 7; i++) {
559 for (int j = 0; j < stavesPerLayer[i]; j++) {
560 string stavestring = std::to_string(j);
561 int precision = 2 - std::min(2, (int)(stavestring.size()));
562 stavenum = std::string(precision, '0').append(std::to_string(j));
563 std::string stave = "L" + std::to_string(i) + "_" + stavenum;
564 vecStaves.push_back(stave);
565 }
566 }
567 return vecStaves;
568}
569
571void ITSDCSParser::appendDeadChipObj()
572{
573 // Append an object to the deadMap
574
575 for (auto ch : this->mDisabledChips) {
576
577 unsigned short int hicPos = getModule(ch);
578 bool hS = getHS(ch);
579 unsigned short int chipInMod = ch % 16;
580
581 unsigned short int globchipID = getGlobalChipID(hicPos, hS, chipInMod);
582 this->mDeadMap.maskFullChip(globchipID);
583 if (mVerboseOutput) {
584 LOG(info) << "Masking dead chip " << globchipID;
585 }
586 }
587}
588
590unsigned short int ITSDCSParser::getGlobalChipID(unsigned short int hicPos, bool hS, unsigned short int chipInMod)
591{
592 // Find the global ID of a chip (0->24119)
593 std::vector<unsigned short int> stavesPerLayer = {12, 16, 20, 24, 30, 42, 48};
594 std::vector<unsigned short int> chipPerStave = {9, 9, 9, 112, 112, 196, 196};
595 std::vector<unsigned short int> maxChipIDlayer = {0};
596 int maxChip = 0;
597 for (int i = 0; i < 7; i++) {
598 maxChip += stavesPerLayer[i] * chipPerStave[i];
599 maxChipIDlayer.push_back(maxChip - 1);
600 }
601
602 unsigned short int layerNum = std::stoi(this->mStaveName.substr(1, 1));
603 unsigned short int staveNum = std::stoi(this->mStaveName.substr(3, 2));
604
605 unsigned short int chipid_in_HIC = ((layerNum > 2 && chipInMod > 7) || layerNum == 0) ? chipInMod : chipInMod + 1;
606 unsigned short int modPerLayer = (layerNum > 2 && layerNum < 5) ? 4 : 7;
607 unsigned short int add_HSL = (hS) ? (14 * modPerLayer) : 0;
608
609 unsigned short int chipIDglob = chipid_in_HIC + maxChipIDlayer[layerNum] + (staveNum)*chipPerStave[layerNum] + (hicPos - 1) * 14 + add_HSL;
610
611 return chipIDglob;
612}
613
615unsigned short int ITSDCSParser::getModule(unsigned short int chipID)
616{
617 // Get the number of the module (1->7)
618 unsigned short int hicPos = 0;
619 if (std::stoi((this->mStaveName).substr(1, 1)) > 2) { // OB case
620 if (chipID / 16 <= 7) {
621 hicPos = chipID / 16;
622 } else {
623 hicPos = (chipID / 16) - 8;
624 }
625 } else {
626 hicPos = 1; // IB case
627 }
628 return hicPos;
629}
630
632bool ITSDCSParser::getHS(unsigned short int chipInMod)
633{
634 // Return 0 if the chip is in the HSL, 1 if the chip is in the HSU
635 bool hS;
636 if (chipInMod / 16 <= 7) {
637 hS = 0; // L
638 } else {
639 hS = 1; // U
640 }
641 return hS;
642}
643
646{
648 std::vector<InputSpec> inputs;
649 inputs.emplace_back("inString", detOrig, "DCS_CONFIG_FILE", 0, Lifetime::Sporadic);
650 inputs.emplace_back("nameString", detOrig, "DCS_CONFIG_NAME", 0, Lifetime::Sporadic);
651
652 std::vector<OutputSpec> outputs;
653 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "DCS_CONFIG"}, Lifetime::Sporadic);
654 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "DCS_CONFIG"}, Lifetime::Sporadic);
655
656 return DataProcessorSpec{
657 "its-parser",
658 inputs,
659 outputs,
660 AlgorithmSpec{adaptFromTask<o2::its::ITSDCSParser>()},
661 Options{
662 {"verbose", VariantType::Bool, false, {"Use verbose output mode"}},
663 {"ccdb-url", VariantType::String, "", {"CCDB url, default is empty (i.e. send output to CCDB populator workflow)"}},
664 {"ccdb-url-rct", VariantType::String, "http://o2-ccdb.internal", {"CCDB url from where to get RCT object for headers, default is o2-ccdb.internal. Use http://alice-ccdb.cern.ch for local tests"}}}};
665}
666} // namespace its
667} // namespace o2
int32_t i
uint16_t pos
Definition RawData.h:3
uint32_t j
Definition RawData.h:0
static BasicCCDBManager & instance()
std::pair< int64_t, int64_t > getRunDuration(int runnumber, bool fatal=true)
void init(std::string const &hosts)
Definition CcdbApi.cxx:165
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
Definition CcdbApi.h:103
int storeAsBinaryFile(const char *buffer, size_t size, const std::string &fileName, const std::string &objectType, const std::string &path, const std::map< std::string, std::string > &metadata, long startValidityTimestamp, long endValidityTimestamp, std::vector< char >::size_type maxSize=0) const
Definition CcdbApi.cxx:351
static constexpr long MINUTE
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
void run(ProcessingContext &pc) final
void init(InitContext &ic) final
static constexpr int getNChips()
number of chips per barrel
static constexpr std::string_view getName()
NoiseMap class for the ITS and MFT.
Definition NoiseMap.h:39
void maskFullChip(int chip, bool cleanNoisyPixels=false)
Definition NoiseMap.h:178
GLeglImageOES image
Definition glcorearb.h:4021
const GLdouble * v
Definition glcorearb.h:832
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
GLenum GLint GLint * precision
Definition glcorearb.h:1899
constexpr o2::header::DataOrigin gDataOriginITS
Definition DataHeader.h:570
long getCurrentTimestamp()
returns the timestamp in long corresponding to "now"
void addConfigItem(DCSconfigObject_t &configVector, std::string key, const T value)
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getITSDCSParserSpec()
const short int UNSET_SHORT
const int UNSET_INT
return * this
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
std::string filename()
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
Definition Utils.h:44
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
Definition Utils.h:43
static std::string getClassName(const T &obj)
get the class name of the object
static std::string concat_string(Ts const &... ts)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
const std::string str