CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

TCTauAlgorithm Class Reference

#include <TCTauAlgorithm.h>

List of all members.

Public Types

enum  {
  TCAlgoUndetermined, TCAlgoMomentum, TCAlgoTrackProblem, TCAlgoMomentumECAL,
  TCAlgoCaloJet, TCAlgoHadronicJet
}

Public Member Functions

int algoComponent ()
int allTauCandidates ()
double efficiency ()
void eventSetup (const edm::Event &, const edm::EventSetup &)
void inputConfig (const edm::ParameterSet &iConfig)
math::XYZTLorentzVector recalculateEnergy (const reco::CaloJet &, const reco::TrackRef &, const reco::TrackRefVector &)
math::XYZTLorentzVector recalculateEnergy (const reco::CaloTau &)
int statistics ()
 TCTauAlgorithm ()
 TCTauAlgorithm (const edm::ParameterSet &)
 ~TCTauAlgorithm ()

Private Member Functions

math::XYZVector getCellMomentum (const CaloCellGeometry *, double &)
std::pair< math::XYZVector,
math::XYZVector
getClusterEnergy (const reco::CaloJet &, math::XYZVector &, double)
void init ()
math::XYZVector trackEcalHitPoint (const reco::Track &)
math::XYZVector trackEcalHitPoint (const reco::TransientTrack &, const reco::CaloJet &)

Private Attributes

int algoComponentUsed
int all
bool dropCaloJets
bool dropRejected
const CaloSubdetectorGeometryEB
edm::Handle< EBRecHitCollectionEBRecHits
double ecalCone
edm::InputTag EcalRecHitsEB_input
edm::InputTag EcalRecHitsEE_input
const CaloSubdetectorGeometryEE
edm::Handle< EERecHitCollectionEERecHits
double etCaloOverTrackMax
double etCaloOverTrackMin
double etHcalOverTrackMax
double etHcalOverTrackMin
const edm::Eventevent
const CaloSubdetectorGeometryHB
edm::Handle< HBHERecHitCollectionHBHERecHits
edm::InputTag HBHERecHits_input
const CaloSubdetectorGeometryHE
const CaloSubdetectorGeometryHF
edm::Handle< HFRecHitCollectionHFRecHits
edm::InputTag HFRecHits_input
const CaloSubdetectorGeometryHO
edm::Handle< HORecHitCollectionHORecHits
edm::InputTag HORecHits_input
int passed
int prongs
const edm::EventSetupsetup
double signalCone
TrackDetectorAssociatortrackAssociator
TrackAssociatorParameters trackAssociatorParameters
const TransientTrackBuildertransientTrackBuilder

Detailed Description

Definition at line 45 of file TCTauAlgorithm.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
TCAlgoUndetermined 
TCAlgoMomentum 
TCAlgoTrackProblem 
TCAlgoMomentumECAL 
TCAlgoCaloJet 
TCAlgoHadronicJet 

Definition at line 47 of file TCTauAlgorithm.h.


Constructor & Destructor Documentation

TCTauAlgorithm::TCTauAlgorithm ( )

Definition at line 15 of file TCTauAlgorithm.cc.

References init.

                              {
        init();
}
TCTauAlgorithm::TCTauAlgorithm ( const edm::ParameterSet iConfig)

Definition at line 19 of file TCTauAlgorithm.cc.

References init.

                                                            {
        init();
        inputConfig(iConfig);
}
TCTauAlgorithm::~TCTauAlgorithm ( )

Definition at line 24 of file TCTauAlgorithm.cc.

{}

Member Function Documentation

int TCTauAlgorithm::algoComponent ( )

Definition at line 76 of file TCTauAlgorithm.cc.

Referenced by TCTauCorrector::algoComponent().

                                 {
        return algoComponentUsed;
}
int TCTauAlgorithm::allTauCandidates ( )

Definition at line 72 of file TCTauAlgorithm.cc.

References cond::ecalcond::all.

Referenced by TCTauCorrector::allTauCandidates().

                                    {
        return all;
}
double TCTauAlgorithm::efficiency ( )

Definition at line 64 of file TCTauAlgorithm.cc.

References cond::ecalcond::all.

Referenced by TCTauCorrector::efficiency().

                                 {
        return double(passed)/all;
}
void TCTauAlgorithm::eventSetup ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 80 of file TCTauAlgorithm.cc.

References egHLT::errCodes::EBRecHits, DetId::Ecal, EcalBarrel, EcalEndcap, egHLT::errCodes::EERecHits, geometry, edm::EventSetup::get(), edm::Event::getByLabel(), egHLT::errCodes::HBHERecHits, DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, egHLT::errCodes::HFRecHits, iEvent, edm::ESHandle< T >::product(), and HcalObjRepresent::setup().

Referenced by TCTauCorrector::eventSetup().

                                                                                 {

        event = &iEvent;
        setup = &iSetup;

        edm::ESHandle<TransientTrackBuilder> builder;
        iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",builder);
        transientTrackBuilder = builder.product();

        // geometry initialization
        edm::ESHandle<CaloGeometry> geometry;
        iSetup.get<CaloGeometryRecord>().get(geometry);


        EB = geometry->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);
        EE = geometry->getSubdetectorGeometry(DetId::Ecal,EcalEndcap);
        HB = geometry->getSubdetectorGeometry(DetId::Hcal,HcalBarrel);
        HE = geometry->getSubdetectorGeometry(DetId::Hcal,HcalEndcap);
        HO = geometry->getSubdetectorGeometry(DetId::Hcal,HcalOuter);
        HF = geometry->getSubdetectorGeometry(DetId::Hcal,HcalForward);

        //hits
        iEvent.getByLabel( EcalRecHitsEB_input, EBRecHits );
        iEvent.getByLabel( EcalRecHitsEE_input, EERecHits );

        iEvent.getByLabel( HBHERecHits_input, HBHERecHits );
        iEvent.getByLabel( HORecHits_input, HORecHits );
        iEvent.getByLabel( HFRecHits_input, HFRecHits );
}
XYZVector TCTauAlgorithm::getCellMomentum ( const CaloCellGeometry cell,
double &  energy 
) [private]

Definition at line 354 of file TCTauAlgorithm.cc.

References funct::cos(), CaloCellGeometry::getPosition(), PV3DBase< T, PVType, FrameType >::phi(), phi, funct::sin(), theta(), and PV3DBase< T, PVType, FrameType >::theta().

                                                                                    {
        XYZVector momentum(0,0,0);
        if(cell){
                GlobalPoint hitPosition = cell->getPosition();

                double phi   = hitPosition.phi();
                double theta = hitPosition.theta();
                if(theta > 3.14159) theta = 2*3.14159 - theta;
                double px = energy * sin(theta)*cos(phi);
                double py = energy * sin(theta)*sin(phi);
                double pz = energy * cos(theta);

                momentum = XYZVector(px,py,pz);
        }
        return momentum;
}
std::pair< XYZVector, XYZVector > TCTauAlgorithm::getClusterEnergy ( const reco::CaloJet ,
math::XYZVector ,
double   
) [private]

Definition at line 254 of file TCTauAlgorithm.cc.

References DetId::det(), egHLT::errCodes::EBRecHits, DetId::Ecal, egHLT::errCodes::EERecHits, relval_parameters_module::energy, reco::CaloJet::getCaloConstituents(), egHLT::errCodes::HBHERecHits, DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, egHLT::errCodes::HFRecHits, i, j, and DetId::subdetId().

                                                                                                                            {

        XYZVector ecalCluster(0,0,0);
        XYZVector hcalCluster(0,0,0);

        std::vector<CaloTowerPtr> towers = caloJet.getCaloConstituents();

        for(std::vector<CaloTowerPtr>::const_iterator iTower = towers.begin();
                                                 iTower!= towers.end(); ++iTower){
                std::vector<XYZVector> ECALCells;
                std::vector<XYZVector> HCALCells;

                size_t numRecHits = (**iTower).constituentsSize();

                // access CaloRecHits
                for(size_t j = 0; j < numRecHits; j++) {
                        DetId recHitDetID = (**iTower).constituent(j);
                        //DetId::Detector detNum=recHitDetID.det();
                        if( recHitDetID.det() == DetId::Ecal ){
                          if( recHitDetID.subdetId() == 1 ){ // Ecal Barrel
                                EBDetId ecalID = recHitDetID;
                                EBRecHitCollection::const_iterator theRecHit = EBRecHits->find(ecalID);
                                if(theRecHit != EBRecHits->end()){
                                  DetId id = theRecHit->detid();
                                  const CaloCellGeometry* this_cell = EB->getGeometry(id);
                                  double energy = theRecHit->energy();
                                  ECALCells.push_back(getCellMomentum(this_cell,energy));
                                }
                          }
                          if( recHitDetID.subdetId() == 2 ){ // Ecal Endcap
                                EEDetId ecalID = recHitDetID;
                                EERecHitCollection::const_iterator theRecHit = EERecHits->find(ecalID);
                                if(theRecHit != EERecHits->end()){
                                  DetId id = theRecHit->detid();
                                  const CaloCellGeometry* this_cell = EE->getGeometry(id);
                                  double energy = theRecHit->energy();
                                  ECALCells.push_back(getCellMomentum(this_cell,energy));
                                }
                          }
                        }
                        if( recHitDetID.det() == DetId::Hcal ){
                          HcalDetId hcalID = recHitDetID;
                          if( recHitDetID.subdetId() == HcalBarrel ){
                            //int depth = hcalID.depth();
                            //if (depth==1){
                                HBHERecHitCollection::const_iterator theRecHit=HBHERecHits->find(hcalID);
                                if(theRecHit != HBHERecHits->end()){
                                  DetId id = theRecHit->detid();
                                  const CaloCellGeometry* this_cell = HB->getGeometry(id);
                                  double energy = theRecHit->energy();
                                  HCALCells.push_back(getCellMomentum(this_cell,energy));
                                }
                            //}
                          }
                          if( recHitDetID.subdetId() == HcalEndcap ){
                            //int depth = hcalID.depth();
                            //if (depth==1){
                                HBHERecHitCollection::const_iterator theRecHit=HBHERecHits->find(hcalID);
                                if(theRecHit != HBHERecHits->end()){
                                  DetId id = theRecHit->detid();
                                  const CaloCellGeometry* this_cell = HE->getGeometry(id);
                                  double energy = theRecHit->energy();
                                  HCALCells.push_back(getCellMomentum(this_cell,energy));
                                }
                            //}
                          }
                          if( recHitDetID.subdetId() == HcalOuter ){
                                HORecHitCollection::const_iterator theRecHit=HORecHits->find(hcalID);
                                if(theRecHit != HORecHits->end()){
                                  DetId id = theRecHit->detid();
                                  const CaloCellGeometry* this_cell = HO->getGeometry(id);
                                  double energy = theRecHit->energy();
                                  HCALCells.push_back(getCellMomentum(this_cell,energy));
                                }
                          }
                          if( recHitDetID.subdetId() == HcalForward ){
                                HFRecHitCollection::const_iterator theRecHit=HFRecHits->find(hcalID);
                                if(theRecHit != HFRecHits->end()){
                                  DetId id = theRecHit->detid();
                                  const CaloCellGeometry* this_cell = HF->getGeometry(id);
                                  double energy = theRecHit->energy();
                                  HCALCells.push_back(getCellMomentum(this_cell,energy));
                                }
                          }
                        }
                }

                std::vector<XYZVector>::const_iterator i;
                for(i = ECALCells.begin(); i != ECALCells.end(); ++i) {
                        double DR = ROOT::Math::VectorUtil::DeltaR(trackEcalHitPoint,*i);
                        if( DR < cone ) ecalCluster += *i;
                }
                for(i = HCALCells.begin(); i != HCALCells.end(); ++i) {
                        double DR = ROOT::Math::VectorUtil::DeltaR(trackEcalHitPoint,*i);
                        if( DR < cone ) hcalCluster += *i;
                }
        }
        return std::pair<XYZVector,XYZVector> (ecalCluster,hcalCluster);
}
void TCTauAlgorithm::init ( void  ) [private]
void TCTauAlgorithm::inputConfig ( const edm::ParameterSet iConfig)

Definition at line 40 of file TCTauAlgorithm.cc.

References edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

Referenced by TCTauCorrector::inputConfig().

                                                              {

        etCaloOverTrackMin = iConfig.getParameter<double>("EtCaloOverTrackMin");
        etCaloOverTrackMax = iConfig.getParameter<double>("EtCaloOverTrackMax");
        etHcalOverTrackMin = iConfig.getParameter<double>("EtHcalOverTrackMin");
        etHcalOverTrackMax = iConfig.getParameter<double>("EtHcalOverTrackMax");

        signalCone         = iConfig.getParameter<double>("SignalConeSize");
        ecalCone           = iConfig.getParameter<double>("EcalConeSize");

        EcalRecHitsEB_input= iConfig.getParameter<edm::InputTag>("EBRecHitCollection");
        EcalRecHitsEE_input= iConfig.getParameter<edm::InputTag>("EERecHitCollection");
        HBHERecHits_input  = iConfig.getParameter<edm::InputTag>("HBHERecHitCollection");
        HORecHits_input    = iConfig.getParameter<edm::InputTag>("HORecHitCollection");
        HFRecHits_input    = iConfig.getParameter<edm::InputTag>("HFRecHitCollection");

        edm::ParameterSet pset = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
        trackAssociatorParameters.loadParameters( pset );

        dropCaloJets       = iConfig.getUntrackedParameter<bool>("DropCaloJets",false);
        dropRejected       = iConfig.getUntrackedParameter<bool>("DropRejectedJets",true);
}
math::XYZTLorentzVector TCTauAlgorithm::recalculateEnergy ( const reco::CaloJet caloJet,
const reco::TrackRef leadTk,
const reco::TrackRefVector associatedTracks 
)

Definition at line 124 of file TCTauAlgorithm.cc.

References cond::ecalcond::all, edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::end(), reco::LeafCandidate::energy(), edm::Ref< C, T, F >::isNull(), reco::LeafCandidate::p4(), p4, reco::LeafCandidate::px(), reco::LeafCandidate::py(), and reco::LeafCandidate::pz().

                                                                                                                                               {

        all++;

        math::XYZTLorentzVector p4(0,0,0,0);
        algoComponentUsed = TCAlgoUndetermined;

        //if(!dropRejected) 
        p4 = caloJet.p4();

        if(leadTk.isNull()) return p4;

        XYZVector momentum(0,0,0);
        int prongCounter = 0;
        edm::RefVector<TrackCollection>::const_iterator iTrack;
        for(iTrack = associatedTracks.begin(); iTrack!= associatedTracks.end(); ++iTrack){
                double DR = ROOT::Math::VectorUtil::DeltaR(leadTk->momentum(),(*iTrack)->momentum());
                if(DR < signalCone) {
                        momentum+=(*iTrack)->momentum();
                        prongCounter++;
                }
        }
        if(momentum.Rho() == 0) return p4;

        XYZVector ltrackEcalHitPoint = trackEcalHitPoint(*leadTk);

        if(! (ltrackEcalHitPoint.Rho() > 0 && ltrackEcalHitPoint.Rho() < 9999) ) return p4;

        std::pair<XYZVector,XYZVector> caloClusters = getClusterEnergy(caloJet,ltrackEcalHitPoint,signalCone);
        XYZVector EcalCluster = caloClusters.first;
        XYZVector HcalCluster = caloClusters.second;

        double eCaloOverTrack = (EcalCluster.R()+HcalCluster.R()-momentum.R())/momentum.R();

        std::pair<XYZVector,XYZVector> caloClustersPhoton = getClusterEnergy(caloJet,ltrackEcalHitPoint,ecalCone);
        XYZVector EcalClusterPhoton = caloClustersPhoton.first;

        math::XYZTLorentzVector p4photons(0,0,0,EcalClusterPhoton.R() - EcalCluster.R());

        if( eCaloOverTrack > etCaloOverTrackMin  && eCaloOverTrack < etCaloOverTrackMax ) {

                double eHcalOverTrack = (HcalCluster.R()-momentum.R())/momentum.R();

                if ( eHcalOverTrack  > etHcalOverTrackMin  && eHcalOverTrack  < etHcalOverTrackMax ) {
                  p4.SetXYZT(EcalCluster.X()   + momentum.X(),
                             EcalCluster.Y()   + momentum.Y(),
                             EcalCluster.Z()   + momentum.Z(),
                             EcalCluster.R()   + momentum.R());
                  p4 += p4photons;
                  algoComponentUsed = TCAlgoMomentumECAL;
                }else{
                  p4.SetXYZT(momentum.X(),
                             momentum.Y(),
                             momentum.Z(),
                             momentum.R());
                  algoComponentUsed = TCAlgoMomentum;
                }
        }
        if( eCaloOverTrack  > etCaloOverTrackMax ) {
                double eHcalOverTrack = (HcalCluster.R()-momentum.R())/momentum.R();

                if ( eHcalOverTrack  > etHcalOverTrackMin  && eHcalOverTrack  < etHcalOverTrackMax ) {
                  p4.SetXYZT(EcalCluster.X()   + momentum.X(),
                             EcalCluster.Y()   + momentum.Y(),
                             EcalCluster.Z()   + momentum.Z(),
                             EcalCluster.R()   + momentum.R());
                  p4 += p4photons;
                  algoComponentUsed = TCAlgoMomentumECAL;
                }
                if ( eHcalOverTrack  < etHcalOverTrackMin ) {
                  if(!dropCaloJets) p4.SetXYZT(caloJet.px(),caloJet.py(),caloJet.pz(),caloJet.energy());
                  else p4.SetXYZT(0,0,0,0);
                  algoComponentUsed = TCAlgoCaloJet;
                }
                if ( eHcalOverTrack  > etHcalOverTrackMax ) {
                  algoComponentUsed = TCAlgoHadronicJet; // reject
                  if(!dropRejected) p4.SetXYZT(caloJet.px(),caloJet.py(),caloJet.pz(),caloJet.energy());
                  else p4.SetXYZT(0,0,0,0);
                }
        }
        if( eCaloOverTrack  < etCaloOverTrackMin ) {
                  algoComponentUsed = TCAlgoTrackProblem; // reject
                  if(!dropRejected) p4.SetXYZT(caloJet.px(),caloJet.py(),caloJet.pz(),caloJet.energy());
        }

        if(p4.Et() > 0) passed++;

        return p4;
}
math::XYZTLorentzVector TCTauAlgorithm::recalculateEnergy ( const reco::CaloTau jet)

Definition at line 111 of file TCTauAlgorithm.cc.

References reco::CaloTau::caloTauTagInfoRef(), edm::Ref< C, T, F >::get(), reco::BaseTau::leadTrack(), reco::LeafCandidate::p4(), and reco::LeafCandidate::setP4().

Referenced by TCTauCorrector::correctedP4(), and TCTauCorrector::correction().

                                                                             {

        const TrackRef& leadTk = jet.leadTrack();

        const TrackRefVector associatedTracks = jet.caloTauTagInfoRef()->Tracks();

        const CaloJet* cJet = jet.caloTauTagInfoRef()->calojetRef().get();
        CaloJet caloJet = *cJet;
        caloJet.setP4(jet.p4());

        return recalculateEnergy(caloJet,leadTk,associatedTracks);
}
int TCTauAlgorithm::statistics ( )

Definition at line 68 of file TCTauAlgorithm.cc.

Referenced by TCTauCorrector::statistics().

                              {
        return passed;
}
XYZVector TCTauAlgorithm::trackEcalHitPoint ( const reco::Track track) [private]
XYZVector TCTauAlgorithm::trackEcalHitPoint ( const reco::TransientTrack transientTrack,
const reco::CaloJet caloJet 
) [private]

Definition at line 215 of file TCTauAlgorithm.cc.

References reco::CaloJet::getCaloConstituents(), TrajectoryStateOnSurface::globalPosition(), reco::TransientTrack::stateOnSurface(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

                                                                                                      {


        GlobalPoint ecalHitPosition(0,0,0);

        double maxTowerEt = 0;
        std::vector<CaloTowerPtr> towers = caloJet.getCaloConstituents();
        for(std::vector<CaloTowerPtr>::const_iterator iTower = towers.begin();
                                                 iTower!= towers.end(); ++iTower){
                if((*iTower)->et() > maxTowerEt){
                        maxTowerEt = (*iTower)->et();
                        ecalHitPosition = (*iTower)->emPosition();
                }
        }


        XYZVector ecalHitPoint(0,0,0);

        try{
                GlobalPoint trackEcalHitPoint = transientTrack.stateOnSurface(ecalHitPosition).globalPosition();

                ecalHitPoint.SetXYZ(trackEcalHitPoint.x(),
                                    trackEcalHitPoint.y(),
                                    trackEcalHitPoint.z());
        }catch(...) {;}

        return ecalHitPoint;
}

Member Data Documentation

Definition at line 89 of file TCTauAlgorithm.h.

int TCTauAlgorithm::all [private]

Definition at line 86 of file TCTauAlgorithm.h.

Definition at line 93 of file TCTauAlgorithm.h.

Definition at line 94 of file TCTauAlgorithm.h.

Definition at line 112 of file TCTauAlgorithm.h.

Definition at line 119 of file TCTauAlgorithm.h.

double TCTauAlgorithm::ecalCone [private]

Definition at line 99 of file TCTauAlgorithm.h.

Definition at line 106 of file TCTauAlgorithm.h.

Definition at line 107 of file TCTauAlgorithm.h.

Definition at line 113 of file TCTauAlgorithm.h.

Definition at line 120 of file TCTauAlgorithm.h.

Definition at line 101 of file TCTauAlgorithm.h.

Definition at line 101 of file TCTauAlgorithm.h.

Definition at line 101 of file TCTauAlgorithm.h.

Definition at line 101 of file TCTauAlgorithm.h.

Definition at line 72 of file TCTauAlgorithm.h.

Definition at line 114 of file TCTauAlgorithm.h.

Definition at line 122 of file TCTauAlgorithm.h.

Definition at line 108 of file TCTauAlgorithm.h.

Definition at line 115 of file TCTauAlgorithm.h.

Definition at line 117 of file TCTauAlgorithm.h.

Definition at line 124 of file TCTauAlgorithm.h.

Definition at line 110 of file TCTauAlgorithm.h.

Definition at line 116 of file TCTauAlgorithm.h.

Definition at line 123 of file TCTauAlgorithm.h.

Definition at line 109 of file TCTauAlgorithm.h.

int TCTauAlgorithm::passed [private]

Definition at line 86 of file TCTauAlgorithm.h.

int TCTauAlgorithm::prongs [private]

Definition at line 91 of file TCTauAlgorithm.h.

Definition at line 73 of file TCTauAlgorithm.h.

double TCTauAlgorithm::signalCone [private]

Definition at line 98 of file TCTauAlgorithm.h.

Definition at line 75 of file TCTauAlgorithm.h.

Definition at line 74 of file TCTauAlgorithm.h.

Definition at line 96 of file TCTauAlgorithm.h.