CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
JetCorrectorDemo Class Reference
Inheritance diagram for JetCorrectorDemo:
edm::EDAnalyzer

Public Types

typedef
reco::Particle::LorentzVector 
LorentzVector
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 

Public Member Functions

 JetCorrectorDemo (const edm::ParameterSet &)
 
 ~JetCorrectorDemo ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 

Private Attributes

edm::Service< TFileServicefs
 
bool mDebug
 
double mEtaMax
 
double mEtaMin
 
TH2F * mJECvsEta
 
TH2F * mJECvsPt
 
std::string mJetCorService
 
int mNGraphPoints
 
int mNHistoPoints
 
std::string mPayloadName
 
double mPtMax
 
double mPtMin
 
TRandom * mRandom
 
TGraph * mUncCorPt [100]
 
std::string mUncertaintyFile
 
std::string mUncertaintyTag
 
TGraph * mUncEta [100]
 
bool mUseCondDB
 
std::vector< double > mVEta
 
TGraphErrors * mVGraphCorPt [100]
 
TGraphErrors * mVGraphEta [100]
 
TGraphErrors * mVGraphPt [100]
 
std::vector< double > mVPt
 
double veta [100][1000]
 
double vex_eta [100][1000]
 
double vex_pt [100][1000]
 
double vjec_eta [100][1000]
 
double vjec_pt [100][1000]
 
double vjecUnc_eta [100][1000]
 
double vjecUnc_pt [100][1000]
 
double vpt [100][1000]
 
double vptcor [100][1000]
 
double vUnc_eta [100][1000]
 
double vUnc_pt [100][1000]
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 28 of file JetCorrectorDemo.cc.

Member Typedef Documentation

Definition at line 32 of file JetCorrectorDemo.cc.

Constructor & Destructor Documentation

JetCorrectorDemo::JetCorrectorDemo ( const edm::ParameterSet iConfig)
explicit

Definition at line 56 of file JetCorrectorDemo.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mDebug, mEtaMax, mEtaMin, mJetCorService, mNGraphPoints, mNHistoPoints, mPayloadName, mPtMax, mPtMin, mUncertaintyFile, mUncertaintyTag, mUseCondDB, mVEta, and mVPt.

57 {
58  mJetCorService = iConfig.getParameter<std::string> ("JetCorrectionService");
59  mPayloadName = iConfig.getParameter<std::string> ("PayloadName");
60  mUncertaintyTag = iConfig.getParameter<std::string> ("UncertaintyTag");
61  mUncertaintyFile = iConfig.getParameter<std::string> ("UncertaintyFile");
62  mNHistoPoints = iConfig.getParameter<int> ("NHistoPoints");
63  mNGraphPoints = iConfig.getParameter<int> ("NGraphPoints");
64  mEtaMin = iConfig.getParameter<double> ("EtaMin");
65  mEtaMax = iConfig.getParameter<double> ("EtaMax");
66  mPtMin = iConfig.getParameter<double> ("PtMin");
67  mPtMax = iConfig.getParameter<double> ("PtMax");
68  mVEta = iConfig.getParameter<std::vector<double> > ("VEta");
69  mVPt = iConfig.getParameter<std::vector<double> > ("VPt");
70  mDebug = iConfig.getUntrackedParameter<bool> ("Debug",false);
71  mUseCondDB = iConfig.getUntrackedParameter<bool> ("UseCondDB",false);
72 }
std::string mPayloadName
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > mVEta
std::string mJetCorService
std::string mUncertaintyTag
std::string mUncertaintyFile
std::vector< double > mVPt
JetCorrectorDemo::~JetCorrectorDemo ( )

Definition at line 74 of file JetCorrectorDemo.cc.

75 {
76 
77 }

Member Function Documentation

void JetCorrectorDemo::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 79 of file JetCorrectorDemo.cc.

References JetCorrector::correction(), gather_cfg::cout, alignCSCRings::e, eta(), edm::FileInPath::fullPath(), edm::EventSetup::get(), JetCorrector::getJetCorrector(), JetCorrectionUncertainty::getUncertainty(), i, patTestJEC_cfi::jec, mDebug, mEtaMax, mEtaMin, mJECvsEta, mJECvsPt, mJetCorService, mNGraphPoints, mNHistoPoints, mPayloadName, mPtMax, mPtMin, mRandom, mUncertaintyFile, mUncertaintyTag, mUseCondDB, mVEta, mVPt, funct::pow(), JetCorrectionUncertainty::setJetEta(), JetCorrectionUncertainty::setJetPt(), tmp, veta, vex_eta, vex_pt, vjec_eta, vjec_pt, vjecUnc_eta, vjecUnc_pt, vpt, vptcor, vUnc_eta, and vUnc_pt.

80 {
82  JetCorrectionUncertainty *jecUnc(0);
83  if (mUncertaintyTag != "")
84  {
85  if (mUseCondDB)
86  {
88  iSetup.get<JetCorrectionsRecord>().get(mPayloadName,JetCorParColl);
89  JetCorrectorParameters const & JetCorPar = (*JetCorParColl)[mUncertaintyTag];
90  jecUnc = new JetCorrectionUncertainty(JetCorPar);
91  std::cout<<"Configured Uncertainty from CondDB"<<std::endl;
92  }
93  else
94  {
95  edm::FileInPath fip("CondFormats/JetMETObjects/data/"+mUncertaintyFile+".txt");
96  jecUnc = new JetCorrectionUncertainty(fip.fullPath());
97  }
98  }
99  double jec,rawPt,corPt,eta,unc;
100  TLorentzVector P4;
101  double dEta = (mEtaMax-mEtaMin)/mNGraphPoints;
102  for(int i=0;i<mNHistoPoints;i++)
103  {
104  rawPt = mRandom->Uniform(mPtMin,mPtMax);
105  eta = mRandom->Uniform(mEtaMin,mEtaMax);
106  P4.SetPtEtaPhiE(rawPt,eta,0,0);
107  LorentzVector rawP4(P4.Px(),P4.Py(),P4.Pz(),P4.E());
108  jec = corrector->correction(rawP4);
109  mJECvsEta->Fill(eta,jec);
110  mJECvsPt->Fill(rawPt,jec);
111  }
112  //--------- Pt Graphs ------------------
113  for(unsigned ieta=0;ieta<mVEta.size();ieta++)
114  {
115  double rPt = pow((3500./TMath::CosH(mVEta[ieta]))/mPtMin,1./mNGraphPoints);
116  for(int i=0;i<mNGraphPoints;i++)
117  {
118  rawPt = mPtMin*pow(rPt,i);
119  eta = mVEta[ieta];
120  vpt[ieta][i] = rawPt;
121  P4.SetPtEtaPhiE(rawPt,eta,0,0);
122  LorentzVector rawP4(P4.Px(),P4.Py(),P4.Pz(),P4.E());
123  jec = corrector->correction(rawP4);// the jec is a function of the raw pt
124  vjec_eta[ieta][i] = jec;
125  vptcor[ieta][i] = rawPt*jec;
126  unc = 0.0;
127  if (mUncertaintyTag != "")
128  {
129  jecUnc->setJetEta(eta);
130  jecUnc->setJetPt(rawPt*jec);// the uncertainty is a function of the corrected pt
131  unc = jecUnc->getUncertainty(true);
132  }
133  vjecUnc_eta[ieta][i] = unc*jec;
134  vUnc_eta[ieta][i] = unc;
135  vex_eta[ieta][i] = 0.0;
136  if (mDebug)
137  std::cout<<rawPt<<" "<<eta<<" "<<jec<<" "<<rawPt*jec<<" "<<unc<<std::endl;
138  }
139  }
140  //--------- Eta Graphs -------------------
141  for(unsigned ipt=0;ipt<mVPt.size();ipt++)
142  {
143  for(int i=0;i<mNGraphPoints;i++)
144  {
145  eta = mEtaMin + i*dEta;
146  corPt = mVPt[ipt];
147  veta[ipt][i] = eta;
148  //---------- find the raw pt -----------
149  double e = 1.0;
150  int nLoop(0);
151  rawPt = corPt;
152  while(e > 0.0001 && nLoop < 10)
153  {
154  P4.SetPtEtaPhiE(rawPt,eta,0,0);
155  LorentzVector rawP4(P4.Px(),P4.Py(),P4.Pz(),P4.E());
156  jec = corrector->correction(rawP4);
157  double tmp = rawPt * jec;
158  e = fabs(tmp-corPt)/corPt;
159  if (jec > 0)
160  rawPt = corPt/jec;
161  nLoop++;
162  }
163  //--------- calculate the jec for the rawPt --------
164  P4.SetPtEtaPhiE(rawPt,eta,0,0);
165  LorentzVector rawP4(P4.Px(),P4.Py(),P4.Pz(),P4.E());
166  jec = corrector->correction(rawP4);// the jec is a function of the raw pt
167  vjec_pt[ipt][i] = jec;
168  unc = 0.0;
169  if (mUncertaintyTag != "")
170  {
171  jecUnc->setJetEta(eta);
172  jecUnc->setJetPt(corPt);// the uncertainty is a function of the corrected pt
173  unc = jecUnc->getUncertainty(true);
174  }
175  vjecUnc_pt[ipt][i] = unc*jec;
176  vUnc_pt[ipt][i] = unc;
177  vex_pt[ipt][i] = 0.0;
178  if (mDebug)
179  std::cout<<rawPt<<" "<<eta<<" "<<jec<<" "<<rawPt*jec<<" "<<unc<<std::endl;
180  }
181  }
182 
183 }
double vptcor[100][1000]
double vex_pt[100][1000]
double veta[100][1000]
std::string mPayloadName
int i
Definition: DBlmapReader.cc:9
std::vector< double > mVEta
virtual double correction(const LorentzVector &fJet) const =0
get correction using Jet information only
double vjec_pt[100][1000]
math::XYZTLorentzVector LorentzVector
std::string mJetCorService
std::string mUncertaintyTag
double vUnc_eta[100][1000]
T eta() const
double vex_eta[100][1000]
std::string mUncertaintyFile
double vjecUnc_eta[100][1000]
double vpt[100][1000]
double vjec_eta[100][1000]
const T & get() const
Definition: EventSetup.h:55
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
Definition: JetCorrector.cc:51
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::vector< double > mVPt
tuple cout
Definition: gather_cfg.py:121
double vjecUnc_pt[100][1000]
double vUnc_pt[100][1000]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void JetCorrectorDemo::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 185 of file JetCorrectorDemo.cc.

References edm::hlt::Exception, fs, TFileDirectory::make(), mEtaMax, mEtaMin, mJECvsEta, mJECvsPt, mNGraphPoints, mPtMax, mPtMin, mRandom, mVEta, and mVPt.

186 {
187  if (mNGraphPoints > 1000)
188  throw cms::Exception("JetCorrectorDemo","Too many graph points !!! Maximum is 1000 !!!");
189  if (mVEta.size() > 100)
190  throw cms::Exception("JetCorrectorDemo","Too many eta values !!! Maximum is 100 !!!");
191  if (mVPt.size() > 100)
192  throw cms::Exception("JetCorrectorDemo","Too many pt values !!! Maximum is 100 !!!");
193  mJECvsEta = fs->make<TH2F>("JECvsEta","JECvsEta",200,mEtaMin,mEtaMax,100,0,5);
194  mJECvsPt = fs->make<TH2F>("JECvsPt","JECvsPt",200,mPtMin,mPtMax,100,0,5);
195  mRandom = new TRandom();
196  mRandom->SetSeed(0);
197 }
std::vector< double > mVEta
edm::Service< TFileService > fs
std::vector< double > mVPt
T * make() const
make new ROOT object
void JetCorrectorDemo::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 199 of file JetCorrectorDemo.cc.

References fs, TFileDirectory::make(), mNGraphPoints, mUncCorPt, mUncEta, mVEta, mVGraphCorPt, mVGraphEta, mVGraphPt, mVPt, mergeVDriftHistosByStation::name, veta, vex_eta, vex_pt, vjec_eta, vjec_pt, vjecUnc_eta, vjecUnc_pt, vpt, vptcor, vUnc_eta, and vUnc_pt.

200 {
201  char name[1000];
202  for(unsigned ipt=0;ipt<mVPt.size();ipt++)
203  {
204  mVGraphEta[ipt] = fs->make<TGraphErrors>(mNGraphPoints,veta[ipt],vjec_pt[ipt],vex_pt[ipt],vjecUnc_pt[ipt]);
205  sprintf(name,"JEC_vs_Eta_CorPt%1.1f",mVPt[ipt]);
206  mVGraphEta[ipt]->SetName(name);
207  mUncEta[ipt] = fs->make<TGraph>(mNGraphPoints,veta[ipt],vUnc_pt[ipt]);
208  sprintf(name,"UNC_vs_Eta_CorPt%1.1f",mVPt[ipt]);
209  mUncEta[ipt]->SetName(name);
210  }
211  for(unsigned ieta=0;ieta<mVEta.size();ieta++)
212  {
213  mVGraphPt[ieta] = fs->make<TGraphErrors>(mNGraphPoints,vpt[ieta],vjec_eta[ieta],vex_eta[ieta],vjecUnc_eta[ieta]);
214  sprintf(name,"JEC_vs_RawPt_eta%1.1f",mVEta[ieta]);
215  mVGraphPt[ieta]->SetName(name);
216  mVGraphCorPt[ieta] = fs->make<TGraphErrors>(mNGraphPoints,vptcor[ieta],vjec_eta[ieta],vex_eta[ieta],vjecUnc_eta[ieta]);
217  sprintf(name,"JEC_vs_CorPt_eta%1.1f",mVEta[ieta]);
218  mVGraphCorPt[ieta]->SetName(name);
219  mUncCorPt[ieta] = fs->make<TGraph>(mNGraphPoints,vptcor[ieta],vUnc_eta[ieta]);
220  sprintf(name,"UNC_vs_CorPt_eta%1.1f",mVEta[ieta]);
221  mUncCorPt[ieta]->SetName(name);
222  }
223 }
double vptcor[100][1000]
double vex_pt[100][1000]
double veta[100][1000]
std::vector< double > mVEta
edm::Service< TFileService > fs
TGraph * mUncEta[100]
double vjec_pt[100][1000]
double vUnc_eta[100][1000]
TGraph * mUncCorPt[100]
TGraphErrors * mVGraphPt[100]
TGraphErrors * mVGraphCorPt[100]
double vex_eta[100][1000]
double vjecUnc_eta[100][1000]
double vpt[100][1000]
double vjec_eta[100][1000]
std::vector< double > mVPt
T * make() const
make new ROOT object
double vjecUnc_pt[100][1000]
double vUnc_pt[100][1000]
TGraphErrors * mVGraphEta[100]

Member Data Documentation

edm::Service<TFileService> JetCorrectorDemo::fs
private

Definition at line 46 of file JetCorrectorDemo.cc.

Referenced by beginJob(), and endJob().

bool JetCorrectorDemo::mDebug
private

Definition at line 40 of file JetCorrectorDemo.cc.

Referenced by analyze(), and JetCorrectorDemo().

double JetCorrectorDemo::mEtaMax
private

Definition at line 42 of file JetCorrectorDemo.cc.

Referenced by analyze(), beginJob(), and JetCorrectorDemo().

double JetCorrectorDemo::mEtaMin
private

Definition at line 42 of file JetCorrectorDemo.cc.

Referenced by analyze(), beginJob(), and JetCorrectorDemo().

TH2F* JetCorrectorDemo::mJECvsEta
private

Definition at line 47 of file JetCorrectorDemo.cc.

Referenced by analyze(), and beginJob().

TH2F * JetCorrectorDemo::mJECvsPt
private

Definition at line 47 of file JetCorrectorDemo.cc.

Referenced by analyze(), and beginJob().

std::string JetCorrectorDemo::mJetCorService
private

Definition at line 39 of file JetCorrectorDemo.cc.

Referenced by analyze(), and JetCorrectorDemo().

int JetCorrectorDemo::mNGraphPoints
private

Definition at line 41 of file JetCorrectorDemo.cc.

Referenced by analyze(), beginJob(), endJob(), and JetCorrectorDemo().

int JetCorrectorDemo::mNHistoPoints
private

Definition at line 41 of file JetCorrectorDemo.cc.

Referenced by analyze(), and JetCorrectorDemo().

std::string JetCorrectorDemo::mPayloadName
private

Definition at line 39 of file JetCorrectorDemo.cc.

Referenced by analyze(), and JetCorrectorDemo().

double JetCorrectorDemo::mPtMax
private

Definition at line 42 of file JetCorrectorDemo.cc.

Referenced by analyze(), beginJob(), and JetCorrectorDemo().

double JetCorrectorDemo::mPtMin
private

Definition at line 42 of file JetCorrectorDemo.cc.

Referenced by analyze(), beginJob(), and JetCorrectorDemo().

TRandom* JetCorrectorDemo::mRandom
private

Definition at line 50 of file JetCorrectorDemo.cc.

Referenced by analyze(), and beginJob().

TGraph * JetCorrectorDemo::mUncCorPt[100]
private

Definition at line 49 of file JetCorrectorDemo.cc.

Referenced by endJob().

std::string JetCorrectorDemo::mUncertaintyFile
private

Definition at line 39 of file JetCorrectorDemo.cc.

Referenced by analyze(), and JetCorrectorDemo().

std::string JetCorrectorDemo::mUncertaintyTag
private

Definition at line 39 of file JetCorrectorDemo.cc.

Referenced by analyze(), and JetCorrectorDemo().

TGraph* JetCorrectorDemo::mUncEta[100]
private

Definition at line 49 of file JetCorrectorDemo.cc.

Referenced by endJob().

bool JetCorrectorDemo::mUseCondDB
private

Definition at line 40 of file JetCorrectorDemo.cc.

Referenced by analyze(), and JetCorrectorDemo().

std::vector<double> JetCorrectorDemo::mVEta
private

Definition at line 43 of file JetCorrectorDemo.cc.

Referenced by analyze(), beginJob(), endJob(), and JetCorrectorDemo().

TGraphErrors * JetCorrectorDemo::mVGraphCorPt[100]
private

Definition at line 48 of file JetCorrectorDemo.cc.

Referenced by endJob().

TGraphErrors* JetCorrectorDemo::mVGraphEta[100]
private

Definition at line 48 of file JetCorrectorDemo.cc.

Referenced by endJob().

TGraphErrors * JetCorrectorDemo::mVGraphPt[100]
private

Definition at line 48 of file JetCorrectorDemo.cc.

Referenced by endJob().

std::vector<double> JetCorrectorDemo::mVPt
private

Definition at line 43 of file JetCorrectorDemo.cc.

Referenced by analyze(), beginJob(), endJob(), and JetCorrectorDemo().

double JetCorrectorDemo::veta[100][1000]
private

Definition at line 44 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().

double JetCorrectorDemo::vex_eta[100][1000]
private

Definition at line 45 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().

double JetCorrectorDemo::vex_pt[100][1000]
private

Definition at line 45 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().

double JetCorrectorDemo::vjec_eta[100][1000]
private

Definition at line 44 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().

double JetCorrectorDemo::vjec_pt[100][1000]
private

Definition at line 44 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().

double JetCorrectorDemo::vjecUnc_eta[100][1000]
private

Definition at line 45 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().

double JetCorrectorDemo::vjecUnc_pt[100][1000]
private

Definition at line 45 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().

double JetCorrectorDemo::vpt[100][1000]
private

Definition at line 44 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().

double JetCorrectorDemo::vptcor[100][1000]
private

Definition at line 44 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().

double JetCorrectorDemo::vUnc_eta[100][1000]
private

Definition at line 45 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().

double JetCorrectorDemo::vUnc_pt[100][1000]
private

Definition at line 45 of file JetCorrectorDemo.cc.

Referenced by analyze(), and endJob().