CMS 3D CMS Logo

L2TauIsolationAlgs.cc

Go to the documentation of this file.
00001 #include "RecoTauTag/HLTProducers/interface/L2TauIsolationAlgs.h"
00002 #include "Math/GenVector/VectorUtil.h"
00003 
00004 #include <cmath>
00005 #include <cstdio>
00006 
00007 //Class Implementation: L2TauECALCluster
00008 
00009 using namespace reco;
00010 
00011 L2TauECALCluster::L2TauECALCluster()
00012 {
00013   p4_ = math::PtEtaPhiELorentzVector();
00014   m_ncrystals=0;
00015 }
00016 
00017 L2TauECALCluster::L2TauECALCluster(const math::PtEtaPhiELorentzVector& c)
00018 {
00019   m_ncrystals=0;
00020   p4_ = math::PtEtaPhiELorentzVector();
00021   addCrystal(c);
00022 }
00023 
00024 
00025 
00026 L2TauECALCluster::~L2TauECALCluster()
00027 {}
00028 
00029 
00030 int
00031 L2TauECALCluster::nCrystals() const
00032 {return m_ncrystals;}
00033 
00034 math::PtEtaPhiELorentzVector
00035 L2TauECALCluster::p4() const
00036 {return p4_;}
00037 
00038 
00039 void 
00040 L2TauECALCluster::addCrystal(const math::PtEtaPhiELorentzVector& crystal)
00041 {
00042   p4_+=crystal;
00043 }
00044 
00045 
00046 //Class Implementation: ECAL Clustering
00047 
00048 
00049 L2TauECALClustering::L2TauECALClustering()
00050 {
00051   m_clusterRadius=0.08;
00052 }
00053 
00054 L2TauECALClustering::L2TauECALClustering(double radius)
00055 {
00056   m_clusterRadius=radius;
00057 }
00058 
00059 L2TauECALClustering::~L2TauECALClustering()
00060 {}
00061 
00062 void
00063 L2TauECALClustering::run(const math::PtEtaPhiELorentzVectorCollection& hits,const CaloJet& jet,L2TauIsolationInfo& l2info)
00064 {
00065   //Create Clusters
00066   clusterize(hits);
00067 
00068 
00069   //Fill info Class
00070   std::vector<double> rms  = clusterSeperation(jet);
00071   l2info.ECALClusterNClusters=m_clusters.size();
00072   l2info.ECALClusterEtaRMS=rms[0];
00073   l2info.ECALClusterPhiRMS=rms[1];
00074   l2info.ECALClusterDRRMS=rms[2];
00075 }
00076 
00077 void 
00078 L2TauECALClustering::clusterize(const math::PtEtaPhiELorentzVectorCollection& myRecHits)
00079 {
00080    //If we have Hits do Clustering
00081    if(myRecHits.size()>0)
00082      {
00083        //Create the first Cluster by maximum Crystal
00084        m_clusters.push_back(L2TauECALCluster(*(myRecHits.begin())));
00085 
00086        //Loop on The Clusters if there are at least two hits
00087        if(myRecHits.size()>=2)
00088        for(math::PtEtaPhiELorentzVectorCollection::const_iterator h = myRecHits.begin()+1;h!=myRecHits.end();++h)
00089        {
00090           //These vars are used to find the nearest clusters to this hits
00091           double dR_min=100;  
00092           int ptr=0;
00093           int ptr_min=-1;
00094          
00095           for(L2TauECALClusterIt j=m_clusters.begin()+1;j!=m_clusters.end();j++)
00096           {
00097              if(ROOT::Math::VectorUtil::DeltaR(*h,j->p4())<m_clusterRadius)
00098                 {
00099                   if(ROOT::Math::VectorUtil::DeltaR(*h,j->p4())<dR_min)
00100                     {
00101                       dR_min=ROOT::Math::VectorUtil::DeltaR(*h,j->p4());
00102                           ptr_min=ptr;
00103                     }
00104                 }
00105                   ptr++;
00106           }
00107              
00108           //If it does not belong to cluster add a new one else add the Crystal to the Cluster
00109           if(ptr_min==-1)
00110             m_clusters.push_back(L2TauECALCluster(*h));
00111           else
00112             m_clusters[ptr_min].addCrystal(*h);
00113 
00114        }
00115               
00116      }
00117 
00118 }
00119 
00120 
00121 std::vector<double> 
00122 L2TauECALClustering::clusterSeperation(const CaloJet& jet) const
00123 {
00124   double eta_rms=0.;
00125   double phi_rms=0.;
00126   double dr_rms=0.;
00127 
00128   double sumpt = 0.;
00129 
00130   std::vector<double> rmsVector; //declare the vector
00131   if(m_clusters.size()>0)
00132     {
00133       for(L2TauECALClusterIt c = m_clusters.begin();c!=m_clusters.end();++c) //loop on clusters
00134         {
00135           eta_rms+=c->p4().Pt()*pow(c->p4().Eta()-jet.eta(),2);
00136           phi_rms+=c->p4().Pt()*pow(ROOT::Math::VectorUtil::DeltaPhi(c->p4(),jet.p4().Vect()),2);
00137           dr_rms+=c->p4().Pt()*pow(ROOT::Math::VectorUtil::DeltaR(c->p4(),jet.p4().Vect()),2);
00138           sumpt+=c->p4().Pt();                     
00139         }
00140     }
00141   else
00142     {
00143       eta_rms=0.;
00144       phi_rms=0.;
00145       dr_rms =0.;
00146       sumpt=1.;
00147     }
00148 
00149   rmsVector.push_back(eta_rms/sumpt);
00150   rmsVector.push_back(phi_rms/sumpt);
00151   rmsVector.push_back(dr_rms/sumpt);
00152 
00153   return rmsVector;
00154 }
00155 
00156 
00157 //CLASS IMPLEMENTATION ----------------ECAL Isolation-------------------------
00158 
00159 L2TauECALIsolation::L2TauECALIsolation()
00160 {
00161    m_innerCone=0.15;
00162    m_outerCone=0.50;
00163 }
00164 
00165 L2TauECALIsolation::L2TauECALIsolation(double inner_cone,double outer_cone)
00166 {
00167    m_innerCone=inner_cone;
00168    m_outerCone=outer_cone;
00169 }
00170 
00171 
00172 
00173 L2TauECALIsolation::~L2TauECALIsolation()
00174 {
00175 
00176 }
00177 
00178 void 
00179 L2TauECALIsolation::run(const  math::PtEtaPhiELorentzVectorCollection& hits,const CaloJet& jet,L2TauIsolationInfo& l2info)
00180 {
00181   //Calculate Isolation Energy
00182   double etIsol = isolatedEt(hits,jet);
00183   
00184   
00185   //Fill Trigger Info Class
00186   l2info.ECALIsolConeCut = etIsol; 
00187 
00188 
00189  }
00190 
00191 double 
00192 L2TauECALIsolation::isolatedEt(const math::PtEtaPhiELorentzVectorCollection& hits,const CaloJet& jet) const
00193 {
00194   //Compute the Isolation
00195   
00196 
00197   double eRMax = 0.;
00198   double eRMin = 0;
00199 
00200   for (math::PtEtaPhiELorentzVectorCollection::const_iterator mRH = hits.begin();mRH!=hits.end();++mRH)
00201     {
00202           double delta = ROOT::Math::VectorUtil::DeltaR(jet.p4().Vect(),(*mRH));
00203           if(delta <m_outerCone)
00204             eRMax+= mRH->pt();
00205           if(delta <m_innerCone)
00206             eRMin+= mRH->pt();
00207     }
00208 
00209   double etIsol = eRMax - eRMin;
00210 
00211 
00212   return etIsol;
00213 
00214 }
00215 
00216 
00217 //CLASS IMPLEMENTATION --------------------L2TauTowerIsolation
00218 
00219 
00220 L2TauTowerIsolation::L2TauTowerIsolation()
00221 {
00222    m_innerCone=0.20;
00223    m_outerCone=0.50;
00224 
00225 
00226 
00227 
00228 }
00229 
00230 L2TauTowerIsolation::L2TauTowerIsolation(double inner_cone,double outer_cone)
00231 {
00232    m_innerCone=inner_cone;
00233    m_outerCone=outer_cone;
00234 
00235   
00236 
00237 
00238 }
00239 
00240 
00241 L2TauTowerIsolation::~L2TauTowerIsolation()
00242 {
00243 
00244 }
00245 
00246 
00247 
00248 void 
00249 L2TauTowerIsolation::run(const CaloJet& jet,const math::PtEtaPhiELorentzVectorCollection& towers,L2TauIsolationInfo& l2info)
00250 {
00251   //Calculate Isolation Energy
00252   double etIsol = isolatedEt(jet,towers);
00253   double seedEt = seedTowerEt(towers);
00254   
00255   //Fill Trigger Info Class
00256   l2info.TowerIsolConeCut = etIsol; 
00257   l2info.SeedTowerEt = seedEt;
00258 
00259 
00260  
00261 }
00262 
00263 
00264 double 
00265 L2TauTowerIsolation::seedTowerEt(const math::PtEtaPhiELorentzVectorCollection& towers) const
00266 {
00267   //get the sorted calotower collection
00268  
00269   if(towers.size()>0)
00270     return (towers[0].pt());
00271   else
00272     return 0;
00273 
00274 
00275 }
00276 
00277 
00278 double 
00279 L2TauTowerIsolation::isolatedEt(const CaloJet& jet,const math::PtEtaPhiELorentzVectorCollection& towers ) const
00280 {
00281   
00282   double eRMin= 0.;
00283   double eRMax =0.;
00284   
00285   for(math::PtEtaPhiELorentzVectorCollection::const_iterator u = towers.begin();u!=towers.end();++u)
00286         {
00287           double delta = ROOT::Math::VectorUtil::DeltaR(jet.p4(), *u);
00288           if(delta<m_outerCone)
00289             eRMax+=u->pt();
00290           if(delta<m_innerCone)
00291             eRMin+= u->pt();
00292         }
00293     
00294   double etIsol = eRMax - eRMin;
00295   return etIsol;
00296 }
00297 

Generated on Tue Jun 9 17:44:58 2009 for CMSSW by  doxygen 1.5.4