27 #include "TDirectory.h" 32 #include <Math/VectorUtil.h> 76 usesResource(
"TFileService");
108 std::vector<reco::Particle *> p4gen, p4rec;
113 if (
genEvt->particles().size() < 10)
121 for (
size_t p = 0;
p <
genEvt->particles().size();
p++) {
132 for (
size_t m = 0;
m <
muons->size();
m++) {
133 for (
size_t p = 0;
p <
genEvt->particles().size();
p++) {
144 if (
jets->size() >= 4) {
145 for (
unsigned int j = 0;
j < 4;
j++) {
146 for (
size_t p = 0;
p <
genEvt->particles().size();
p++) {
158 if (
jets->size() >= 4) {
159 for (
unsigned int j = 0;
j < 4;
j++) {
160 for (
size_t p = 0;
p <
genEvt->particles().size();
p++) {
172 if (!
mets->empty()) {
173 if (
genEvt->isSemiLeptonic() &&
genEvt->singleNeutrino() !=
nullptr &&
182 for (std::vector<pat::Tau>::const_iterator
tau =
taus->begin();
tau !=
taus->end(); ++
tau) {
195 for (
unsigned m = 0;
m < p4gen.size();
m++) {
196 double Egen = p4gen[
m]->
energy();
197 double Thetagen = p4gen[
m]->theta();
198 double Phigen = p4gen[
m]->phi();
199 double Etgen = p4gen[
m]->et();
200 double Etagen = p4gen[
m]->eta();
201 double Ecal = p4rec[
m]->energy();
202 double Thetacal = p4rec[
m]->theta();
203 double Phical = p4rec[
m]->phi();
204 double Etcal = p4rec[
m]->et();
205 double Etacal = p4rec[
m]->eta();
206 double phidiff = Phical - Phigen;
238 ROOT::Math::SVector<double, 3> pcalvec(p4rec[
m]->
px(), p4rec[
m]->
py(), p4rec[
m]->pz());
239 ROOT::Math::SVector<double, 3> pgenvec(p4gen[
m]->
px(), p4gen[
m]->
py(), p4gen[
m]->pz());
241 ROOT::Math::SVector<double, 3> u_z(0, 0, 1);
242 ROOT::Math::SVector<double, 3> u_1 = ROOT::Math::Unit(pcalvec);
243 ROOT::Math::SVector<double, 3> u_3 = ROOT::Math::Cross(u_z, u_1) / ROOT::Math::Mag(ROOT::Math::Cross(u_z, u_1));
244 ROOT::Math::SVector<double, 3> u_2 = ROOT::Math::Cross(u_1, u_3) / ROOT::Math::Mag(ROOT::Math::Cross(u_1, u_3));
249 double agen = ROOT::Math::Dot(pgenvec, u_1) / ROOT::Math::Mag(pcalvec);
250 double bgen = ROOT::Math::Dot(pgenvec, u_2);
251 double cgen = ROOT::Math::Dot(pgenvec, u_3);
252 double dgen = Egen / Ecal;
260 hResPtEtaBin[4][etabin][ptbin]->Fill(Thetacal - Thetagen);
277 TString resObsName[8] = {
"_ares",
"_bres",
"_cres",
"_dres",
"_thres",
"_phres",
"_etres",
"_etares"};
278 int resObsNrBins = 120;
281 std::vector<double> resObsMin, resObsMax;
283 resObsMin.push_back(-0.15);
284 resObsMin.push_back(-0.2);
285 resObsMin.push_back(-0.1);
286 resObsMin.push_back(-0.15);
287 resObsMin.push_back(-0.0012);
288 resObsMin.push_back(-0.009);
289 resObsMin.push_back(-16);
290 resObsMin.push_back(-0.0012);
291 resObsMax.push_back(0.15);
292 resObsMax.push_back(0.2);
293 resObsMax.push_back(0.1);
294 resObsMax.push_back(0.15);
295 resObsMax.push_back(0.0012);
296 resObsMax.push_back(0.009);
297 resObsMax.push_back(16);
298 resObsMax.push_back(0.0012);
300 resObsMin.push_back(-0.15);
301 resObsMin.push_back(-0.1);
302 resObsMin.push_back(-0.05);
303 resObsMin.push_back(-0.15);
304 resObsMin.push_back(-0.004);
305 resObsMin.push_back(-0.003);
306 resObsMin.push_back(-8);
307 resObsMin.push_back(-0.004);
308 resObsMax.push_back(0.15);
309 resObsMax.push_back(0.1);
310 resObsMax.push_back(0.05);
311 resObsMax.push_back(0.15);
312 resObsMax.push_back(0.004);
313 resObsMax.push_back(0.003);
314 resObsMax.push_back(8);
315 resObsMax.push_back(0.004);
317 resObsMin.push_back(-1.);
318 resObsMin.push_back(-10.);
319 resObsMin.push_back(-10);
320 resObsMin.push_back(-1.);
321 resObsMin.push_back(-0.1);
322 resObsMin.push_back(-0.1);
323 resObsMin.push_back(-80);
324 resObsMin.push_back(-0.1);
325 resObsMax.push_back(1.);
326 resObsMax.push_back(10.);
327 resObsMax.push_back(10);
328 resObsMax.push_back(1.);
329 resObsMax.push_back(0.1);
330 resObsMax.push_back(0.1);
331 resObsMax.push_back(50);
332 resObsMax.push_back(0.1);
334 resObsMin.push_back(-1.);
335 resObsMin.push_back(-10.);
336 resObsMin.push_back(-10.);
337 resObsMin.push_back(-1.);
338 resObsMin.push_back(-0.4);
339 resObsMin.push_back(-0.6);
340 resObsMin.push_back(-80);
341 resObsMin.push_back(-0.6);
342 resObsMax.push_back(1.);
343 resObsMax.push_back(10.);
344 resObsMax.push_back(10.);
345 resObsMax.push_back(1.);
346 resObsMax.push_back(0.4);
347 resObsMax.push_back(0.6);
348 resObsMax.push_back(80);
349 resObsMax.push_back(0.6);
351 resObsMin.push_back(-2.);
352 resObsMin.push_back(-150.);
353 resObsMin.push_back(-150.);
354 resObsMin.push_back(-2.);
355 resObsMin.push_back(-6);
356 resObsMin.push_back(-6);
357 resObsMin.push_back(-180);
358 resObsMin.push_back(-6);
359 resObsMax.push_back(3.);
360 resObsMax.push_back(150.);
361 resObsMax.push_back(150.);
362 resObsMax.push_back(3.);
363 resObsMax.push_back(6);
364 resObsMax.push_back(6);
365 resObsMax.push_back(180);
366 resObsMax.push_back(6);
369 const char *resObsVsPtFit[8] = {
"[0]+[1]*exp(-[2]*x)",
370 "[0]+[1]*exp(-[2]*x)",
371 "[0]+[1]*exp(-[2]*x)",
372 "[0]+[1]*exp(-[2]*x)",
373 "[0]+[1]*exp(-[2]*x)",
374 "[0]+[1]*exp(-[2]*x)",
376 "[0]+[1]*exp(-[2]*x)"};
396 for (Int_t ro = 0; ro < 8; ro++) {
397 for (Int_t etab = 0; etab <
etanrbins; etab++) {
398 for (Int_t ptb = 0; ptb <
ptnrbins; ptb++) {
400 obsName += resObsName[ro];
401 obsName +=
"_etabin";
405 hResPtEtaBin[ro][etab][ptb] =
fs->make<TH1F>(obsName, obsName, resObsNrBins, resObsMin[ro], resObsMax[ro]);
406 fResPtEtaBin[ro][etab][ptb] =
fs->make<TF1>(
"F_" + obsName,
"gaus");
409 obsName2 += resObsName[ro];
410 obsName2 +=
"_etabin";
417 tResVar =
fs->make<TTree>(
"tResVar",
"Resolution tree");
425 TString resObsName2[8] = {
"a",
"b",
"c",
"d",
"theta",
"phi",
"et",
"eta"};
433 tResVar->Branch(
"ro", &ro,
"ro/I");
437 for (ro = 0; ro < 8; ro++) {
438 for (
int etab = 0; etab <
etanrbins; etab++) {
441 for (
int ptb = 0; ptb <
ptnrbins; ptb++) {
444 double maxcontent = 0.;
446 for (
int nb = 1; nb <
hResPtEtaBin[ro][etab][ptb]->GetNbinsX(); nb++) {
447 if (
hResPtEtaBin[ro][etab][ptb]->GetBinContent(nb) > maxcontent) {
448 maxcontent =
hResPtEtaBin[ro][etab][ptb]->GetBinContent(nb);
480 edm::LogProblem(
"SummaryError") <<
"No plots filled for light jets \n";
493 edm::LogVerbatim(
"MainResults") <<
" ----------------------------------------------";
494 edm::LogVerbatim(
"MainResults") <<
" ----------------------------------------------";
496 edm::LogVerbatim(
"MainResults") <<
" ----------------------------------------------";
497 edm::LogVerbatim(
"MainResults") <<
" ----------------------------------------------";
499 for (ro = 0; ro < 8; ro++) {
501 edm::LogVerbatim(
"MainResults") <<
"\n Resolutions on " << resObsName2[ro] <<
"\n";
503 for (
int etab = 0; etab <
etanrbins; etab++) {
508 <<
"+" <<
fResEtaBin[ro][etab]->GetParameter(1) <<
"*exp(-(" <<
fResEtaBin[ro][etab]->GetParameter(2)
512 <<
"else if(fabs(eta)<" <<
etabinVals_[etab + 1] <<
") res = " <<
fResEtaBin[ro][etab]->GetParameter(0)
513 <<
"+" <<
fResEtaBin[ro][etab]->GetParameter(1) <<
"*exp(-(" <<
fResEtaBin[ro][etab]->GetParameter(2)
516 }
else if (
nrFilled != 0 && ro == 6) {
520 <<
"+" <<
fResEtaBin[ro][etab]->GetParameter(1) <<
"*pt;";
523 <<
"else if(fabs(eta)<" <<
etabinVals_[etab + 1] <<
") res = " <<
fResEtaBin[ro][etab]->GetParameter(0)
524 <<
"+" <<
fResEtaBin[ro][etab]->GetParameter(1) <<
"*pt;";
530 for (ro = 0; ro < 8; ro++) {
532 edm::LogVerbatim(
"MainResults") <<
"\n Resolutions on " << resObsName2[ro] <<
"\n";
536 <<
fResEtaBin[ro][0]->GetParameter(1) <<
"*exp(-(" 537 <<
fResEtaBin[ro][0]->GetParameter(2) <<
"*pt));";
538 }
else if (
nrFilled != 0 && ro == 6) {
540 <<
fResEtaBin[ro][0]->GetParameter(1) <<
"*pt;";
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
int status() const final
status word
double phidiff(double phi)
Normalized difference in azimuthal angles to a range between .
edm::EDGetTokenT< TtGenEvent > genEvtToken_
size_t numberOfMothers() const override
number of mothers
const LorentzVector & p4() const final
four-momentum Lorentz vector
int pdgId() const final
PDG identifier.
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
edm::EDGetTokenT< std::vector< pat::Tau > > tausToken_
std::vector< double > etabinVals_
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
TH1F * hResEtaBin[10][20]
TF1 * fResPtEtaBin[10][20][20]
virtual int pdgId() const =0
PDG identifier.
TH1F * hResPtEtaBin[10][20][20]
void analyze(const edm::Event &, const edm::EventSetup &) override
ResolutionCreator(const edm::ParameterSet &)
edm::EDGetTokenT< std::vector< pat::Electron > > electronsToken_
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
std::vector< double > pTbinVals_
edm::EDGetTokenT< std::vector< pat::Muon > > muonsToken_
Log< level::Error, true > LogProblem
double energy() const final
energy