CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL Class Reference
Inheritance diagram for PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual void endJob () override
 
 PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL (const edm::ParameterSet &)
 
 ~PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL ()
 
- 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
 
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 Attributes

std::string inputTxtFile
 
std::string rec1
 
std::string rec2
 

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 15 of file PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL.cc.

Constructor & Destructor Documentation

PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL ( const edm::ParameterSet p)
PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::~PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL ( )
inline

Definition at line 22 of file PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL.cc.

22 {}

Member Function Documentation

virtual void PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::analyze ( const edm::Event ,
const edm::EventSetup  
)
inlineoverridevirtual

Definition at line 20 of file PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL.cc.

20 {}
void PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::beginJob ( void  )
overridevirtual

JUST A STUPID PATCH

Reimplemented from edm::EDAnalyzer.

Definition at line 38 of file PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), stringResolutionProvider_cfi::bin, create_public_pileup_plots::bins, gather_cfg::cout, cond::service::PoolDBOutputService::createNewIOV(), TkAlMuonSelectors_cfi::cut, DEFINE_FWK_MODULE, cond::service::PoolDBOutputService::endOfTime(), PerformancePayloadFromBinnedTFormula::formulaPayloads(), recoMuon::in, inputTxtFile, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), rec1, rec2, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and tmp.

39 {
40  //
41  // read object from file
42  //
43 
44  //
45  // File Format is
46  // - tagger name
47  // - cut
48  // - concrete class name
49  // number of results (btageff, btagSF....)
50  // number of binning variables in the parameterization (eta, pt ...)
51  // number of bins
52  // - results (as ints)
53  // - variables (as ints)
54  // - formulas
55  // - the limits
56  //
57 
58  std::ifstream in;
59  in.open(inputTxtFile.c_str());
60  std::string tagger;
61  float cut;
62 
63  std::string concreteType;
64 
65  in >> tagger;
66  std::cout << "WP Tagger is "<<tagger<<std::endl;
67 
68  in >> cut;
69  std::cout << "WP Cut is "<<cut<<std::endl;
70 
71  in >> concreteType;
72  std::cout << "concrete Type is "<<concreteType<<std::endl;
73 
74  int nres=0, nvar=0;
75 
76  in >> nres;
77  in >> nvar;
78 
79  std::cout <<"Using "<<nres<<" results and "<< nvar<<" variables"<<std::endl;
80 
81  unsigned int bins = 0; //temporary for now!!!!!!
82 
83  in >> bins;
84 
85  std::cout <<"Using "<<bins<<" bins"<<std::endl;
86 
87  int number=0;;
88 
89  std::vector<PerformanceResult::ResultType> res;
90  std::vector<BinningVariables::BinningVariablesType> bin;
91  //
92  // read results
93  //
94  number=0;
95  while (number<nres && !in.eof()) {
96  int tmp;
97  in>> tmp;
98  res.push_back((PerformanceResult::ResultType)(tmp));
99  std::cout <<" Result #"<<number <<" is "<<tmp<<std::endl;;
100  number++;
101  }
102  if (number != nres){
103  std::cout <<" Table not well formed"<<std::endl;
104  }
105 
106  //
107  // read the variables
108  //
109 
110 
111 
112  PerformanceWorkingPoint * wp = new PerformanceWorkingPoint(cut, tagger);
114 
115  std::vector<PhysicsTFormulaPayload> v_ppl;
116 
117  number=0;
118  while (number<nvar && !in.eof()) {
119  int tmp;
120  in>> tmp;
121  bin.push_back((BinningVariables::BinningVariablesType)(tmp));
122  std::cout <<" Variable #"<<number <<" is "<<tmp<<std::endl;;
123  number++;
124  }
125  if (number != nvar){
126  std::cout <<" Table not well formed"<<std::endl;
127  }
128 
129  //
130  // now read the formulas
131  //
132 
133  for (unsigned int recregion =0 ; recregion<bins; ++recregion){
134 
135  std::vector< std::pair<float, float> > limits;
136  std::vector<std::string> formulas;
137 
138  number =0;
139 
140  while (number < nres && (!in.eof())){
142  in >> temp;
143  std::cout <<" Inserting "<<temp<< " as formula in position "<<number<<std::endl;
144  number++;
145  formulas.push_back(temp);
146  }
147  /*
148  if (nres!= number ){
149  std::cout <<" NOT OK, this is not what I would expect"<<std::endl;
150  abort();
151  }
152  */
153 
154  number=0;
155  while (number < nvar && (!in.eof())){
156  float temp1,temp2;
157  in >> temp1;
158  in >> temp2;
159  std::cout <<" Inserting "<<temp1<<","<<temp2<< " as limits in position "<<number<<std::endl;
160  number++;
161  limits.push_back(std::pair<float, float>(temp1,temp2));
162  }
163  /*
164  if (nvar != number ){
165  std::cout <<" NOT OK, this is not what I would expect"<<std::endl;
166  abort();
167  }
168  */
169 
170  //
171  // push it
172  //
173 
174  PhysicsTFormulaPayload ppl(limits, formulas);
175  v_ppl.push_back(ppl);
176 
177  }
178  in.close();
179 
180 
181  if (concreteType == "PerformancePayloadFromBinnedTFormula"){
182  btagpl = new PerformancePayloadFromBinnedTFormula(res, bin, v_ppl);
183  std::cout <<" CHECK: "<<btagpl->formulaPayloads().size()<<std::endl;
184  }else{
185  std::cout <<" Non existing request: " <<concreteType<<std::endl;
186  }
187 
188  std::cout <<" Created the "<<concreteType <<" object"<<std::endl;
189 
190  std::cout << "Start writing the payload" << std::endl;
192  if (s.isAvailable())
193  {
194  if (s->isNewTagRequest(rec1))
195  {
196  s->createNewIOV<PerformancePayload>(btagpl,
197  s->beginOfTime(),
198  s->endOfTime(),
199  rec1);
200  }
201  else
202  {
204  // JUST A STUPID PATCH
205  111,
206  rec1);
207  }
208  }
209  std::cout << "Finised writing the payload" << std::endl;
210 
211  // write also the WP
212  std::cout << "Start writing the WP" << std::endl;
213  if (s.isAvailable())
214  {
215  if (s->isNewTagRequest(rec2))
216  {
218  s->beginOfTime(),
219  s->endOfTime(),
220  rec2);
221  }
222  else
223  {
224 
227  111,
228  rec2);
229  }
230  }
231  std::cout << "Finished writing the WP" << std::endl;
232 
233 
234 }
Definition: Electron.h:4
const std::vector< PhysicsTFormulaPayload > & formulaPayloads() const
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:46
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
bin
set the eta bin as selection string.
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
virtual void PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 21 of file PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL.cc.

21 {}

Member Data Documentation

std::string PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::inputTxtFile
private
std::string PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::rec1
private
std::string PhysicsPerformanceDBWriterTFormula_fromfile_WPandPL::rec2
private