25 edm::LogInfo(
"SiStripGainFromAsciiFile::~SiStripGainFromAsciiFile");
30 auto obj = std::make_unique<SiStripApvGain>();
35 ss <<
"[SiStripGainFromAsciiFile::getNewObject]\n Reading Ascii File\n";
39 while(fgets(line, 4096, infile)!=
nullptr){
42 MG.
apv[0] = 0.0; MG.
apv[1] = 0.0; MG.
apv[2] = 0.0; MG.
apv[3] = 0.0; MG.
apv[4] = 0.0; MG.
apv[5] = 0.0;
44 char* pch=strtok_r(line,
" ",&saveptr);
int Arg=0;
47 sscanf(pch,
"%d", &detid);
49 sscanf(pch,
"%f", &(MG.
apv[Arg-1]));
53 pch=strtok_r(
nullptr,
" ",&saveptr);Arg++;
55 ss << detid <<
" " << MG.
apv[0] <<
" " << MG.
apv[1] <<
" " << MG.
apv[2] <<
" " << MG.
apv[3] <<
" " << MG.
apv[4] <<
" " << MG.
apv[5] << std::endl;
56 GainsMap.insert(std::pair<unsigned int,ModuleGain>(detid,MG));
61 edm::LogError(
"SiStripGainFromAsciiFile")<<
" [SiStripGainFromAsciiFile::getNewObject] Error opening file " <<
Asciifilename_ << std::endl;
69 const std::vector<uint32_t>& DetIds =
reader.getAllDetIds();
72 ss <<
"[SiStripGainFromAsciiFile::getNewObject]\n Filling SiStripApvGain object";
74 for(std::vector<uint32_t>::const_iterator it=DetIds.begin(); it!=DetIds.end(); it++){
79 nApvPair=
reader.getNumberOfApvsAndStripLength(*it).first/2;
81 ss <<
"Looking at detid " << *it <<
" nApvPairs " << nApvPair << std::endl;
85 ss <<
" " << MG.
apv[0] <<
" " << MG.
apv[1] <<
" " << MG.
apv[2] <<
" " << MG.
apv[3] <<
" " << MG.
apv[4] <<
" " << MG.
apv[5] << std::endl;
87 ss <<
"Hard reset for detid " << *it << std::endl;
91 std::vector<float> DetGainsVector;
98 }
else if (nApvPair==3){
106 edm::LogError(
"SiStripGainFromAsciiFile") <<
" SiStripGainFromAsciiFile::getNewObject] ERROR for detid " << *it <<
" not expected number of APV pairs " << nApvPair <<std::endl;
110 if ( !
obj->put(*it,range) ){
111 edm::LogError(
"SiStripGainFromAsciiFile")<<
" [SiStripGainFromAsciiFile::getNewObject] detid already exists"<<std::endl;
112 ss <<
" [SiStripGainFromAsciiFile::getNewObject] detid already exists"<<std::endl;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
SiStripGainFromAsciiFile(const edm::ParameterSet &)
void hard_reset(float val)
std::string Asciifilename_
~SiStripGainFromAsciiFile() override
std::pair< ContainerIterator, ContainerIterator > Range
std::unique_ptr< SiStripApvGain > getNewObject() override
std::unordered_map< unsigned int, ModuleGain > GainsMap
std::string fullPath() const
constexpr Detector det() const
get the detector field from this detid