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;
138 std::vector <CaloTowerPtr> calotwrs = (*rawcalojet).getCaloConstituents();
142 for(std::vector <CaloTowerPtr>::const_iterator icalot = calotwrs.begin();
143 icalot!= calotwrs.end(); icalot++) {
146 double deta=(*jet).eta()-(*icalot)->eta();
147 double dphi=(*jet).phi()-(*icalot)->phi();
149 if(dphi >
M_PI ) dphi = dphi-2.*
M_PI;
150 if(dphi < -1.*
M_PI ) dphi = dphi+2.*
M_PI;
152 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;
155 if(
abs((*icalot)->ieta())<30) EE = EE + (*icalot)->emEnergy();
156 if(
abs((*icalot)->ieta())<30) HE = HE + (*icalot)->hadEnergy();
157 if(
abs((*icalot)->ieta())>29) EELong = EELong + (*icalot)->emEnergy();
158 if(
abs((*icalot)->ieta())>29) EEShort = EEShort + (*icalot)->hadEnergy();
160 sumpt = sumpt + (*icalot)->pt();
161 dphi2 = dphi2 + dphi*dphi*(*icalot)->pt();
162 deta2 = deta2 + deta*deta*(*icalot)->pt();
163 dphi1 = dphi1 + dphi*(*icalot)->pt();
164 deta1 = deta1 + deta*(*icalot)->pt();
165 dphideta = dphideta + dphi*deta*(*icalot)->pt();
175 dphideta = dphideta/sumpt;
180 double detavar = deta2-deta1*deta1;
181 double dphivar = dphi2-dphi1*dphi1;
182 double dphidetacov = dphideta - deta1*dphi1;
184 double det = (detavar-dphivar)*(detavar-dphivar)+4*dphidetacov*dphidetacov;
186 double x1 = (detavar+dphivar+det)/2.;
187 double x2 = (detavar+dphivar-det)/2.;
192 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;
202 double dphidetatr=0.;
207 if ((*it)->pt() > 0.5 && ((*it)->ptError()/(*it)->pt()) < 0.05 )
210 sumpttr = sumpttr + (*it)->pt();
211 double deta=(*jet).eta()-(*it)->eta();
212 double dphi=(*jet).phi()-(*it)->phi();
214 if(dphi >
M_PI ) dphi = dphi-2.*
M_PI;
215 if(dphi < -1.*
M_PI ) dphi = dphi+2.*
M_PI;
217 dphitr2 = dphitr2 + dphi*dphi*(*it)->pt();
218 detatr2 = detatr2 + deta*deta*(*it)->pt();
219 dphitr1 = dphitr1 + dphi*(*it)->pt();
220 detatr1 = detatr1 + deta*(*it)->pt();
221 dphidetatr = dphidetatr + dphi*deta*(*it)->pt();
222 if(
verbosity>0)
std::cout<<
" Tracks-in-in "<<(*it)->pt()<<
" "<<(*it)->eta()<<
" "<<(*it)->phi()<<
" in jet "<<(*jet).eta()<<
" "<<
223 (*jet).phi()<<
" jet pt "<<(*jet).pt()<<std::endl;
231 if ((*it)->pt() > 0.5 && ((*it)->ptError()/(*it)->pt()) < 0.05 )
234 sumpttr = sumpttr + (*it)->pt();
235 double deta=(*jet).eta()-(*it)->eta();
236 double dphi=(*jet).phi()-(*it)->phi();
238 if(dphi >
M_PI ) dphi = dphi-2.*
M_PI;
239 if(dphi < -1.*
M_PI ) dphi = dphi+2.*
M_PI;
241 dphitr2 = dphitr2 + dphi*dphi*(*it)->pt();
242 detatr2 = detatr2 + deta*deta*(*it)->pt();
243 dphitr1 = dphitr1 + dphi*(*it)->pt();
244 detatr1 = detatr1 + deta*(*it)->pt();
245 dphidetatr = dphidetatr + dphi*deta*(*it)->pt();
246 if(
verbosity>0)
std::cout<<
" Tracks-in-in "<<(*it)->pt()<<
" "<<(*it)->eta()<<
" "<<(*it)->phi()<<
" in jet "<<(*jet).eta()<<
" "<<
247 (*jet).phi()<<
" jet pt "<<(*jet).pt()<<std::endl;
255 detatr1 = detatr1/sumpttr;
256 dphitr1 = dphitr1/sumpttr;
257 detatr2 = detatr2/sumpttr;
258 dphitr2 = dphitr2/sumpttr;
259 dphidetatr = dphidetatr/sumpttr;
264 double detavart = detatr2-detatr1*detatr1;
265 double dphivart = dphitr2-dphitr1*dphitr1;
266 double dphidetacovt = dphidetatr - detatr1*dphitr1;
268 double dettr = (detavart-dphivart)*(detavart-dphivart)+4*dphidetacovt*dphidetacovt;
270 double x1tr = (detavart+dphivart+dettr)/2.;
271 double x2tr = (detavart+dphivart-dettr)/2.;
273 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;
278 Beta = (*jet).getSpecific().Zch;
283 MultCalo = ncalotowers;
288 mva_ = reader_->EvaluateMVA(
"BDTG method" );
291 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.
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)
Namespace of DDCMS conversion namespace.
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
size_type size() const
Size of the RefVector.
std::string fullPath() const