46 preshClusterShapeCollectionX_ = ps.
getParameter<std::string>(
"preshClusterShapeCollectionX");
47 preshClusterShapeCollectionY_ = ps.
getParameter<std::string>(
"preshClusterShapeCollectionY");
48 preshClusterShapeProducer_ = ps.
getParameter<std::string>(
"preshClusterShapeProducer");
50 photonCorrCollectionProducer_ = ps.
getParameter<
string>(
"corrPhoProducer");
51 correctedPhotonCollection_ = ps.
getParameter<
string>(
"correctedPhotonCollection");
60 preshStripECut_ = ps.
getParameter<
double>(
"preshStripEnergyCut");
64 PhotonPi0DiscriminatorAssociationMap_ = ps.
getParameter<
string>(
"Pi0Association");
66 string debugString = ps.
getParameter<
string>(
"debugLevel");
68 if (debugString ==
"DEBUG") debugL_pi0 = pDEBUG;
69 else if (debugString ==
"INFO") debugL_pi0 = pINFO;
70 else debugL_pi0 = pERROR;
72 string tmpPath = ps.
getUntrackedParameter<
string>(
"pathToWeightFiles",
"RecoEcal/EgammaClusterProducers/data/");
76 produces< PhotonPi0DiscriminatorAssociationMap >(PhotonPi0DiscriminatorAssociationMap_);
85 delete presh_pi0_algo;
93 if ( debugL_pi0 <= pDEBUG )
94 cout <<
"\n PiZeroDiscriminatorProducer: ....... Event " << evt.
id() <<
" with Number = " << nEvt_+1
95 <<
" is analyzing ....... " << endl << endl;
99 evt.
getByLabel(preshClusterShapeProducer_, preshClusterShapeCollectionX_, pPreshowerShapeClustersX);
101 if ( debugL_pi0 <= pDEBUG ) {
102 cout <<
"\n PiZeroDiscriminatorProducer: pPreshowerShapeClustersX->size() = " << clustersX->size() << endl;
106 evt.
getByLabel(preshClusterShapeProducer_, preshClusterShapeCollectionY_, pPreshowerShapeClustersY);
108 if ( debugL_pi0 <= pDEBUG ) {
109 cout <<
"\n PiZeroDiscriminatorProducer: pPreshowerShapeClustersY->size() = " << clustersY->size() << endl;
114 evt.
getByLabel( barrelRecHitCollection_, pEBRecHits );
118 evt.
getByLabel( endcapRecHitCollection_, pEERecHits );
131 evt.
getByLabel(photonCorrCollectionProducer_, correctedPhotonCollection_ , correctedPhotonHandle);
133 if ( debugL_pi0 <= pDEBUG ) {
134 cout <<
" PiZeroDiscriminatorProducer: Photon Collection size : " << corrPhoCollection.size() << endl;
137 for( PhotonCollection::const_iterator iPho = corrPhoCollection.begin(); iPho != corrPhoCollection.end(); iPho++) {
139 float Phot_En = iPho->energy();
140 float Phot_Et = Phot_En*
sin(2*atan(
exp(-iPho->eta())));
141 float Phot_eta = iPho->eta();
142 float Phot_phi = iPho->phi();
143 float Phot_R9 = iPho->r9();
145 if ( debugL_pi0 <= pDEBUG ) {
146 cout <<
" PiZeroDiscriminatorProducer: Photon index : " << iPho - corrPhoCollection.begin()
147 <<
" with Energy = " << Phot_En
148 <<
" Et = " << Phot_Et
149 <<
" ETA = " << Phot_eta
150 <<
" PHI = " << Phot_phi
151 <<
" R9 = " << Phot_R9 << endl;
155 float SC_En = it_super->energy();
156 float SC_Et = SC_En*
sin(2*atan(
exp(-it_super->eta())));
157 float SC_eta = it_super->eta();
158 float SC_phi = it_super->phi();
160 if ( debugL_pi0 <= pDEBUG ) {
161 cout <<
" PiZeroDiscriminatorProducer: superE = " << SC_En
162 <<
" superEt = " << SC_Et
163 <<
" superETA = " << SC_eta
164 <<
" superPHI = " << SC_phi << endl;
174 float nnoutput = -1.;
175 if(fabs(SC_eta) >= 1.65 && fabs(SC_eta) <= 2.5) {
176 const GlobalPoint pointSC(it_super->x(),it_super->y(),it_super->z());
177 if ( debugL_pi0 <= pDEBUG )
cout <<
"SC centroind = " << pointSC << endl;
178 double SC_seed_energy = it_super->seed()->energy();
188 if ( debugL_pi0 <= pDEBUG ) {
189 cout <<
"PiZeroDiscriminatorProducer: ( SeedBC_energy, E1, E3x3, E5x5) = "
190 << SC_seed_energy <<
" "
191 << SC_seed_Shape_E1 <<
" "
192 << SC_seed_Shape_E3x3 <<
" "
193 << SC_seed_Shape_E5x5 << endl;
197 vector<float> vout_stripE1;
198 vector<float> vout_stripE2;
199 for(reco::PreshowerClusterShapeCollection::const_iterator esClus = clustersX->begin();
200 esClus !=clustersX->end(); esClus++) {
202 float dR =
sqrt((SC_eta-sc_ref->eta())*(SC_eta-sc_ref->eta()) +
203 (SC_phi-sc_ref->phi())*(SC_phi-sc_ref->phi()));
206 vout_stripE1 = esClus->getStripEnergies();
210 for(reco::PreshowerClusterShapeCollection::const_iterator esClus = clustersY->begin();
211 esClus !=clustersY->end(); esClus++) {
213 float dR =
sqrt((SC_eta-sc_ref->eta())*(SC_eta-sc_ref->eta()) +
214 (SC_phi-sc_ref->phi())*(SC_phi-sc_ref->phi()));
217 vout_stripE2 = esClus->getStripEnergies();
222 if(vout_stripE1.size() == 0 || vout_stripE2.size() == 0 ) {
223 if ( debugL_pi0 <= pDEBUG )
224 cout <<
" PiZeroDiscriminatorProducer: Attention!!!!! Not Valid ES NN input Variables Return NNout = -1" << endl;
225 Pi0Assocs_p->insert(
Ref<PhotonCollection>(correctedPhotonHandle,iPho - corrPhoCollection.begin()), nnoutput);
229 if ( debugL_pi0 <= pDEBUG ) {
230 cout <<
"PiZeroDiscriminatorProducer : vout_stripE1.size = " << vout_stripE1.size()
231 <<
" vout_stripE2.size = " << vout_stripE2.size() << endl;
232 cout <<
"PiZeroDiscriminatorProducer : ES_input_vector = " ;
233 for(
int k1=0;k1<11;k1++) {
234 cout << vout_stripE1[k1] <<
" " ;
236 for(
int k1=0;k1<11;k1++) {
237 cout << vout_stripE2[k1] <<
" " ;
242 bool valid_NNinput = presh_pi0_algo->calculateNNInputVariables(vout_stripE1, vout_stripE2,
243 SC_seed_Shape_E1, SC_seed_Shape_E3x3, SC_seed_Shape_E5x5, EScorr_);
246 if ( debugL_pi0 <= pDEBUG )
247 cout <<
" PiZeroDiscriminatorProducer: Attention!!!!! Not Valid ES NN input Variables Return NNout = -1" << endl;
248 Pi0Assocs_p->insert(
Ref<PhotonCollection>(correctedPhotonHandle,iPho - corrPhoCollection.begin()), nnoutput);
252 float* nn_input_var = presh_pi0_algo->get_input_vector();
254 if ( debugL_pi0 <= pDEBUG ) {
255 cout <<
" PiZeroDiscriminatorProducer: NN_ESEndcap_input_vector+Et+Eta+Phi+R9 = " ;
256 for(
int k1=0;k1<25;k1++) {
257 cout << nn_input_var[k1] <<
" " ;
259 cout << SC_Et <<
" " << SC_eta <<
" " << SC_phi <<
" " << Phot_R9 << endl;
262 nnoutput = presh_pi0_algo->GetNNOutput(SC_Et);
264 if ( debugL_pi0 <= pDEBUG ) {
265 cout <<
" PiZeroDiscriminatorProducer: Event : " << evt.
id()
266 <<
" SC id = " << iPho - corrPhoCollection.begin()
267 <<
" with Pt = " << SC_Et
268 <<
" eta = " << SC_eta
269 <<
" phi = " << SC_phi
270 <<
" contains: " << it_super->clustersSize() <<
" BCs "
271 <<
" has NNout = " << nnoutput << endl;
274 Pi0Assocs_p->insert(
Ref<PhotonCollection>(correctedPhotonHandle,iPho - corrPhoCollection.begin()), nnoutput);
276 }
else if((fabs(SC_eta) <= 1.4442) || (fabs(SC_eta) < 1.65 && fabs(SC_eta) >= 1.566) || fabs(SC_eta) >= 2.5) {
287 double SC_seed_Shape_cEE = vCov[0];
288 double SC_seed_Shape_cEP = vCov[1];
289 double SC_seed_Shape_cPP = vCov[2];
294 double SC_seed_Shape_E3x2r = 0.0;
300 double DA = SC_seed_Shape_E2x2 - SC_seed_Shape_E2 - SC_seed_Shape_E1;
302 if(SC_seed_Shape_E2==SC_seed_Shape_ETop || SC_seed_Shape_E2==SC_seed_Shape_EBottom) {
303 if( SC_seed_Shape_ELeft > SC_seed_Shape_ERight ) {
304 SC_seed_Shape_E3x2r = (DA - SC_seed_Shape_ELeft)/(0.25+SC_seed_Shape_ELeft);
306 SC_seed_Shape_E3x2r = (DA - SC_seed_Shape_ERight)/(0.25+SC_seed_Shape_ERight);
309 }
else if(SC_seed_Shape_E2==SC_seed_Shape_ELeft || SC_seed_Shape_E2==SC_seed_Shape_ERight) {
311 if( SC_seed_Shape_ETop > SC_seed_Shape_EBottom ) {
312 SC_seed_Shape_E3x2r = (DA - SC_seed_Shape_ETop)/(0.25+SC_seed_Shape_ETop);
314 SC_seed_Shape_E3x2r = (DA - SC_seed_Shape_EBottom)/(0.25+SC_seed_Shape_EBottom);
323 if ( debugL_pi0 <= pDEBUG ) {
324 cout <<
"PiZeroDiscriminatorProduce: lazyTool (E1,E3x3,E5x5,E2,cEE,cEP,cPP,E2x2,E3x2_E3x2r,Xcog,Ycog,E2x5Bottom,E2x5Top,Et,Eta,PhiR9) = ( "
325 << SC_seed_Shape_E1 <<
" "
326 << SC_seed_Shape_E3x3 <<
" "
327 << SC_seed_Shape_E5x5 <<
" "
328 << SC_seed_Shape_E2 <<
" "
329 << SC_seed_Shape_cEE <<
" "
330 << SC_seed_Shape_cEP <<
" "
331 << SC_seed_Shape_cPP <<
" "
332 << SC_seed_Shape_E2x2 <<
" "
333 << SC_seed_Shape_E3x2 <<
" "
334 << SC_seed_Shape_E3x2r <<
" "
335 << SC_seed_Shape_xcog <<
" "
336 << SC_seed_Shape_ycog <<
" "
342 << Phot_R9 <<
" )" << endl;
345 float SC_et = it_super->energy()*
sin(2*atan(
exp(-it_super->eta())));
347 presh_pi0_algo->calculateBarrelNNInputVariables(SC_et, SC_seed_Shape_E1, SC_seed_Shape_E3x3,
348 SC_seed_Shape_E5x5, SC_seed_Shape_E2,
349 SC_seed_Shape_cEE, SC_seed_Shape_cEP,
350 SC_seed_Shape_cPP, SC_seed_Shape_E2x2,
351 SC_seed_Shape_E3x2, SC_seed_Shape_E3x2r,
352 SC_seed_Shape_xcog, SC_seed_Shape_ycog);
354 float* nn_input_var = presh_pi0_algo->get_input_vector();
356 if ( debugL_pi0 <= pDEBUG ) {
357 cout <<
" PiZeroDiscriminatorProducer : NN_barrel_nonESEndcap_variables+Et+Eta+Phi+R9 = " ;
358 for(
int k3=0;k3<12;k3++) {
359 cout << nn_input_var[k3] <<
" " ;
361 cout << SC_Et <<
" " << SC_eta <<
" " << SC_phi <<
" " << Phot_R9 << endl;
365 nnoutput = presh_pi0_algo->GetBarrelNNOutput(SC_et);
368 if ( debugL_pi0 <= pDEBUG ) {
369 cout <<
"PiZeroDiscriminatorProducer : Event : " << evt.
id()
370 <<
" SC id = " << iPho - corrPhoCollection.begin()
371 <<
" with Pt = " << SC_Et
372 <<
" eta = " << SC_eta
373 <<
" phi = " << SC_phi
374 <<
" contains: " << it_super->clustersSize() <<
" BCs "
375 <<
" has NNout = " << nnoutput
379 Pi0Assocs_p->insert(
Ref<PhotonCollection>(correctedPhotonHandle,iPho - corrPhoCollection.begin()), nnoutput);
380 }
else { Pi0Assocs_p->insert(
Ref<PhotonCollection>(correctedPhotonHandle,iPho - corrPhoCollection.begin()), -1.);}
383 evt.
put(Pi0Assocs_p,PhotonPi0DiscriminatorAssociationMap_);
384 if ( debugL_pi0 <= pDEBUG )
cout <<
"PiZeroDiscriminatorProducer: PhotonPi0DiscriminatorAssociationMap added to the event" << endl;
388 LogDebug(
"PiZeroDiscriminatorDebug") << ostr.str();
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
Sin< T >::type sin(const T &t)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
std::vector< PreshowerClusterShape > PreshowerClusterShapeCollection
collection of PreshowerClusterShape objects
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
T const * product() const
std::vector< Photon > PhotonCollection
collectin of Photon objects
T const * product() const
ESHandle< TrackerGeometry > geometry
PiZeroDiscriminatorProducer(const edm::ParameterSet &ps)
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
~PiZeroDiscriminatorProducer()