19 #include <Math/VectorUtil.h>
55 bool checkPos(std::vector<math::XYZPoint> CalPos,
math::XYZPoint CandPos) {
57 for (
unsigned int i = 0;
i < CalPos.size();
i++) {
58 if (CalPos[
i] == CandPos) {
69 double myECALenergy = 0.;
70 double myHCALenergy = 0.;
71 double myHCALenergy3x3 = 0.;
72 double myMaximumHCALPFClusterE = 0.;
73 double myMaximumHCALPFClusterEt = 0.;
74 double myStripClusterE = 0.;
75 double myEmfrac = -1.;
76 double myElectronPreIDOutput = -1111.;
77 bool myElecPreid =
false;
85 std::vector<PFCandidatePtr> myPFCands;
86 myPFCands.reserve(
tau.isolationPFCands().size() +
tau.signalPFCands().size());
88 std::copy(
tau.isolationPFCands().begin(),
tau.isolationPFCands().end(), std::back_inserter(myPFCands));
89 std::copy(
tau.signalPFCands().begin(),
tau.signalPFCands().end(), std::back_inserter(myPFCands));
93 myElectronPreIDOutput = myleadPFChargedCand->mva_e_pi();
95 math::XYZPointF myElecTrkEcalPos = myleadPFChargedCand->positionAtECALEntrance();
96 myElecTrk = myleadPFChargedCand->trackRef();
102 for (
int i = 0;
i < (
int)myPFCands.size();
i++) {
103 myHCALenergy += myPFCands[
i]->hcalEnergy();
104 myECALenergy += myPFCands[
i]->ecalEnergy();
107 if (myPFCands[
i]->particleId() == 1 || myPFCands[
i]->particleId() == 2)
108 candPos = myPFCands[
i]->positionAtECALEntrance();
115 double deltaPhiOverQ =
deltaPhi / (double)myElecTrk->charge();
120 myStripClusterE += myPFCands[
i]->ecalEnergy();
123 myHCALenergy3x3 += myPFCands[
i]->hcalEnergy();
125 if (myPFCands[
i]->hcalEnergy() > myMaximumHCALPFClusterE) {
126 myMaximumHCALPFClusterE = myPFCands[
i]->hcalEnergy();
128 if ((myPFCands[
i]->hcalEnergy() * fabs(
sin(candPos.Theta()))) > myMaximumHCALPFClusterEt) {
129 myMaximumHCALPFClusterEt = (myPFCands[
i]->hcalEnergy() * fabs(
sin(candPos.Theta())));
135 std::vector<math::XYZPoint> hcalPosV;
137 std::vector<math::XYZPoint> ecalPosV;
139 for (
int i = 0;
i < (
int)myPFCands.size();
i++) {
141 for (ElementsInBlocks::const_iterator it = elts.begin(); it != elts.end(); ++it) {
143 unsigned indexOfElementInBlock = it->second;
151 double en = (double)element.clusterRef()->energy();
152 double et = (double)element.clusterRef()->energy() * fabs(
sin(clusPos.Theta()));
153 if (en > myMaximumHCALPFClusterE) {
154 myMaximumHCALPFClusterE = en;
156 if (
et > myMaximumHCALPFClusterEt) {
157 myMaximumHCALPFClusterEt =
et;
159 if (!checkPos(hcalPosV, clusPos)) {
160 hcalPosV.push_back(clusPos);
164 myHCALenergy3x3 += en;
168 double en = (double)element.clusterRef()->energy();
170 if (!checkPos(ecalPosV, clusPos)) {
171 ecalPosV.push_back(clusPos);
175 double deltaPhiOverQ =
deltaPhi / (double)myElecTrk->charge();
179 myStripClusterE += en;
189 if ((myHCALenergy + myECALenergy) > 0.)
190 myEmfrac = myECALenergy / (myHCALenergy + myECALenergy);
191 tau.setemFraction((
float)myEmfrac);
195 float myElectronMomentum = (
float)myElecTrk->p();
196 if (myElectronMomentum > 0.) {
197 myHCALenergy /= myElectronMomentum;
198 myMaximumHCALPFClusterE /= myElectronMomentum;
199 myHCALenergy3x3 /= myElectronMomentum;
200 myStripClusterE /= myElectronMomentum;
203 tau.sethcalTotOverPLead((
float)myHCALenergy);
204 tau.sethcalMaxOverPLead((
float)myMaximumHCALPFClusterE);
205 tau.sethcal3x3OverPLead((
float)myHCALenergy3x3);
206 tau.setecalStripSumEOverPLead((
float)myStripClusterE);
207 tau.setmaximumHCALPFClusterEt(myMaximumHCALPFClusterEt);
208 tau.setelectronPreIDOutput(myElectronPreIDOutput);
210 tau.setelectronPreIDTrack(myElecTrk);
213 tau.setelectronPreIDDecision(myElecPreid);
225 "RecoTauElectronRejectionPlugin");