CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
modGains Class Reference
Inheritance diagram for modGains:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 modGains (const edm::ParameterSet &)
 
 ~modGains () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (edm::Event const &, edm::EventSetup const &) override
 
void beginRun (edm::Run const &iEvent, edm::EventSetup const &) override
 
void endRun (edm::Run const &iEvent, edm::EventSetup const &) override
 

Private Attributes

std::string fileCorr
 
std::string fileIn
 
std::string fileOut
 
std::string s_operation
 
edm::ESGetToken< HcalTopology, HcalRecNumberingRecordtok_htopo_
 
double val
 
bool vectorop
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, 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)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 21 of file modGains.cc.

Constructor & Destructor Documentation

◆ modGains()

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

Definition at line 37 of file modGains.cc.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, Exception, fileCorr, fileIn, fileOut, edm::ParameterSet::getUntrackedParameter(), s_operation, AlCaHLTBitMon_QueryRunRegistry::string, tok_htopo_, val, and vectorop.

37  : vectorop(false) {
38  s_operation = iConfig.getUntrackedParameter<std::string>("Operation");
39  fileIn = iConfig.getUntrackedParameter<std::string>("FileIn");
40  fileOut = iConfig.getUntrackedParameter<std::string>("FileOut");
41  fileCorr = iConfig.getUntrackedParameter<std::string>("FileCorr");
42  val = iConfig.getUntrackedParameter<double>("ScalarFactor");
43  tok_htopo_ = esConsumes<HcalTopology, HcalRecNumberingRecord>();
44 
45  if ((std::strcmp(s_operation.c_str(), "add") == 0) || (std::strcmp(s_operation.c_str(), "sub") == 0) ||
46  (std::strcmp(s_operation.c_str(), "mult") == 0) ||
47  (std::strcmp(s_operation.c_str(), "div") == 0)) { // vector operation
48  vectorop = true;
49  } else if ((std::strcmp(s_operation.c_str(), "sadd") == 0) || (std::strcmp(s_operation.c_str(), "ssub") == 0) ||
50  (std::strcmp(s_operation.c_str(), "smult") == 0) ||
51  (std::strcmp(s_operation.c_str(), "sdiv") == 0)) { // scalar operation
52  std::cerr << "Scalar operation: using val=" << val << std::endl;
53  } else {
54  throw cms::Exception("Unknown", "modGains") << "Unknown operator. " << s_operation << " Stopping.\n";
55  }
56 }
std::string fileOut
Definition: modGains.cc:31
double val
Definition: modGains.cc:32
T getUntrackedParameter(std::string const &, T const &) const
std::string fileIn
Definition: modGains.cc:31
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > tok_htopo_
Definition: modGains.cc:34
std::string s_operation
Definition: modGains.cc:30
bool vectorop
Definition: modGains.cc:33
std::string fileCorr
Definition: modGains.cc:31

◆ ~modGains()

modGains::~modGains ( )
override

Definition at line 58 of file modGains.cc.

58 {}

Member Function Documentation

◆ analyze()

void modGains::analyze ( edm::Event const &  ,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 60 of file modGains.cc.

References HcalCondObjectContainer< Item >::addValues(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, ewkTauDQM_cfi::channels, HcalDbASCIIIO::dumpObject(), HcalCondObjectContainer< Item >::exists(), fileCorr, fileIn, fileOut, edm::EventSetup::getData(), HcalDbASCIIIO::getObject(), HcalRespCorr::getValue(), HcalCondObjectContainer< Item >::getValues(), mps_fire::i, s_operation, tok_htopo_, val, and vectorop.

60  {
61  HcalTopology topo = iSetup.getData(tok_htopo_);
62 
63  // get base conditions
64  std::cerr << fileIn << std::endl;
65  std::ifstream inStream(fileIn.c_str());
66  HcalGains gainsIn(&topo);
67  ;
68  HcalDbASCIIIO::getObject(inStream, &gainsIn);
69  inStream.close();
70 
71  HcalRespCorrs corrsIn(&topo);
72  ;
73  if (vectorop) {
74  std::ifstream inCorr(fileCorr.c_str());
75  HcalDbASCIIIO::getObject(inCorr, &corrsIn);
76  inCorr.close();
77  }
78 
79  HcalGains gainsOut(&topo);
80  ;
81  std::vector<DetId> channels = gainsIn.getAllChannels();
82  std::cerr << "size = " << channels.size() << std::endl;
83  for (unsigned i = 0; i < channels.size(); i++) {
84  DetId id = channels[i];
85 
86  if (vectorop) { // vector operation
87  if ((std::strcmp(s_operation.c_str(), "mult") == 0) || (std::strcmp(s_operation.c_str(), "div") == 0))
88  val = 1.0; // mult,div
89  if ((std::strcmp(s_operation.c_str(), "add") == 0) || (std::strcmp(s_operation.c_str(), "sub") == 0))
90  val = 0.0; // add,sub
91  if (corrsIn.exists(id)) {
92  val = corrsIn.getValues(id)->getValue();
93  }
94  if (i % 100 == 0)
95  std::cerr << "Vector operation, " << i << "th channel: using val=" << val << std::endl;
96  }
97 
98  std::unique_ptr<HcalGain> p_item;
99  if ((std::strcmp(s_operation.c_str(), "add") == 0) || (std::strcmp(s_operation.c_str(), "sadd") == 0))
100  p_item = std::make_unique<HcalGain>(id,
101  gainsIn.getValues(id)->getValue(0) + val,
102  gainsIn.getValues(id)->getValue(1) + val,
103  gainsIn.getValues(id)->getValue(2) + val,
104  gainsIn.getValues(id)->getValue(3) + val);
105 
106  if ((std::strcmp(s_operation.c_str(), "sub") == 0) || (std::strcmp(s_operation.c_str(), "ssub") == 0))
107  p_item = std::make_unique<HcalGain>(id,
108  gainsIn.getValues(id)->getValue(0) - val,
109  gainsIn.getValues(id)->getValue(1) - val,
110  gainsIn.getValues(id)->getValue(2) - val,
111  gainsIn.getValues(id)->getValue(3) - val);
112 
113  if ((std::strcmp(s_operation.c_str(), "mult") == 0) || (std::strcmp(s_operation.c_str(), "smult") == 0))
114  p_item = std::make_unique<HcalGain>(id,
115  gainsIn.getValues(id)->getValue(0) * val,
116  gainsIn.getValues(id)->getValue(1) * val,
117  gainsIn.getValues(id)->getValue(2) * val,
118  gainsIn.getValues(id)->getValue(3) * val);
119 
120  if ((std::strcmp(s_operation.c_str(), "div") == 0) || (std::strcmp(s_operation.c_str(), "sdiv") == 0))
121  p_item = std::make_unique<HcalGain>(id,
122  gainsIn.getValues(id)->getValue(0) / val,
123  gainsIn.getValues(id)->getValue(1) / val,
124  gainsIn.getValues(id)->getValue(2) / val,
125  gainsIn.getValues(id)->getValue(3) / val);
126 
127  // for all
128  if (p_item)
129  gainsOut.addValues(*p_item);
130  // std::cerr << i << std::endl;
131  }
132  // write out
133  std::ofstream outStream(fileOut.c_str());
134  HcalDbASCIIIO::dumpObject(outStream, gainsOut);
135  outStream.close();
136 }
std::string fileOut
Definition: modGains.cc:31
double val
Definition: modGains.cc:32
std::string fileIn
Definition: modGains.cc:31
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > tok_htopo_
Definition: modGains.cc:34
Definition: DetId.h:17
std::string s_operation
Definition: modGains.cc:30
bool getObject(std::istream &fInput, HcalPedestals *fObject)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
bool vectorop
Definition: modGains.cc:33
std::string fileCorr
Definition: modGains.cc:31

◆ beginRun()

void modGains::beginRun ( edm::Run const &  iEvent,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 27 of file modGains.cc.

27 {}

◆ endRun()

void modGains::endRun ( edm::Run const &  iEvent,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 29 of file modGains.cc.

29 {}

Member Data Documentation

◆ fileCorr

std::string modGains::fileCorr
private

Definition at line 31 of file modGains.cc.

Referenced by analyze(), and modGains().

◆ fileIn

std::string modGains::fileIn
private

Definition at line 31 of file modGains.cc.

Referenced by analyze(), and modGains().

◆ fileOut

std::string modGains::fileOut
private

Definition at line 31 of file modGains.cc.

Referenced by analyze(), and modGains().

◆ s_operation

std::string modGains::s_operation
private

Definition at line 30 of file modGains.cc.

Referenced by analyze(), and modGains().

◆ tok_htopo_

edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> modGains::tok_htopo_
private

Definition at line 34 of file modGains.cc.

Referenced by analyze(), and modGains().

◆ val

double modGains::val
private

◆ vectorop

bool modGains::vectorop
private

Definition at line 33 of file modGains.cc.

Referenced by analyze(), and modGains().