00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020 #include "Math/GenVector/VectorUtil.h"
00021 #include "RecoTauTag/Pi0Tau/interface/TauVariables.h"
00022
00023 #include <cmath>
00024
00025 const double PIMASS = 0.139;
00026
00027 using namespace reco;
00028
00029
00030
00031
00032
00033 TauVariables::TauVariables(const reco::Tau3D *tau, const edm::Handle<reco::CaloTauTagInfoCollection> *tauTagInfoHandle)
00034 {
00035
00036 this->init();
00037
00038 tau3D_ = tau;
00039 tauTagInfoHandle_ = tauTagInfoHandle;
00040
00041 use3DAngle_ = false;
00042 signalConeSize_ = 0.175;
00043 isolationConeSize_ = 0.524;
00044 useVariableSignalCone_ = false;
00045 signalConeFunction_ = 5.0;
00046 useVariableIsolationCone_ = false;
00047 isolationConeFunction_ = 5.0;
00048
00049 seedTrackThreshold_ = 5.0;
00050 shoulderTrackThreshold_ = 1.0;
00051 pi0Threshold_ = 1.0;
00052 dZTrackAssociation_ = 2.0;
00053
00054
00055
00056 }
00057
00058
00059 TauVariables::~TauVariables()
00060 {
00061
00062
00063
00064
00065 }
00066
00067 void TauVariables::init(){
00068
00069 tracksMomentum_ *= 0;
00070 pi0sMomentum_ *= 0;
00071
00072 seedTrack_ = TrackRef();
00073 nSignalTracks_ = 0;
00074 nSignalPi0s_ = 0;
00075 nIsolationTracks_ = 0;
00076 nIsolationPi0s_ = 0;
00077 signalCharge_ = 0;
00078 maxPtTrackInIsolation_ = reco::TrackRef();
00079 maxPtPi0InIsolation_ = reco::Pi0();
00080
00081 signalTracks_.clear();
00082 signalPi0s_.clear();
00083 isolationTracks_.clear();
00084 isolationPi0s_.clear();
00085 tauTagRef_ = CaloTauTagInfoRef();
00086 tau3D_ = 0;
00087 tauTagInfoHandle_ = 0;
00088
00089 }
00090
00091
00092 void TauVariables::makeVariables(){
00093
00094 seedTrack_ = tau3D().seedTrack();
00095 if(seedTrack_.isNull()) return;
00096
00097 const CaloTauTagInfoCollection &tauTagColl = *(tauTagInfoHandle_->product());
00098 CaloTauTagInfoCollection::const_iterator endIter = tauTagColl.end();
00099 CaloTauTagInfoCollection::const_iterator tauIter = tauTagColl.begin();
00100 int itau=0;
00101 double minAlpha = 999.0;
00102 for(; tauIter != endIter; tauIter++){
00103 const CaloTauTagInfoRef tauTagRef(*tauTagInfoHandle_,itau);
00104 itau++;
00105
00106 double dist = use3DAngle_ ? ROOT::Math::VectorUtil::Angle(seedTrack_->momentum(),tauTagRef->calojetRef()->momentum()) :
00107 ROOT::Math::VectorUtil::DeltaR(seedTrack_->momentum(),tauTagRef->calojetRef()->momentum());
00108
00109 if(dist < minAlpha){
00110 minAlpha = dist;
00111 tauTagRef_ = tauTagRef;
00112 }
00113 }
00114
00115
00116 if(useVariableSignalCone_){
00117 if(!tauTagRef_.isNull()) signalConeSize_ = std::min(0.175, std::max(signalConeFunction_/tauTagRef_->calojetRef()->energy(),0.05));
00118 }
00119 if(useVariableIsolationCone_){
00120 if(!tauTagRef_.isNull()) isolationConeSize_ = std::min(0.524, std::max(isolationConeFunction_/tauTagRef_->calojetRef()->energy(),0.05));
00121 }
00122
00123
00124
00125 double maxPtIso = 0.0;
00126 maxPtTrackInIsolation_ = reco::TrackRef();
00127
00128 for(TrackRefVector::const_iterator trkIter = tau3D().tracks().begin();
00129 trkIter != tau3D().tracks().end(); trkIter++){
00130 const TrackRef trk = *trkIter;
00131
00132 double dZ = seedTrack_->vertex().z() - trk->vertex().z();
00133 if(std::abs(dZ) > dZTrackAssociation_) continue;
00134
00135 double energy = std::sqrt(trk->momentum().Mag2() + PIMASS*PIMASS);
00136 math::XYZTLorentzVector trkP4(trk->momentum().X(),trk->momentum().Y(),trk->momentum().Z(),energy);
00137
00138 double pt = trk->pt();
00139 if(pt < shoulderTrackThreshold_) continue;
00140
00141 double angle = use3DAngle_ ? ROOT::Math::VectorUtil::Angle(seedTrack_->momentum(),trk->momentum()) :
00142 ROOT::Math::VectorUtil::DeltaR(seedTrack_->momentum(),trk->momentum());
00143
00144 if(angle > isolationConeSize_) continue;
00145
00146 if(angle < signalConeSize_){
00147 nSignalTracks_++;
00148 signalCharge_ += trk->charge();
00149 tracksMomentum_ += trkP4;
00150 signalTracks_.push_back(trk);
00151 }
00152 else {
00153 nIsolationTracks_++;
00154 isolationTracks_.push_back(trk);
00155 if(pt > maxPtIso){
00156 maxPtIso = pt;
00157 maxPtTrackInIsolation_ = trk;
00158 }
00159 }
00160
00161 }
00162
00163
00164 maxPtIso = 0.0;
00165 maxPtPi0InIsolation_ = reco::Pi0();
00166
00167 for(Pi0Collection::const_iterator pIter = tau3D().pi0s().begin(); pIter != tau3D().pi0s().end(); pIter++){
00168 const Pi0 &pi0 = *pIter;
00169
00170 math::XYZTLorentzVector p4 = pi0.momentum(seedTrack_->vertex());
00171
00172 double et = p4.Et();
00173 if(et < pi0Threshold_) continue;
00174
00175 double angle = use3DAngle_ ? ROOT::Math::VectorUtil::Angle(seedTrack_->momentum(),p4) :
00176 ROOT::Math::VectorUtil::DeltaR(seedTrack_->momentum(),p4);
00177
00178 if(angle > isolationConeSize_) continue;
00179
00180 if(angle < signalConeSize_){
00181 nSignalPi0s_++;
00182 pi0sMomentum_ += p4;
00183 signalPi0s_.push_back(pi0);
00184 }
00185 else {
00186 nIsolationPi0s_++;
00187 isolationPi0s_.push_back(pi0);
00188 if(et > maxPtIso){
00189 maxPtIso = et;
00190 maxPtPi0InIsolation_ = pi0;
00191 }
00192 }
00193 }
00194
00195
00196 }