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 ()
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- 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
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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 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 21 of file modGains.cc.

Constructor & Destructor Documentation

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

Definition at line 37 of file modGains.cc.

References MessageLogger_cfi::cerr, Exception, fileCorr, fileIn, fileOut, edm::ParameterSet::getUntrackedParameter(), s_operation, AlCaHLTBitMon_QueryRunRegistry::string, 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 
44  if ( (std::strcmp(s_operation.c_str(),"add")==0) ||
45  (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) ||
50  (std::strcmp(s_operation.c_str(),"ssub")==0) ||
51  (std::strcmp(s_operation.c_str(),"smult")==0) ||
52  (std::strcmp(s_operation.c_str(),"sdiv")==0)) {// scalar operation
53  std::cerr << "Scalar operation: using val=" << val << std::endl;
54  } else {
55  throw cms::Exception("Unknown", "modGains") << "Unknown operator. "
56  << s_operation <<" Stopping.\n";
57  }
58 }
std::string fileOut
Definition: modGains.cc:32
T getUntrackedParameter(std::string const &, T const &) const
double val
Definition: modGains.cc:33
std::string fileIn
Definition: modGains.cc:32
std::string s_operation
Definition: modGains.cc:31
bool vectorop
Definition: modGains.cc:34
std::string fileCorr
Definition: modGains.cc:32
modGains::~modGains ( )

Definition at line 60 of file modGains.cc.

60 { }

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 62 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().

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

Definition at line 28 of file modGains.cc.

References analyze().

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

Definition at line 30 of file modGains.cc.

30 {}

Member Data Documentation

std::string modGains::fileCorr
private

Definition at line 32 of file modGains.cc.

Referenced by analyze(), and modGains().

std::string modGains::fileIn
private

Definition at line 32 of file modGains.cc.

Referenced by analyze(), and modGains().

std::string modGains::fileOut
private

Definition at line 32 of file modGains.cc.

Referenced by analyze(), and modGains().

std::string modGains::s_operation
private

Definition at line 31 of file modGains.cc.

Referenced by analyze(), and modGains().

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

Definition at line 34 of file modGains.cc.

Referenced by analyze(), and modGains().