CMS 3D CMS Logo

PhysicsPerformanceDBWriterFromFile_WPandPayload.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <string>
3 #include <fstream>
4 #include <iostream>
13 
15 
17 public:
19  void beginJob() override;
20  void analyze(const edm::Event&, const edm::EventSetup&) override {}
21  void endJob() override {}
23 
24 private:
27 };
28 
30  const edm::ParameterSet& p) {
31  inputTxtFile = p.getUntrackedParameter<std::string>("inputTxtFile");
32  rec1 = p.getUntrackedParameter<std::string>("RecordPayload");
33  rec2 = p.getUntrackedParameter<std::string>("RecordWP");
34 }
35 
37  //
38  // read object from file
39  //
40 
41  //
42  // File Format is
43  // - tagger name
44  // - cut
45  // - concrete class name
46  // - how many results and how many binning
47  // - their values
48  // - vector<float>
49  //
50 
51  std::ifstream in;
52  std::cout << "Opening " << inputTxtFile << std::endl;
53  in.open(inputTxtFile.c_str());
54  std::string tagger;
55  float cut;
56 
57  std::string concreteType;
58  std::string comment;
59  std::vector<float> pl;
60  int stride;
61 
62  in >> tagger;
63  std::cout << "WP Tagger is " << tagger << std::endl;
64 
65  in >> cut;
66  std::cout << "WP Cut is " << cut << std::endl;
67 
68  in >> concreteType;
69  std::cout << "concrete Type is " << concreteType << std::endl;
70 
71  // return ;
72 
73  // read # of results
74 
75  int nres, nbin;
76  in >> nres;
77  in >> nbin;
78  std::cout << " Results: " << nres << " Binning variables: " << nbin << std::endl;
79 
80  stride = nres + nbin * 2;
81  if (!stride) {
82  std::cout << " Malformed input file" << std::endl;
83  exit(1);
84  }
85 
86  int number = 0;
87 
88  std::vector<PerformanceResult::ResultType> res;
89  std::vector<BinningVariables::BinningVariablesType> bin;
90 
91  while (number < nres && !in.eof()) {
92  int tmp;
93  in >> tmp;
95  number++;
96  }
97  if (number != nres) {
98  std::cout << " Table not well formed" << std::endl;
99  }
100  number = 0;
101  while (number < nbin && !in.eof()) {
102  int tmp;
103  in >> tmp;
105  number++;
106  }
107  if (number != nbin) {
108  std::cout << " Table not well formed" << std::endl;
109  }
110 
111  number = 0;
112  while (!in.eof()) {
113  float temp;
114  in >> temp;
115  std::cout << " Intersing " << temp << " in position " << number << std::endl;
116  number++;
117  pl.push_back(temp);
118  }
119 
120  //
121  // CHECKS
122  //
123  if (stride != nbin * 2 + nres) {
124  std::cout << " Table not well formed" << std::endl;
125  }
126  if ((number % stride) != 0) {
127  std::cout << " Table not well formed" << std::endl;
128  }
129 
130  std::cout << " CLOSING " << std::endl;
131  in.close();
132 
133  /* for (int k=0;k<(number/stride); k++){
134  for (int j=0; j<stride; j++){
135  std::cout << "Pos["<<k<<","<<j<<"] = "<<pl[k*stride+j]<<std::endl;
136  }
137  }
138  */
139 
140  //
141  // now create pl etc etc
142  //
143 
145 
146  PerformancePayloadFromTable* btagpl = nullptr;
147 
148  if (concreteType == "PerformancePayloadFromTable") {
149  btagpl = new PerformancePayloadFromTable(res, bin, stride, pl);
150  } else {
151  std::cout << " Non existing request: " << concreteType << std::endl;
152  }
153 
154  std::cout << " Created the " << concreteType << " object" << std::endl;
155 
157  if (s.isAvailable()) {
158  if (s->isNewTagRequest(rec1)) {
159  s->createNewIOV<PerformancePayload>(btagpl, s->beginOfTime(), s->endOfTime(), rec1);
160  } else {
161  s->appendSinceTime<PerformancePayload>(btagpl,
162  // JUST A STUPID PATCH
163  111,
164  rec1);
165  }
166  }
167 
168  // write also the WP
169 
170  if (s.isAvailable()) {
171  if (s->isNewTagRequest(rec2)) {
172  s->createNewIOV<PerformanceWorkingPoint>(wp, s->beginOfTime(), s->endOfTime(), rec2);
173  } else {
174  s->appendSinceTime<PerformanceWorkingPoint>(wp,
176  111,
177  rec2);
178  }
179  }
180 }
181 
PhysicsPerformanceDBWriterFromFile_WPandPayload::inputTxtFile
std::string inputTxtFile
Definition: PhysicsPerformanceDBWriterFromFile_WPandPayload.cc:25
TkAlMuonSelectors_cfi.cut
cut
Definition: TkAlMuonSelectors_cfi.py:5
PerformanceWorkingPoint
Definition: PerformanceWorkingPoint.h:8
pfClustersFromHGC3DClusters_cfi.wp
wp
Definition: pfClustersFromHGC3DClusters_cfi.py:20
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PerformancePayloadFromTable.h
PerformanceWorkingPoint.h
PhysicsPerformanceDBWriterFromFile_WPandPayload::endJob
void endJob() override
Definition: PhysicsPerformanceDBWriterFromFile_WPandPayload.cc:21
EDAnalyzer.h
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
MakerMacros.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
PerformancePayloadFromTable
Definition: PerformancePayloadFromTable.h:15
PoolDBOutputService.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
Service.h
PhysicsPerformanceDBWriterFromFile_WPandPayload::rec2
std::string rec2
Definition: PhysicsPerformanceDBWriterFromFile_WPandPayload.cc:26
PerformancePayload
Definition: PerformancePayload.h:14
PhysicsPerformanceDBWriterFromFile_WPandPayload::beginJob
void beginJob() override
Definition: PhysicsPerformanceDBWriterFromFile_WPandPayload.cc:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PerformanceResult::ResultType
ResultType
Definition: PerformanceResult.h:8
PhysicsPerformanceDBWriterFromFile_WPandPayload::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: PhysicsPerformanceDBWriterFromFile_WPandPayload.cc:20
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
recoMuon::in
Definition: RecoMuonEnumerators.h:6
edm::Service< cond::service::PoolDBOutputService >
edm::EventSetup
Definition: EventSetup.h:58
PhysicsPerformanceDBWriterFromFile_WPandPayload
Definition: PhysicsPerformanceDBWriterFromFile_WPandPayload.cc:16
res
Definition: Electron.h:6
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
Frameworkfwd.h
PhysicsPerformanceDBWriterFromFile_WPandPayload::PhysicsPerformanceDBWriterFromFile_WPandPayload
PhysicsPerformanceDBWriterFromFile_WPandPayload(const edm::ParameterSet &)
Definition: PhysicsPerformanceDBWriterFromFile_WPandPayload.cc:29
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
ParameterSet.h
edm::Event
Definition: Event.h:73
BinningVariables::BinningVariablesType
BinningVariablesType
Definition: BinningVariables.h:10
PhysicsPerformanceDBWriterFromFile_WPandPayload::~PhysicsPerformanceDBWriterFromFile_WPandPayload
~PhysicsPerformanceDBWriterFromFile_WPandPayload() override
Definition: PhysicsPerformanceDBWriterFromFile_WPandPayload.cc:22
gpuPixelDoublets::stride
auto stride
Definition: gpuPixelDoubletsAlgos.h:80
PhysicsPerformanceDBWriterFromFile_WPandPayload::rec1
std::string rec1
Definition: PhysicsPerformanceDBWriterFromFile_WPandPayload.cc:26