27 #include "TDirectory.h" 32 #include <Math/VectorUtil.h> 46 virtual void endJob()
override ;
85 else if(objectType_ ==
"lJets" || objectType_ ==
"bJets")
jetsToken_ = consumes<std::vector<pat::Jet> >(
edm::InputTag(labelName_));
88 if(objectType_ !=
"met"){
114 std::vector<reco::Particle *> p4gen, p4rec;
119 if(genEvt->
particles().size()<10)
return;
124 for(
size_t e=0;
e<electrons->size();
e++) {
136 for(
size_t m=0;
m<muons->size();
m++) {
148 if(jets->size()>=4) {
149 for(
unsigned int j = 0;
j<4;
j++){
162 if(jets->size()>=4) {
163 for(
unsigned int j = 0;
j<4;
j++){
176 if(mets->size()>=1) {
186 for(std::vector<pat::Tau>::const_iterator
tau = taus->begin();
tau != taus->end(); ++
tau) {
201 for(
unsigned m=0;
m<p4gen.size();
m++){
202 double Egen = p4gen[
m]->
energy();
203 double Thetagen = p4gen[
m]->theta();
204 double Phigen = p4gen[
m]->phi();
205 double Etgen = p4gen[
m]->et();
206 double Etagen = p4gen[
m]->eta();
207 double Ecal = p4rec[
m]->energy();
208 double Thetacal = p4rec[
m]->theta();
209 double Phical = p4rec[
m]->phi();
210 double Etcal = p4rec[
m]->et();
211 double Etacal = p4rec[
m]->eta();
212 double phidiff = Phical- Phigen;
213 if(phidiff>3.14159) phidiff = 2.*3.14159 -
phidiff;
214 if(phidiff<-3.14159) phidiff = -phidiff - 2.*3.14159;
240 ROOT::Math::SVector<double,3> pcalvec(p4rec[
m]->px(),p4rec[
m]->py(),p4rec[
m]->pz());
241 ROOT::Math::SVector<double,3> pgenvec(p4gen[
m]->px(),p4gen[
m]->py(),p4gen[
m]->pz());
243 ROOT::Math::SVector<double,3> u_z(0,0,1);
244 ROOT::Math::SVector<double,3> u_1 = ROOT::Math::Unit(pcalvec);
245 ROOT::Math::SVector<double,3> u_3 = ROOT::Math::Cross(u_z,u_1)/ROOT::Math::Mag(ROOT::Math::Cross(u_z,u_1));
246 ROOT::Math::SVector<double,3> u_2 = ROOT::Math::Cross(u_1,u_3)/ROOT::Math::Mag(ROOT::Math::Cross(u_1,u_3));
251 double agen = ROOT::Math::Dot(pgenvec,u_1)/ROOT::Math::Mag(pcalvec);
252 double bgen = ROOT::Math::Dot(pgenvec,u_2);
253 double cgen = ROOT::Math::Dot(pgenvec,u_3);
254 double dgen = Egen/
Ecal;
282 TString resObsName[8] = {
"_ares",
"_bres",
"_cres",
"_dres",
"_thres",
"_phres",
"_etres",
"_etares"};
283 int resObsNrBins = 120;
285 std::vector<double> resObsMin, resObsMax;
287 resObsMin.push_back(-0.15); resObsMin.push_back(-0.2); resObsMin.push_back(-0.1); resObsMin.push_back(-0.15); resObsMin.push_back(-0.0012); resObsMin.push_back(-0.009); resObsMin.push_back(-16); resObsMin.push_back(-0.0012);
288 resObsMax.push_back( 0.15); resObsMax.push_back( 0.2); resObsMax.push_back( 0.1); resObsMax.push_back( 0.15); resObsMax.push_back( 0.0012); resObsMax.push_back( 0.009); resObsMax.push_back( 16); resObsMax.push_back( 0.0012);
290 resObsMin.push_back(-0.15); resObsMin.push_back(-0.1); resObsMin.push_back(-0.05); resObsMin.push_back(-0.15); resObsMin.push_back(-0.004); resObsMin.push_back(-0.003); resObsMin.push_back(-8); resObsMin.push_back(-0.004);
291 resObsMax.push_back( 0.15); resObsMax.push_back( 0.1); resObsMax.push_back( 0.05); resObsMax.push_back( 0.15); resObsMax.push_back( 0.004); resObsMax.push_back( 0.003); resObsMax.push_back( 8); resObsMax.push_back( 0.004);
293 resObsMin.push_back(-1.); resObsMin.push_back(-10.); resObsMin.push_back(-10); resObsMin.push_back(-1.); resObsMin.push_back(-0.1); resObsMin.push_back(-0.1); resObsMin.push_back(-80); resObsMin.push_back(-0.1);
294 resObsMax.push_back( 1.); resObsMax.push_back( 10.); resObsMax.push_back( 10); resObsMax.push_back( 1.); resObsMax.push_back( 0.1); resObsMax.push_back( 0.1); resObsMax.push_back( 50); resObsMax.push_back( 0.1);
296 resObsMin.push_back(-1.); resObsMin.push_back(-10.); resObsMin.push_back(-10.); resObsMin.push_back(-1.); resObsMin.push_back(-0.4); resObsMin.push_back(-0.6); resObsMin.push_back( -80); resObsMin.push_back(-0.6);
297 resObsMax.push_back( 1.); resObsMax.push_back( 10.); resObsMax.push_back( 10.); resObsMax.push_back( 1.); resObsMax.push_back( 0.4); resObsMax.push_back( 0.6); resObsMax.push_back( 80); resObsMax.push_back( 0.6);
299 resObsMin.push_back(-2.); resObsMin.push_back(-150.); resObsMin.push_back(-150.); resObsMin.push_back(-2.); resObsMin.push_back(-6); resObsMin.push_back(-6); resObsMin.push_back( -180); resObsMin.push_back(-6);
300 resObsMax.push_back( 3.); resObsMax.push_back( 150.); resObsMax.push_back( 150.); resObsMax.push_back( 3.); resObsMax.push_back( 6); resObsMax.push_back( 6); resObsMax.push_back( 180); resObsMax.push_back( 6);
303 const char* resObsVsPtFit[8] = {
"[0]+[1]*exp(-[2]*x)",
304 "[0]+[1]*exp(-[2]*x)",
305 "[0]+[1]*exp(-[2]*x)",
306 "[0]+[1]*exp(-[2]*x)",
307 "[0]+[1]*exp(-[2]*x)",
308 "[0]+[1]*exp(-[2]*x)",
310 "[0]+[1]*exp(-[2]*x)" 314 double *ptbins =
new double[
pTbinVals_.size()];
323 etabins =
new double[2];
324 etabins[0] = 0; etabins[1] = 5.;
329 for(Int_t ro=0; ro<8; ro++) {
330 for(Int_t etab=0; etab<
etanrbins; etab++) {
331 for(Int_t ptb=0; ptb<
ptnrbins; ptb++) {
332 TString obsName =
objectType_; obsName += resObsName[ro]; obsName +=
"_etabin"; obsName += etab; obsName +=
"_ptbin";
334 hResPtEtaBin[ro][etab][ptb] = fs->
make<TH1F>(obsName,obsName,resObsNrBins,resObsMin[ro],resObsMax[ro]);
337 TString obsName2 =
objectType_; obsName2 += resObsName[ro]; obsName2 +=
"_etabin"; obsName2 += etab;
339 fResEtaBin[ro][etab] = fs->
make<TF1>(
"F_"+obsName2,resObsVsPtFit[ro],
pTbinVals_[0],pTbinVals_[pTbinVals_.size()-1]);
342 tResVar = fs->
make< TTree >(
"tResVar",
"Resolution tree");
352 TString resObsName2[8] = {
"a",
"b",
"c",
"d",
"theta",
"phi",
"et",
"eta"};
358 tResVar->Branch(
"Pt",&pt,
"Pt/D");
359 tResVar->Branch(
"Eta",&eta,
"Eta/D");
360 tResVar->Branch(
"ro",&ro,
"ro/I");
361 tResVar->Branch(
"value",&value,
"value/D");
362 tResVar->Branch(
"error",&error,
"error/D");
364 for(ro=0; ro<8; ro++) {
365 for(
int etab=0; etab<
etanrbins; etab++) {
368 for(
int ptb=0; ptb<
ptnrbins; ptb++) {
371 double maxcontent = 0.;
373 for(
int nb=1; nb<
hResPtEtaBin[ro][etab][ptb]->GetNbinsX(); nb ++){
374 if (
hResPtEtaBin[ro][etab][ptb]->GetBinContent(nb)>maxcontent) {
375 maxcontent =
hResPtEtaBin[ro][etab][ptb]->GetBinContent(nb);
381 hResPtEtaBin[ro][etab][ptb]->GetBinCenter(maxbin+range));
411 edm::LogVerbatim (
"MainResults") <<
" ----------------------------------------------";
412 edm::LogVerbatim (
"MainResults") <<
" ----------------------------------------------";
414 edm::LogVerbatim (
"MainResults") <<
" ----------------------------------------------";
415 edm::LogVerbatim (
"MainResults") <<
" ----------------------------------------------";
417 for(ro=0; ro<8; ro++) {
419 edm::LogVerbatim (
"MainResults") <<
"\n Resolutions on " << resObsName2[ro] <<
"\n";
421 for(
int etab=0; etab<
etanrbins; etab++) {
422 if(nrFilled != 0 && ro != 6) {
426 <<
"*exp(-(" <<
fResEtaBin[ro][etab]->GetParameter(2) <<
"*pt));";
430 <<
"*exp(-(" <<
fResEtaBin[ro][etab]->GetParameter(2) <<
"*pt));";
432 }
else if(nrFilled != 0 && ro == 6){
447 for(ro=0; ro<8; ro++) {
449 edm::LogVerbatim (
"MainResults") <<
"\n Resolutions on " << resObsName2[ro] <<
"\n";
451 if(nrFilled != 0 && ro != 6) {
454 <<
"*exp(-(" <<
fResEtaBin[ro][0]->GetParameter(2) <<
"*pt));";
455 }
else if(nrFilled != 0 && ro == 6){
T getParameter(std::string const &) const
bool isSemiLeptonic(bool excludeTauLeptons=false) const
check if the event can be classified as semi-laptonic
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
virtual void endJob() override
virtual void beginJob() override
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
T * make(const Args &...args) const
make new ROOT object
virtual int status() const final
status word
double phidiff(double phi)
Normalized difference in azimuthal angles to a range between .
edm::EDGetTokenT< TtGenEvent > genEvtToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
edm::EDGetTokenT< std::vector< pat::Tau > > tausToken_
std::vector< double > etabinVals_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
virtual size_t numberOfMothers() const
number of mothers
virtual int pdgId() const =0
PDG identifier.
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
virtual int pdgId() const final
PDG identifier.
virtual double energy() const final
energy
Abs< T >::type abs(const T &t)
TH1F * hResEtaBin[10][20]
TF1 * fResPtEtaBin[10][20][20]
const reco::GenParticle * singleNeutrino(bool excludeTauLeptons=false) const
return single neutrino if available; 0 else
TH1F * hResPtEtaBin[10][20][20]
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
ResolutionCreator(const edm::ParameterSet &)
edm::EDGetTokenT< std::vector< pat::Electron > > electronsToken_
const reco::GenParticleCollection & particles() const
return particles of decay chain
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
std::vector< double > pTbinVals_
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
edm::EDGetTokenT< std::vector< pat::Muon > > muonsToken_