14 constexpr
int Nfiles_EE = 5;
18 : preshStripEnergyCut_(stripEnergyCut), preshSeededNstr_(nStripCut) {
20 constexpr std::array<char const*, Nfiles_EE> file_pt{{
"20",
"30",
"40",
"50",
"60"}};
21 constexpr std::array<char const*, 5> file_barrel_pt{{
"20",
"30",
"40",
"50",
"60"}};
23 for (
auto ptName : file_pt) {
24 string nn_paterns_file =
"endcapPiZeroDiscriminatorWeights_et";
25 nn_paterns_file += ptName;
26 nn_paterns_file +=
".wts";
28 readWeightFile(WFile.fullPath().c_str(), EE_Layers, EE_Indim, EE_Hidden, EE_Outdim);
31 for (
auto ptName : file_barrel_pt) {
32 string nn_paterns_file =
"barrelPiZeroDiscriminatorWeights_et";
33 nn_paterns_file += ptName;
34 nn_paterns_file +=
".wts";
36 readWeightFile(WFile.fullPath().c_str(), EB_Layers, EB_Indim, EB_Hidden, EB_Outdim);
43 vector<float> vout_stripE;
46 if (rechits_map->empty()) {
47 edm::LogWarning(
"EndcapPiZeroDiscriminatorAlgo") <<
"RecHitsMap has size 0.";
53 vector<ESDetId> road_2d;
56 int plane =
strip.plane();
59 <<
"EndcapPiZeroDiscriminatorAlgo: findPreshVectors: Preshower Seeded Algorithm - looking for clusters"
61 <<
"findPreshVectors: Preshower is intersected at strip " <<
strip.strip() <<
", at plane " << plane;
64 for (
int i = 0;
i < 11;
i++) {
65 vout_stripE.push_back(-100.);
70 road_2d.push_back(
strip);
79 <<
"EndcapPiZeroDiscriminatorAlgo:findPreshVectors: Total number of strips in the central road: "
83 RecHitsMap::iterator final_strip = rechits_map->end();
87 ESDetId last_stripID = final_strip->first;
89 vector<ESDetId>::iterator itID;
90 for (itID = road_2d.begin(); itID != road_2d.end(); itID++) {
91 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPreshVectors: ID = " << *itID;
94 RecHitsMap::iterator strip_it = rechits_map->find(*itID);
96 E = strip_it->second.energy();
98 vout_stripE.push_back(E);
99 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPreshVectors: E = " << E;
105 vector<float> vout_ElevenStrips_Energy;
106 for (
int i = 0;
i < 11;
i++) {
107 vout_ElevenStrips_Energy.push_back(0.);
110 for (
unsigned int i = 0;
i < vout_stripE.size();
i++) {
111 vout_ElevenStrips_Energy[
i] = vout_stripE.at(
i);
115 return vout_ElevenStrips_Energy;
121 RecHitsMap::iterator candidate_tmp = candidate_it;
125 if (candidate_tmp->first == lastID)
127 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: goodPi0Strip No such a strip in rechits_map ";
131 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: goodPi0Strip Strip energy "
132 << candidate_it->second.energy() <<
" is below threshold ";
143 vector<ESDetId>& vout) {
148 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: starts from strip " <<
strip;
153 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the East ";
156 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: East: " << n_east <<
" current strip is "
159 vout.push_back(
next);
166 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the West ";
170 LogTrace(
"EcalClusters") <<
"findPi0Road: West: " << n_west <<
" current strip is " <<
next;
172 vout.push_back(
next);
178 <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 1-st plane is "
181 }
else if (plane == 2) {
184 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the North ";
187 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: North: " << n_north
188 <<
" current strip is " <<
next;
190 vout.push_back(
next);
197 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the South ";
201 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: South: " << n_south
202 <<
" current strip is " <<
next;
204 vout.push_back(
next);
210 <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 2-nd plane is "
211 << n_south + n_north;
215 <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Wrong plane number, null cluster will be returned! ";
228 const char* Weights_file,
int& Layers,
int& Indim,
int& Hidden,
int& Outdim) {
233 bool checkinit =
false;
237 weights = fopen(Weights_file,
"r");
238 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: I opeded the Weights file = " << Weights_file;
240 throw cms::Exception(
"MissingWeightFile") <<
"Could not open the weights file: " << Weights_file;
250 if (
line[0] ==
'A') {
251 fscanf(
weights,
"%d", &Layers);
253 fscanf(
weights,
"%d", &Hidden);
254 fscanf(
weights,
"%d", &Outdim);
261 }
else if (
line[0] ==
'B') {
263 for (
int i = 0;
i < Indim;
i++) {
264 for (
int j = 0;
j < Hidden;
j++) {
268 }
else if (
line[0] ==
'C') {
270 for (
int i = 0;
i < Hidden;
i++) {
273 }
else if (
line[0] ==
'D') {
275 for (
int i = 0;
i < Hidden * Outdim;
i++) {
278 }
else if (
line[0] ==
'E') {
280 for (
int i = 0;
i < Outdim;
i++) {
284 edm::LogError(
"EEPi0Discrim") <<
"EndcapPiZeroDiscriminatorAlgo: Not a Net file of Corrupted Net file " << endl;
297 int sel_wfile,
int Layers,
int Indim,
int Hidden,
int Outdim,
int barrelstart)
const {
301 std::vector<float> I_SUM(
size_t(Hidden), 0.0);
302 std::vector<float>
OUT(
size_t(Outdim), 0.0);
304 for (
int h = 0;
h < Hidden;
h++) {
306 for (
int i = 0;
i < Indim;
i++) {
312 for (
int o1 = 0;
o1 < Outdim;
o1++) {
314 sel_wfile * Outdim * Hidden] *
318 for (
int o2 = 0; o2 < Outdim; o2++) {
322 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: getNNoutput :: -> NNout = " << nnout;
340 vector<float>& vph1, vector<float>& vph2,
float pS1_max,
float pS9_max,
float pS25_max,
int EScorr) {
342 bool valid_NNinput =
true;
355 for (
int k = 0;
k < 11;
k++) {
357 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " <<
k
358 <<
" of X plane Do not exists";
363 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " <<
k
364 <<
" of Y plane Do not exists";
384 for (
int kk = 0;
kk < 11;
kk++) {
426 for (
int kk1 = 0; kk1 < 22; kk1++) {
433 float ECAL_norm_factor = 500.;
434 if (pS25_max > 500 && pS25_max <= 1000)
435 ECAL_norm_factor = 1000;
437 ECAL_norm_factor = 7000;
439 input_var[22] = pS1_max / ECAL_norm_factor;
440 input_var[23] = pS9_max / ECAL_norm_factor;
441 input_var[24] = pS25_max / ECAL_norm_factor;
443 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: S1/ECAL_norm_factor = " <<
input_var[22];
444 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: S9/ECAL_norm_factor = " <<
input_var[23];
445 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: S25/ECAL_norm_factor = " <<
input_var[24];
449 valid_NNinput =
false;
454 LogTrace(
"EcalClusters") <<
" valid_NNinput = " << valid_NNinput;
456 return valid_NNinput;
481 double lam, lam1, lam2;
527 lam =
sqrt((cee - cpp) * (cee - cpp) + 4 * cep * cep);
528 lam1 = (cee + cpp + lam) / 2;
529 lam2 = (cee + cpp - lam) / 2;
552 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo::GetNNoutput :nn_invar_presh = ";
554 LogTrace(
"EcalClusters").log([&](
auto& lt) {
565 }
else if (EE_Et >= 25.0 && EE_Et < 35.0) {
567 }
else if (EE_Et >= 35.0 && EE_Et < 45.0) {
569 }
else if (EE_Et >= 45.0 && EE_Et < 55.0) {
575 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: Et_SC = " << EE_Et
576 <<
" and I select Weight file Number = " << sel_wfile;
581 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout;
595 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo::GetBarrelNNoutput :nn_invar_presh = ";
597 LogTrace(
"EcalCluster").log([&](
auto& lt) {
608 }
else if (EB_Et >= 25.0 && EB_Et < 35.0) {
610 }
else if (EB_Et >= 35.0 && EB_Et < 45.0) {
612 }
else if (EB_Et >= 45.0 && EB_Et < 55.0) {
617 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: E_SC = " << EB_Et
618 <<
" and I select Weight file Number = " << sel_wfile;
623 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout;