CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TxCalculator Class Reference

#include <TxCalculator.h>

List of all members.

Public Member Functions

double getCTx (const reco::Photon clus, double i, double threshold, double innerDR=0, double effRatio=2)
double getJct (const reco::Photon cluster, double r1=0.4, double r2=0.04, double jWidth=0.015, double threshold=2)
double getJt (const reco::Photon cluster, double r1=0.4, double r2=0.04, double jWidth=0.015, double threshold=2)
double getJurassicArea (double r1, double r2, double width)
double getMPT (double ptCut=0, double etaCut=1000)
double getTx (const reco::Photon clus, double i, double threshold, double innerDR=0, double effRatio=2)
 TxCalculator (const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::InputTag trackLabel)

Private Member Functions

double calcDphi (double phi1_, double phi2_)
double dRDistance (double eta1, double phi1, double eta2, double phi2)

Private Attributes

edm::Handle
< reco::TrackCollection
recCollection
CLHEP::RandFlat * theDice

Detailed Description

Definition at line 27 of file TxCalculator.h.


Constructor & Destructor Documentation

TxCalculator::TxCalculator ( const edm::Event iEvent,
const edm::EventSetup iSetup,
edm::InputTag  trackLabel 
)

Definition at line 24 of file TxCalculator.cc.

References Exception, edm::Event::getByLabel(), and edm::Service< T >::isAvailable().

{
   iEvent.getByLabel(trackLabel, recCollection); 
   edm::Service<edm::RandomNumberGenerator> rng;
   if ( ! rng.isAvailable()) {
      throw cms::Exception("Configuration")
         << "XXXXXXX requires the RandomNumberGeneratorService\n"
         "which is not present in the configuration file.  You must add the service\n"
         "in the configuration file or remove the modules that require it.";
   }
   CLHEP::HepRandomEngine& engine = rng->getEngine();
   theDice = new CLHEP::RandFlat(engine, 0, 1);
   
} 

Member Function Documentation

double TxCalculator::calcDphi ( double  phi1_,
double  phi2_ 
) [inline, private]

Definition at line 54 of file TxCalculator.h.

References PI.

Referenced by dRDistance().

   {
       double dphi=phi1_-phi2_;

      if (dphi>0){
         while (dphi>2*PI) dphi-=2*PI;
         if (dphi>PI) dphi=2*PI-dphi; 
      } else {
         while (dphi<-2*PI) dphi+=2*PI;
         if (dphi<-PI) dphi=-2*PI-dphi;
      }
      return dphi;
   }
double TxCalculator::dRDistance ( double  eta1,
double  phi1,
double  eta2,
double  phi2 
) [inline, private]

Definition at line 46 of file TxCalculator.h.

References calcDphi(), and mathSSE::sqrt().

   {
      double deta = eta1 - eta2;
      double dphi = (calcDphi(phi1, phi2));
      
      return sqrt(deta * deta + dphi * dphi);
   }
double TxCalculator::getCTx ( const reco::Photon  clus,
double  i,
double  threshold,
double  innerDR = 0,
double  effRatio = 2 
)

Definition at line 124 of file TxCalculator.cc.

References reco::LeafCandidate::eta(), reco::LeafCandidate::phi(), dt_dqm_sourceclient_common_cff::reco, and x.

{
   using namespace edm;
   using namespace reco;

   double SClusterEta = cluster.eta();
   double SClusterPhi = cluster.phi();
   double TotalPt = 0;

   TotalPt = 0;

   for(reco::TrackCollection::const_iterator
          recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
      {
         double diceNum = theDice->fire();
         if ( (effRatio < 1 ) &&  ( diceNum > effRatio))
            continue;
         
         
         double pt = recTrack->pt();
         double eta2 = recTrack->eta();
         double phi2 = recTrack->phi();
         double dEta = fabs(eta2-SClusterEta);
         
      if(dEta >= 0.1 * x)
         continue;
      if(dRDistance(SClusterEta,SClusterPhi,eta2,phi2) < innerDR)
         continue;
      
      if(pt > threshold)
         TotalPt = TotalPt + pt;
   }
   
   double Tx = getTx(cluster,x,threshold,innerDR,effRatio);
   double CTx = Tx - TotalPt / 40.0 * x;

   return CTx;
}
double TxCalculator::getJct ( const reco::Photon  cluster,
double  r1 = 0.4,
double  r2 = 0.04,
double  jWidth = 0.015,
double  threshold = 2 
)

Definition at line 203 of file TxCalculator.cc.

References gather_cfg::cout, dPhi(), eta(), reco::LeafCandidate::eta(), reco::LeafCandidate::phi(), phi, PI, diffTwoXMLs::r1, and dt_dqm_sourceclient_common_cff::reco.

{

   using namespace edm;
   using namespace reco;


   double SClusterEta = cluster.eta();
   double SClusterPhi = cluster.phi();
   double TotalPt = 0;

   for(reco::TrackCollection::const_iterator
          recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
      {
         double pt = recTrack->pt();
         double eta = recTrack->eta();
         double phi = recTrack->phi();
         double dEta = fabs(eta-SClusterEta);
         double dPhi = phi-SClusterPhi;
         if ( dPhi < -PI )    dPhi = dPhi + 2*PI ;
         if ( dPhi >  PI )    dPhi = dPhi - 2*PI ;
         if ( fabs(dPhi) >PI )   cout << " error!!! dphi > 2pi   : " << dPhi << endl;
         //         double dR = sqrt(dEta*dEta+dPhi*dPhi);
         

         if ( fabs(dEta) > r1 ) continue;
         if ( fabs(dPhi) <r1 ) continue;
         
         if(pt > threshold)
            TotalPt = TotalPt + pt;
      }
   
   double areaStrip = 4*PI*r1 -  4*r1*r1;
   double areaJura  = getJurassicArea(r1,r2, jWidth) ;
   double theCJ     = getJt(cluster,r1,  r2, jWidth, threshold);

   double theCCJ   = theCJ - TotalPt * areaJura / areaStrip ;
   return theCCJ;

}
double TxCalculator::getJt ( const reco::Photon  cluster,
double  r1 = 0.4,
double  r2 = 0.04,
double  jWidth = 0.015,
double  threshold = 2 
)

Definition at line 165 of file TxCalculator.cc.

References gather_cfg::cout, dPhi(), eta(), reco::LeafCandidate::eta(), reco::LeafCandidate::phi(), phi, PI, dt_dqm_sourceclient_common_cff::reco, and mathSSE::sqrt().

{

   using namespace edm;
   using namespace reco;


   double SClusterEta = cluster.eta();
   double SClusterPhi = cluster.phi();
   double TotalPt = 0;

   for(reco::TrackCollection::const_iterator
          recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
      {
         double pt = recTrack->pt();
         double eta = recTrack->eta();
         double phi = recTrack->phi();
         double dEta = fabs(eta-SClusterEta);
         double dPhi = phi-SClusterPhi;
         if ( dPhi < -PI )    dPhi = dPhi + 2*PI ;
         if ( dPhi >  PI )    dPhi = dPhi - 2*PI ;
         if ( fabs(dPhi) >PI )   cout << " error!!! dphi > 2pi   : " << dPhi << endl;
         double dR = sqrt(dEta*dEta+dPhi*dPhi);
         // Jurassic Cone /////                                                                                                     
         if ( dR > r1 ) continue;
         if ( dR < r2 ) continue;
         if ( fabs(dEta) <  jWidth)  continue;
         // stupid bug if ( fabs(dPhi) >  jWidth)  continue;
         
         if(pt > threshold)
            TotalPt = TotalPt + pt;
      }

   return TotalPt;
}
double TxCalculator::getJurassicArea ( double  r1,
double  r2,
double  width 
)

Definition at line 40 of file TxCalculator.cc.

References funct::cos(), and mathSSE::sqrt().

                                                                        {
   
   float theta1 = asin( width / r1);
   float theta2 = asin( width / r2);
   float theA   = sqrt ( r1*r1 + r2*r2 - 2 * r1 * r2 * cos ( theta1 - theta2) );
   float area1 =  0.5 * r1*r1 * ( 3.141592 - 2 * theta1 )   ;
   float area2 =  0.5 * r2*r2 * ( 3.141592 - 2 * theta2 )   ;
   float area3 =  width * theA;
   float finalArea = 2 * ( area1 - area2 - area3);
   return finalArea;
}
double TxCalculator::getMPT ( double  ptCut = 0,
double  etaCut = 1000 
)

Definition at line 53 of file TxCalculator.cc.

References eta(), dt_dqm_sourceclient_common_cff::reco, and mathSSE::sqrt().

{
   using namespace edm;
   using namespace reco;
   
   double sumpx(0), sumpy(0);
   
   for(reco::TrackCollection::const_iterator
          recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
      {
         double pt = recTrack->pt();
         double eta = recTrack->eta();
         
         if(pt < ptCut ) 
            continue;
         if ( fabs( eta) > etaCut ) 
            continue;
         
         double pxTemp = recTrack->px();
         double pyTemp = recTrack->py();
         
         sumpx = sumpx + pxTemp;
         sumpy = sumpy + pyTemp;
         //      cout << " pt  = " << recTrack->pt() <<  "    and px = " << pxTemp << " and  py = " << pyTemp << endl;
      }
   //   cout << " square = " << sumpx*sumpx + sumpy*sumpy << endl;
   double theMPT = sqrt(sumpx*sumpx + sumpy*sumpy) ;
   //  cout << " mpt    = "<< theMPT << endl;
   
   return theMPT;
}
double TxCalculator::getTx ( const reco::Photon  clus,
double  i,
double  threshold,
double  innerDR = 0,
double  effRatio = 2 
)

Definition at line 86 of file TxCalculator.cc.

References reco::LeafCandidate::eta(), reco::LeafCandidate::phi(), and dt_dqm_sourceclient_common_cff::reco.

{

   using namespace edm;
   using namespace reco;

   
   
   double SClusterEta = cluster.eta();
   double SClusterPhi = cluster.phi();
   double TotalPt = 0;
   
   for(reco::TrackCollection::const_iterator
          recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++)
      {
         double diceNum = theDice->fire();
         if ( (effRatio < 1 ) &&  ( diceNum > effRatio))
            continue;
         
         double pt = recTrack->pt();
         double eta2 = recTrack->eta();
         double phi2 = recTrack->phi();
         
         if(dRDistance(SClusterEta,SClusterPhi,eta2,phi2) >= 0.1 * x)
            continue;
         if(dRDistance(SClusterEta,SClusterPhi,eta2,phi2) < innerDR)
            continue;
         if(pt > threshold)
            TotalPt = TotalPt + pt;
      }
   
   return TotalPt;
}

Member Data Documentation

Definition at line 43 of file TxCalculator.h.

CLHEP::RandFlat* TxCalculator::theDice [private]

Definition at line 44 of file TxCalculator.h.