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;
43 char* pch=strtok(line,
" ");
int Arg=0;
46 sscanf(pch,
"%d", &detid);
48 sscanf(pch,
"%f", &(MG.
apv[Arg-1]));
52 pch=strtok(
nullptr,
" ");Arg++;
54 ss << detid <<
" " << MG.
apv[0] <<
" " << MG.
apv[1] <<
" " << MG.
apv[2] <<
" " << MG.
apv[3] <<
" " << MG.
apv[4] <<
" " << MG.
apv[5] << std::endl;
55 GainsMap.insert(std::pair<unsigned int,ModuleGain>(detid,MG));
60 edm::LogError(
"SiStripGainFromAsciiFile")<<
" [SiStripGainFromAsciiFile::getNewObject] Error opening file " <<
Asciifilename_ << std::endl;
68 const std::vector<uint32_t>& DetIds =
reader.getAllDetIds();
71 ss <<
"[SiStripGainFromAsciiFile::getNewObject]\n Filling SiStripApvGain object";
73 for(std::vector<uint32_t>::const_iterator it=DetIds.begin(); it!=DetIds.end(); it++){
78 nApvPair=
reader.getNumberOfApvsAndStripLength(*it).first/2;
80 ss <<
"Looking at detid " << *it <<
" nApvPairs " << nApvPair << std::endl;
84 ss <<
" " << MG.
apv[0] <<
" " << MG.
apv[1] <<
" " << MG.
apv[2] <<
" " << MG.
apv[3] <<
" " << MG.
apv[4] <<
" " << MG.
apv[5] << std::endl;
86 ss <<
"Hard reset for detid " << *it << std::endl;
90 std::vector<float> DetGainsVector;
97 }
else if (nApvPair==3){
105 edm::LogError(
"SiStripGainFromAsciiFile") <<
" SiStripGainFromAsciiFile::getNewObject] ERROR for detid " << *it <<
" not expected number of APV pairs " << nApvPair <<std::endl;
109 if ( !
obj->put(*it,range) ){
110 edm::LogError(
"SiStripGainFromAsciiFile")<<
" [SiStripGainFromAsciiFile::getNewObject] detid already exists"<<std::endl;
111 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