CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
EndcapPiZeroDiscriminatorAlgo Class Reference

#include <EndcapPiZeroDiscriminatorAlgo.h>

Public Types

typedef std::map< DetId,
EcalRecHit
RecHitsMap
 

Public Member Functions

float Activation_fun (float SUM)
 
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)
 
bool calculateNNInputVariables (std::vector< float > &vph1, std::vector< float > &vph2, float pS1_max, float pS9_max, float pS25_max, int EScorr)
 
 EndcapPiZeroDiscriminatorAlgo ()
 
 EndcapPiZeroDiscriminatorAlgo (double stripEnergyCut, int nStripCut, const std::string &path)
 
void findPi0Road (ESDetId strip, EcalPreshowerNavigator &theESNav, int plane, std::vector< ESDetId > &vout)
 
std::vector< float > findPreshVector (ESDetId strip, RecHitsMap *rechits_map, CaloSubdetectorTopology *topology_p)
 
float * get_input_vector ()
 
float GetBarrelNNOutput (float EB_Et)
 
float getNNoutput (int sel_wfile)
 
float GetNNOutput (float EE_Et)
 
bool goodPi0Strip (RecHitsMap::iterator candidate_it, ESDetId lastID)
 
void readWeightFile (const char *WFile)
 
 ~EndcapPiZeroDiscriminatorAlgo ()
 

Private Attributes

int barrelstart
 
int debugLevel_
 
int EB_Hidden
 
int EB_Indim
 
int EB_Layers
 
int EB_Outdim
 
int EE_Hidden
 
int EE_Indim
 
int EE_Layers
 
int EE_Outdim
 
float * H_O_Weight
 
std::vector< float > H_O_Weight_all
 
float * H_Thresh
 
std::vector< float > H_Thresh_all
 
int Hidden
 
float * I_H_Weight
 
std::vector< float > I_H_Weight_all
 
int Indim
 
int inp_var
 
float * input_var
 
int Layers
 
int Nfiles_EB
 
int Nfiles_EE
 
float * O_Thresh
 
std::vector< float > O_Thresh_all
 
int Outdim
 
std::string pathToFiles_
 
int preshSeededNstr_
 
double preshStripEnergyCut_
 
RecHitsMaprechits_map
 

Detailed Description

Definition at line 16 of file EndcapPiZeroDiscriminatorAlgo.h.

Member Typedef Documentation

Definition at line 20 of file EndcapPiZeroDiscriminatorAlgo.h.

Constructor & Destructor Documentation

EndcapPiZeroDiscriminatorAlgo::EndcapPiZeroDiscriminatorAlgo ( )
inline
EndcapPiZeroDiscriminatorAlgo::EndcapPiZeroDiscriminatorAlgo ( double  stripEnergyCut,
int  nStripCut,
const std::string &  path 
)
EndcapPiZeroDiscriminatorAlgo::~EndcapPiZeroDiscriminatorAlgo ( )
inline

Definition at line 29 of file EndcapPiZeroDiscriminatorAlgo.h.

29 {};

Member Function Documentation

float EndcapPiZeroDiscriminatorAlgo::Activation_fun ( float  SUM)

Definition at line 344 of file EndcapPiZeroDiscriminatorAlgo.cc.

References create_public_lumi_plots::exp.

Referenced by getNNoutput().

344  {
345  return( 1.0 / ( 1.0 + exp(-2.0*SUM) ) );
346 }
#define SUM(A, B)
void EndcapPiZeroDiscriminatorAlgo::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 
)

Definition at line 484 of file EndcapPiZeroDiscriminatorAlgo.cc.

References EB_Indim, input_var, and mathSSE::sqrt().

488 {
489  input_var = new float[EB_Indim];
490 
491  double lam, lam1, lam2;
492 
493  if(xcog < 0.) {
494  input_var[0] = -xcog/s25;
495  } else {
496  input_var[0] = xcog/s25;
497  }
498 
499  input_var[1] = cee/0.0004;
500 
501  if(cpp<.001) {
502  input_var[2] = cpp/.001;
503  } else {
504  input_var[2] = 0.;
505  }
506 
507  if(s9!=0.) {
508  input_var[3] = s1/s9;
509  input_var[8] = s6/s9;
510  input_var[10] = (m2+s1)/s9;
511  }
512  else {
513  input_var[3] = 0.;
514  input_var[8] = 0.;
515  input_var[10] = 0.;
516  }
517 
518  if(s25-s1>0.) {
519  input_var[4] = (s9-s1)/(s25-s1);
520  } else {
521  input_var[4] = 0.;
522  }
523 
524  if(s25>0.) {
525  input_var[5] = s4/s25;
526  } else {
527  input_var[5] = 0.;
528  }
529 
530  if(ycog < 0.) {
531  input_var[6] = -ycog/s25;
532  } else {
533  input_var[6] = ycog/s25;
534  }
535 
536  input_var[7] = ratio;
537 
538  lam=sqrt((cee -cpp)*(cee -cpp)+4*cep*cep);
539  lam1=(cee + cpp + lam)/2;
540  lam2=(cee + cpp - lam)/2;
541 
542  if(lam1 == 0) {
543  input_var[9] = .0;
544  } else {
545  input_var[9] = lam2/lam1;
546  }
547  if(s4!=0.) {
548  input_var[11] = (m2+s1)/s4;
549  } else {
550  input_var[11] = 0.;
551  }
552 
553 }
T sqrt(T t)
Definition: SSEVec.h:18
bool EndcapPiZeroDiscriminatorAlgo::calculateNNInputVariables ( std::vector< float > &  vph1,
std::vector< float > &  vph2,
float  pS1_max,
float  pS9_max,
float  pS25_max,
int  EScorr 
)

Definition at line 358 of file EndcapPiZeroDiscriminatorAlgo.cc.

References alignCSCRings::e, EE_Indim, input_var, relval_2017::k, GetRecoTauVFromDQM_MC_cff::kk, and LogTrace.

360 {
361  input_var = new float[EE_Indim];
362 
363  bool valid_NNinput = true;
364 
365  /*
366  for(int i = 0; i<11;i++) {
367  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in X plane = " << vph1[i] ;
368  }
369 
370  for(int i = 0; i<11;i++) {
371  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in Y plane = " << vph2[i] ;
372  }
373  */
374 
375  // check if all Preshower info is availabla - If NOT use remaning info
376  for(int k = 0; k<11; k++) {
377  if(vph1[k] < 0 ) {
378 
379  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " << k << " of X plane Do not exists" ;
380 
381  vph1[k] = 0.0;
382  }
383  if(vph2[k] < 0 ) {
384  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " << k << " of Y plane Do not exists" ;
385 
386  vph2[k] = 0.0;
387  }
388  }
389 
390  /*
391  for(int i = 0; i<11;i++) {
392  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in X plane = " << vph1[i] ;
393  }
394 
395  for(int i = 0; i<11;i++) {
396 
397  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in Y plane = " << vph2[i] ;
398  }
399  */
400 
401 
402 // FIRST : Produce the 22 NN variables related with the Preshower
403 // --------------------------------------------------------------
404 // New normalization of the preshower strip energies Aris 8/11/2004
405  for(int kk=0;kk<11;kk++){
406  input_var[kk] = fabs(vph1[kk]/0.01);
407  input_var[kk + 11] = fabs(vph2[kk]/0.02);
408  if(input_var[kk] < 0.0001) input_var[kk] = 0.;
409  if(input_var[kk + 11] < 0.0001) input_var[kk + 11] = 0.;
410  }
411  input_var[0] = fabs(input_var[0]/2.);
412  input_var[1] = fabs(input_var[1]/2.);
413  input_var[6] = fabs(input_var[6]/2.);
414  input_var[11] = fabs(input_var[11]/2.);
415  input_var[12] = fabs(input_var[12]/2.);
416  input_var[17] = fabs(input_var[17]/2.);
417 
418 // correction for version > CMSSW_3_1_0_pre5 where extra enegry is given to the ES strips
419 // Aris 18/5/2009
420  if( EScorr == 1) {
421  input_var[0] -= 0.05;
422  input_var[1] -= 0.035;
423  input_var[2] -= 0.035;
424  input_var[3] -= 0.02;
425  input_var[4] -= 0.015;
426  input_var[5] -= 0.0075;
427  input_var[6] -= 0.035;
428  input_var[7] -= 0.035;
429  input_var[8] -= 0.02;
430  input_var[9] -= 0.015;
431  input_var[10] -= 0.0075;
432 
433  input_var[11] -= 0.05;
434  input_var[12] -= 0.035;
435  input_var[13] -= 0.035;
436  input_var[14] -= 0.02;
437  input_var[15] -= 0.015;
438  input_var[16] -= 0.0075;
439  input_var[17] -= 0.035;
440  input_var[18] -= 0.035;
441  input_var[19] -= 0.02;
442  input_var[20] -= 0.015;
443  input_var[21] -= 0.0075;
444 
445  for(int kk1=0;kk1<22;kk1++){
446  if(input_var[kk1] < 0 ) input_var[kk1] = 0.0;
447  }
448  }
449 // SECOND: Take the final NN variable related to the ECAL
450 // -----------------------------------------------
451  float ECAL_norm_factor = 500.;
452  if(pS25_max>500&&pS25_max<=1000) ECAL_norm_factor = 1000;
453  if(pS25_max>1000) ECAL_norm_factor = 7000;
454 
455  input_var[22] = pS1_max/ECAL_norm_factor;
456  input_var[23] = pS9_max/ECAL_norm_factor;
457  input_var[24] = pS25_max/ECAL_norm_factor;
458 
459  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: S1/ECAL_norm_factor = " << input_var[22];
460  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: S9/ECAL_norm_factor = " << input_var[23];
461  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: S25/ECAL_norm_factor = " << input_var[24] ;
462 
463  for(int i=0;i<EE_Indim;i++){
464  if(input_var[i] > 1.0e+00) {
465  valid_NNinput = false;
466  break;
467  }
468  }
469 
470  LogTrace("EcalClusters") << " valid_NNinput = " << valid_NNinput ;
471 
472 
473  return valid_NNinput;
474 }
int i
Definition: DBlmapReader.cc:9
#define LogTrace(id)
void EndcapPiZeroDiscriminatorAlgo::findPi0Road ( ESDetId  strip,
EcalPreshowerNavigator theESNav,
int  plane,
std::vector< ESDetId > &  vout 
)

Definition at line 163 of file EndcapPiZeroDiscriminatorAlgo.cc.

References CaloNavigator< T, TOPO >::east(), CaloNavigator< T, TOPO >::home(), LogTrace, GetRecoTauVFromDQM_MC_cff::next, CaloNavigator< T, TOPO >::north(), preshSeededNstr_, CaloNavigator< T, TOPO >::setHome(), CaloNavigator< T, TOPO >::south(), and CaloNavigator< T, TOPO >::west().

Referenced by findPreshVector().

164  {
165  if ( strip == ESDetId(0) ) return;
166  ESDetId next;
167  theESNav.setHome(strip);
168  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: starts from strip " << strip ;
169 
170  if (plane == 1) {
171  // east road
172  int n_east= 0;
173  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the East " ;
174 
175  while ( ((next=theESNav.east()) != ESDetId(0) && next != strip) ) {
176  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: East: " << n_east << " current strip is " << next ;
177 
178  vout.push_back(next);
179  ++n_east;
180  if (n_east == preshSeededNstr_) break;
181  }
182  // west road
183  int n_west= 0;
184  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the West " ;
185 
186  theESNav.home();
187  while ( ((next=theESNav.west()) != ESDetId(0) && next != strip )) {
188  LogTrace("EcalClusters") << "findPi0Road: West: " << n_west << " current strip is " << next ;
189 
190  vout.push_back(next);
191  ++n_west;
192  if (n_west == preshSeededNstr_) break;
193  }
194  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 1-st plane is " << n_east+n_west ;
195 
196  }
197  else if (plane == 2) {
198  // north road
199  int n_north= 0;
200  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the North " ;
201 
202  while ( ((next=theESNav.north()) != ESDetId(0) && next != strip) ) {
203  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: North: " << n_north << " current strip is " << next;
204 
205  vout.push_back(next);
206  ++n_north;
207  if (n_north == preshSeededNstr_) break;
208  }
209  // south road
210  int n_south= 0;
211  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the South " ;
212 
213  theESNav.home();
214  while ( ((next=theESNav.south()) != ESDetId(0) && next != strip) ) {
215  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: South: " << n_south << " current strip is " << next ;
216 
217  vout.push_back(next);
218  ++n_south;
219  if (n_south == preshSeededNstr_) break;
220  }
221  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 2-nd plane is " << n_south+n_north ;
222 
223  }
224  else {
225  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Wrong plane number, null cluster will be returned! " ;
226 
227  } // end of if
228 
229  theESNav.home();
230 }
void setHome(const T &startingPoint)
set the starting position
T west() const
move the navigator west
Definition: CaloNavigator.h:59
T south() const
move the navigator south
Definition: CaloNavigator.h:45
#define LogTrace(id)
T east() const
move the navigator east
Definition: CaloNavigator.h:52
void home() const
move the navigator back to the starting point
T north() const
move the navigator north
Definition: CaloNavigator.h:38
vector< float > EndcapPiZeroDiscriminatorAlgo::findPreshVector ( ESDetId  strip,
RecHitsMap rechits_map,
CaloSubdetectorTopology topology_p 
)

Definition at line 62 of file EndcapPiZeroDiscriminatorAlgo.cc.

References findPi0Road(), goodPi0Strip(), i, LogTrace, HLT_25ns10e33_v2_cff::navigator, ESDetId::plane(), CaloNavigator< T, TOPO >::setHome(), and ESDetId::strip().

64 {
65  vector<float> vout_stripE;
66 
67  // skip if rechits_map contains no hits
68  if ( rechits_map->size() == 0 ) {
69  edm::LogWarning("EndcapPiZeroDiscriminatorAlgo") << "RecHitsMap has size 0.";
70  return vout_stripE;
71  }
72 
73  vout_stripE.clear();
74 
75  vector<ESDetId> road_2d;
76  road_2d.clear();
77 
78  int plane = strip.plane();
79 
80  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: Preshower Seeded Algorithm - looking for clusters" << "n"<< "findPreshVectors: Preshower is intersected at strip " << strip.strip() << ", at plane " << plane ;
81 
82 
83  if ( strip == ESDetId(0) ) { //works in case of no intersected strip found
84  for(int i=0;i<11;i++) {
85  vout_stripE.push_back(-100.);
86  }
87  }
88 
89  // Add to the road the central strip
90  road_2d.push_back(strip);
91 
92  //Make a navigator, and set it to the strip cell.
93  EcalPreshowerNavigator navigator(strip, topology_p);
94  navigator.setHome(strip);
95  //search for neighbours in the central road
96  findPi0Road(strip, navigator, plane, road_2d);
97 
98  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo:findPreshVectors: Total number of strips in the central road: " << road_2d.size() ;
99 
100  // Find the energy of each strip
101  RecHitsMap::iterator final_strip = rechits_map->end();
102  // very dangerous, added a protection on the rechits_map->size()
103  // at the beginning of the method
104  final_strip--;
105  ESDetId last_stripID = final_strip->first;
106 
107  float E = 0;
108  vector<ESDetId>::iterator itID;
109  for (itID = road_2d.begin(); itID != road_2d.end(); itID++) {
110  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: ID = " << *itID ;
111 
112  RecHitsMap::iterator strip_it = rechits_map->find(*itID);
113  if(goodPi0Strip(strip_it,last_stripID)) { // continue if strip not found in rechit_map
114  E = strip_it->second.energy();
115  } else E = 0;
116  vout_stripE.push_back(E);
117  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: E = " << E ;
118 
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 }
void findPi0Road(ESDetId strip, EcalPreshowerNavigator &theESNav, int plane, std::vector< ESDetId > &vout)
int i
Definition: DBlmapReader.cc:9
int strip() const
Definition: ESDetId.h:52
#define LogTrace(id)
bool goodPi0Strip(RecHitsMap::iterator candidate_it, ESDetId lastID)
int plane() const
Definition: ESDetId.h:46
float* EndcapPiZeroDiscriminatorAlgo::get_input_vector ( )
inline
float EndcapPiZeroDiscriminatorAlgo::GetBarrelNNOutput ( float  EB_Et)

Definition at line 601 of file EndcapPiZeroDiscriminatorAlgo.cc.

References barrelstart, EB_Hidden, EB_Indim, EB_Layers, EB_Outdim, getNNoutput(), Indim, input_var, Layers, LogTrace, and Outdim.

602 {
603 
605 
606  float nnout = -1;
607 // Print the NN input variables that are related to the ECAL Barrel
608 // ------------------------------------------------------------------------
609  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo::GetBarrelNNoutput :nn_invar_presh = " ;
610 
611  for(int k1=0;k1<Indim;k1++) {
612  LogTrace("EcalClusters") << input_var[k1] << " " ;
613 
614  }
615  LogTrace("EcalClusters") << " " ;
616 
617  // select the appropriate Weigth file
618  int sel_wfile;
619  if(EB_Et<25.0) {sel_wfile = 0;}
620  else if(EB_Et>=25.0 && EB_Et<35.0) {sel_wfile = 1;}
621  else if(EB_Et>=35.0 && EB_Et<45.0) {sel_wfile = 2;}
622  else if(EB_Et>=45.0 && EB_Et<55.0) {sel_wfile = 3;}
623  else {sel_wfile = 4;}
624  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: E_SC = " << EB_Et << " and I select Weight file Number = " << sel_wfile ;
625 
626  nnout = getNNoutput(sel_wfile); // calculate the nnoutput for the given ECAL object
627 
628  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout ;
629 
630  return nnout;
631 }
#define LogTrace(id)
float EndcapPiZeroDiscriminatorAlgo::getNNoutput ( int  sel_wfile)

Definition at line 304 of file EndcapPiZeroDiscriminatorAlgo.cc.

References Activation_fun(), barrelstart, EE_Hidden, EE_Indim, EE_Outdim, h, H_O_Weight_all, H_Thresh_all, Hidden, i, I_H_Weight_all, Indim, input_var, relval_2017::k, LogTrace, O_Thresh_all, and Outdim.

Referenced by GetBarrelNNOutput(), and GetNNOutput().

305 {
306  float* I_SUM;
307  float* OUT;
308  float nnout=0.0;
309  int mij;
310 
311  I_SUM = new float[Hidden];
312  OUT = new float[Outdim];
313 
314  for(int k=0;k<Hidden;k++) I_SUM[k]=0.0;
315  for(int k1=0;k1<Outdim;k1++) OUT[k1]=0.0;
316 
317  for (int h = 0; h<Hidden; h++){
318  mij = h - Hidden;
319  for (int i = 0; i<Indim; i++){
320  mij = mij + Hidden;
321  I_SUM[h] += I_H_Weight_all[mij+sel_wfile*Indim*Hidden + barrelstart*Nfiles_EE*EE_Indim*EE_Hidden] * input_var[i];
322  }
323  I_SUM[h] += H_Thresh_all[h+sel_wfile*Hidden + barrelstart*Nfiles_EE*EE_Hidden];
324  for (int o1 = 0; o1<Outdim; o1++) {
325  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]);
326 
327  }
328  }
329  for (int o2 = 0; o2<Outdim; o2++){
330  OUT[o2] += O_Thresh_all[barrelstart*Nfiles_EE*EE_Outdim + o2 + sel_wfile*Outdim];
331  }
332  nnout = Activation_fun(OUT[0]);
333  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: getNNoutput :: -> NNout = " << nnout ;
334 
335 
336  delete[] I_SUM;
337  delete[] OUT;
338  delete[] input_var;
339 
340  return (nnout);
341 }
int i
Definition: DBlmapReader.cc:9
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
#define LogTrace(id)
float EndcapPiZeroDiscriminatorAlgo::GetNNOutput ( float  EE_Et)

Definition at line 561 of file EndcapPiZeroDiscriminatorAlgo.cc.

References barrelstart, EE_Hidden, EE_Indim, EE_Layers, EE_Outdim, getNNoutput(), Indim, input_var, Layers, LogTrace, and Outdim.

562 {
564 
565  float nnout = -1;
566 // Print the NN input variables that are related to the Preshower + ECAL
567 // ------------------------------------------------------------------------
568  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo::GetNNoutput :nn_invar_presh = " ;
569 
570  for(int k1=0;k1<Indim;k1++) {
571  LogTrace("EcalClusters") << input_var[k1] << " " ;
572 
573  }
574  LogTrace("EcalClusters") << " " ;
575 
576  // select the appropriate Weigth file
577  int sel_wfile;
578  if(EE_Et<25.0) {sel_wfile = 0;}
579  else if(EE_Et>=25.0 && EE_Et<35.0) {sel_wfile = 1;}
580  else if(EE_Et>=35.0 && EE_Et<45.0) {sel_wfile = 2;}
581  else if(EE_Et>=45.0 && EE_Et<55.0) {sel_wfile = 3;}
582  else {sel_wfile = 4;}
583 
584  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Et_SC = " << EE_Et << " and I select Weight file Number = " << sel_wfile ;
585 
586 
587  nnout = getNNoutput(sel_wfile); // calculate the nnoutput for the given ECAL object
588 
589  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout ;
590 
591 
592  return nnout;
593 }
#define LogTrace(id)
bool EndcapPiZeroDiscriminatorAlgo::goodPi0Strip ( RecHitsMap::iterator  candidate_it,
ESDetId  lastID 
)

Definition at line 142 of file EndcapPiZeroDiscriminatorAlgo.cc.

References LogTrace, and preshStripEnergyCut_.

Referenced by findPreshVector().

143 {
144  RecHitsMap::iterator candidate_tmp = candidate_it;
145  candidate_tmp--;
146 
147  if (candidate_tmp->first == lastID )
148  LogTrace("EcalClusters") <<"EndcapPiZeroDiscriminatorAlgo: goodPi0Strip No such a strip in rechits_map " ;
149  if (candidate_it->second.energy() <= preshStripEnergyCut_)
150  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip Strip energy " << candidate_it->second.energy() <<" is below threshold " ;
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 }
#define LogTrace(id)
void EndcapPiZeroDiscriminatorAlgo::readWeightFile ( const char *  WFile)

Definition at line 238 of file EndcapPiZeroDiscriminatorAlgo.cc.

References assert(), H_O_Weight, H_Thresh, Hidden, I_H_Weight, Indim, inp_var, j, Layers, geometryCSVtoXML::line, LogTrace, O_Thresh, Outdim, and create_public_pileup_plots::weights.

238  {
239  FILE *weights;
240 
241  char *line;
242  line = new char[80];
243 
244  bool checkinit=false;
245 // Open the weights file, generated by jetnet, and read
246 // in the nodes and weights
247 //*******************************************************
248  weights = fopen(Weights_file, "r");
249  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: I opeded the Weights file = " << Weights_file ;
250 
251 
252  while( !feof(weights) ){
253  fscanf(weights, "%s", line);
254  if (line[0] == 'A') { //Read in ANN nodes: Layers, input , Hidden, Output
255  fscanf(weights, "%d", &Layers); // # of NN Layers used
256  fscanf(weights, "%d", &Indim); // # of Inputs actually used
257  fscanf(weights, "%d", &Hidden); // # of hidden nodes
258  fscanf(weights, "%d", &Outdim); // # of output nodes
259 
260  inp_var = Indim + 1;
261 
262  I_H_Weight = new float[Indim*Hidden];
263  H_Thresh = new float[Hidden];
264  H_O_Weight = new float[Hidden*Outdim];
265  O_Thresh = new float[Outdim];
266  checkinit=true;
267  }else if (line[0] == 'B') { // read in weights between hidden and intput nodes
268  assert(checkinit);
269  for (int i = 0; i<Indim; i++){
270  for (int j = 0; j<Hidden; j++){
271  fscanf(weights, "%f", &I_H_Weight[i*Hidden+j]);
272  }
273  }
274  }else if (line[0] == 'C'){ // Read in the thresholds for hidden nodes
275  assert(checkinit);
276  for (int i = 0; i<Hidden; i++){
277  fscanf(weights, "%f", &H_Thresh[i]);
278  }
279  }else if (line[0] == 'D'){ // read in weights between hidden and output nodes
280  assert(checkinit);
281  for (int i = 0; i<Hidden*Outdim; i++){
282  fscanf(weights, "%f", &H_O_Weight[i]);
283  }
284  }else if (line[0] == 'E'){ // read in the threshold for the output nodes
285  assert(checkinit);
286  for (int i = 0; i<Outdim; i++){
287  fscanf(weights, "%f", &O_Thresh[i]);
288 
289  }
290  }
291  else{edm::LogError("EEPi0Discrim")<< "EndcapPiZeroDiscriminatorAlgo: Not a Net file of Corrupted Net file " << endl;
292  }
293  }
294  fclose(weights);
295  delete[] line;
296 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)

Member Data Documentation

int EndcapPiZeroDiscriminatorAlgo::barrelstart
private

Definition at line 65 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput(), getNNoutput(), and GetNNOutput().

int EndcapPiZeroDiscriminatorAlgo::debugLevel_
private

Definition at line 62 of file EndcapPiZeroDiscriminatorAlgo.h.

int EndcapPiZeroDiscriminatorAlgo::EB_Hidden
private

Definition at line 72 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput().

int EndcapPiZeroDiscriminatorAlgo::EB_Indim
private
int EndcapPiZeroDiscriminatorAlgo::EB_Layers
private

Definition at line 72 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput().

int EndcapPiZeroDiscriminatorAlgo::EB_Outdim
private

Definition at line 72 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput().

int EndcapPiZeroDiscriminatorAlgo::EE_Hidden
private

Definition at line 71 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput(), and GetNNOutput().

int EndcapPiZeroDiscriminatorAlgo::EE_Indim
private
int EndcapPiZeroDiscriminatorAlgo::EE_Layers
private

Definition at line 71 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetNNOutput().

int EndcapPiZeroDiscriminatorAlgo::EE_Outdim
private

Definition at line 71 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput(), and GetNNOutput().

float* EndcapPiZeroDiscriminatorAlgo::H_O_Weight
private

Definition at line 75 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by readWeightFile().

std::vector<float> EndcapPiZeroDiscriminatorAlgo::H_O_Weight_all
private

Definition at line 80 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput().

float* EndcapPiZeroDiscriminatorAlgo::H_Thresh
private

Definition at line 76 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by readWeightFile().

std::vector<float> EndcapPiZeroDiscriminatorAlgo::H_Thresh_all
private

Definition at line 81 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput().

int EndcapPiZeroDiscriminatorAlgo::Hidden
private

Definition at line 70 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput(), and readWeightFile().

float* EndcapPiZeroDiscriminatorAlgo::I_H_Weight
private

Definition at line 74 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by readWeightFile().

std::vector<float> EndcapPiZeroDiscriminatorAlgo::I_H_Weight_all
private

Definition at line 79 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput().

int EndcapPiZeroDiscriminatorAlgo::Indim
private
int EndcapPiZeroDiscriminatorAlgo::inp_var
private

Definition at line 64 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by readWeightFile().

float* EndcapPiZeroDiscriminatorAlgo::input_var
private
int EndcapPiZeroDiscriminatorAlgo::Layers
private

Definition at line 70 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput(), GetNNOutput(), and readWeightFile().

int EndcapPiZeroDiscriminatorAlgo::Nfiles_EB
private

Definition at line 67 of file EndcapPiZeroDiscriminatorAlgo.h.

int EndcapPiZeroDiscriminatorAlgo::Nfiles_EE
private

Definition at line 68 of file EndcapPiZeroDiscriminatorAlgo.h.

float* EndcapPiZeroDiscriminatorAlgo::O_Thresh
private

Definition at line 77 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by readWeightFile().

std::vector<float> EndcapPiZeroDiscriminatorAlgo::O_Thresh_all
private

Definition at line 82 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput().

int EndcapPiZeroDiscriminatorAlgo::Outdim
private
std::string EndcapPiZeroDiscriminatorAlgo::pathToFiles_
private

Definition at line 92 of file EndcapPiZeroDiscriminatorAlgo.h.

int EndcapPiZeroDiscriminatorAlgo::preshSeededNstr_
private

Definition at line 61 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by findPi0Road().

double EndcapPiZeroDiscriminatorAlgo::preshStripEnergyCut_
private

Definition at line 56 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by goodPi0Strip().

RecHitsMap* EndcapPiZeroDiscriminatorAlgo::rechits_map
private

Definition at line 89 of file EndcapPiZeroDiscriminatorAlgo.h.