CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
UETableProducer Class Reference
Inheritance diagram for UETableProducer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 UETableProducer (const edm::ParameterSet &)
 
 ~UETableProducer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginRun (const edm::EventSetup &)
 
virtual void endJob ()
 

Private Attributes

string calibrationFile_
 
bool debug_
 
unsigned int index = 0
 
bool jetCorrectorFormat_
 
unsigned int ni0 [2]
 
unsigned int ni1 [2]
 
unsigned int ni2 [2]
 
unsigned int np [5]
 
unsigned int runnum_
 

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 &)
 
- 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 35 of file UETableProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 76 of file UETableProducer.cc.

References calibrationFile_, debug_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), jetCorrectorFormat_, ni0, ni1, ni2, np, and AlCaHLTBitMon_QueryRunRegistry::string.

76  :
77  runnum_(0)
78 {
79  //now do what ever initialization is needed
80  calibrationFile_ = iConfig.getParameter<std::string>("txtFile");
81  //calibrationFile_ = "RecoHI/HiJetAlgos/data/ue_calibrations_pf_data.txt";
82 
83  debug_ = iConfig.getUntrackedParameter<bool>("debug",false);
84  jetCorrectorFormat_ = iConfig.getUntrackedParameter<bool>("jetCorrectorFormat",false);
85 
86  np[0] = 3;// Number of reduced PF ID (track, ECAL, HCAL)
87  np[1] = 15;// Number of pseudorapidity block
88  np[2] = 5;// Fourier series order
89  np[3] = 2;// Re or Im
90  np[4] = 82;// Number of feature parameter
91 
92  ni0[0] = np[1];
93  ni0[1] = 344;// Number of track binning (kept = ECAL)
94 
95  ni1[0] = np[1];
96  ni1[1] = 344;// Number of ECAL binning
97 
98  ni2[0] = np[1];
99  ni2[1] = 82;// Number of HCAL binning
100 
101 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned int ni2[2]
unsigned int np[5]
unsigned int ni1[2]
unsigned int runnum_
unsigned int ni0[2]
UETableProducer::~UETableProducer ( )

Definition at line 103 of file UETableProducer.cc.

104 {
105  // do anything here that needs to be done at desctruction time
106  // (e.g. close files, deallocate resources etc.)
107 }

Member Function Documentation

void UETableProducer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 115 of file UETableProducer.cc.

116 {
117  // nothing
118 
119 }
void UETableProducer::beginRun ( const edm::EventSetup iSetup)
privatevirtual

Definition at line 123 of file UETableProducer.cc.

124 {
125 }
void UETableProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 129 of file UETableProducer.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), calibrationFile_, filterCSVwithJSON::copy, gather_cfg::cout, cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::currentTime(), UETable::edgeEta, cond::service::PoolDBOutputService::endOfTime(), index, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), jetCorrectorFormat_, JetCorrectorParametersCollection::L1Offset, geometryCSVtoXML::line, UETable::ni0, ni0, UETable::ni1, ni1, UETable::ni2, ni2, UETable::np, np, NULL, fetchall_from_DQM_v2::pool, JetCorrectorParametersCollection::push_back(), record, AlCaHLTBitMon_QueryRunRegistry::string, and UETable::values.

129  {
130  std::string qpDataName = calibrationFile_.c_str();
131  std::ifstream textTable_(qpDataName.c_str());
132 
133  std::vector<float> ue_vec;
134  UETable *ue_predictor_pf = NULL;
135 
136  if (!jetCorrectorFormat_) {
137  ue_predictor_pf = new UETable();
138  }
139  // unsigned int Nnp_full = np[0] * np[1] * np[2] * np[3] * np[4];
140  unsigned int Nnp = np[0] * np[1] * (1 + (np[2] - 1) * np[3]) * np[4];
141  unsigned int Nni0 = ni0[0]*ni0[1];
142  unsigned int Nni1 = ni1[0]*ni1[1];
143  unsigned int Nni2 = ni2[0]*ni2[1];
144 
145  if (!jetCorrectorFormat_) {
146  ue_predictor_pf->np.resize(5);
147  ue_predictor_pf->ni0.resize(2);
148  ue_predictor_pf->ni1.resize(2);
149  ue_predictor_pf->ni2.resize(2);
150 
151  std::copy(np, np + 5, ue_predictor_pf->np.begin());
152  std::copy(ni0, ni0 + 2, ue_predictor_pf->ni0.begin());
153  std::copy(ni1, ni1 + 2, ue_predictor_pf->ni1.begin());
154  std::copy(ni2, ni2 + 2, ue_predictor_pf->ni2.begin());
155 
156  static const float edge_pseudorapidity[16] = {
157  -5.191, -2.650, -2.043, -1.740, -1.479, -1.131, -0.783, -0.522, 0.522, 0.783, 1.131, 1.479, 1.740, 2.043, 2.650, 5.191
158  };
159 
160  ue_predictor_pf->edgeEta.resize(16);
161 
162  std::copy(edge_pseudorapidity, edge_pseudorapidity + 16, ue_predictor_pf->edgeEta.begin());
163 
164  }
165 
167 
168  while( std::getline( textTable_, line)){
169  if(!line.size() || line[0]=='#') {
170  std::cout<<" continue "<<std::endl;
171  continue;
172  }
173  std::istringstream linestream(line);
174  float val;
175  int bin0, bin1, bin2, bin3, bin4;
176  if(index < Nnp){
177  linestream>>bin0>>bin1>>bin2>>bin3>>bin4>>val;
178  ue_vec.push_back(val);
179  }else if(index < Nnp + Nni0){
180  linestream>>bin0>>bin1>>val;
181  ue_vec.push_back(val);
182  }else if(index < Nnp + Nni0 + Nni1){
183  linestream>>bin0>>bin1>>val;
184  ue_vec.push_back(val);
185  }else if(index < Nnp + Nni0 + Nni1 + Nni2){
186  linestream>>bin0>>bin1>>val;
187  ue_vec.push_back(val);
188  }
189  ++index;
190 
191  }
192 
194 
195  if( pool.isAvailable() ){
196 
197  if (jetCorrectorFormat_) {
198  // A minimal dummy line that satisfies the JME # token >= 6 requirement, and has the correct key type
199  JetCorrectorParameters::Definitions definition("1 0 0 0 Correction L1Offset");
200  std::vector<JetCorrectorParameters::Record> record(1, JetCorrectorParameters::Record(ue_vec.size(), std::vector<float>(ue_vec.size(), 0), std::vector<float>(ue_vec.size(), 0), ue_vec));
202 
204 
206 
207  if( pool->isNewTagRequest( "JetCorrectionsRecord" ) ){
208  pool->createNewIOV<JetCorrectorParametersCollection>( jme_payload, pool->beginOfTime(), pool->endOfTime(), "JetCorrectionsRecord" );
209  }else{
210  pool->appendSinceTime<JetCorrectorParametersCollection>( jme_payload, pool->currentTime(), "JetCorrectionsRecord" );
211  }
212  }
213  else {
214  ue_predictor_pf->values = ue_vec;
215 
216  if( pool->isNewTagRequest( "HeavyIonUERcd" ) ){
217  pool->createNewIOV<UETable>( ue_predictor_pf, pool->beginOfTime(), pool->endOfTime(), "HeavyIonUERcd" );
218  }else{
219  pool->appendSinceTime<UETable>( ue_predictor_pf, pool->currentTime(), "HeavyIonUERcd" );
220  }
221  }
222  }
223 }
JetCorrectorParameters::Record record
Definition: classes.h:7
void push_back(key_type i, value_type const &j, label_type const &flav="")
std::vector< unsigned int > ni2
Definition: UETable.h:29
std::vector< unsigned int > np
Definition: UETable.h:26
#define NULL
Definition: scimark2.h:8
unsigned int ni2[2]
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
std::vector< unsigned int > ni1
Definition: UETable.h:28
unsigned int np[5]
bool isAvailable() const
Definition: Service.h:46
unsigned int ni1[2]
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
std::vector< unsigned int > ni0
Definition: UETable.h:27
std::vector< float > values
Definition: UETable.h:25
std::vector< float > edgeEta
Definition: UETable.h:30
unsigned int index
tuple cout
Definition: gather_cfg.py:121
Definition: UETable.h:7
unsigned int ni0[2]

Member Data Documentation

string UETableProducer::calibrationFile_
private

Definition at line 50 of file UETableProducer.cc.

Referenced by endJob(), and UETableProducer().

bool UETableProducer::debug_
private

Definition at line 47 of file UETableProducer.cc.

Referenced by UETableProducer().

unsigned int UETableProducer::index = 0
private

Definition at line 53 of file UETableProducer.cc.

Referenced by BeautifulSoup.PageElement::_invert(), and endJob().

bool UETableProducer::jetCorrectorFormat_
private

Definition at line 48 of file UETableProducer.cc.

Referenced by endJob(), and UETableProducer().

unsigned int UETableProducer::ni0[2]
private

Definition at line 53 of file UETableProducer.cc.

Referenced by endJob(), and UETableProducer().

unsigned int UETableProducer::ni1[2]
private

Definition at line 53 of file UETableProducer.cc.

Referenced by endJob(), and UETableProducer().

unsigned int UETableProducer::ni2[2]
private

Definition at line 53 of file UETableProducer.cc.

Referenced by endJob(), and UETableProducer().

unsigned int UETableProducer::np[5]
private

Definition at line 53 of file UETableProducer.cc.

Referenced by endJob(), and UETableProducer().

unsigned int UETableProducer::runnum_
private

Definition at line 51 of file UETableProducer.cc.