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 vout_ElevenStrips_Energy.reserve(11);
107 for (
int i = 0;
i < 11;
i++) {
108 vout_ElevenStrips_Energy.push_back(0.);
111 for (
unsigned int i = 0;
i < vout_stripE.size();
i++) {
112 vout_ElevenStrips_Energy[
i] = vout_stripE.at(
i);
116 return vout_ElevenStrips_Energy;
122 RecHitsMap::iterator candidate_tmp = candidate_it;
126 if (candidate_tmp->first == lastID)
128 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: goodPi0Strip No such a strip in rechits_map ";
132 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: goodPi0Strip Strip energy " 133 << candidate_it->second.energy() <<
" is below threshold ";
144 vector<ESDetId>& vout) {
149 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: starts from strip " <<
strip;
154 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the East ";
157 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: East: " << n_east <<
" current strip is " 160 vout.push_back(
next);
167 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the West ";
171 LogTrace(
"EcalClusters") <<
"findPi0Road: West: " << n_west <<
" current strip is " <<
next;
173 vout.push_back(
next);
179 <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 1-st plane is " 182 }
else if (plane == 2) {
185 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the North ";
188 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: North: " << n_north
189 <<
" current strip is " <<
next;
191 vout.push_back(
next);
198 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the South ";
202 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: South: " << n_south
203 <<
" current strip is " <<
next;
205 vout.push_back(
next);
211 <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 2-nd plane is " 212 << n_south + n_north;
216 <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Wrong plane number, null cluster will be returned! ";
229 const char* Weights_file,
int& Layers,
int& Indim,
int& Hidden,
int& Outdim) {
234 bool checkinit =
false;
238 weights = fopen(Weights_file,
"r");
239 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: I opeded the Weights file = " << Weights_file;
241 throw cms::Exception(
"MissingWeightFile") <<
"Could not open the weights file: " << Weights_file;
251 if (
line[0] ==
'A') {
252 fscanf(
weights,
"%d", &Layers);
254 fscanf(
weights,
"%d", &Hidden);
255 fscanf(
weights,
"%d", &Outdim);
262 }
else if (
line[0] ==
'B') {
264 for (
int i = 0;
i < Indim;
i++) {
265 for (
int j = 0;
j < Hidden;
j++) {
269 }
else if (
line[0] ==
'C') {
271 for (
int i = 0;
i < Hidden;
i++) {
274 }
else if (
line[0] ==
'D') {
276 for (
int i = 0;
i < Hidden * Outdim;
i++) {
279 }
else if (
line[0] ==
'E') {
281 for (
int i = 0;
i < Outdim;
i++) {
285 edm::LogError(
"EEPi0Discrim") <<
"EndcapPiZeroDiscriminatorAlgo: Not a Net file of Corrupted Net file " << endl;
298 int sel_wfile,
int Layers,
int Indim,
int Hidden,
int Outdim,
int barrelstart)
const {
302 std::vector<float> I_SUM(
size_t(Hidden), 0.0);
303 std::vector<float>
OUT(
size_t(Outdim), 0.0);
305 for (
int h = 0;
h < Hidden;
h++) {
307 for (
int i = 0;
i < Indim;
i++) {
313 for (
int o1 = 0;
o1 < Outdim;
o1++) {
315 sel_wfile * Outdim * Hidden] *
319 for (
int o2 = 0; o2 < Outdim; o2++) {
323 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: getNNoutput :: -> NNout = " << nnout;
341 vector<float>& vph1, vector<float>& vph2,
float pS1_max,
float pS9_max,
float pS25_max,
int EScorr) {
343 bool valid_NNinput =
true;
356 for (
int k = 0;
k < 11;
k++) {
358 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " <<
k 359 <<
" of X plane Do not exists";
364 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " <<
k 365 <<
" of Y plane Do not exists";
385 for (
int kk = 0;
kk < 11;
kk++) {
427 for (
int kk1 = 0; kk1 < 22; kk1++) {
434 float ECAL_norm_factor = 500.;
435 if (pS25_max > 500 && pS25_max <= 1000)
436 ECAL_norm_factor = 1000;
438 ECAL_norm_factor = 7000;
440 input_var[22] = pS1_max / ECAL_norm_factor;
441 input_var[23] = pS9_max / ECAL_norm_factor;
442 input_var[24] = pS25_max / ECAL_norm_factor;
444 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: S1/ECAL_norm_factor = " <<
input_var[22];
445 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: S9/ECAL_norm_factor = " <<
input_var[23];
446 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: S25/ECAL_norm_factor = " <<
input_var[24];
450 valid_NNinput =
false;
455 LogTrace(
"EcalClusters") <<
" valid_NNinput = " << valid_NNinput;
457 return valid_NNinput;
482 double lam, lam1, lam2;
528 lam =
sqrt((cee - cpp) * (cee - cpp) + 4 * cep * cep);
529 lam1 = (cee + cpp + lam) / 2;
530 lam2 = (cee + cpp - lam) / 2;
553 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo::GetNNoutput :nn_invar_presh = ";
555 LogTrace(
"EcalClusters").log([&](
auto& lt) {
566 }
else if (EE_Et >= 25.0 && EE_Et < 35.0) {
568 }
else if (EE_Et >= 35.0 && EE_Et < 45.0) {
570 }
else if (EE_Et >= 45.0 && EE_Et < 55.0) {
576 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: Et_SC = " << EE_Et
577 <<
" and I select Weight file Number = " << sel_wfile;
582 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout;
596 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo::GetBarrelNNoutput :nn_invar_presh = ";
598 LogTrace(
"EcalCluster").log([&](
auto& lt) {
609 }
else if (EB_Et >= 25.0 && EB_Et < 35.0) {
611 }
else if (EB_Et >= 35.0 && EB_Et < 45.0) {
613 }
else if (EB_Et >= 45.0 && EB_Et < 55.0) {
618 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: E_SC = " << EB_Et
619 <<
" and I select Weight file Number = " << sel_wfile;
624 LogTrace(
"EcalClusters") <<
"EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout;
void findPi0Road(ESDetId strip, EcalPreshowerNavigator &theESNav, int plane, std::vector< ESDetId > &vout)
void home() const
move the navigator back to the starting point
float GetNNOutput(float EE_Et)
T north() const
move the navigator north
void calculateBarrelNNInputVariables(float et, double s1, double s9, double s25, double m2, double cee, double cep, double cpp, double s4, double s6, double ratio, double xcog, double ycog)
std::vector< float > O_Thresh_all
std::map< DetId, EcalRecHit > RecHitsMap
T south() const
move the navigator south
Log< level::Error, false > LogError
EndcapPiZeroDiscriminatorAlgo()
double preshStripEnergyCut_
void readWeightFile(const char *WFile, int &Layers, int &Indim, int &Hidden, int &Outdim)
std::vector< float > input_var
void setHome(const T &startingPoint)
set the starting position
std::vector< float > findPreshVector(ESDetId strip, RecHitsMap *rechits_map, CaloSubdetectorTopology *topology_p)
float getNNoutput(int sel_wfile, int Layers, int Indim, int Hidden, int Outdim, int barrelstart) const
std::vector< float > I_H_Weight_all
float GetBarrelNNOutput(float EB_Et)
bool goodPi0Strip(RecHitsMap::iterator candidate_it, ESDetId lastID)
std::vector< float > H_O_Weight_all
T east() const
move the navigator east
bool calculateNNInputVariables(std::vector< float > &vph1, std::vector< float > &vph2, float pS1_max, float pS9_max, float pS25_max, int EScorr)
float Activation_fun(float SUM) const
T west() const
move the navigator west
Log< level::Warning, false > LogWarning
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::vector< float > H_Thresh_all