Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L1 prefiring weight producer #25380

Merged
merged 5 commits into from Jan 12, 2019
Merged

L1 prefiring weight producer #25380

merged 5 commits into from Jan 12, 2019

Conversation

lathomas
Copy link
Contributor

Dear CMSSW managers/PR reviewers,

This PR contains an EDProducer computing weights associated to the L1 ECAL prefiring issue that affected 2016 and 2017 data.
Since the effect is not present in MC, the proposed solution is to reweight simulations by those weights.
I add some links to documentation at the end of this post for more information.

The code is a producer returning three double (central, up/down weights). The code loops over all photons and jets found in the event and multiplies their prefiring probabilities.

I expect the PR to need a bit of iteration before being approved.
In particular, I would greatly appreciate your suggestions regarding the following points:

  • Can you please provide advise regarding the code location? I created a new package but it can/should maybe enter an already existing one?
  • The code relies on prefiring maps stored as TH2F in a root file. I'm not sure this is allowed... If not, can you suggest a proper format? (sorry for my ignorance).

Please let me know if anything else is unclear,

Thanks a lot,

Laurent

Documentation
-Talk at CMS week about prefiring:
https://indico.cern.ch/event/704625/contributions/3164334/attachments/1726987/2790093/prefiringupdateCMSweek.pdf
-Prefiring discussion at the XPOG forum:
https://indico.cern.ch/event/764279/
-Twiki describing how to run the producer:
https://twiki.cern.ch/twiki/bin/viewauth/CMS/L1ECALPrefiringWeightRecipe
-L1 prefiring maps per object:
https://lathomas.web.cern.ch/lathomas/TSGStuff/L1Prefiring/PrefiringMaps_2016and2017/
-Validation plots:
https://twiki.cern.ch/twiki/pub/CMS/L1ECALPrefiringWeightRecipe/prefiring_producervalidation.pdf

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@lathomas
Copy link
Contributor Author

@peruzzim @fgolf

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @lathomas for master.

It involves the following packages:

L1Prefiring/EventWeightProducer

The following packages do not have a category, yet:

L1Prefiring/EventWeightProducer
Please create a PR for https://github.com/cms-sw/cms-bot/blob/master/categories_map.py to assign category

@cmsbuild can you please review it and eventually sign? Thanks.
@davidlange6, @slava77, @fabiocos you are the release manager for this.

cms-bot commands are listed here

@peruzzim
Copy link
Contributor

If the review and backport to 10_2_X proceed in an expedite way, this could get into the next NanoAOD production, which would be very valuable.

for(int fluct = 0; fluct<3;fluct++) {
//Start by applying the prefiring maps to photons in the affected regions.
std::vector < pat::Photon > affectedphotons;
for( std::vector<pat::Photon>::const_iterator photon = (*thePhotons).begin(); photon != (*thePhotons).end(); photon++ ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be more cleanly/efficiently written as
for ( const auto & photon : *thePhotons ) {
double pt_gam = photon.pt();

etc

if( pt_gam < 20.) continue;
if( fabs(eta_gam) <2.) continue;
if( fabs(eta_gam) >3.) continue;
affectedphotons.push_back((*photon));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider storing a const & or just a vector of bools instead of copying the photon object here

@davidlange6
Copy link
Contributor

how big is the TH2F?

@davidlange6
Copy link
Contributor

probably PhysicsTools/PatUtils is a good home for this code

Copy link
Contributor

@peruzzim peruzzim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to speed up the review I give a few comments from a quick look at the code

if( pt_gam < 20.) continue;
if( fabs(eta_gam) <2.) continue;
if( fabs(eta_gam) >3.) continue;
affectedphotons.push_back((*photon));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to avoid copies by value here

edm::EDGetTokenT<std::vector< pat::Jet> > jets_token_;


TH2F * h_prefmap_photon;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this get deleted? should we use smart pointers?


TFile * file_prefiringmaps_;
std::string fname = iConfig.getParameter<std::string>( "L1Maps" );
file_prefiringmaps_ = new TFile( fname.c_str(),"read" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to use FileInPath to eventually read from different locations here

std::string fname = iConfig.getParameter<std::string>( "L1Maps" );
file_prefiringmaps_ = new TFile( fname.c_str(),"read" );
TString mapphotonfullname= "L1prefiring_photonptvseta_"+ dataera_;
h_prefmap_photon =(TH2F*) file_prefiringmaps_->Get(mapphotonfullname);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs protection/check if the file does not contain the histogram with that name

// virtual void beginJob();
//virtual void endJob(void);
void endStream() override;
virtual double GetPrefiringRate( double eta, double pt, TH2F * h_prefmap,/*std::string object, std::string dataera, */ int fluctuation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here it's probably cleaner to pass the enum type and not the int


}
//If overlapping photons have a non prefiring rate smaller than the jet, don't consider the jet in the event weight
else if(nonprefiringprobfromoverlappingphotons < nonprefiringprobfromoverlappingjet ) NonPrefiringProba[fluct]*=1.;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this line actually doing? (multiply by 1)


double L1ECALPrefiringWeightProducer::GetPrefiringRate( double eta, double pt, TH2F * h_prefmap /*std::string object, std::string dataera*/ , int fluctuation){

if(h_prefmap==nullptr) return 0.;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is dangerous as it fails silently in case of a configuration mistake

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@lathomas
Copy link
Contributor Author

@peruzzim @davidlange6
I tried to address all your comments and moved the code to PhysicsTools/PatUtils.
The root file size is 15kB. Judging by the size of other files in PhysicsTools/PatUtils/data I assume this is fine (?)

Thanks !

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Pull request #25380 was updated. @perrotta, @cmsbuild, @santocch, @slava77 can you please check and sign again.

@perrotta
Copy link
Contributor

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Jan 10, 2019

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/32516/console Started: 2019/01/10 15:52

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Comparison job queued.

@cmsbuild
Copy link
Contributor

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-25380/32516/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 4 differences found in the comparisons
  • DQMHistoTests: Total files compared: 33
  • DQMHistoTests: Total histograms compared: 3153717
  • DQMHistoTests: Total failures: 1
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3153512
  • DQMHistoTests: Total skipped: 204
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 32 files compared)
  • Checked 137 log files, 14 edm output root files, 33 DQM output files

@perrotta
Copy link
Contributor

@lathomas : do you have an analyzer (which runs on nanoAOD, possibly) that consumes these weights? I.e. something obtained with https://twiki.cern.ch/twiki/bin/viewauth/CMS/L1ECALPrefiringWeightRecipe but avoiding me the need to recreate everything from scratch following that recipe.
Once I can verify that this PR can run correctly even after the last updates I will sign it.

@perrotta
Copy link
Contributor

+1

  • Already signed (see L1 prefiring weight producer  #25380 (comment)), then cfg fixed, rebased, and a few further adjustments were applied following the code review
  • This is an analysis tool not used by default in any official workflow, but meant for now to private analyses and eventually possibly also nanoAOD production
  • By following the recipe provided, it runs (I managed to do it on nanoAOD)
  • The code reflects what declared, and subsequent review comments
  • Jenkins tests pass and show no differences
  • Needed external got already merged in the master

@lathomas
Copy link
Contributor Author

@perrotta : thanks !

@fabiocos
Copy link
Contributor

+1

the configuration of the module has been properly adjusted, thanks

@fabiocos
Copy link
Contributor

merge

@cmsbuild cmsbuild merged commit 842f8a0 into cms-sw:master Jan 12, 2019
@lathomas
Copy link
Contributor Author

@fabiocos @perrotta @peruzzim
Thanks for the merging and for your help.
Can I proceed with the backport? What branches should I consider? I guess at least 94X is needed but are there others?

@perrotta
Copy link
Contributor

perrotta commented Jan 14, 2019 via email

@mrodozov
Copy link
Contributor

@perrotta @lathomas
cms-sw/cmsdist#4635
cms-sw/cmsdist#4636
are for 10_2 and 9_4

@perrotta
Copy link
Contributor

perrotta commented Jan 14, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants