15 preshStripEnergyCut_(stripEnergyCut), preshSeededNstr_(nStripCut), debugLevel_(
debugLevel), pathToFiles_(path)
21 string file_pt[5] = {
"20",
"30",
"40",
"50",
"60"};
22 string file_barrel_pt[5] = {
"20",
"30",
"40",
"50",
"60"};
24 string nn_paterns_file =
"";
25 for(
int j=0;
j<Nfiles_EE;
j++) {
26 nn_paterns_file =
"endcapPiZeroDiscriminatorWeights_et"+file_pt[
j]+
".wts";
28 readWeightFile(WFile.fullPath().c_str());
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]);
41 for(
int k=0;
k<Nfiles_EB;
k++) {
42 nn_paterns_file =
"barrelPiZeroDiscriminatorWeights_et"+file_barrel_pt[
k]+
".wts";
44 readWeightFile(WFile.fullPath().c_str());
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]);
66 vector<float> vout_stripE;
69 if ( rechits_map->size() == 0 ) {
70 edm::LogWarning(
"EndcapPiZeroDiscriminatorAlgo") <<
"RecHitsMap has size 0.";
76 vector<ESDetId> road_2d;
79 int plane = strip.
plane();
82 cout <<
"EndcapPiZeroDiscriminatorAlgo: findPreshVectors: Preshower Seeded Algorithm - looking for clusters" <<
"n"
83 <<
"findPreshVectors: Preshower is intersected at strip " << strip.
strip() <<
", at plane " << plane << endl;
87 for(
int i=0;i<11;i++) {
88 vout_stripE.push_back(-100.);
93 road_2d.push_back(strip);
100 if (
debugLevel_ <=
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo:findPreshVectors: Total number of strips in the central road: " << road_2d.size() << endl;
103 RecHitsMap::iterator final_strip = rechits_map->end();
107 ESDetId last_stripID = final_strip->first;
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);
115 E = strip_it->second.energy();
117 vout_stripE.push_back(E);
118 if (
debugLevel_ ==
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: findPreshVectors: E = " << E << endl;
124 vector<float> vout_ElevenStrips_Energy;
125 for(
int i=0;i<11;i++)
127 vout_ElevenStrips_Energy.push_back(0.);
130 for(
unsigned int i=0;i<vout_stripE.size();i++)
132 vout_ElevenStrips_Energy[
i] = vout_stripE.at(i);
136 return vout_ElevenStrips_Energy;
144 RecHitsMap::iterator candidate_tmp = candidate_it;
147 if (candidate_tmp->first == lastID )
148 cout <<
"EndcapPiZeroDiscriminatorAlgo: goodPi0Strip No such a strip in rechits_map " << endl;
150 cout <<
"EndcapPiZeroDiscriminatorAlgo: goodPi0Strip Strip energy " << candidate_it->second.energy() <<
" is below threshold " << endl;
153 if ( (candidate_tmp->first == lastID ) ||
164 int plane, vector<ESDetId>& vout) {
165 if ( strip ==
ESDetId(0) )
return;
169 if (
debugLevel_ <=
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: starts from strip " << strip << endl;
173 if (
debugLevel_ ==
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the East " << endl;
175 if (
debugLevel_ ==
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: East: " << n_east <<
" current strip is " << next << endl;
176 vout.push_back(next);
182 if (
debugLevel_ ==
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the West " << endl;
185 if (
debugLevel_ ==
pDEBUG )
cout <<
"findPi0Road: West: " << n_west <<
" current strip is " << next << endl;
186 vout.push_back(next);
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;
192 else if (plane == 2) {
195 if (
debugLevel_ ==
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the North " << endl;
197 if (
debugLevel_ ==
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: North: " << n_north <<
" current strip is " << next << endl;
198 vout.push_back(next);
204 if (
debugLevel_ ==
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the South " << endl;
207 if (
debugLevel_ ==
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: South: " << n_south <<
" current strip is " << next << endl;
208 vout.push_back(next);
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;
215 if (
debugLevel_ ==
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: findPi0Road: Wrong plane number, null cluster will be returned! " << endl;
233 bool checkinit=
false;
237 weights = fopen(Weights_file,
"r");
238 if (
debugLevel_ <=
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: I opeded the Weights file = " << Weights_file << endl;
240 while( !feof(weights) ){
241 fscanf(weights,
"%s", line);
242 if (line[0] ==
'A') {
243 fscanf(weights,
"%d", &
Layers);
244 fscanf(weights,
"%d", &
Indim);
245 fscanf(weights,
"%d", &Hidden);
246 fscanf(weights,
"%d", &
Outdim);
255 }
else if (line[0] ==
'B') {
257 for (
int i = 0; i<
Indim; i++){
262 }
else if (line[0] ==
'C'){
264 for (
int i = 0; i<
Hidden; i++){
265 fscanf(weights,
"%f", &
H_Thresh[i]);
267 }
else if (line[0] ==
'D'){
269 for (
int i = 0; i<Hidden*
Outdim; i++){
272 }
else if (line[0] ==
'E'){
274 for (
int i = 0; i<
Outdim; i++){
275 fscanf(weights,
"%f", &
O_Thresh[i]);
279 else{
cout <<
"EndcapPiZeroDiscriminatorAlgo: Not a Net file of Corrupted Net file " << endl;
298 I_SUM =
new float[
Hidden];
302 for(
int k1=0;k1<
Outdim;k1++) OUT[k1]=0.0;
306 for (
int i = 0; i<
Indim; i++){
311 for (
int o1 = 0; o1<
Outdim; o1++) {
316 for (
int o2 = 0; o2<
Outdim; o2++){
321 if (
debugLevel_ <=
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: getNNoutput :: -> NNout = " << nnout << endl;
332 return( 1.0 / ( 1.0 +
exp(-2.0*SUM) ) );
346 float pS1_max,
float pS9_max,
float pS25_max,
int EScorr)
350 bool valid_NNinput =
true;
353 cout <<
"EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in X plane = ( ";
354 for(
int i = 0; i<11;i++) {
355 cout <<
" " << vph1[
i];
358 cout <<
"EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in Y plane = ( ";
359 for(
int i = 0; i<11;i++) {
360 cout <<
" " << vph2[
i];
365 for(
int k = 0;
k<11;
k++) {
368 cout <<
"EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " <<
k <<
" of X plane Do not exists" << endl;
374 cout <<
"EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " <<
k <<
" of Y plane Do not exists" << endl;
380 cout <<
"EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in X plane = ( ";
381 for(
int i = 0; i<11;i++) {
382 cout <<
" " << vph1[
i];
385 cout <<
"EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in Y plane = ( ";
386 for(
int i = 0; i<11;i++) {
387 cout <<
" " << vph2[
i];
395 for(
int kk=0;kk<11;kk++){
397 input_var[kk + 11] = fabs(vph2[kk]/0.02);
435 for(
int kk1=0;kk1<22;kk1++){
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;
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;
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;
456 valid_NNinput =
false;
461 cout <<
" valid_NNinput = " << valid_NNinput << endl; }
462 return valid_NNinput;
474 double m2,
double cee,
double cep,
double cpp,
475 double s4,
double s6,
double ratio,
476 double xcog,
double ycog)
480 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;
557 if (
debugLevel_ <=
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo::GetNNoutput :nn_invar_presh = " ;
558 for(
int k1=0;k1<
Indim;k1++) {
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;}
572 cout <<
"EndcapPiZeroDiscriminatorAlgo: Et_SC = " << EE_Et <<
" and I select Weight file Number = " << sel_wfile << endl;
576 if (
debugLevel_ <=
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout << endl;
594 if (
debugLevel_ <=
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo::GetBarrelNNoutput :nn_invar_presh = " ;
595 for(
int k1=0;k1<
Indim;k1++) {
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;}
609 cout <<
"EndcapPiZeroDiscriminatorAlgo: E_SC = " << EB_Et <<
" and I select Weight file Number = " << sel_wfile << endl;
613 if (
debugLevel_ <=
pDEBUG )
cout <<
"EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout << endl;
void findPi0Road(ESDetId strip, EcalPreshowerNavigator &theESNav, int plane, std::vector< ESDetId > &vout)
float GetNNOutput(float EE_Et)
void setHome(const T &startingPoint)
set the starting position
void home() const
move the navigator back to the starting point
virtual T west() const
move the navigator west
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)
float Activation_fun(float SUM)
std::vector< float > O_Thresh_all
std::map< DetId, EcalRecHit > RecHitsMap
Exp< T >::type exp(const T &t)
EndcapPiZeroDiscriminatorAlgo()
virtual T north() const
move the navigator north
double preshStripEnergyCut_
virtual T east() const
move the navigator east
std::vector< float > findPreshVector(ESDetId strip, RecHitsMap *rechits_map, CaloSubdetectorTopology *topology_p)
float getNNoutput(int sel_wfile)
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
void readWeightFile(const char *WFile)
bool calculateNNInputVariables(std::vector< float > &vph1, std::vector< float > &vph2, float pS1_max, float pS9_max, float pS25_max, int EScorr)
virtual T south() const
move the navigator south
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