37 #include "CLHEP/Units/GlobalPhysicalConstants.h"
38 #include "Math/GenVector/VectorUtil.h"
39 #include "Math/GenVector/PxPyPzE4D.h"
64 PileupJPTJetIdAlgo::~PileupJPTJetIdAlgo()
69 void PileupJPTJetIdAlgo::bookMVAReader()
79 if(
verbosity>0)
std::cout<<
" TMVA method "<<tmvaMethod_.c_str()<<
" "<<tmvaWeights_.c_str()<<std::endl;
80 reader_ =
new TMVA::Reader(
"!Color:!Silent" );
82 reader_->AddVariable(
"Nvtx", &Nvtx );
83 reader_->AddVariable(
"PtJ", &PtJ );
84 reader_->AddVariable(
"EtaJ", &EtaJ );
85 reader_->AddVariable(
"Beta", &Beta );
86 reader_->AddVariable(
"MultCalo", &MultCalo );
87 reader_->AddVariable(
"dAxis1c", &dAxis1c );
88 reader_->AddVariable(
"dAxis2c", &dAxis2c );
89 reader_->AddVariable(
"MultTr", &MultTr );
90 reader_->AddVariable(
"dAxis1t", &dAxis1t );
91 reader_->AddVariable(
"dAxis2t", &dAxis2t );
98 readerF_ =
new TMVA::Reader(
"!Color:!Silent" );
100 readerF_->AddVariable(
"Nvtx", &Nvtx );
101 readerF_->AddVariable(
"PtJ", &PtJ );
102 readerF_->AddVariable(
"EtaJ", &EtaJ );
103 readerF_->AddVariable(
"MultCalo", &MultCalo );
104 readerF_->AddVariable(
"dAxis1c", &dAxis1c );
105 readerF_->AddVariable(
"dAxis2c", &dAxis2c );
117 std::cout<<
"================================ JET LOOP ==================== " << std::endl;
118 std::cout<<
"================ jetPt = " << (*jet).pt() << std::endl;
119 std::cout<<
"================ jetEta = " << (*jet).eta() << std::endl;
147 for(std::vector <CaloTowerPtr>::const_iterator icalot = calotwrs.begin();
148 icalot!= calotwrs.end(); icalot++) {
151 double deta=(*jet).eta()-(*icalot)->eta();
152 double dphi=(*jet).phi()-(*icalot)->phi();
154 if(dphi >
M_PI ) dphi = dphi-2.*
M_PI;
155 if(dphi < -1.*
M_PI ) dphi = dphi+2.*
M_PI;
157 if (
verbosity > 0)
std::cout<<
" CaloTower jet eta "<<(*jet).eta()<<
" tower eta "<<(*icalot)->eta()<<
" jet phi "<<(*jet).phi()<<
" tower phi "<<(*icalot)->phi()<<
" dphi "<<dphi<<
" "<<(*icalot)->pt()<<
" ieta "<<(*icalot)->ieta()<<
" "<<
abs((*icalot)->ieta())<<std::endl;
159 double dr =
sqrt(dphi*dphi+deta*deta);
160 double enc = (*icalot)->emEnergy()+(*icalot)->hadEnergy();
161 if(dr < 0.1) ffrac01 = ffrac01 + enc;
162 if(dr < 0.2) ffrac02 = ffrac02 + enc;
163 if(dr < 0.3) ffrac03 = ffrac03 + enc;
164 if(dr < 0.4) ffrac04 = ffrac04 + enc;
165 if(dr < 0.5) ffrac05 = ffrac05 + enc;
167 if(
abs((*icalot)->ieta())<30) EE = EE + (*icalot)->emEnergy();
168 if(
abs((*icalot)->ieta())<30) HE = HE + (*icalot)->hadEnergy();
169 if(
abs((*icalot)->ieta())>29) EELong = EELong + (*icalot)->emEnergy();
170 if(
abs((*icalot)->ieta())>29) EEShort = EEShort + (*icalot)->hadEnergy();
172 sumpt = sumpt + (*icalot)->pt();
173 dphi2 = dphi2 + dphi*dphi*(*icalot)->pt();
174 deta2 = deta2 + deta*deta*(*icalot)->pt();
175 dphi1 = dphi1 + dphi*(*icalot)->pt();
176 deta1 = deta1 + deta*(*icalot)->pt();
177 dphideta = dphideta + dphi*deta*(*icalot)->pt();
187 dphideta = dphideta/sumpt;
192 double detavar = deta2-deta1*deta1;
193 double dphivar = dphi2-dphi1*dphi1;
194 double dphidetacov = dphideta - deta1*dphi1;
196 double det = (detavar-dphivar)*(detavar-dphivar)+4*dphidetacov*dphidetacov;
198 double x1 = (detavar+dphivar+det)/2.;
199 double x2 = (detavar+dphivar-det)/2.;
204 ffrac01 = ffrac01/(*jet).energy();
205 ffrac02 = ffrac02/(*jet).energy();
206 ffrac03 = ffrac03/(*jet).energy();
207 ffrac04 = ffrac04/(*jet).energy();
208 ffrac05 = ffrac05/(*jet).energy();
211 std::cout<<
" ncalo "<<ncalotowers<<
" deta2 "<<deta2<<
" dphi2 "<<dphi2<<
" deta1 "<<deta1<<
" dphi1 "<<dphi1<<
" detavar "<<detavar<<
" dphivar "<<dphivar<<
" dphidetacov "<<dphidetacov<<
" sqrt(det) "<<
sqrt(det)<<
" x1 "<<x1<<
" x2 "<<x2<<std::endl;
221 double dphidetatr=0.;
226 if ((*it)->pt() > 0.5 && ((*it)->ptError()/(*it)->pt()) < 0.05 )
229 sumpttr = sumpttr + (*it)->pt();
230 double deta=(*jet).eta()-(*it)->eta();
231 double dphi=(*jet).phi()-(*it)->phi();
233 if(dphi >
M_PI ) dphi = dphi-2.*
M_PI;
234 if(dphi < -1.*
M_PI ) dphi = dphi+2.*
M_PI;
236 dphitr2 = dphitr2 + dphi*dphi*(*it)->pt();
237 detatr2 = detatr2 + deta*deta*(*it)->pt();
238 dphitr1 = dphitr1 + dphi*(*it)->pt();
239 detatr1 = detatr1 + deta*(*it)->pt();
240 dphidetatr = dphidetatr + dphi*deta*(*it)->pt();
241 if(
verbosity>0)
std::cout<<
" Tracks-in-in "<<(*it)->pt()<<
" "<<(*it)->eta()<<
" "<<(*it)->phi()<<
" in jet "<<(*jet).eta()<<
" "<<
242 (*jet).phi()<<
" jet pt "<<(*jet).pt()<<std::endl;
250 if ((*it)->pt() > 0.5 && ((*it)->ptError()/(*it)->pt()) < 0.05 )
253 sumpttr = sumpttr + (*it)->pt();
254 double deta=(*jet).eta()-(*it)->eta();
255 double dphi=(*jet).phi()-(*it)->phi();
257 if(dphi >
M_PI ) dphi = dphi-2.*
M_PI;
258 if(dphi < -1.*
M_PI ) dphi = dphi+2.*
M_PI;
260 dphitr2 = dphitr2 + dphi*dphi*(*it)->pt();
261 detatr2 = detatr2 + deta*deta*(*it)->pt();
262 dphitr1 = dphitr1 + dphi*(*it)->pt();
263 detatr1 = detatr1 + deta*(*it)->pt();
264 dphidetatr = dphidetatr + dphi*deta*(*it)->pt();
265 if(
verbosity>0)
std::cout<<
" Tracks-in-in "<<(*it)->pt()<<
" "<<(*it)->eta()<<
" "<<(*it)->phi()<<
" in jet "<<(*jet).eta()<<
" "<<
266 (*jet).phi()<<
" jet pt "<<(*jet).pt()<<std::endl;
274 detatr1 = detatr1/sumpttr;
275 dphitr1 = dphitr1/sumpttr;
276 detatr2 = detatr2/sumpttr;
277 dphitr2 = dphitr2/sumpttr;
278 dphidetatr = dphidetatr/sumpttr;
283 double detavart = detatr2-detatr1*detatr1;
284 double dphivart = dphitr2-dphitr1*dphitr1;
285 double dphidetacovt = dphidetatr - detatr1*dphitr1;
287 double dettr = (detavart-dphivart)*(detavart-dphivart)+4*dphidetacovt*dphidetacovt;
289 double x1tr = (detavart+dphivart+dettr)/2.;
290 double x2tr = (detavart+dphivart-dettr)/2.;
292 if (
verbosity > 0)
std::cout<<
" ntracks "<<ntracks<<
" detatr2 "<<detatr2<<
" dphitr2 "<<dphitr2<<
" detatr1 "<<detatr1<<
" dphitr1 "<<dphitr1<<
" detavart "<<detavart<<
" dphivart "<<dphivart<<
" dphidetacovt "<<dphidetacovt<<
" sqrt(det) "<<
sqrt(dettr)<<
" x1tr "<<x1tr<<
" x2tr "<<x2tr<<std::endl;
297 Beta = (*jet).getSpecific().Zch;
302 MultCalo = ncalotowers;
307 mva_ = reader_->EvaluateMVA(
"BDTG method" );
310 mva_ = readerF_->EvaluateMVA(
"BDTG method" );
T getParameter(std::string const &) const
Jets made from CaloTowers.
const edm::RefToBase< reco::Jet > & getCaloJetRef() const
const_iterator end() const
Termination of iteration.
virtual std::vector< CaloTowerPtr > getCaloConstituents() const
get all constituents
const_iterator begin() const
Initialize an iterator over the RefVector.
Jets made from CaloJets corrected for ZSP and tracks.
Abs< T >::type abs(const T &t)
size_type size() const
Size of the RefVector.
std::string fullPath() const
void loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)