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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

Definition at line 22 of file modGains.cc.

Constructor & Destructor Documentation

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

Definition at line 38 of file modGains.cc.

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

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

Definition at line 61 of file modGains.cc.

61 { }

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 63 of file modGains.cc.

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

Referenced by beginRun().

63  {
64 
66  iSetup.get<HcalRecNumberingRecord>().get(htopo);
67  HcalTopology topo = (*htopo);
68 
69  // get base conditions
70  std::cerr << fileIn << std::endl;
71  std::ifstream inStream (fileIn.c_str());
72  HcalGains gainsIn(&topo);;
73  HcalDbASCIIIO::getObject (inStream, &gainsIn);
74  inStream.close();
75 
76  HcalRespCorrs corrsIn(&topo);;
77  if (vectorop) {
78  std::ifstream inCorr (fileCorr.c_str());
79  HcalDbASCIIIO::getObject (inCorr, &corrsIn);
80  inCorr.close();
81  }
82 
83  HcalGains gainsOut(&topo);;
84  std::vector<DetId> channels = gainsIn.getAllChannels ();
85  std::cerr << "size = " << channels.size() << std::endl;
86  for (unsigned i = 0; i < channels.size(); i++) {
87  DetId id = channels[i];
88 
89  if (vectorop) { // vector operation
90  if ((std::strcmp(s_operation.c_str(),"mult")==0)||(std::strcmp(s_operation.c_str(),"div")==0)) val = 1.0; // mult,div
91  if ((std::strcmp(s_operation.c_str(),"add")==0)||(std::strcmp(s_operation.c_str(),"sub")==0)) 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, gainsIn.getValues(id)->getValue(0) + val, gainsIn.getValues(id)->getValue(1) + val,
102  gainsIn.getValues(id)->getValue(2) + val, gainsIn.getValues(id)->getValue(3) + val);
103 
104  if ((std::strcmp(s_operation.c_str(),"sub")==0) || (std::strcmp(s_operation.c_str(),"ssub")==0))
105  p_item = std::make_unique<HcalGain>(id, gainsIn.getValues(id)->getValue(0) - val, gainsIn.getValues(id)->getValue(1) - val,
106  gainsIn.getValues(id)->getValue(2) - val, gainsIn.getValues(id)->getValue(3) - val);
107 
108  if ((std::strcmp(s_operation.c_str(),"mult")==0) || (std::strcmp(s_operation.c_str(),"smult")==0))
109  p_item = std::make_unique<HcalGain>(id, gainsIn.getValues(id)->getValue(0) * val, gainsIn.getValues(id)->getValue(1) * val,
110  gainsIn.getValues(id)->getValue(2) * val, gainsIn.getValues(id)->getValue(3) * val);
111 
112  if ((std::strcmp(s_operation.c_str(),"div")==0) || (std::strcmp(s_operation.c_str(),"sdiv")==0))
113  p_item = std::make_unique<HcalGain>(id, gainsIn.getValues(id)->getValue(0) / val, gainsIn.getValues(id)->getValue(1) / val,
114  gainsIn.getValues(id)->getValue(2) / val, gainsIn.getValues(id)->getValue(3) / val);
115 
116 
117  // for all
118  if (p_item) gainsOut.addValues(*p_item);
119  // std::cerr << i << std::endl;
120  }
121  // write out
122  std::ofstream outStream (fileOut.c_str());
123  HcalDbASCIIIO::dumpObject (outStream, gainsOut);
124  outStream.close();
125 }
std::string fileOut
Definition: modGains.cc:33
double val
Definition: modGains.cc:34
std::string fileIn
Definition: modGains.cc:33
Definition: DetId.h:18
std::string s_operation
Definition: modGains.cc:32
bool getObject(std::istream &fInput, HcalPedestals *fObject)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
bool vectorop
Definition: modGains.cc:35
std::string fileCorr
Definition: modGains.cc:33
void modGains::beginRun ( edm::Run const &  iEvent,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 29 of file modGains.cc.

References analyze().

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

Definition at line 31 of file modGains.cc.

31 {}

Member Data Documentation

std::string modGains::fileCorr
private

Definition at line 33 of file modGains.cc.

Referenced by analyze(), and modGains().

std::string modGains::fileIn
private

Definition at line 33 of file modGains.cc.

Referenced by analyze(), and modGains().

std::string modGains::fileOut
private

Definition at line 33 of file modGains.cc.

Referenced by analyze(), and modGains().

std::string modGains::s_operation
private

Definition at line 32 of file modGains.cc.

Referenced by analyze(), and modGains().

double modGains::val
private
bool modGains::vectorop
private

Definition at line 35 of file modGains.cc.

Referenced by analyze(), and modGains().