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
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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 &&)=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

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
 
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
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 22 of file modGains.cc.

Constructor & Destructor Documentation

◆ modGains()

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

Definition at line 37 of file modGains.cc.

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 
44  if ((std::strcmp(s_operation.c_str(), "add") == 0) || (std::strcmp(s_operation.c_str(), "sub") == 0) ||
45  (std::strcmp(s_operation.c_str(), "mult") == 0) ||
46  (std::strcmp(s_operation.c_str(), "div") == 0)) { // vector operation
47  vectorop = true;
48  } else if ((std::strcmp(s_operation.c_str(), "sadd") == 0) || (std::strcmp(s_operation.c_str(), "ssub") == 0) ||
49  (std::strcmp(s_operation.c_str(), "smult") == 0) ||
50  (std::strcmp(s_operation.c_str(), "sdiv") == 0)) { // scalar operation
51  std::cerr << "Scalar operation: using val=" << val << std::endl;
52  } else {
53  throw cms::Exception("Unknown", "modGains") << "Unknown operator. " << s_operation << " Stopping.\n";
54  }
55 }

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

◆ ~modGains()

modGains::~modGains ( )
override

Definition at line 57 of file modGains.cc.

57 {}

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 59 of file modGains.cc.

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

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

◆ beginRun()

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

Definition at line 28 of file modGains.cc.

28 {}

◆ endRun()

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

Definition at line 30 of file modGains.cc.

30 {}

Member Data Documentation

◆ fileCorr

std::string modGains::fileCorr
private

Definition at line 32 of file modGains.cc.

Referenced by analyze(), and modGains().

◆ fileIn

std::string modGains::fileIn
private

Definition at line 32 of file modGains.cc.

Referenced by analyze(), and modGains().

◆ fileOut

std::string modGains::fileOut
private

Definition at line 32 of file modGains.cc.

Referenced by analyze(), and modGains().

◆ s_operation

std::string modGains::s_operation
private

Definition at line 31 of file modGains.cc.

Referenced by analyze(), and modGains().

◆ val

double modGains::val
private

◆ vectorop

bool modGains::vectorop
private

Definition at line 34 of file modGains.cc.

Referenced by analyze(), and modGains().

modGains::fileOut
std::string fileOut
Definition: modGains.cc:32
HcalRespCorrs
Definition: HcalRespCorrs.h:17
mps_fire.i
i
Definition: mps_fire.py:355
HcalTopology
Definition: HcalTopology.h:26
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DetId
Definition: DetId.h:17
modGains::fileIn
std::string fileIn
Definition: modGains.cc:32
edm::ESHandle< HcalTopology >
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
get
#define get
modGains::s_operation
std::string s_operation
Definition: modGains.cc:31
HcalDbASCIIIO::dumpObject
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
modGains::fileCorr
std::string fileCorr
Definition: modGains.cc:32
Exception
Definition: hltDiff.cc:246
HcalDbASCIIIO::getObject
bool getObject(std::istream &fInput, HcalPedestals *fObject)
ewkTauDQM_cfi.channels
channels
Definition: ewkTauDQM_cfi.py:14
HcalGains
Definition: HcalGains.h:17
modGains::val
double val
Definition: modGains.cc:33
modGains::vectorop
bool vectorop
Definition: modGains.cc:34