CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EndcapPiZeroDiscriminatorAlgo.cc
Go to the documentation of this file.
1 
5 
8 #include <fstream>
9 #include <iostream>
10 
11 using namespace std;
12 
13 EndcapPiZeroDiscriminatorAlgo::EndcapPiZeroDiscriminatorAlgo(double stripEnergyCut, int nStripCut, const string& path,
14  DebugLevel_pi0 debugLevel = pINFO ) :
15  preshStripEnergyCut_(stripEnergyCut), preshSeededNstr_(nStripCut), debugLevel_(debugLevel), pathToFiles_(path)
16 {
17 
18  // Read all Weight files
19  Nfiles_EB = 5;
20  Nfiles_EE = 5;
21  string file_pt[5] = {"20","30","40","50","60"};
22  string file_barrel_pt[5] = {"20","30","40","50","60"};
23 
24  string nn_paterns_file = "";
25  for(int j=0;j<Nfiles_EE;j++) {
26  nn_paterns_file = "endcapPiZeroDiscriminatorWeights_et"+file_pt[j]+".wts";
27  edm::FileInPath WFile(pathToFiles_+nn_paterns_file);
28  readWeightFile(WFile.fullPath().c_str()); // read the weights' file
29 
30  EE_Layers = Layers;
31  EE_Indim = Indim;
32  EE_Hidden = Hidden;
33  EE_Outdim = Outdim;
34 
35  for(int i=0;i<Indim*Hidden;i++) I_H_Weight_all.push_back(I_H_Weight[i]);
36  for(int i=0;i<Hidden;i++) H_Thresh_all.push_back(H_Thresh[i]);
37  for(int i=0;i<Outdim*Hidden;i++) H_O_Weight_all.push_back(H_O_Weight[i]);
38  for(int i=0;i<Outdim;i++) O_Thresh_all.push_back(O_Thresh[i]);
39  }
40 
41  for(int k=0;k<Nfiles_EB;k++) {
42  nn_paterns_file = "barrelPiZeroDiscriminatorWeights_et"+file_barrel_pt[k]+".wts";
43  edm::FileInPath WFile(pathToFiles_+nn_paterns_file);
44  readWeightFile(WFile.fullPath().c_str()); // read the weights' file
45 
46  EB_Layers = Layers;
47  EB_Indim = Indim;
48  EB_Hidden = Hidden;
49  EB_Outdim = Outdim;
50 
51  for(int i=0;i<Indim*Hidden;i++) I_H_Weight_all.push_back(I_H_Weight[i]);
52  for(int i=0;i<Hidden;i++) H_Thresh_all.push_back(H_Thresh[i]);
53  for(int i=0;i<Outdim*Hidden;i++) H_O_Weight_all.push_back(H_O_Weight[i]);
54  for(int i=0;i<Outdim;i++) O_Thresh_all.push_back(O_Thresh[i]);
55  }
56  delete [] I_H_Weight;
57  delete [] H_Thresh;
58  delete [] H_O_Weight;
59  delete [] O_Thresh;
60 }
61 
62 
64  CaloSubdetectorTopology *topology_p)
65 {
66  vector<float> vout_stripE;
67 
68  // skip if rechits_map contains no hits
69  if ( rechits_map->size() == 0 ) {
70  edm::LogWarning("EndcapPiZeroDiscriminatorAlgo") << "RecHitsMap has size 0.";
71  return vout_stripE;
72  }
73 
74  vout_stripE.clear();
75 
76  vector<ESDetId> road_2d;
77  road_2d.clear();
78 
79  int plane = strip.plane();
80 
81  if ( debugLevel_ <= pDEBUG ) {
82  cout << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: Preshower Seeded Algorithm - looking for clusters" << "n"
83  << "findPreshVectors: Preshower is intersected at strip " << strip.strip() << ", at plane " << plane << endl;
84  }
85 
86  if ( strip == ESDetId(0) ) { //works in case of no intersected strip found
87  for(int i=0;i<11;i++) {
88  vout_stripE.push_back(-100.);
89  }
90  }
91 
92  // Add to the road the central strip
93  road_2d.push_back(strip);
94 
95  //Make a navigator, and set it to the strip cell.
96  EcalPreshowerNavigator navigator(strip, topology_p);
97  navigator.setHome(strip);
98  //search for neighbours in the central road
99  findPi0Road(strip, navigator, plane, road_2d);
100  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo:findPreshVectors: Total number of strips in the central road: " << road_2d.size() << endl;
101 
102  // Find the energy of each strip
103  RecHitsMap::iterator final_strip = rechits_map->end();
104  // very dangerous, added a protection on the rechits_map->size()
105  // at the beginning of the method
106  final_strip--;
107  ESDetId last_stripID = final_strip->first;
108 
109  float E = 0;
110  vector<ESDetId>::iterator itID;
111  for (itID = road_2d.begin(); itID != road_2d.end(); itID++) {
112  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: ID = " << *itID << endl;
113  RecHitsMap::iterator strip_it = rechits_map->find(*itID);
114  if(goodPi0Strip(strip_it,last_stripID)) { // continue if strip not found in rechit_map
115  E = strip_it->second.energy();
116  } else E = 0;
117  vout_stripE.push_back(E);
118  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: E = " << E << endl;
119  }
120 
121  // ***ML beg***
122  // vector of size=11, content of vout_stripE is copied into vout_ElevenStrips_Energy
123  // to avoid problem in case number of strips is less than 11
124  vector<float> vout_ElevenStrips_Energy;
125  for(int i=0;i<11;i++)
126  {
127  vout_ElevenStrips_Energy.push_back(0.);
128  }
129 
130  for(unsigned int i=0;i<vout_stripE.size();i++)
131  {
132  vout_ElevenStrips_Energy[i] = vout_stripE.at(i);
133  }
134 
135  //return vout_stripE;
136  return vout_ElevenStrips_Energy;
137  // ***ML end***
138 
139 }
140 
141 // returns true if the candidate strip fulfills the requirements to be added to the cluster:
142 bool EndcapPiZeroDiscriminatorAlgo::goodPi0Strip(RecHitsMap::iterator candidate_it, ESDetId lastID)
143 {
144  RecHitsMap::iterator candidate_tmp = candidate_it;
145  candidate_tmp--;
146  if ( debugLevel_ == pDEBUG ) {
147  if (candidate_tmp->first == lastID )
148  cout << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip No such a strip in rechits_map " << endl;
149  if (candidate_it->second.energy() <= preshStripEnergyCut_)
150  cout << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip Strip energy " << candidate_it->second.energy() <<" is below threshold " << endl;
151  }
152  // crystal should not be included...
153  if ( (candidate_tmp->first == lastID ) || // ...if it corresponds to a hit
154  (candidate_it->second.energy() <= preshStripEnergyCut_ ) ) // ...if it has a negative or zero energy
155  {
156  return false;
157  }
158 
159  return true;
160 }
161 
162 // find strips in the road of size +/- preshSeededNstr_ from the central strip
164  int plane, vector<ESDetId>& vout) {
165  if ( strip == ESDetId(0) ) return;
166  ESDetId next;
167  theESNav.setHome(strip);
168 
169  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: starts from strip " << strip << endl;
170  if (plane == 1) {
171  // east road
172  int n_east= 0;
173  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the East " << endl;
174  while ( ((next=theESNav.east()) != ESDetId(0) && next != strip) ) {
175  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: East: " << n_east << " current strip is " << next << endl;
176  vout.push_back(next);
177  ++n_east;
178  if (n_east == preshSeededNstr_) break;
179  }
180  // west road
181  int n_west= 0;
182  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the West " << endl;
183  theESNav.home();
184  while ( ((next=theESNav.west()) != ESDetId(0) && next != strip )) {
185  if ( debugLevel_ == pDEBUG ) cout << "findPi0Road: West: " << n_west << " current strip is " << next << endl;
186  vout.push_back(next);
187  ++n_west;
188  if (n_west == preshSeededNstr_) break;
189  }
190  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 1-st plane is " << n_east+n_west << endl;
191  }
192  else if (plane == 2) {
193  // north road
194  int n_north= 0;
195  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the North " << endl;
196  while ( ((next=theESNav.north()) != ESDetId(0) && next != strip) ) {
197  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: North: " << n_north << " current strip is " << next << endl;
198  vout.push_back(next);
199  ++n_north;
200  if (n_north == preshSeededNstr_) break;
201  }
202  // south road
203  int n_south= 0;
204  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the South " << endl;
205  theESNav.home();
206  while ( ((next=theESNav.south()) != ESDetId(0) && next != strip) ) {
207  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: South: " << n_south << " current strip is " << next << endl;
208  vout.push_back(next);
209  ++n_south;
210  if (n_south == preshSeededNstr_) break;
211  }
212  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 2-nd plane is " << n_south+n_north << endl;
213  }
214  else {
215  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Wrong plane number, null cluster will be returned! " << endl;
216  } // end of if
217 
218  theESNav.home();
219 }
220 
221 
222 //===================================================================
223 // EndcapPiZeroDiscriminatorAlgo::readWeightFile(...), a method that reads the weigths of the NN
224 // INPUT: Weights_file
225 // OUTPUT: I_H_Weight, H_Thresh, H_O_Weight, O_Thresh arrays
226 //===================================================================
227 void EndcapPiZeroDiscriminatorAlgo::readWeightFile(const char *Weights_file){
228  FILE *weights;
229 
230  char *line;
231  line = new char[80];
232 
233  bool checkinit=false;
234 // Open the weights file, generated by jetnet, and read
235 // in the nodes and weights
236 //*******************************************************
237  weights = fopen(Weights_file, "r");
238  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: I opeded the Weights file = " << Weights_file << endl;
239 
240  while( !feof(weights) ){
241  fscanf(weights, "%s", line);
242  if (line[0] == 'A') { //Read in ANN nodes: Layers, input , Hidden, Output
243  fscanf(weights, "%d", &Layers); // # of NN Layers used
244  fscanf(weights, "%d", &Indim); // # of Inputs actually used
245  fscanf(weights, "%d", &Hidden); // # of hidden nodes
246  fscanf(weights, "%d", &Outdim); // # of output nodes
247 
248  inp_var = Indim + 1;
249 
250  I_H_Weight = new float[Indim*Hidden];
251  H_Thresh = new float[Hidden];
252  H_O_Weight = new float[Hidden*Outdim];
253  O_Thresh = new float[Outdim];
254  checkinit=true;
255  }else if (line[0] == 'B') { // read in weights between hidden and intput nodes
256  assert(checkinit);
257  for (int i = 0; i<Indim; i++){
258  for (int j = 0; j<Hidden; j++){
259  fscanf(weights, "%f", &I_H_Weight[i*Hidden+j]);
260  }
261  }
262  }else if (line[0] == 'C'){ // Read in the thresholds for hidden nodes
263  assert(checkinit);
264  for (int i = 0; i<Hidden; i++){
265  fscanf(weights, "%f", &H_Thresh[i]);
266  }
267  }else if (line[0] == 'D'){ // read in weights between hidden and output nodes
268  assert(checkinit);
269  for (int i = 0; i<Hidden*Outdim; i++){
270  fscanf(weights, "%f", &H_O_Weight[i]);
271  }
272  }else if (line[0] == 'E'){ // read in the threshold for the output nodes
273  assert(checkinit);
274  for (int i = 0; i<Outdim; i++){
275  fscanf(weights, "%f", &O_Thresh[i]);
276 
277  }
278  }
279  else{cout << "EndcapPiZeroDiscriminatorAlgo: Not a Net file of Corrupted Net file " << endl;
280  }
281  }
282  fclose(weights);
283 }
284 
285 //=====================================================================================
286 // EndcapPiZeroDiscriminatorAlgo::getNNoutput(int sel_wfile), a method that calculated the NN output
287 // INPUT: sel_wfile -> Weight file selection
288 // OUTPUT : nnout -> the NN output
289 //=====================================================================================
290 
292 {
293  float* I_SUM;
294  float* OUT;
295  float nnout=0.0;
296  int mij;
297 
298  I_SUM = new float[Hidden];
299  OUT = new float[Outdim];
300 
301  for(int k=0;k<Hidden;k++) I_SUM[k]=0.0;
302  for(int k1=0;k1<Outdim;k1++) OUT[k1]=0.0;
303 
304  for (int h = 0; h<Hidden; h++){
305  mij = h - Hidden;
306  for (int i = 0; i<Indim; i++){
307  mij = mij + Hidden;
308  I_SUM[h] += I_H_Weight_all[mij+sel_wfile*Indim*Hidden + barrelstart*Nfiles_EE*EE_Indim*EE_Hidden] * input_var[i];
309  }
310  I_SUM[h] += H_Thresh_all[h+sel_wfile*Hidden + barrelstart*Nfiles_EE*EE_Hidden];
311  for (int o1 = 0; o1<Outdim; o1++) {
312  OUT[o1] += H_O_Weight_all[barrelstart*Nfiles_EE*EE_Outdim*EE_Hidden + h*Outdim+o1 + sel_wfile*Outdim*Hidden]*Activation_fun(I_SUM[h]);
313 
314  }
315  }
316  for (int o2 = 0; o2<Outdim; o2++){
317  OUT[o2] += O_Thresh_all[barrelstart*Nfiles_EE*EE_Outdim + o2 + sel_wfile*Outdim];
318  }
319  nnout = Activation_fun(OUT[0]);
320 
321  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: getNNoutput :: -> NNout = " << nnout << endl;
322 
323  delete I_SUM;
324  delete OUT;
325  delete input_var;
326 
327  return (nnout);
328 }
329 
330 
332  return( 1.0 / ( 1.0 + exp(-2.0*SUM) ) );
333 }
334 //=====================================================================================
335 // EndcapPiZeroDiscriminatorAlgo::calculateNNInputVariables(...), a method that calculates the 25 input variables
336 // INPUTS:
337 // vph1 -> vector of the stip energies in 1st Preshower plane
338 // vph2 -> vector of the stip energies in 2nd Preshower plane
339 // pS1_max -> E1
340 // pS9_max -> E9
341 // pS25_max -> E25
342 // OUTPUT:
343 // input_var[25] -> the 25 input to the NN variables array
344 //=====================================================================================
345 bool EndcapPiZeroDiscriminatorAlgo::calculateNNInputVariables(vector<float>& vph1, vector<float>& vph2,
346  float pS1_max, float pS9_max, float pS25_max, int EScorr)
347 {
348  input_var = new float[EE_Indim];
349 
350  bool valid_NNinput = true;
351 
352  if ( debugLevel_ <= pDEBUG ) {
353  cout << "EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in X plane = ( ";
354  for(int i = 0; i<11;i++) {
355  cout << " " << vph1[i];
356  }
357  cout << ")" << endl;
358  cout << "EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in Y plane = ( ";
359  for(int i = 0; i<11;i++) {
360  cout << " " << vph2[i];
361  }
362  cout << ")" << endl;
363  }
364  // check if all Preshower info is availabla - If NOT use remaning info
365  for(int k = 0; k<11; k++) {
366  if(vph1[k] < 0 ) {
367  if ( debugLevel_ <= pDEBUG ) {
368  cout << "EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " << k << " of X plane Do not exists" << endl;
369  }
370  vph1[k] = 0.0;
371  }
372  if(vph2[k] < 0 ) {
373  if ( debugLevel_ <= pDEBUG ) {
374  cout << "EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " << k << " of Y plane Do not exists" << endl;
375  }
376  vph2[k] = 0.0;
377  }
378  }
379  if ( debugLevel_ <= pDEBUG ) {
380  cout << "EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in X plane = ( ";
381  for(int i = 0; i<11;i++) {
382  cout << " " << vph1[i];
383  }
384  cout << ")" << endl;
385  cout << "EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in Y plane = ( ";
386  for(int i = 0; i<11;i++) {
387  cout << " " << vph2[i];
388  }
389  cout << ")" << endl;
390  }
391 
392 // FIRST : Produce the 22 NN variables related with the Preshower
393 // --------------------------------------------------------------
394 // New normalization of the preshower strip energies Aris 8/11/2004
395  for(int kk=0;kk<11;kk++){
396  input_var[kk] = fabs(vph1[kk]/0.01);
397  input_var[kk + 11] = fabs(vph2[kk]/0.02);
398  if(input_var[kk] < 0.0001) input_var[kk] = 0.;
399  if(input_var[kk + 11] < 0.0001) input_var[kk + 11] = 0.;
400  }
401  input_var[0] = fabs(input_var[0]/2.);
402  input_var[1] = fabs(input_var[1]/2.);
403  input_var[6] = fabs(input_var[6]/2.);
404  input_var[11] = fabs(input_var[11]/2.);
405  input_var[12] = fabs(input_var[12]/2.);
406  input_var[17] = fabs(input_var[17]/2.);
407 
408 // correction for version > CMSSW_3_1_0_pre5 where extra enegry is given to the ES strips
409 // Aris 18/5/2009
410  if( EScorr == 1) {
411  input_var[0] -= 0.05;
412  input_var[1] -= 0.035;
413  input_var[2] -= 0.035;
414  input_var[3] -= 0.02;
415  input_var[4] -= 0.015;
416  input_var[5] -= 0.0075;
417  input_var[6] -= 0.035;
418  input_var[7] -= 0.035;
419  input_var[8] -= 0.02;
420  input_var[9] -= 0.015;
421  input_var[10] -= 0.0075;
422 
423  input_var[11] -= 0.05;
424  input_var[12] -= 0.035;
425  input_var[13] -= 0.035;
426  input_var[14] -= 0.02;
427  input_var[15] -= 0.015;
428  input_var[16] -= 0.0075;
429  input_var[17] -= 0.035;
430  input_var[18] -= 0.035;
431  input_var[19] -= 0.02;
432  input_var[20] -= 0.015;
433  input_var[21] -= 0.0075;
434 
435  for(int kk1=0;kk1<22;kk1++){
436  if(input_var[kk1] < 0 ) input_var[kk1] = 0.0;
437  }
438  }
439 // SECOND: Take the final NN variable related to the ECAL
440 // -----------------------------------------------
441  float ECAL_norm_factor = 500.;
442  if(pS25_max>500&&pS25_max<=1000) ECAL_norm_factor = 1000;
443  if(pS25_max>1000) ECAL_norm_factor = 7000;
444 
445  input_var[22] = pS1_max/ECAL_norm_factor;
446  input_var[23] = pS9_max/ECAL_norm_factor;
447  input_var[24] = pS25_max/ECAL_norm_factor;
448 
449  if ( debugLevel_ <= pDEBUG ) {
450  cout << "EndcapPiZeroDiscriminatorAlgo: S1/ECAL_norm_factor = " << input_var[22] << endl;
451  cout << "EndcapPiZeroDiscriminatorAlgo: S9/ECAL_norm_factor = " << input_var[23] << endl;
452  cout << "EndcapPiZeroDiscriminatorAlgo: S25/ECAL_norm_factor = " << input_var[24] << endl;
453  }
454  for(int i=0;i<EE_Indim;i++){
455  if(input_var[i] > 1.0e+00) {
456  valid_NNinput = false;
457  break;
458  }
459  }
460  if ( debugLevel_ <= pDEBUG ) {
461  cout << " valid_NNinput = " << valid_NNinput << endl; }
462  return valid_NNinput;
463 }
464 
465 
466 //=====================================================================================
467 // EndcapPiZeroDiscriminatorAlgo::calculateBarrelNNInputVariables(...), a method that calculates
468 // the 12 barrel NN input
469 // OUTPUT:
470 // input_var[12] -> the 12 input to the barrel NN variables array
471 //=====================================================================================
472 
473 void EndcapPiZeroDiscriminatorAlgo::calculateBarrelNNInputVariables(float et, double s1, double s9, double s25,
474  double m2, double cee, double cep,double cpp,
475  double s4, double s6, double ratio,
476  double xcog, double ycog)
477 {
478  input_var = new float[EB_Indim];
479 
480  double lam, lam1, lam2;
481 
482  if(xcog < 0.) {
483  input_var[0] = -xcog/s25;
484  } else {
485  input_var[0] = xcog/s25;
486  }
487 
488  input_var[1] = cee/0.0004;
489 
490  if(cpp<.001) {
491  input_var[2] = cpp/.001;
492  } else {
493  input_var[2] = 0.;
494  }
495 
496  if(s9!=0.) {
497  input_var[3] = s1/s9;
498  input_var[8] = s6/s9;
499  input_var[10] = (m2+s1)/s9;
500  }
501  else {
502  input_var[3] = 0.;
503  input_var[8] = 0.;
504  input_var[10] = 0.;
505  }
506 
507  if(s25-s1>0.) {
508  input_var[4] = (s9-s1)/(s25-s1);
509  } else {
510  input_var[4] = 0.;
511  }
512 
513  if(s25>0.) {
514  input_var[5] = s4/s25;
515  } else {
516  input_var[5] = 0.;
517  }
518 
519  if(ycog < 0.) {
520  input_var[6] = -ycog/s25;
521  } else {
522  input_var[6] = ycog/s25;
523  }
524 
525  input_var[7] = ratio;
526 
527  lam=sqrt((cee -cpp)*(cee -cpp)+4*cep*cep);
528  lam1=(cee + cpp + lam)/2;
529  lam2=(cee + cpp - lam)/2;
530 
531  if(lam1 == 0) {
532  input_var[9] = .0;
533  } else {
534  input_var[9] = lam2/lam1;
535  }
536  if(s4!=0.) {
537  input_var[11] = (m2+s1)/s4;
538  } else {
539  input_var[11] = 0.;
540  }
541 
542 }
543 
544 
545 //=====================================================================================
546 // EndcapPiZeroDiscriminatorAlgo::GetNNOutput(...), a method that calculates the NNoutput
547 // INPUTS: Super Cluster Energy
548 // OUTPUTS : NNoutput
549 //=====================================================================================
551 {
553 
554  float nnout = -1;
555 // Print the NN input variables that are related to the Preshower + ECAL
556 // ------------------------------------------------------------------------
557  if ( debugLevel_ <= pDEBUG )cout << "EndcapPiZeroDiscriminatorAlgo::GetNNoutput :nn_invar_presh = " ;
558  for(int k1=0;k1<Indim;k1++) {
559  if ( debugLevel_ <= pDEBUG )cout << input_var[k1] << " " ;
560  }
561  if ( debugLevel_ <= pDEBUG )cout << endl;
562 
563  // select the appropriate Weigth file
564  int sel_wfile;
565  if(EE_Et<25.0) {sel_wfile = 0;}
566  else if(EE_Et>=25.0 && EE_Et<35.0) {sel_wfile = 1;}
567  else if(EE_Et>=35.0 && EE_Et<45.0) {sel_wfile = 2;}
568  else if(EE_Et>=45.0 && EE_Et<55.0) {sel_wfile = 3;}
569  else {sel_wfile = 4;}
570 
571  if ( debugLevel_ <= pDEBUG ) {
572  cout << "EndcapPiZeroDiscriminatorAlgo: Et_SC = " << EE_Et << " and I select Weight file Number = " << sel_wfile << endl;
573  }
574 
575  nnout = getNNoutput(sel_wfile); // calculate the nnoutput for the given ECAL object
576  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout << endl;
577  return nnout;
578 }
579 
580 
581 //=====================================================================================
582 // EndcapPiZeroDiscriminatorAlgo::GetBarrelNNOutput(...), a method that calculates the barrel NNoutput
583 // INPUTS: Super Cluster Energy
584 // OUTPUTS : NNoutput
585 //=====================================================================================
587 {
588 
590 
591  float nnout = -1;
592 // Print the NN input variables that are related to the ECAL Barrel
593 // ------------------------------------------------------------------------
594  if ( debugLevel_ <= pDEBUG )cout << "EndcapPiZeroDiscriminatorAlgo::GetBarrelNNoutput :nn_invar_presh = " ;
595  for(int k1=0;k1<Indim;k1++) {
596  if ( debugLevel_ <= pDEBUG )cout << input_var[k1] << " " ;
597  }
598  if ( debugLevel_ <= pDEBUG )cout << endl;
599 
600  // select the appropriate Weigth file
601  int sel_wfile;
602  if(EB_Et<25.0) {sel_wfile = 0;}
603  else if(EB_Et>=25.0 && EB_Et<35.0) {sel_wfile = 1;}
604  else if(EB_Et>=35.0 && EB_Et<45.0) {sel_wfile = 2;}
605  else if(EB_Et>=45.0 && EB_Et<55.0) {sel_wfile = 3;}
606  else {sel_wfile = 4;}
607 
608  if ( debugLevel_ <= pDEBUG ) {
609  cout << "EndcapPiZeroDiscriminatorAlgo: E_SC = " << EB_Et << " and I select Weight file Number = " << sel_wfile << endl;
610  }
611 
612  nnout = getNNoutput(sel_wfile); // calculate the nnoutput for the given ECAL object
613  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout << endl;
614 
615  return nnout;
616 }
617 
void findPi0Road(ESDetId strip, EcalPreshowerNavigator &theESNav, int plane, std::vector< ESDetId > &vout)
int i
Definition: DBlmapReader.cc:9
int strip() const
Definition: ESDetId.h:41
void setHome(const T &startingPoint)
set the starting position
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
void home() const
move the navigator back to the starting point
virtual T west() const
move the navigator west
Definition: CaloNavigator.h:81
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::map< DetId, EcalRecHit > RecHitsMap
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
virtual T north() const
move the navigator north
Definition: CaloNavigator.h:51
int path() const
Definition: HLTadd.h:3
virtual T east() const
move the navigator east
Definition: CaloNavigator.h:71
std::vector< float > findPreshVector(ESDetId strip, RecHitsMap *rechits_map, CaloSubdetectorTopology *topology_p)
T sqrt(T t)
Definition: SSEVec.h:28
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
bool goodPi0Strip(RecHitsMap::iterator candidate_it, ESDetId lastID)
#define SUM(A, B)
int plane() const
Definition: ESDetId.h:35
bool calculateNNInputVariables(std::vector< float > &vph1, std::vector< float > &vph2, float pS1_max, float pS9_max, float pS25_max, int EScorr)
tuple cout
Definition: gather_cfg.py:41
virtual T south() const
move the navigator south
Definition: CaloNavigator.h:61
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4