CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
SiStripGainFromAsciiFile Class Reference

#include <SiStripGainFromAsciiFile.h>

Inheritance diagram for SiStripGainFromAsciiFile:
ConditionDBWriter< SiStripApvGain > edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  ModuleGain
 

Public Member Functions

 SiStripGainFromAsciiFile (const edm::ParameterSet &)
 
 ~SiStripGainFromAsciiFile () override
 
- Public Member Functions inherited from ConditionDBWriter< SiStripApvGain >
 ConditionDBWriter (const edm::ParameterSet &iConfig)
 
 ~ConditionDBWriter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

std::unique_ptr< SiStripApvGaingetNewObject () override
 

Private Attributes

std::string Asciifilename_
 
edm::FileInPath fp_
 
std::unordered_map< unsigned int, ModuleGainGainsMap
 
float referenceValue_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from ConditionDBWriter< SiStripApvGain >
void setDoStore (const bool doStore)
 When set to false the payload will not be written to the db. More...
 
void storeOnDbNow ()
 
cond::Time_t timeOfLastIOV ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 13 of file SiStripGainFromAsciiFile.h.

Constructor & Destructor Documentation

◆ SiStripGainFromAsciiFile()

SiStripGainFromAsciiFile::SiStripGainFromAsciiFile ( const edm::ParameterSet iConfig)
explicit

Definition at line 13 of file SiStripGainFromAsciiFile.cc.

15  Asciifilename_ = iConfig.getParameter<std::string>("InputFileName");
16  referenceValue_ = iConfig.getParameter<double>("referenceValue");
18  "file", edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"));
19 }

References Asciifilename_, fp_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), referenceValue_, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~SiStripGainFromAsciiFile()

SiStripGainFromAsciiFile::~SiStripGainFromAsciiFile ( )
override

Definition at line 21 of file SiStripGainFromAsciiFile.cc.

21  {
22  edm::LogInfo("SiStripGainFromAsciiFile::~SiStripGainFromAsciiFile");
23 }

Member Function Documentation

◆ getNewObject()

std::unique_ptr< SiStripApvGain > SiStripGainFromAsciiFile::getNewObject ( )
overrideprivatevirtual

Implements ConditionDBWriter< SiStripApvGain >.

Definition at line 25 of file SiStripGainFromAsciiFile.cc.

25  {
26  auto obj = std::make_unique<SiStripApvGain>();
27 
28  std::stringstream ss;
29  ss.str("");
30  ss << "[SiStripGainFromAsciiFile::getNewObject]\n Reading Ascii File\n";
31  FILE* infile = fopen(Asciifilename_.c_str(), "r");
32  char line[4096];
33  if (infile) {
34  while (fgets(line, 4096, infile) != nullptr) {
35  uint32_t detid;
36  ModuleGain MG;
37  MG.apv[0] = 0.0;
38  MG.apv[1] = 0.0;
39  MG.apv[2] = 0.0;
40  MG.apv[3] = 0.0;
41  MG.apv[4] = 0.0;
42  MG.apv[5] = 0.0;
43  char* saveptr;
44  char* pch = strtok_r(line, " ", &saveptr);
45  int Arg = 0;
46  while (pch != nullptr) {
47  if (Arg == 0) {
48  sscanf(pch, "%d", &detid);
49  } else if (Arg <= 6) {
50  sscanf(pch, "%f", &(MG.apv[Arg - 1]));
51  } else {
52  //nothing to do here
53  }
54  pch = strtok_r(nullptr, " ", &saveptr);
55  Arg++;
56  }
57  ss << detid << " " << MG.apv[0] << " " << MG.apv[1] << " " << MG.apv[2] << " " << MG.apv[3] << " " << MG.apv[4]
58  << " " << MG.apv[5] << std::endl;
59  GainsMap.insert(std::pair<unsigned int, ModuleGain>(detid, MG));
60  }
61  fclose(infile);
62  edm::LogInfo("SiStripGainFromAsciiFile") << ss.str();
63  } else {
64  edm::LogError("SiStripGainFromAsciiFile")
65  << " [SiStripGainFromAsciiFile::getNewObject] Error opening file " << Asciifilename_ << std::endl;
66  assert(0);
67  }
68 
70 
71  const std::vector<uint32_t>& DetIds = reader.getAllDetIds();
72 
73  ss.str("");
74  ss << "[SiStripGainFromAsciiFile::getNewObject]\n Filling SiStripApvGain object";
75  short nApvPair;
76  for (std::vector<uint32_t>::const_iterator it = DetIds.begin(); it != DetIds.end(); it++) {
77  ModuleGain MG;
78  if (DetId(*it).det() != DetId::Tracker)
79  continue;
80 
81  nApvPair = reader.getNumberOfApvsAndStripLength(*it).first / 2;
82 
83  ss << "Looking at detid " << *it << " nApvPairs " << nApvPair << std::endl;
84  auto iter = GainsMap.find(*it);
85  if (iter != GainsMap.end()) {
86  MG = iter->second;
87  ss << " " << MG.apv[0] << " " << MG.apv[1] << " " << MG.apv[2] << " " << MG.apv[3] << " " << MG.apv[4] << " "
88  << MG.apv[5] << std::endl;
89  } else {
90  ss << "Hard reset for detid " << *it << std::endl;
91  MG.hard_reset(referenceValue_);
92  }
93 
94  std::vector<float> DetGainsVector;
95 
96  if (nApvPair == 2) {
97  DetGainsVector.push_back(MG.apv[0] / referenceValue_);
98  DetGainsVector.push_back(MG.apv[1] / referenceValue_);
99  DetGainsVector.push_back(MG.apv[2] / referenceValue_);
100  DetGainsVector.push_back(MG.apv[3] / referenceValue_);
101  } else if (nApvPair == 3) {
102  DetGainsVector.push_back(MG.apv[0] / referenceValue_);
103  DetGainsVector.push_back(MG.apv[1] / referenceValue_);
104  DetGainsVector.push_back(MG.apv[2] / referenceValue_);
105  DetGainsVector.push_back(MG.apv[3] / referenceValue_);
106  DetGainsVector.push_back(MG.apv[4] / referenceValue_);
107  DetGainsVector.push_back(MG.apv[5] / referenceValue_);
108  } else {
109  edm::LogError("SiStripGainFromAsciiFile") << " SiStripGainFromAsciiFile::getNewObject] ERROR for detid " << *it
110  << " not expected number of APV pairs " << nApvPair << std::endl;
111  }
112 
113  SiStripApvGain::Range range(DetGainsVector.begin(), DetGainsVector.end());
114  if (!obj->put(*it, range)) {
115  edm::LogError("SiStripGainFromAsciiFile")
116  << " [SiStripGainFromAsciiFile::getNewObject] detid already exists" << std::endl;
117  ss << " [SiStripGainFromAsciiFile::getNewObject] detid already exists" << std::endl;
118  }
119  }
120  edm::LogInfo("SiStripGainFromAsciiFile") << ss.str();
121 
122  return obj;
123 }

References SiStripGainFromAsciiFile::ModuleGain::apv, Asciifilename_, cms::cuda::assert(), DetId::det(), fp_, edm::FileInPath::fullPath(), GainsMap, SiStripGainFromAsciiFile::ModuleGain::hard_reset(), timingPdfMaker::infile, mps_splice::line, getGTfromDQMFile::obj, FastTimerService_cff::range, DQM::reader, referenceValue_, contentValuesCheck::ss, and DetId::Tracker.

Member Data Documentation

◆ Asciifilename_

std::string SiStripGainFromAsciiFile::Asciifilename_
private

Definition at line 36 of file SiStripGainFromAsciiFile.h.

Referenced by getNewObject(), and SiStripGainFromAsciiFile().

◆ fp_

edm::FileInPath SiStripGainFromAsciiFile::fp_
private

Definition at line 38 of file SiStripGainFromAsciiFile.h.

Referenced by getNewObject(), and SiStripGainFromAsciiFile().

◆ GainsMap

std::unordered_map<unsigned int, ModuleGain> SiStripGainFromAsciiFile::GainsMap
private

Definition at line 40 of file SiStripGainFromAsciiFile.h.

Referenced by getNewObject().

◆ referenceValue_

float SiStripGainFromAsciiFile::referenceValue_
private

Definition at line 37 of file SiStripGainFromAsciiFile.h.

Referenced by getNewObject(), and SiStripGainFromAsciiFile().

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
SiStripGainFromAsciiFile::fp_
edm::FileInPath fp_
Definition: SiStripGainFromAsciiFile.h:38
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
edm::LogInfo
Definition: MessageLogger.h:254
SiStripGainFromAsciiFile::GainsMap
std::unordered_map< unsigned int, ModuleGain > GainsMap
Definition: SiStripGainFromAsciiFile.h:40
SiStripGainFromAsciiFile::Asciifilename_
std::string Asciifilename_
Definition: SiStripGainFromAsciiFile.h:36
cms::cuda::assert
assert(be >=bs)
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripDetInfoFileReader
Definition: SiStripDetInfoFileReader.h:30
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:64
ConditionDBWriter< SiStripApvGain >
DQM.reader
reader
Definition: DQM.py:105
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogError
Definition: MessageLogger.h:183
DetId::Tracker
Definition: DetId.h:25
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripApvGain.h:28
SiStripGainFromAsciiFile::referenceValue_
float referenceValue_
Definition: SiStripGainFromAsciiFile.h:37
timingPdfMaker.infile
infile
Definition: timingPdfMaker.py:350
mps_splice.line
line
Definition: mps_splice.py:76
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163