60 CaloJetRef myCaloJet=(*myCaloTauTagInfoRef).calojetRef();
61 const std::vector<CaloTowerPtr> myCaloTowers=(*myCaloJet).getCaloConstituents();
62 JetBaseRef jetRef = myCaloTauTagInfoRef->jetRef();
63 CaloTau myCaloTau(std::numeric_limits<int>::quiet_NaN(),jetRef->
p4());
72 double myCaloTau_refInnerPosition_x=0.;
73 double myCaloTau_refInnerPosition_y=0.;
74 double myCaloTau_refInnerPosition_z=0.;
76 myCaloTau.setleadTrack(myleadTk);
77 double myleadTkDZ=(*myleadTk).dz(myPV.
position());
81 GlobalVector myCaloJetdir((*myCaloJet).px(),(*myCaloJet).py(),(*myCaloJet).pz());
85 if((*myleadTk).innerOk()){
86 myCaloTau_refInnerPosition_x=(*myleadTk).innerPosition().
x();
87 myCaloTau_refInnerPosition_y=(*myleadTk).innerPosition().y();
88 myCaloTau_refInnerPosition_z=(*myleadTk).innerPosition().z();
93 if(mypropagleadTrackECALSurfContactPoint.R()!=0.){
94 double myleadTrackHCAL3x3hottesthitDEta=0.;
95 double myleadTrackHCAL3x3hottesthitEt=0.;
96 double myleadTrackHCAL3x3hitsEtSum=0.;
100 CaloTowerDetId mypropagleadTrack_closestCaloTowerId((*myCaloSubdetectorGeometry).getClosestCell(
GlobalPoint(mypropagleadTrackECALSurfContactPoint.x(),
101 mypropagleadTrackECALSurfContactPoint.y(),
102 mypropagleadTrackECALSurfContactPoint.z())));
103 std::vector<CaloTowerDetId> mypropagleadTrack_closestCaloTowerNeighbourIds=
getCaloTowerneighbourDetIds(myCaloSubdetectorGeometry,mypropagleadTrack_closestCaloTowerId);
104 for(std::vector<CaloTowerPtr>::const_iterator iCaloTower=myCaloTowers.begin();iCaloTower!=myCaloTowers.end();iCaloTower++){
106 bool CaloTower_inside3x3matrix=
false;
107 if (iCaloTowerId==mypropagleadTrack_closestCaloTowerId) CaloTower_inside3x3matrix=
true;
108 if (!CaloTower_inside3x3matrix){
109 for(std::vector<CaloTowerDetId>::const_iterator iCaloTowerDetId=mypropagleadTrack_closestCaloTowerNeighbourIds.begin();iCaloTowerDetId!=mypropagleadTrack_closestCaloTowerNeighbourIds.end();iCaloTowerDetId++){
110 if (iCaloTowerId==(*iCaloTowerDetId)){
111 CaloTower_inside3x3matrix=
true;
116 if (!CaloTower_inside3x3matrix)
continue;
117 myleadTrackHCAL3x3hitsEtSum+=(**iCaloTower).hadEt();
118 if((**iCaloTower).hadEt()>=myleadTrackHCAL3x3hottesthitEt ){
119 if ((**iCaloTower).hadEt()!=myleadTrackHCAL3x3hottesthitEt ||
120 ((**iCaloTower).hadEt()==myleadTrackHCAL3x3hottesthitEt && fabs((**iCaloTower).eta()-mypropagleadTrackECALSurfContactPoint.Eta())<myleadTrackHCAL3x3hottesthitDEta)) myleadTrackHCAL3x3hottesthitDEta = fabs((**iCaloTower).eta()-mypropagleadTrackECALSurfContactPoint.Eta());
121 myleadTrackHCAL3x3hottesthitEt=(**iCaloTower).hadEt();
124 myCaloTau.setleadTrackHCAL3x3hitsEtSum(myleadTrackHCAL3x3hitsEtSum);
125 if (myleadTrackHCAL3x3hottesthitEt!=0.) myCaloTau.setleadTrackHCAL3x3hottesthitDEta(myleadTrackHCAL3x3hottesthitDEta);
146 myCaloTau.setsignalTracks(mySignalTks);
150 if((
int)(mySignalTks.
size())!=0){
151 int mySignalTks_qsum=0;
152 for(
int i=0;
i<(int)mySignalTks.
size();
i++){
153 mySignalTks_qsum+=mySignalTks[
i]->charge();
155 mySignalTksInvariantMass+=mychargedpicand_fromTk_LorentzVect;
157 myCaloTau.setCharge(mySignalTks_qsum);
159 myCaloTau.setsignalTracksInvariantMass(mySignalTksInvariantMass.mass());
165 myCaloTau.setisolationTracks(myIsolTks);
168 float myIsolTks_Ptsum=0.;
169 for(
int i=0;
i<(int)myIsolTks.
size();
i++) myIsolTks_Ptsum+=myIsolTks[
i]->
pt();
170 myCaloTau.setisolationTracksPtSum(myIsolTks_Ptsum);
174 std::vector<std::pair<math::XYZPoint,float> > thePositionAndEnergyEcalRecHits;
186 double maxDeltaR = 0.8;
187 math::XYZPoint myCaloJetdir((*myCaloJet).px(),(*myCaloJet).py(),(*myCaloJet).pz());
193 if(ROOT::Math::VectorUtil::DeltaR(myCaloJetdir,theRecHitCell_XYZPoint) < maxDeltaR){
194 std::pair<math::XYZPoint,float> thePositionAndEnergyEcalRecHit(theRecHitCell_XYZPoint,theRecHit->energy());
195 thePositionAndEnergyEcalRecHits.push_back(thePositionAndEnergyEcalRecHit);
204 if(ROOT::Math::VectorUtil::DeltaR(myCaloJetdir,theRecHitCell_XYZPoint) < maxDeltaR){
205 std::pair<math::XYZPoint,float> thePositionAndEnergyEcalRecHit(theRecHitCell_XYZPoint,theRecHit->energy());
206 thePositionAndEnergyEcalRecHits.push_back(thePositionAndEnergyEcalRecHit);
214 if(ROOT::Math::VectorUtil::DeltaR(myCaloJetdir,theRecHitCell_XYZPoint) < maxDeltaR){
215 std::pair<math::XYZPoint,float> thePositionAndEnergyEcalRecHit(theRecHitCell_XYZPoint,theRecHit->energy());
216 thePositionAndEnergyEcalRecHits.push_back(thePositionAndEnergyEcalRecHit);
262 float myIsolEcalRecHits_EtSum=0.;
265 for(std::vector< std::pair<math::XYZPoint,float> >::const_iterator iEcalRecHit=myIsolPositionAndEnergyEcalRecHits.begin();iEcalRecHit!=myIsolPositionAndEnergyEcalRecHits.end();iEcalRecHit++){
266 myIsolEcalRecHits_EtSum+=(*iEcalRecHit).second*fabs(
sin((*iEcalRecHit).first.theta()));
268 myCaloTau.setisolationECALhitsEtSum(myIsolEcalRecHits_EtSum);
276 myTks_XYZTLorentzVect+=iChargedPionCand_XYZTLorentzVect;
277 alternatLorentzVect+=iChargedPionCand_XYZTLorentzVect;
279 myCaloTau.setTracksInvariantMass(myTks_XYZTLorentzVect.mass());
281 std::vector<BasicClusterRef> myneutralECALBasicClusters=(*myCaloTauTagInfoRef).neutralECALBasicClusters();
282 for(std::vector<BasicClusterRef>::const_iterator iBasicCluster=myneutralECALBasicClusters.begin();iBasicCluster!=myneutralECALBasicClusters.end();iBasicCluster++) {
284 double iGammaCand_px=(**iBasicCluster).energy()*
sin((**iBasicCluster).position().theta())*
cos((**iBasicCluster).position().phi());
285 double iGammaCand_py=(**iBasicCluster).energy()*
sin((**iBasicCluster).position().theta())*
sin((**iBasicCluster).position().phi());
286 double iGammaCand_pz=(**iBasicCluster).energy()*
cos((**iBasicCluster).position().theta());
287 math::XYZTLorentzVector iGammaCand_XYZTLorentzVect(iGammaCand_px,iGammaCand_py,iGammaCand_pz,(**iBasicCluster).energy());
288 alternatLorentzVect+=iGammaCand_XYZTLorentzVect;
290 myCaloTau.setalternatLorentzVect(alternatLorentzVect);
293 myCaloTau.setVertex(
math::XYZPoint(myCaloTau_refInnerPosition_x,myCaloTau_refInnerPosition_y,myCaloTau_refInnerPosition_z));
296 double mymaxEtHCALtower_Et=0.;
297 for(
unsigned int iTower=0;iTower<myCaloTowers.size();iTower++){
298 if((*myCaloTowers[iTower]).hadEt()>=mymaxEtHCALtower_Et) mymaxEtHCALtower_Et=(*myCaloTowers[iTower]).hadEt();
300 myCaloTau.setmaximumHCALhitEt(mymaxEtHCALtower_Et);
307 std::vector<CaloTowerDetId> myCaloTowerneighbourDetIds;
308 std::vector<DetId> northDetIds=myCaloTowerTopology.north(myCaloTowerDetId);
309 std::vector<DetId> westDetIds=myCaloTowerTopology.west(myCaloTowerDetId);
310 std::vector<DetId> northwestDetIds,southwestDetIds;
311 if (westDetIds.size()>0){
312 northwestDetIds=myCaloTowerTopology.north(westDetIds[0]);
313 southwestDetIds=myCaloTowerTopology.south(westDetIds[(
int)westDetIds.size()-1]);
315 std::vector<DetId> southDetIds=myCaloTowerTopology.south(myCaloTowerDetId);
316 std::vector<DetId> eastDetIds=myCaloTowerTopology.east(myCaloTowerDetId);
317 std::vector<DetId> northeastDetIds,southeastDetIds;
318 if (eastDetIds.size()>0){
319 northeastDetIds=myCaloTowerTopology.north(eastDetIds[0]);
320 southeastDetIds=myCaloTowerTopology.south(eastDetIds[(
int)eastDetIds.size()-1]);
322 std::vector<DetId> myneighbourDetIds=northDetIds;
323 myneighbourDetIds.insert(myneighbourDetIds.end(),westDetIds.begin(),westDetIds.end());
324 myneighbourDetIds.insert(myneighbourDetIds.end(),northwestDetIds.begin(),northwestDetIds.end());
325 myneighbourDetIds.insert(myneighbourDetIds.end(),southwestDetIds.begin(),southwestDetIds.end());
326 myneighbourDetIds.insert(myneighbourDetIds.end(),southDetIds.begin(),southDetIds.end());
327 myneighbourDetIds.insert(myneighbourDetIds.end(),eastDetIds.begin(),eastDetIds.end());
328 myneighbourDetIds.insert(myneighbourDetIds.end(),northeastDetIds.begin(),northeastDetIds.end());
329 myneighbourDetIds.insert(myneighbourDetIds.end(),southeastDetIds.begin(),southeastDetIds.end());
330 for(std::vector<DetId>::const_iterator iDetId=myneighbourDetIds.begin();iDetId!=myneighbourDetIds.end();iDetId++){
332 myCaloTowerneighbourDetIds.push_back(iCaloTowerId);
334 return myCaloTowerneighbourDetIds;
double computeConeSize(const TFormula &ConeSizeTFormula, double ConeSizeMin, double ConeSizeMax)
edm::InputTag ESRecHitsLabel_
T getParameter(std::string const &) const
std::vector< CaloTowerDetId > getCaloTowerneighbourDetIds(const CaloSubdetectorGeometry *, CaloTowerDetId)
double TrackerIsolConeSize_min_
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
std::vector< DetId > mySelectedDetId_
double TrackLeadTrack_maxDZ_
const reco::TrackRef leadTk(std::string matchingConeMetric, double matchingConeSize, double ptTrackMin) const
Sin< T >::type sin(const T &t)
edm::InputTag EERecHitsLabel_
std::vector< EcalRecHit >::const_iterator const_iterator
reco::TransientTrack build(const reco::Track *p) const
std::string TrackerSignalConeMetric_
double AreaMetric_recoElements_maxabsEta_
bool UseTrackLeadTrackDZconstraint_
double IsolationTrack_minPt_
edm::InputTag EBRecHitsLabel_
const_iterator end() const
Termination of iteration.
double MatchingConeSize_min_
double ECALSignalConeSize_max_
const Point & position() const
position
std::string ECALIsolConeSizeFormula_
const_iterator begin() const
Initialize an iterator over the RefVector.
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::string ECALSignalConeMetric_
double MatchingConeSize_max_
std::string TrackerSignalConeSizeFormula_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
bool isNonnull() const
Checks for non-null.
TFormula myTrackerIsolConeSizeTFormula
const reco::TrackRefVector tracksInCone(const math::XYZVector &coneAxis, const std::string coneMetric, const double coneSize, const double ptTrackMin) const
std::string ECALIsolConeMetric_
reco::CaloTau buildCaloTau(edm::Event &, const edm::EventSetup &, const reco::CaloTauTagInfoRef &, const reco::Vertex &)
std::string TrackerIsolConeMetric_
static const int SubdetId
Cos< T >::type cos(const T &t)
const MagneticField * MagneticField_
TFormula myTrackerSignalConeSizeTFormula
std::string TrackerIsolConeSizeFormula_
std::string ECALSignalConeSizeFormula_
double ECALIsolConeSize_max_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double ECALIsolConeSize_min_
double ECALSignalConeSize_min_
void setMagneticField(const MagneticField *)
std::string MatchingConeSizeFormula_
TFormula myECALSignalConeSizeTFormula
XYZPointD XYZPoint
point in space with cartesian internal representation
double TrackerSignalConeSize_max_
TFormula myECALIsolConeSizeTFormula
TFormula myMatchingConeSizeTFormula
const double chargedpi_mass_
std::vector< std::pair< math::XYZPoint, float > > EcalRecHitsInAnnulus(const math::XYZVector &coneAxis, const std::string innerconeMetric, const double innerconeSize, const std::string outerconeMetric, const double outerconeSize, const double EcalRecHit_minEt, const std::vector< std::pair< math::XYZPoint, float > > &myEcalRecHits) const
unsigned int IsolationTrack_minHits_
void setcaloTauTagInfoRef(const CaloTauTagInfoRef)
double TrackerIsolConeSize_max_
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
size_type size() const
Size of the RefVector.
std::string MatchingConeMetric_
double TrackerSignalConeSize_min_
const reco::TrackRefVector tracksInAnnulus(const math::XYZVector &coneAxis, const std::string innerconeMetric, const double innerconeSize, const std::string outerconeMetric, const double outerconeSize, const double ptTrackMin) const
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
Power< A, B >::type pow(const A &a, const B &b)
const TransientTrackBuilder * TransientTrackBuilder_
void setTransientTrackBuilder(const TransientTrackBuilder *)