00001
00002
00003
00004
00005 #include <iostream>
00006 #include <sstream>
00007 #include <istream>
00008 #include <fstream>
00009 #include <iomanip>
00010 #include <string>
00011 #include <cmath>
00012 #include <functional>
00013
00014 #include "SimJetResponseAnalysis.h"
00015
00016
00017 #include "FWCore/Framework/interface/Event.h"
00018 #include "DataFormats/Common/interface/Handle.h"
00019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00020 #include "FWCore/Framework/interface/EventSetup.h"
00021 #include "FWCore/Framework/interface/ESHandle.h"
00022 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00023
00024 #include "DataFormats/JetReco/interface/CaloJet.h"
00025 #include "DataFormats/METReco/interface/CaloMET.h"
00026 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00027 #include "DataFormats/JetReco/interface/GenJet.h"
00028 #include "DataFormats/METReco/interface/GenMET.h"
00029 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00030
00031
00032 #include "CaloTowerBoundriesMC.h"
00033 #include "JetUtilMC.h"
00034
00035 typedef CaloJetCollection::const_iterator CalJetIter;
00036 typedef GenJetCollection::const_iterator GenJetIter;
00037
00038 void GetMPV(TH1* h,double& mean,double& width,double& error);
00039
00040 SimJetResponseAnalysis::SimJetResponseAnalysis(edm::ParameterSet const& cfg) {
00041
00042
00043
00044 MatchRadius_ = 0.2;
00045 RecJetPtMin_ = 5.;
00046 NJetMax_ = 2;
00047
00048 genjets_ = cfg.getParameter<std::string> ("genjets");
00049 recjets_ = cfg.getParameter<std::string> ("recjets");
00050 genmet_ = cfg.getParameter<std::string> ("genmet");
00051 recmet_ = cfg.getParameter<std::string> ("recmet");
00052
00053 NJetMax_ = cfg.getParameter<int> ("NJetMax");
00054 MatchRadius_ =cfg.getParameter<double> ("MatchRadius");
00055 RecJetPtMin_ =cfg.getParameter<double> ("RecJetPtMin");
00056 GenJetPtBins_ =cfg.getParameter< std::vector<double> >("GenJetPtBins");
00057 std::vector<double> EtaBins =cfg.getParameter< std::vector<double> >("RecJetEtaBins");
00058
00059 int nb=EtaBins.size();
00060 for(int i=nb;i>1;i--){RecJetEtaBins_.push_back(-1.0*EtaBins[i-1]);}
00061 for(int i=0;i<nb;i++){RecJetEtaBins_.push_back(EtaBins[i]);}
00062
00063 histogramFile_= cfg.getParameter<std::string> ("HistogramFile"),
00064
00065 hist_file_=new TFile(histogramFile_.c_str(),"RECREATE");
00066
00067 NPtBins = GenJetPtBins_.size()-1;
00068 NEtaBins = RecJetEtaBins_.size()-1;
00069
00070 bookHistograms();
00071
00072 }
00073 void SimJetResponseAnalysis::endJob() {
00074 done();
00075 }
00076
00077 void SimJetResponseAnalysis::analyze(edm::Event const& event, edm::EventSetup const& iSetup) {
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 edm::Handle<GenJetCollection> genjets;
00090 edm::Handle<CaloJetCollection> recjets;
00091 edm::Handle<GenMETCollection> genmet;
00092 edm::Handle<CaloMETCollection> recmet;
00093
00094 event.getByLabel (genjets_,genjets);
00095 event.getByLabel (recjets_,recjets);
00096 event.getByLabel (genmet_,genmet);
00097 event.getByLabel (recmet_,recmet);
00098
00099 analyze(*genjets,*recjets,*genmet,*recmet);
00100 }
00101
00102
00103 SimJetResponseAnalysis::SimJetResponseAnalysis() {
00104 hist_file_=0;
00105 }
00106
00108 void SimJetResponseAnalysis::fillHist1D(const TString& histName,const Double_t& value, const Double_t& wt) {
00109
00110 std::map<TString, TH1*>::iterator hid=m_HistNames1D.find(histName);
00111 if (hid==m_HistNames1D.end()){
00112 std::cout << "%fillHist -- Could not find histogram with name: " << histName << std::endl;
00113 }
00114 else{
00115 hid->second->Fill(value,wt);
00116 }
00117 }
00119
00120 void SimJetResponseAnalysis::fillHist2D(const TString& histName, const Double_t& x,const Double_t& y,const Double_t& wt) {
00121
00122 std::map<TString, TH2*>::iterator hid=m_HistNames2D.find(histName);
00123 if (hid==m_HistNames2D.end()){
00124
00125 }
00126 else {
00127 hid->second->Fill(x,y,wt);
00128 }
00129 }
00130
00132 void SimJetResponseAnalysis::bookHistograms() {
00133
00134 bookGeneralHistograms();
00135 bookJetHistograms("Gen");
00136 bookJetHistograms("Calo");
00137 bookMetHists("Gen");
00138 bookMetHists("Calo");
00139 bookSimJetResponse();
00140
00141
00142
00143 }
00144
00145
00146 void SimJetResponseAnalysis::analyze(const GenJetCollection& genjets,const CaloJetCollection& calojets,
00147 const GenMETCollection& genmets,const CaloMETCollection& recmets){
00148 fillJetHists(genjets,"Gen");
00149 fillJetHists(calojets,"Calo");
00150 fillMetHists(genmets,"Gen");
00151 fillMetHists(recmets,"Calo");
00152
00153 SimulatedJetResponse(genjets,calojets);
00154 }
00155
00157 void SimJetResponseAnalysis::bookGeneralHistograms() {
00158
00159 TString hname;
00160 TString htitle;
00161
00162 hname= "nevents";
00163
00164 m_HistNames1D[hname] = new TH1F(hname,hname,20,0.0,20.0);
00165 m_HistNames1D[hname]->GetXaxis()->SetBinLabel(1,"Total");
00166 m_HistNames1D[hname]->GetXaxis()->SetBinLabel(2,"TwoJets");
00167 m_HistNames1D[hname]->GetXaxis()->SetBinLabel(3,"Central");
00168 m_HistNames1D[hname]->GetXaxis()->SetBinLabel(4,"AvePt");
00169 m_HistNames1D[hname]->GetXaxis()->SetBinLabel(5,"DeltaPhi");
00170 m_HistNames1D[hname]->GetXaxis()->SetBinLabel(6,"ThirdJet");
00171
00172 m_HistNames1D[hname]->GetXaxis()->SetBinLabel(7,"CentralTrig0");
00173 m_HistNames1D[hname]->GetXaxis()->SetBinLabel(8,"CentralTrig1");
00174
00175
00176 }
00177
00179
00180 void SimJetResponseAnalysis::bookJetHistograms(const TString& prefix) {
00181
00182 TString hname;
00183 TString htitle;
00184
00185 hname=prefix + "NumberOfJet";
00186 htitle=hname;
00187 m_HistNames1D[hname] = new TH1F(hname,htitle,100,-.0,100.0);
00188
00189 for(int i=0; i<5; i++) {
00190 std::ostringstream oi; oi << i;
00191 hname=prefix + "PhiJet"+oi.str();
00192 htitle=hname;
00193 m_HistNames1D[hname] = new TH1F(hname,htitle,72,-M_PI,M_PI);
00194
00195 hname=prefix + "EtJet"+oi.str();
00196 m_HistNames1D[hname]= new TH1F(hname,hname,500,0.0,5000.);
00197 hname=prefix + "PtJet"+oi.str();
00198 m_HistNames1D[hname]= new TH1F(hname,hname,500,0.0,5000.);
00199
00200 hname=prefix + "RapidityJet"+oi.str();
00201 m_HistNames1D[hname] = new TH1F(hname,hname,100,-5.0,5.0);
00202 }
00203 }
00204
00206
00207 template <typename T> void SimJetResponseAnalysis::fillJetHists(const T& jets, const TString& prefix) {
00208
00209 typedef typename T::const_iterator iter;
00210 TString hname;
00211
00212 int NumOfJets=jets.size();
00213
00214 hname=prefix + "NumberOfJet";
00215 fillHist1D(hname,NumOfJets);
00216
00217 int ijet(0);
00218
00219 for ( iter i=jets.begin(); i!=jets.end(); i++) {
00220
00221
00222 if(ijet>4) break;
00223
00224 Double_t jetRapidity = i->y();
00225 Double_t jetPt = i->pt();
00226 Double_t jetEt = i->et();
00227 Double_t jetPhi = i->phi();
00228
00229 std::ostringstream oi; oi << ijet;
00230
00231 hname=prefix + "PhiJet"+oi.str();
00232 fillHist1D(hname,jetPhi);
00233 hname=prefix + "RapidityJet"+oi.str();
00234 fillHist1D(hname,jetRapidity);
00235 hname=prefix + "PtJet"+oi.str();
00236 fillHist1D(hname,jetPt);
00237
00238 hname=prefix + "EtJet"+oi.str();
00239 fillHist1D(hname,jetEt);
00240
00241 ijet++;
00242 }
00243 }
00244
00245 void SimJetResponseAnalysis::bookMetHists(const TString& prefix) {
00246
00247 TString hname;
00248 TString htitle;
00249
00250 hname =prefix+"NumberOfMetObjects";
00251 htitle =prefix+"Number of MET objects";
00252 m_HistNames1D[hname] = new TH1I(hname,htitle,10,0.,10.);
00253
00254 hname=prefix+"etMiss";
00255 htitle=prefix+" Missing Et";
00256 m_HistNames1D[hname] = new TH1F(hname,htitle,100,0.0,100.);
00257
00258 hname=prefix+"etMissX";
00259 htitle=prefix+" Missing Et-X";
00260 m_HistNames1D[hname] = new TH1F(hname,htitle,200,-100.0,100.);
00261
00262 hname=prefix+"etMissPhi";
00263 htitle=prefix+" Phi of Missing Et";
00264 m_HistNames1D[hname] = new TH1F(hname,htitle,100,-M_PI,M_PI);
00265
00266 hname=prefix+"sumEt";
00267 htitle=prefix+" Sum Et";
00268 m_HistNames1D[hname] = new TH1F(hname,htitle,1400,0.0,14000.);
00269 }
00270
00272 template <typename T> void SimJetResponseAnalysis::fillMetHists(const T& mets, const TString& prefix) {
00273
00274 Int_t NumMet=mets.size();
00275 TString hname;
00276 hname=prefix + "NumberOfMetObjects";
00277 fillHist1D(hname,NumMet);
00278
00279 typedef typename T::const_iterator iter;
00280 for ( iter met=mets.begin(); met!=mets.end(); met++) {
00281 Double_t mEt=met->et();
00282 Double_t sumEt=met->sumEt();
00283 Double_t mEtPhi=met->phi();
00284 Double_t mEtX=met->px();
00285
00286 fillHist1D(prefix+"etMiss",mEt);
00287 fillHist1D(prefix + "sumEt",sumEt);
00288 fillHist1D(prefix + "etMissX",mEtX);
00289 fillHist1D(prefix + "etMissPhi",mEtPhi);
00290 }
00291 }
00292
00294 void SimJetResponseAnalysis::done() {
00295
00296 if (hist_file_!=0) {
00297 GetSimJetResponse();
00298 hist_file_->Write();
00299
00300 delete hist_file_;
00301 hist_file_=0;
00302 }
00303 }
00304
00305 void SimJetResponseAnalysis::bookSimJetResponse() {
00306
00307 TString hname;
00308 TString htitle;
00309
00310 for(int ip=0;ip<NPtBins;ip++){
00311 std::ostringstream oip; oip << GenJetPtBins_[ip];
00312
00313 int nBinPt(100);
00314 double PtMinBin=0.0;
00315 double PtMaxBin=7000.0;
00316
00317 if(GenJetPtBins_[ip+1]<200){
00318 nBinPt=400;
00319 PtMaxBin=400.;
00320 }
00321 else if(GenJetPtBins_[ip+1]<1000){
00322 nBinPt=400;
00323 PtMaxBin=2000.;
00324 }
00325 else {
00326 nBinPt=500;
00327 PtMaxBin=10000.;
00328 }
00329
00330 for(int ie=0;ie<NEtaBins;ie++){
00331
00332
00333 std::ostringstream oie; oie << ie;
00334 hname="JetResponsePt"+oip.str()+"Eta"+oie.str();
00335 htitle="JetResponsePt"+oip.str()+"Eta"+oie.str();
00336 m_HistNames1D[hname] = new TH1F(hname,htitle,100,0.,2.0);
00337
00338 hname="RminPt"+oip.str()+"Eta"+oie.str();
00339 htitle="Rmin"+oip.str()+"_"+oie.str();
00340
00341 m_HistNames1D[hname] = new TH1F(hname,htitle,100,0.,2.0);
00342
00343 hname="PtGenJetPt"+oip.str()+"Eta"+oie.str();
00344 htitle="PtGenJetPt"+oip.str()+"Eta"+oie.str();
00345 m_HistNames1D[hname] = new TH1F(hname,htitle,nBinPt,PtMinBin,PtMaxBin);
00346
00347 hname="PtCaloJetPt"+oip.str()+"Eta"+oie.str();
00348 htitle="PtCaloJetPt"+oip.str()+"Eta"+oie.str();
00349 m_HistNames1D[hname] = new TH1F(hname,htitle,nBinPt,PtMinBin,PtMaxBin);
00350
00351 hname="EtaGenJetPt"+oip.str()+"Eta"+oie.str();
00352 htitle="EtaGenJetPt"+oip.str()+"Eta"+oie.str();
00353 m_HistNames1D[hname] = new TH1F(hname,htitle,82,CaloTowerEtaBoundries);
00354
00355 hname="EtaCaloJetPt"+oip.str()+"Eta"+oie.str();
00356 htitle="EtaCaloJetPt"+oip.str()+"Eta"+oie.str();
00357 m_HistNames1D[hname] = new TH1F(hname,htitle,82,CaloTowerEtaBoundries);
00358
00359
00360
00361
00362
00363 hname="JetResponseEt"+oip.str()+"Eta"+oie.str();
00364 htitle="JetResponseEt"+oip.str()+"Eta"+oie.str();
00365 m_HistNames1D[hname] = new TH1F(hname,htitle,100,0.,2.0);
00366
00367 hname="RminEt"+oip.str()+"Eta"+oie.str();
00368 htitle="Rmin"+oip.str()+"_"+oie.str();
00369
00370 m_HistNames1D[hname] = new TH1F(hname,htitle,100,0.,2.0);
00371
00372 hname="EtGenJetEt"+oip.str()+"Eta"+oie.str();
00373 htitle="EtGenJetEt"+oip.str()+"Eta"+oie.str();
00374 m_HistNames1D[hname] = new TH1F(hname,htitle,nBinPt,PtMinBin,PtMaxBin);
00375
00376 hname="EtCaloJetEt"+oip.str()+"Eta"+oie.str();
00377 htitle="EtCaloJetEt"+oip.str()+"Eta"+oie.str();
00378 m_HistNames1D[hname] = new TH1F(hname,htitle,nBinPt,PtMinBin,PtMaxBin);
00379
00380 hname="EtaGenJetEt"+oip.str()+"Eta"+oie.str();
00381 htitle="EtaGenJetEt"+oip.str()+"Eta"+oie.str();
00382 m_HistNames1D[hname] = new TH1F(hname,htitle,82,CaloTowerEtaBoundries);
00383
00384 hname="EtaCaloJetEt"+oip.str()+"Eta"+oie.str();
00385 htitle="EtaCaloJetEt"+oip.str()+"Eta"+oie.str();
00386 m_HistNames1D[hname] = new TH1F(hname,htitle,82,CaloTowerEtaBoundries);
00387
00388 }
00389
00390
00391
00392
00393 for(int it=0; it<NETA; it++){
00394 std::ostringstream oit; oit << it;
00395 hname="JetResponsePt"+oip.str()+"Tower"+oit.str();
00396 htitle="JetResponsePt"+oip.str()+"Tower"+oit.str();
00397 m_HistNames1D[hname] = new TH1F(hname,htitle,100,0.,2.0);
00398
00399 hname="EtaCaloJetPt"+oip.str()+"Tower"+oit.str();
00400 htitle="EtaCaloJetPt"+oip.str()+"Tower"+oit.str();
00401 m_HistNames1D[hname] = new TH1F(hname,htitle,82,CaloTowerEtaBoundries);
00402
00403
00404 hname="EtaGenJetPt"+oip.str()+"Tower"+oit.str();
00405 htitle="EtaGenJetPt"+oip.str()+"Tower"+oit.str();
00406 m_HistNames1D[hname] = new TH1F(hname,htitle,82,CaloTowerEtaBoundries);
00407
00408 hname="PtGenJetPt"+oip.str()+"Tower"+oit.str();
00409 htitle="PtGenJetPt"+oip.str()+"Tower"+oit.str();
00410 m_HistNames1D[hname] = new TH1F(hname,htitle,nBinPt,PtMinBin,PtMaxBin);
00411
00412 hname="PtCaloJetPt"+oip.str()+"Tower"+oit.str();
00413 htitle="PtCaloJetPt"+oip.str()+"Tower"+oit.str();
00414 m_HistNames1D[hname] = new TH1F(hname,htitle,nBinPt,PtMinBin,PtMaxBin);
00415
00416 }
00417 }
00418
00419 for(int ip=0;ip<NPtBins;ip++){
00420 std::ostringstream oip; oip << GenJetPtBins_[ip];
00421 hname="ResponseVsEtaMean"+oip.str();
00422 htitle="ResponseVsEtaMean"+oip.str();
00423 m_HistNames1D[hname] = new TH1F(hname,htitle,82,CaloTowerEtaBoundries);
00424
00425 hname="ResponseVsEtaMPV"+oip.str();
00426 htitle="ResponseVsEtaMPV"+oip.str();
00427 m_HistNames1D[hname] = new TH1F(hname,htitle,82,CaloTowerEtaBoundries);
00428 }
00429 }
00430 int SimJetResponseAnalysis::GetPtBin(double GenJetPt){
00431 for(int ip=0;ip<NPtBins;ip++){
00432 if(GenJetPtBins_[ip] <GenJetPt && GenJetPt < GenJetPtBins_[ip+1] ){
00433 return ip;
00434 }
00435 }
00436 return 0;
00437 }
00438 int SimJetResponseAnalysis::TowerNumber(double eta){
00439 for(int i=0;i<NETA;i++){
00440 if(CaloTowerEtaBoundries[i]<eta && eta<=CaloTowerEtaBoundries[i+1]){
00441 return i;
00442 }
00443 }
00444 return 0;
00445 }
00446 int SimJetResponseAnalysis::GetEtaBin(double eta){
00447 for(int ie=0;ie<NEtaBins;ie++){
00448 if(eta>= RecJetEtaBins_[ie] && eta< RecJetEtaBins_[ie+1]){
00449 return ie;
00450 }
00451 }
00452 return 0;
00453 }
00454
00455 void SimJetResponseAnalysis::SimulatedJetResponse(const GenJetCollection& genjets,const CaloJetCollection& calojets){
00456
00457 if(genjets.size()==0) return;
00458 if(calojets.size()==0) return;
00459
00460 const double GenJetEtaMax=5.5;
00461
00462 double GenJetPtMin=GenJetPtBins_[0];
00463
00464 TString hname;
00465
00466 int njet(0);
00467
00468 for(GenJetIter i=genjets.begin();i!=genjets.end(); i++) {
00469 njet++;
00470 if(njet>NJetMax_) return;
00471 Double_t GenJetPt = i->pt();
00472 Double_t GenJetEt = i->et();
00473 Double_t GenJetEta = i->eta();
00474 if(GenJetPt>GenJetPtMin) {
00475 if(fabs(GenJetEta)<GenJetEtaMax){
00476 float rmin(99);
00477 CalJetIter caljet;
00478 for(CalJetIter j=calojets.begin();j!=calojets.end();j++){
00479 float rr=radius(i,j);
00480 if(rr<rmin){rmin=rr;caljet=j;}
00481 }
00482
00483 double CaloJetPt=caljet->pt();
00484 double CaloJetEt=caljet->et();
00485 double CaloJetEta=caljet->eta();
00486 double ResponsePt=CaloJetPt/GenJetPt;
00487 double ResponseEt=CaloJetEt/GenJetEt;
00488
00489 if(CaloJetPt<RecJetPtMin_) continue;
00490
00491 int ipt = GetPtBin(GenJetPt);
00492 int iet = GetPtBin(GenJetEt);
00493 int ie = GetEtaBin(CaloJetEta);
00494 int it = TowerNumber(CaloJetEta);
00495 std::ostringstream oipt; oipt << GenJetPtBins_[ipt];
00496 std::ostringstream oiet; oiet << GenJetPtBins_[iet];
00497
00498 std::ostringstream oie; oie <<ie;
00499 std::ostringstream oit; oit << it;
00500
00501 hname="RminPt"+oipt.str()+"Eta"+oie.str();
00502 fillHist1D(hname,rmin);
00503 if(rmin<MatchRadius_){
00504
00505 hname="JetResponsePt"+oipt.str()+"Eta"+oie.str();
00506 fillHist1D(hname,ResponsePt);
00507
00508 hname="EtaGenJetPt"+oipt.str()+"Eta"+oie.str();
00509 fillHist1D(hname,GenJetEta);
00510
00511 hname="PtGenJetPt"+oipt.str()+"Eta"+oie.str();
00512 fillHist1D(hname,GenJetPt);
00513
00514 hname="PtCaloJetPt"+oipt.str()+"Eta"+oie.str();
00515 fillHist1D(hname,CaloJetPt);
00516
00517 hname="EtaCaloJetPt"+oipt.str()+"Eta"+oie.str();
00518 fillHist1D(hname,CaloJetEta);
00519
00520
00521
00522 hname="JetResponseEt"+oiet.str()+"Eta"+oie.str();
00523 fillHist1D(hname,ResponseEt);
00524
00525 hname="EtaGenJetEt"+oiet.str()+"Eta"+oie.str();
00526 fillHist1D(hname,GenJetEta);
00527
00528 hname="EtGenJetEt"+oiet.str()+"Eta"+oie.str();
00529 fillHist1D(hname,GenJetEt);
00530
00531 hname="EtCaloJetEt"+oiet.str()+"Eta"+oie.str();
00532 fillHist1D(hname,CaloJetEt);
00533
00534 hname="EtaCaloJetEt"+oiet.str()+"Eta"+oie.str();
00535 fillHist1D(hname,CaloJetEta);
00536
00537
00538
00539 hname="JetResponsePt"+oipt.str()+"Tower"+oit.str();
00540 fillHist1D(hname,ResponsePt);
00541
00542 hname="EtaCaloJetPt"+oipt.str()+"Tower"+oit.str();
00543 fillHist1D(hname,CaloJetEta);
00544
00545 hname="EtaGenJetPt"+oipt.str()+"Tower"+oit.str();
00546 fillHist1D(hname,GenJetEta);
00547
00548 hname="PtGenJetPt"+oipt.str()+"Tower"+oit.str();
00549 fillHist1D(hname,GenJetPt);
00550
00551 hname="PtCaloJetPt"+oipt.str()+"Tower"+oit.str();
00552 fillHist1D(hname,CaloJetPt);
00553 }
00554 }
00555 }
00556 }
00557 }
00558
00559 void GetMPV(TH1* h,double& mean,double& width,double& error) {
00560
00561 mean=0.0;
00562 width=0.0;
00563 error=0.0;
00564 Double_t nevents=h->GetEntries();
00565 if(nevents<1) return;
00566
00567 h->SetNormFactor(1.0);
00568
00569
00570
00571
00572
00573
00574 Double_t gausmean=h->GetMean();
00575 Double_t gauswidth=h->GetRMS();
00576 Double_t norm=1.0;
00577
00578 TF1 *g = new TF1("g","gaus(0)",gausmean-2.0*gauswidth,gausmean+2.0*gauswidth);
00579 g->SetParLimits(0,0.0,2.0);
00580 g->SetParameter(0,norm);
00581 g->SetParameter(1,gausmean);
00582 g->SetParameter(2,gauswidth);
00583 h->Fit(g,"RQN");
00584
00585 norm=g->GetParameter(0);
00586 gausmean=g->GetParameter(1);
00587 gauswidth=g->GetParameter(2);
00588
00589 g->SetRange(gausmean-1.0*gauswidth,gausmean+1.0*gauswidth);
00590 g->SetParameter(0,norm);
00591 g->SetParameter(1,gausmean);
00592 g->SetParameter(2,gauswidth);
00593 h->Fit(g,"RQN");
00594
00595 norm=g->GetParameter(0);
00596 gausmean=g->GetParameter(1);
00597 gauswidth=g->GetParameter(2);
00598
00599 g->SetRange(gausmean-1.0*gauswidth,gausmean+1.0*gauswidth);
00600 g->SetParameter(0,norm);
00601 g->SetParameter(1,gausmean);
00602 g->SetParameter(2,gauswidth);
00603 h->Fit(g,"RQ");
00604
00605 mean=g->GetParameter(1);
00606 width=g->GetParameter(2);
00607 error=width/sqrt(nevents);
00608
00609 }
00610
00611 void SimJetResponseAnalysis::GetSimJetResponse(){
00612
00613 TString hname;
00614
00615 std::map<TString, TH1*>::iterator h1D;
00616
00617 const int MinimumEvents=25;
00618
00619 for(int ip=0;ip<NPtBins;ip++){
00620 std::ostringstream oip; oip << GenJetPtBins_[ip];
00621
00622
00623 std::vector<double> x(NETA);
00624 std::vector<double> y(NETA);
00625 std::vector<double> n(NETA);
00626 std::vector<double> m(NETA);
00627 std::vector<double> e(NETA);
00628
00629 std::vector<double> fittedMean(NETA);
00630 std::vector<double> fittedWidth(NETA);
00631 std::vector<double> fittedError(NETA);
00632
00633 std::vector<double> neve(NETA);
00634 std::vector<double> ex(NETA);
00635 std::vector<double> ey(NETA);
00636
00637 int np=0;
00638 for(int it=0; it<NETA; it++){
00639 x[np] = (CaloTowerEtaBoundries[it]+CaloTowerEtaBoundries[it+1])/2.0;
00640 std::ostringstream oit; oit << it;
00641 hname="JetResponsePt"+oip.str()+"Tower"+oit.str();
00642 h1D=m_HistNames1D.find(hname);
00643
00644 if(h1D!=m_HistNames1D.end()){
00645 int nevents = int(h1D->second->GetEntries());
00646 n[it] = nevents;
00647
00648 if(nevents>MinimumEvents){
00649 m[it] = h1D->second->GetMean();
00650 e[it] = h1D->second->GetRMS()/sqrt(n[it]);
00651 GetMPV(h1D->second,fittedMean[it],fittedWidth[it],fittedError[it]);
00652
00653 }
00654 else{
00655 m[it] =0.0;
00656 e[it] = 0.0;
00657 fittedMean[it] =0.0;
00658 fittedWidth[it] =0.0;
00659 fittedError[it] =0.0;
00660 }
00661 }
00662 else {
00663
00664 }
00665
00666 }
00667
00668 hname="ResponseVsEtaMean"+oip.str();
00669 h1D=m_HistNames1D.find(hname);
00670
00671 for(int i=0;i<NETA;i++){
00672 h1D->second->SetBinContent(i,m[i]);
00673 h1D->second->SetBinError(i,e[i]);
00674 }
00675
00676 hname="ResponseVsEtaMPV"+oip.str();
00677 h1D=m_HistNames1D.find(hname);
00678
00679 for(int i=0;i<NETA;i++){
00680 h1D->second->SetBinContent(i,fittedMean[i]);
00681 h1D->second->SetBinError(i,fittedError[i]);
00682 }
00683 }
00684 }
00685
00686
00687 #include "FWCore/PluginManager/interface/ModuleDef.h"
00688 #include "FWCore/Framework/interface/MakerMacros.h"
00689
00690 DEFINE_FWK_MODULE(SimJetResponseAnalysis);