25 edm::LogInfo(
"SiStripGainFromAsciiFile::~SiStripGainFromAsciiFile");
35 ss <<
"[SiStripGainFromAsciiFile::getNewObject]\n Reading Ascii File\n";
39 while(fgets(line, 4096, infile)!=
NULL){
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(
NULL,
" ");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;
81 __gnu_cxx::hash_map< unsigned int,ModuleGain>::const_iterator iter=
GainsMap.find(*it);
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
SiStripApvGain * getNewObject()
SiStripGainFromAsciiFile(const edm::ParameterSet &)
void hard_reset(float val)
std::string Asciifilename_
bool put(const uint32_t &detID, Range input)
~SiStripGainFromAsciiFile()
std::pair< ContainerIterator, ContainerIterator > Range
__gnu_cxx::hash_map< unsigned int, ModuleGain > GainsMap
std::string fullPath() const
Detector det() const
get the detector field from this detid