00001 #include "PhysicsTools/StarterKit/interface/HistoTau.h"
00002 #include "DataFormats/Math/interface/LorentzVector.h"
00003 #include "DataFormats/TrackReco/interface/Track.h"
00004
00005 #include <iostream>
00006 #include <sstream>
00007
00008 using pat::HistoTau;
00009 using namespace std;
00010
00011
00012
00013
00014 HistoTau::HistoTau(std::string dir, std::string group,std::string pre,
00015 double pt1, double pt2, double m1, double m2,
00016 TFileDirectory * parentDir)
00017 : HistoGroup<Tau>( dir, group, pre, pt1, pt2, m1, m2, parentDir)
00018 {
00019
00020 histoLeadingTrack_ = new HistoTrack( dir, group + "TauLeadingTrack", pre + "tauLeadingTrack" );
00021 histoSignalTrack_ = new HistoTrack( dir, group + "TauSignalTracks", pre + "tauSignalTracks" );
00022 histoIsolationTrack_ = new HistoTrack( dir, group + "TauIsolationTracks", pre + "tauIsolationTracks" );
00023
00024 addHisto( h_emEnergyFraction_ =
00025 new PhysVarHisto( pre + "EmEnergyFraction", "Tau EM Energy Fraction", 20, 0, 10, currDir_, "", "vD" )
00026 );
00027
00028 addHisto( h_eOverP_ =
00029 new PhysVarHisto( pre + "EOverP", "Tau E over P", 20, 0, 10, currDir_, "", "vD" )
00030 );
00031
00032
00033 }
00034
00035
00036
00037 void HistoTau::fill( const Tau *tau, uint iTau, double weight )
00038 {
00039
00040
00041 HistoGroup<Tau>::fill( tau, iTau, weight);
00042
00043
00044
00045 const double M_PION = 0.13957018;
00046
00047 if ( tau->leadTrack().isNonnull() ) {
00048 const reco::Track & trk = *( tau->leadTrack() );
00049 ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> > p4;
00050 p4.SetPt( trk.pt() );
00051 p4.SetEta( trk.eta() );
00052 p4.SetPhi( trk.phi() );
00053 p4.SetM( M_PION );
00054 reco::Particle::LorentzVector p4_2( p4.x(), p4.y(), p4.z(), p4.t() );
00055 reco::RecoChargedCandidate trk_p4( trk.charge(), p4_2 );
00056 trk_p4.setTrack( tau->leadTrack() );
00057 histoLeadingTrack_->fill( &trk_p4, 1, weight );
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 }
00097
00098 void HistoTau::fill( const reco::ShallowClonePtrCandidate * pshallow, uint iTau, double weight )
00099 {
00100
00101
00102 const pat::Tau * tau = dynamic_cast<const pat::Tau*>(pshallow);
00103
00104 if ( tau == 0 ) {
00105 cout << "Error! Was passed a shallow clone that is not at heart a tau" << endl;
00106 return;
00107 }
00108
00109
00110
00111 HistoGroup<Tau>::fill( pshallow, iTau, weight);
00112
00113
00114
00115 const double M_PION = 0.13957018;
00116
00117
00118 if ( tau->leadTrack().isNonnull() ) {
00119
00120 const reco::Track & trk = *( tau->leadTrack() );
00121 ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> > p4;
00122 p4.SetPt( trk.pt() );
00123 p4.SetEta( trk.eta() );
00124 p4.SetPhi( trk.phi() );
00125 p4.SetM( M_PION );
00126 reco::Particle::LorentzVector p4_2( p4.x(), p4.y(), p4.z(), p4.t() );
00127 reco::RecoChargedCandidate trk_p4( trk.charge(), p4_2 );
00128 trk_p4.setTrack( tau->leadTrack() );
00129 histoLeadingTrack_->fill( &trk_p4, 1, weight );
00130 }
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159 }
00160
00161
00162 void HistoTau::fillCollection( const std::vector<Tau> & coll, double weight )
00163 {
00164
00165 h_size_->fill( coll.size(), 1, weight );
00166
00167 std::vector<Tau>::const_iterator
00168 iobj = coll.begin(),
00169 iend = coll.end();
00170
00171 uint i = 1;
00172 for ( ; iobj != iend; ++iobj, ++i ) {
00173 fill( &*iobj, i, weight);
00174 }
00175 }
00176
00177
00178 void HistoTau::clearVec()
00179 {
00180 HistoGroup<Tau>::clearVec();
00181
00182 h_emEnergyFraction_->clearVec();
00183 h_eOverP_->clearVec();
00184 }