diff --git a/README.md b/README.md index d996e18..a479fb0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is a [NanoAOD](https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookNanoAOD) framework for advanced developments of jet algorithms. -The repository consists of multiple branches which are each dedicated to specific releases of [CMSSW](https://github.com/cms-sw/cmssw). If you came here to run over Run3 samples, please checkout the most up-to-date 12_4_8 branch (e.g. from the dropdown menu above). The master branch you are viewing right now is optimized to run over Run2 samples, using the 106X release cycle. +The repository consists of multiple branches which are each dedicated to specific releases of [CMSSW](https://github.com/cms-sw/cmssw). If you came here to run over Run3 samples, please checkout the most up-to-date 12_4_8 branch (e.g. from the dropdown menu above). The branch you are viewing right now is optimized to run over Run2 UL samples, using the 106X release cycle. The current full content of this development branch can be seen [here](https://annika-stein.web.cern.ch/PFNano/AddDeepJetTagInfo_desc.html) and the size [here](https://annika-stein.web.cern.ch/PFNano/AddDeepJetTagInfo_size.html). @@ -13,32 +13,52 @@ This format can be used with [fastjet](http://fastjet.fr) directly. **THIS IS A DEVELOPMENT BRANCH** -For **UL** 2016, 2017 and 2018 data and MC **NanoAODv8** according to the [XPOG](https://gitlab.cern.ch/cms-nanoAOD/nanoaod-doc/-/wikis/Releases/NanoAODv8) and [PPD](https://twiki.cern.ch/twiki/bin/view/CMS/PdmVRun2LegacyAnalysisSummaryTable) recommendations: +For **UL** 2016, 2017 and 2018 data and MC **NanoAODv8/v9** according to the [XPOG](https://gitlab.cern.ch/cms-nanoAOD/nanoaod-doc/-/wikis/home) and [PPD](https://twiki.cern.ch/twiki/bin/view/CMS/PdmVRun2LegacyAnalysisSummaryTable) recommendations: +### Prerequisites +If not already done in your `.bashrc` or similar: ``` -cmsrel CMSSW_10_6_20 # in principle not a constraint -cd CMSSW_10_6_20/src +source /cvmfs/grid.desy.de/etc/profile.d/grid-ui-env.sh or /cvmfs/grid.cern.ch/centos7-umd4-ui-4_200423/etc/profile.d/setup-c7-ui-example.sh +source /cvmfs/cms.cern.ch/common/crab-setup.sh prod +source /cvmfs/cms.cern.ch/cmsset_default.sh +``` +### Setup PFNano +``` +cmsrel CMSSW_10_6_30 +cd CMSSW_10_6_30/src cmsenv -git cms-rebase-topic andrzejnovak:614nosort -git clone https://github.com/cms-jet/PFNano.git PhysicsTools/PFNano +git clone https://github.com/AnnikaStein/PFNano.git PhysicsTools/PFNano #change once it's officially included: git clone https://github.com/cms-jet/PFNano.git PhysicsTools/PFNano +cd PhysicsTools/PFNano +git fetch +git switch ParT_106X +cd ../.. scram b -j 10 cd PhysicsTools/PFNano/test +voms-proxy-init --voms cms:/cms/dcms --valid 192:00 # cms:/cms/dcms if you have a German grid certificate, prio to run at German sites; use cms only otherwise ``` Note: When running over a new dataset you should check with [the nanoAOD workbook twiki](https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookNanoAOD#Running_on_various_datasets_from) to see if the era modifiers in the CRAB configuration files are correct. The jet correction versions are taken from the global tag. ## Local Usage: -There are python config files ready to run in `PhysicsTools/PFNano/test/` for the UL campaign of nanoAODv8, named `nano106Xv8_on_mini106X_201*_data_NANO.py`. Notice that the current version can create different types of files depending on the PF candidates content. +There are python config files ready to run in `PhysicsTools/PFNano/test/` for the UL campaign of nanoAODv8(v9), named `nano106Xv8_on_mini106X_201*_data_NANO.py` (`nano_data_2017_ULv2_allPF_ParT_NANO.py`, similar for MC). Notice that the current version can create different types of files depending on the PF candidates content. Run a configuration via `cmsRun nano_data_2017_ULv2_allPF_ParT_NANO.py` to test on one file locally. If that works, configure your crab submission (more below). + +### Different use cases: -New since Pull Request [#39](https://github.com/cms-jet/PFNano/pull/39): Examples to include or exclude the input features for the DeepJet tagger are given in `nano106Xv8_on_mini106X_2017_mc_NANO.py`. Now the list of options that are currently implemented inside `pfnano_cff.py` (e.g. for MC) looks like that: +New since December 2022: Particle Transformer inputs. Particle Transformer variables can be added by specifying one of the suiting customizations `*add_DeepJet_ParT*`. + +Now the list of options that are currently implemented inside `pfnano_cff.py` (e.g. for MC) looks like that: ``` process = PFnano_customizeMC(process) #process = PFnano_customizeMC_add_DeepJet(process) ##### DeepJet inputs are added to the Jet collection -#process = PFnano_customizeMC_allPF(process) ##### PFcands will content ALL the PF Cands -#process = PFnano_customizeMC_allPF_add_DeepJet(process) ##### PFcands will content ALL the PF Cands; + DeepJet inputs for Jets -#process = PFnano_customizeMC_AK4JetsOnly(process) ##### PFcands will content only the AK4 jets PF cands -#process = PFnano_customizeMC_AK4JetsOnly_add_DeepJet(process) ##### PFcands will content only the AK4 jets PF cands; + DeepJet inputs for Jets -#process = PFnano_customizeMC_AK8JetsOnly(process) ##### PFcands will content only the AK8 jets PF cands +#process = PFnano_customizeMC_add_DeepJet_and_Truth(process) ##### DeepJet inputs as well as a truth branch with fine-grained labels +#process = PFnano_customizeMC_add_DeepJet_ParT_and_Truth(process) ##### DeepJet & ParT inputs as well as a truth branch with fine-grained labels +#process = PFnano_customizeMC_allPF(process) ##### PFcands will contain ALL the PF Cands +#process = PFnano_customizeMC_allPF_add_DeepJet(process) ##### PFcands will contain ALL the PF Cands; + DeepJet inputs for Jets +#process = PFnano_customizeMC_allPF_add_DeepJet_and_Truth(process) ##### PFcands will contain ALL the PF Cands; + DeepJet inputs + truth labels for Jets +#process = PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth(process) ##### PFcands will contain ALL the PF Cands; + DeepJet & ParT inputs + truth labels for Jets +#process = PFnano_customizeMC_AK4JetsOnly(process) ##### PFcands will contain only the AK4 jets PF cands +#process = PFnano_customizeMC_AK4JetsOnly_add_DeepJet(process) ##### PFcands will contain only the AK4 jets PF cands; + DeepJet inputs for Jets +#process = PFnano_customizeMC_AK8JetsOnly(process) ##### PFcands will contain only the AK8 jets PF cands #process = PFnano_customizeMC_noInputs(process) ##### No PFcands but all the other content is available. ``` In general, whenever `_add_DeepJet` is specified (does not apply to `AK8JetsOnly` and `noInputs`), the DeepJet inputs are added to the Jet collection. For all other cases that involve adding tagger inputs, only DeepCSV and / or DDX are taken into account as default (= the old behaviour when `keepInputs=True`). Internally, this is handled by selecting a list of taggers, namely choosing from `DeepCSV`, `DeepJet`, and `DDX` (or an empty list for the `noInputs`-case, formerly done by setting `keepInputs=False`, now set `keepInputs=[]`). This refers to a change of the logic inside `pfnano_cff.py` and `addBTV.py`. If one wants to use this new flexibility, one can also define new customization functions with other combinations of taggers. Currently, there are all configurations to reproduce the ones that were available previously, and all configuations that extend the old ones by adding DeepJet inputs. DeepJet outputs, on top of the discriminators already present in NanoAOD, are added in any case where AK4Jets are added, i.e. there is no need to require the full set of inputs to get the individual output nodes / probabilities. The updated description using `PFnano_customizeMC_add_DeepJet` can be viewed [here](https://annika-stein.web.cern.ch/PFNano/AddDeepJetTagInfo_desc.html) and the size [here](https://annika-stein.web.cern.ch/PFNano/AddDeepJetTagInfo_size.html). @@ -47,10 +67,12 @@ The latest addition before moving to the Run3 recipe was the inclusion of a fine ### How to create python files using cmsDriver +(You can skip this step, if the existing configurations are sufficient for your use case.) + All python config files were produced with `cmsDriver.py`. Two imporant parameters that one needs to verify in the central nanoAOD documentation are `--conditions` and `--era`. -- `--era` options from [WorkBookNanoAOD](https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookNanoAOD) or [XPOG](https://gitlab.cern.ch/cms-nanoAOD/nanoaod-doc/-/wikis/Releases/NanoAODv8) +- `--era` options from [WorkBookNanoAOD](https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookNanoAOD) or [XPOG](https://gitlab.cern.ch/cms-nanoAOD/nanoaod-doc/-/wikis/home) - `--conditions` can be found here [PdMV](https://twiki.cern.ch/twiki/bin/view/CMS/PdmV) Pre UL `cmsRun` python config files are generated by running `make_configs_preUL.sh` @@ -79,14 +101,14 @@ submission yaml card `card_example.yml` are provided. python crabby.py -c card.yml --make --submit ``` - `--make` and `--submit` calls are independent, allowing manual inspection of submit configs -- Add `--test` to disable publication on otherwise publishable config and produce a single file per dataset +- Add `--test True` to disable publication on otherwise publishable config and produce a single file per dataset
If experiencing problems with crab submission using the above instructions, e.g. on NAF-DESY ``` - source /cvmfs/grid.cern.ch/centos7-umd4-ui-4_200423/etc/profile.d/setup-c7-ui-example.sh + source /cvmfs/grid.desy.de/etc/profile.d/grid-ui-env.sh or /cvmfs/grid.cern.ch/centos7-umd4-ui-4_200423/etc/profile.d/setup-c7-ui-example.sh source /cvmfs/cms.cern.ch/common/crab-setup.sh prod source /cvmfs/cms.cern.ch/cmsset_default.sh < navigate to CMSSW_X_Y_Z/src > @@ -101,11 +123,13 @@ submission yaml card `card_example.yml` are provided.
Useful commands to get paths to individual processed files + This is to get a list of files stored at the respective site. ``` xrdfs [insert redirector to site] ls /store/path/to/your/crab/output/serialnumber > filelist.txt - ( if there is more than one serial number (more than 1k files processed) repeat command but append to textfile using >> instead of > ) - ( clean textfile for log entries ) - ( then append the redirector (needs modification by you for specific site) using this helper ) + # (example for T2_DE_RWTH: redirector would be grid-cms-xrootd.physik.rwth-aachen.de) + # ( if there is more than one serial number (more than 1k files processed) repeat command but append to textfile using >> instead of > ) + # ( clean textfile for log entries ) + # ( then append the redirector (needs modification by you for specific site) using this helper: ) python dataset_paths.py name_of_txt_file T2_DE_RWTH ``` @@ -144,9 +168,9 @@ When processing data, a lumi mask should be applied. The so called golden JSON s * Golden JSON, UL ``` +# 2ß16: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions16/13TeV/Legacy_2016/Cert_271036-284044_13TeV_Legacy2016_Collisions16_JSON.txt # 2017: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions17/13TeV/Legacy_2017/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt # 2018: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions18/13TeV/Legacy_2018/Cert_314472-325175_13TeV_Legacy2018_Collisions18_JSON.txt -# ``` * Golden JSON, pre-UL diff --git a/plugins/ParTTableProducer.cc b/plugins/ParTTableProducer.cc new file mode 100644 index 0000000..8516c2b --- /dev/null +++ b/plugins/ParTTableProducer.cc @@ -0,0 +1,728 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" + +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "TLorentzVector.h" +#include "DataFormats/Math/interface/deltaR.h" +#include "RecoVertex/VertexTools/interface/VertexDistance3D.h" +#include "RecoVertex/VertexTools/interface/VertexDistanceXY.h" +#include "RecoVertex/VertexPrimitives/interface/ConvertToFromReco.h" +#include "RecoVertex/VertexPrimitives/interface/VertexState.h" + +#include "DataFormats/PatCandidates/interface/Jet.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" + +#include "DataFormats/Candidate/interface/CandidateFwd.h" + +#include "RecoBTag/FeatureTools/interface/TrackInfoBuilder.h" +#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" +#include "TrackingTools/IPTools/interface/IPTools.h" +#include "TrackingTools/Records/interface/TransientTrackRecord.h" +#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" +#include "TrackingTools/GeomPropagators/interface/AnalyticalTrajectoryExtrapolatorToLine.h" +#include "TrackingTools/GeomPropagators/interface/AnalyticalImpactPointExtrapolator.h" + +#include "DataFormats/BTauReco/interface/TrackIPTagInfo.h" +#include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h" +#include "RecoBTag/FeatureTools/interface/deep_helpers.h" +#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h" + +#include "RecoBTag/FeatureTools/interface/sorting_modules.h" + + +#include "TVector3.h" + +#include "DataFormats/GeometrySurface/interface/Line.h" +#include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h" + +using btagbtvdeep::SortingClass; +using btagbtvdeep::mindrsvpfcand; +using btagbtvdeep::invertSortingVector; + +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" +#include "DataFormats/NanoAOD/interface/FlatTable.h" +#include + +// add tag info and a way to go back to the jet reference +#include "FWCore/Framework/interface/makeRefToBaseProdFrom.h" +#include "DataFormats/BTauReco/interface/JetTag.h" +#include "DataFormats/BTauReco/interface/DeepFlavourTagInfo.h" + + +class TrackInfoBuilder{ +public: + TrackInfoBuilder(edm::ESHandle & build): + builder(build), + trackMomentum_(0), + trackEta_(0), + trackEtaRel_(0), + trackPtRel_(0), + trackPPar_(0), + trackDeltaR_(0), + trackPtRatio_(0), + trackPParRatio_(0), + trackSip2dVal_(0), + trackSip2dSig_(0), + trackSip3dVal_(0), + trackSip3dSig_(0), + + trackJetDistVal_(0), + trackJetDistSig_(0), + //trackMinDistSV_(0), + //trackMinDistXSV_(0), + //trackMinDistYSV_(0), + //trackMinDistZSV_(0) + ttrack_(0) + +{ + + +} + + void buildTrackInfo(const pat::PackedCandidate* PackedCandidate_ ,const math::XYZVector& jetDir, GlobalVector refjetdirection, const reco::Vertex & pv){ + TVector3 jetDir3(jetDir.x(),jetDir.y(),jetDir.z()); + if(!PackedCandidate_->hasTrackDetails()) { + TVector3 trackMom3( + PackedCandidate_->momentum().x(), + PackedCandidate_->momentum().y(), + PackedCandidate_->momentum().z() + ); + trackMomentum_=PackedCandidate_->p(); + trackEta_= PackedCandidate_->eta(); + trackEtaRel_=reco::btau::etaRel(jetDir, PackedCandidate_->momentum()); + trackPtRel_=trackMom3.Perp(jetDir3); + trackPPar_=jetDir.Dot(PackedCandidate_->momentum()); + trackDeltaR_=reco::deltaR(PackedCandidate_->momentum(), jetDir); + trackPtRatio_=trackMom3.Perp(jetDir3) / PackedCandidate_->p(); + trackPParRatio_=jetDir.Dot(PackedCandidate_->momentum()) / PackedCandidate_->p(); + trackSip2dVal_=0.; + trackSip2dSig_=0.; + trackSip3dVal_=0.; + trackSip3dSig_=0.; + trackJetDistVal_=0.; + trackJetDistSig_=0.; + //ttrack_ = 0; + //trackMinDistSV_=0.; + //trackMinDistXSV_=0.; + //trackMinDistYSV_=0.; + //trackMinDistZSV_=0.; + return; + } + + const reco::Track & PseudoTrack = PackedCandidate_->pseudoTrack(); + + reco::TransientTrack transientTrack; + //reco::TransientTrack* transientTrack2; + transientTrack=builder->build(PseudoTrack); + Measurement1D meas_ip2d=IPTools::signedTransverseImpactParameter(transientTrack, refjetdirection, pv).second; + Measurement1D meas_ip3d=IPTools::signedImpactParameter3D(transientTrack, refjetdirection, pv).second; + Measurement1D jetdist=IPTools::jetTrackDistance(transientTrack, refjetdirection, pv).second; + math::XYZVector trackMom = PseudoTrack.momentum(); + double trackMag = std::sqrt(trackMom.Mag2()); + TVector3 trackMom3(trackMom.x(),trackMom.y(),trackMom.z()); + //float mindistsv = mindistsvpfcand(transientTrack); + //GlobalPoint mindistgpsv = mingpsvpfcand(transientTrack); + + + trackMomentum_=std::sqrt(trackMom.Mag2()); + trackEta_= trackMom.Eta(); + trackEtaRel_=reco::btau::etaRel(jetDir, trackMom); + trackPtRel_=trackMom3.Perp(jetDir3); + trackPPar_=jetDir.Dot(trackMom); + trackDeltaR_=reco::deltaR(trackMom, jetDir); + trackPtRatio_=trackMom3.Perp(jetDir3) / trackMag; + trackPParRatio_=jetDir.Dot(trackMom) / trackMag; + trackSip2dVal_=(meas_ip2d.value()); + + trackSip2dSig_=(meas_ip2d.significance()); + trackSip3dVal_=(meas_ip3d.value()); + + + trackSip3dSig_= meas_ip3d.significance(); + trackJetDistVal_= jetdist.value(); + trackJetDistSig_= jetdist.significance(); + + //trackMinDistSV_= mindistsv; + //trackMinDistXSV_= mindistgpsv.x(); + //trackMinDistYSV_= mindistgpsv.y(); + //trackMinDistZSV_= mindistgpsv.z(); + ttrack_ = transientTrack; + + + } + + const float& getTrackDeltaR() const {return trackDeltaR_;} + const float& getTrackEta() const {return trackEta_;} + const float& getTrackEtaRel() const {return trackEtaRel_;} + const float& getTrackJetDistSig() const {return trackJetDistSig_;} + const float& getTrackJetDistVal() const {return trackJetDistVal_;} + const float& getTrackMomentum() const {return trackMomentum_;} + const float& getTrackPPar() const {return trackPPar_;} + const float& getTrackPParRatio() const {return trackPParRatio_;} + const float& getTrackPtRatio() const {return trackPtRatio_;} + const float& getTrackPtRel() const {return trackPtRel_;} + const float& getTrackSip2dSig() const {return trackSip2dSig_;} + const float& getTrackSip2dVal() const {return trackSip2dVal_;} + const float& getTrackSip3dSig() const {return trackSip3dSig_;} + const float& getTrackSip3dVal() const {return trackSip3dVal_;} + + const reco::TransientTrack getTTrack() const {return ttrack_;} + + //const float& getrackMinDistSV() const {return trackMinDistSV_;} + //const float& getTrackMinDistXSV() const {return trackMinDistXSV_;} + //const float& getTrackMinDistYSV() const {return trackMinDistYSV_;} + //const float& getTrackMinDistZSV() const {return trackMinDistZSV_;} + +private: + + edm::ESHandle& builder; + + float trackMomentum_; + float trackEta_; + float trackEtaRel_; + float trackPtRel_; + float trackPPar_; + float trackDeltaR_; + float trackPtRatio_; + float trackPParRatio_; + float trackSip2dVal_; + float trackSip2dSig_; + float trackSip3dVal_; + float trackSip3dSig_; + + float trackJetDistVal_; + float trackJetDistSig_; + reco::TransientTrack ttrack_; + //float trackMinDistSV_; + //float trackMinDistXSV_; + //float trackMinDistYSV_; + //float trackMinDistZSV_; + +}; + + +template +class ParTTableProducer : public edm::stream::EDProducer<> { +public: + explicit ParTTableProducer(const edm::ParameterSet &); + ~ParTTableProducer() override; + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + static float mindistsvpfcand(const reco::TransientTrack track, const reco::VertexCompositePtrCandidateCollection svs_unsorted); + + +private: + void produce(edm::Event &, const edm::EventSetup &) override; + + typedef reco::VertexCollection VertexCollection; + typedef reco::VertexCompositePtrCandidateCollection SVCollection; + + + + const std::string nameParT_; + const std::string idx_nameParT_; + + edm::EDGetTokenT> jet_token_; + edm::EDGetTokenT vtx_token_; + edm::EDGetTokenT cand_token_; + edm::EDGetTokenT sv_token_; + + edm::Handle vtxs_; + edm::Handle cands_; + edm::Handle svs_; + edm::ESHandle track_builder_; + + const reco::Vertex *pv_ = nullptr; + + const float min_candidate_pt_ = 0.95; + + + constexpr static unsigned n_cpf_ = 25; + constexpr static unsigned n_npf_ = 25; + constexpr static unsigned n_sv_ = 5; + + constexpr static double jetR_ = 0.4; + + +}; + +// +// constructors and destructor +// +template< typename T> +ParTTableProducer::ParTTableProducer(const edm::ParameterSet &iConfig) + : nameParT_(iConfig.getParameter("nameParT")), + idx_nameParT_(iConfig.getParameter("idx_nameParT")), + jet_token_(consumes>(iConfig.getParameter("jets"))), + vtx_token_(consumes(iConfig.getParameter("vertices"))), + cand_token_(consumes(iConfig.getParameter("candidates"))), + sv_token_(consumes(iConfig.getParameter("secondary_vertices"))){ + produces(nameParT_); +} + +template< typename T> +ParTTableProducer::~ParTTableProducer() {} + +template< typename T> +void ParTTableProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { + // elements in all these collections must have the same order! + + // only necessary to explicitly check correct matching of jets + std::vector jetIdx_dj; + + auto jets = iEvent.getHandle(jet_token_); + iEvent.getByToken(vtx_token_, vtxs_); + iEvent.getByToken(cand_token_, cands_); + iEvent.getByToken(sv_token_, svs_); + + iSetup.get().get("TransientTrackBuilder", track_builder_); + + + unsigned nJets = jets->size(); + + // new variables for ParT + + std::vector> Cpfcan_distminsv_nCpf(n_cpf_, std::vector(nJets)); + // 4 vectors + std::vector> Cpfcan_pt_nCpf(n_cpf_, std::vector(nJets)); + std::vector> Cpfcan_eta_nCpf(n_cpf_, std::vector(nJets)); + std::vector> Cpfcan_phi_nCpf(n_cpf_, std::vector(nJets)); + std::vector> Cpfcan_e_nCpf(n_cpf_, std::vector(nJets)); + + + std::vector> Npfcan_etarel_nNpf(n_npf_, std::vector(nJets)); + std::vector> Npfcan_phirel_nNpf(n_npf_, std::vector(nJets)); + // 4 vectors + std::vector> Npfcan_pt_nNpf(n_npf_, std::vector(nJets)); + std::vector> Npfcan_eta_nNpf(n_npf_, std::vector(nJets)); + std::vector> Npfcan_phi_nNpf(n_npf_, std::vector(nJets)); + std::vector> Npfcan_e_nNpf(n_npf_, std::vector(nJets)); + + + std::vector> sv_etarel_nSV(n_sv_, std::vector(nJets)); + std::vector> sv_phirel_nSV(n_sv_, std::vector(nJets)); + // 4 vectors (pt was already included in DeepJet) + std::vector> sv_eta_nSV(n_sv_, std::vector(nJets)); + std::vector> sv_phi_nSV(n_sv_, std::vector(nJets)); + std::vector> sv_e_nSV(n_sv_, std::vector(nJets)); + + + // old variables, but use a fifth SV as well for ParT + std::vector sv_mass_4(nJets); + std::vector sv_pt_4(nJets); + std::vector sv_ntracks_4(nJets); + std::vector sv_chi2_4(nJets); + std::vector sv_normchi2_4(nJets); + std::vector sv_dxy_4(nJets); + std::vector sv_dxysig_4(nJets); + std::vector sv_d3d_4(nJets); + std::vector sv_d3dsig_4(nJets); + std::vector sv_costhetasvpv_4(nJets); + std::vector sv_deltaR_4(nJets); + std::vector sv_enratio_4(nJets); + + + for (unsigned i_jet = 0; i_jet < jets->size(); ++i_jet) { + const auto &jet = jets->at(i_jet); + + const float jet_uncorr_pt=jet.correctedJet("Uncorrected").pt(); + const float jet_uncorr_e=jet.correctedJet("Uncorrected").energy(); + + math::XYZVector jet_dir = jet.momentum().Unit(); + GlobalVector jet_ref_track_dir(jet.px(), jet.py(), jet.pz()); + VertexDistance3D vdist; + + pv_ = &vtxs_->at(0); + + ////////////////////// + // Secondary Vertices + std::vector jetSVs; + std::vector allSVs; + + + jetIdx_dj.push_back(i_jet); + + for (const auto &sv : *svs_) { + // Factor in cuts in NanoAOD for indexing + Measurement1D dl= vdist.distance(vtxs_->front(), VertexState(RecoVertex::convertPos(sv.position()),RecoVertex::convertError(sv.error()))); + if(dl.significance() > 3){ + allSVs.push_back(&sv); + } + if (reco::deltaR2(sv, jet) < jetR_ * jetR_) { + jetSVs.push_back(&sv); + } + } + + + // sort by dxy significance + std::sort(jetSVs.begin(), + jetSVs.end(), + [&](const reco::VertexCompositePtrCandidate *sva, const reco::VertexCompositePtrCandidate *svb) { + return btagbtvdeep::sv_vertex_comparator(*sva, *svb, *pv_); + }); + + // counter to get flat info per jet for SVs + unsigned i_sv_in_jet = 0; + + for (const auto &sv : jetSVs) { + //if (readBtag_ && !vtxs_->empty()) { + if (!vtxs_->empty()) { + + if (i_sv_in_jet < 4) { + + // this is new for ParT: + sv_etarel_nSV[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(sv->eta()-jet.eta())-0.5,0,-2,0); + sv_phirel_nSV[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaPhi(sv->phi(),jet.phi()))-0.5,0,-2,0); + + sv_eta_nSV[i_sv_in_jet][i_jet] = sv->eta(); + sv_phi_nSV[i_sv_in_jet][i_jet] = sv->phi(); + sv_e_nSV[i_sv_in_jet][i_jet] = sv->energy(); + + } else { + if (i_sv_in_jet == 4) { // the fifth SV, new for ParT, not yet for DeepJet + sv_pt_4[i_jet] = sv->pt(); + sv_deltaR_4[i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaR(*sv, jet)) - 0.5, 0, -2, 0); + sv_mass_4[i_jet] = sv->mass(); + sv_ntracks_4[i_jet] = sv->numberOfDaughters(); + sv_chi2_4[i_jet] = sv->vertexChi2(); + sv_normchi2_4[i_jet] = btagbtvdeep::catch_infs_and_bound(sv_chi2_4[i_jet] / sv->vertexNdof(), 1000, -1000, 1000); + const auto& dxy_meas = btagbtvdeep::vertexDxy(*sv, *pv_); + sv_dxy_4[i_jet] = dxy_meas.value(); + sv_dxysig_4[i_jet] = btagbtvdeep::catch_infs_and_bound(sv_dxy_4[i_jet] / dxy_meas.error(), 0, -1, 800); + const auto& d3d_meas = btagbtvdeep::vertexD3d(*sv, *pv_); + sv_d3d_4[i_jet] = d3d_meas.value(); + sv_d3dsig_4[i_jet] = btagbtvdeep::catch_infs_and_bound(sv_d3d_4[i_jet] / d3d_meas.error(), 0, -1, 800); + sv_costhetasvpv_4[i_jet] = btagbtvdeep::vertexDdotP(*sv, *pv_); + sv_enratio_4[i_jet] = sv->energy() / jet_uncorr_e; + + + // also the fifth SV needs new features: + sv_etarel_nSV[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(sv->eta()-jet.eta())-0.5,0,-2,0); + sv_phirel_nSV[i_sv_in_jet][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaPhi(sv->phi(),jet.phi()))-0.5,0,-2,0); + + sv_eta_nSV[i_sv_in_jet][i_jet] = sv->eta(); + sv_phi_nSV[i_sv_in_jet][i_jet] = sv->phi(); + sv_e_nSV[i_sv_in_jet][i_jet] = sv->energy(); + } else { // more than 5 SV irrelevant for this tagger + continue; + } + } + + } + i_sv_in_jet++; + } // end sv loop + + // PF Cands + std::vector const & daughters = jet.daughterPtrVector(); + + const auto& svs_unsorted = *svs_; + + std::vector> c_sorted, n_sorted; + + // first time looping over all pf candidates + // to fill sorted indices and get a connection back to the old indices + for (unsigned int i = 0; i < jet.numberOfDaughters(); i++) { + auto cand = jet.daughter(i); + if (cand) { + // candidates under 950MeV (configurable) are not considered + // might change if we use also white-listing + if (cand->pt() < min_candidate_pt_) continue; + + if (cand->charge() != 0) { + btagbtvdeep::TrackInfoBuilder trkinfo(track_builder_); + // similar to https://github.com/cms-sw/cmssw/blob/master/RecoBTag/FeatureTools/interface/ChargedCandidateConverter.h + trkinfo.buildTrackInfo(cand, jet_dir, jet_ref_track_dir, *pv_); + c_sorted.emplace_back( + i, trkinfo.getTrackSip2dSig(), -btagbtvdeep::mindrsvpfcand(svs_unsorted, cand), cand->pt() / jet_uncorr_pt); + } else { + n_sorted.emplace_back(i, -1, -btagbtvdeep::mindrsvpfcand(svs_unsorted, cand), cand->pt() / jet_uncorr_pt); + } + } + } + + // sort collections (open the black-box if you please) + std::sort(c_sorted.begin(), c_sorted.end(), btagbtvdeep::SortingClass::compareByABCInv); + std::sort(n_sorted.begin(), n_sorted.end(), btagbtvdeep::SortingClass::compareByABCInv); + + std::vector c_sortedindices, n_sortedindices; + + // this puts 0 everywhere and the right position in ind + c_sortedindices = btagbtvdeep::invertSortingVector(c_sorted); + n_sortedindices = btagbtvdeep::invertSortingVector(n_sorted); + + + int i_pf_in_jet = 0; + for (const auto &cand : daughters) { + + auto candPtrs = cands_->ptrs(); + auto candInNewList = std::find( candPtrs.begin(), candPtrs.end(), cand ); + if ( candInNewList == candPtrs.end() ) { + continue; + } + + if (!vtxs_->empty()) { + if ( cand.isNull() ) continue; + auto const *packedCand = dynamic_cast (cand.get()); + if ( packedCand == nullptr ) continue; + if (packedCand->pt() < min_candidate_pt_) continue; + + if ( packedCand->charge() != 0 ) { + + // is charged candidate + auto entry_sorted = c_sortedindices.at(i_pf_in_jet); + // need only the first 25 cpfs for ParT + if (entry_sorted >= n_cpf_) { + continue; + } + + Cpfcan_pt_nCpf[entry_sorted][i_jet] = cand->pt(); + Cpfcan_eta_nCpf[entry_sorted][i_jet] = cand->eta(); + Cpfcan_phi_nCpf[entry_sorted][i_jet] = cand->phi(); + Cpfcan_e_nCpf[entry_sorted][i_jet] = cand->energy(); + + + if ( packedCand && packedCand->hasTrackDetails()){ + + TrackInfoBuilder trkinfo(track_builder_); + // similar to https://github.com/cms-sw/cmssw/blob/master/RecoBTag/FeatureTools/interface/ChargedCandidateConverter.h + trkinfo.buildTrackInfo(&(*packedCand), jet_dir, jet_ref_track_dir, *pv_); + + const reco::TransientTrack ttrack = trkinfo.getTTrack(); + float mindistsv = mindistsvpfcand(ttrack, svs_unsorted); + + Cpfcan_distminsv_nCpf[entry_sorted][i_jet] = mindistsv; + + + } else { + continue; + // nothing else new to fill for ParT which does not have track details for cpfs + } + } else { + + // is neutral candidate + auto entry_sorted = n_sortedindices.at(i_pf_in_jet); + // need only the first 25 npfs for ParT + if (entry_sorted >= n_npf_) { + continue; + } + Npfcan_etarel_nNpf[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(cand->eta()-jet.eta()), 0, -2, 0, -0.5); + Npfcan_phirel_nNpf[entry_sorted][i_jet] = btagbtvdeep::catch_infs_and_bound(std::fabs(reco::deltaPhi(cand->phi(),jet.phi())), 0, -2, 0, -0.5); + Npfcan_pt_nNpf[entry_sorted][i_jet] = cand->pt(); + Npfcan_eta_nNpf[entry_sorted][i_jet] = cand->eta(); + Npfcan_phi_nNpf[entry_sorted][i_jet] = cand->phi(); + Npfcan_e_nNpf[entry_sorted][i_jet] = cand->energy(); + + } + } + i_pf_in_jet++; + } // end constituents loop + } // end jet loop + + + // ParTInputs table + auto partTable = std::make_unique(nJets, nameParT_, false, true); + + + // ============================================================== Cpfs =================================================================== + for (unsigned int p = 0; p < n_cpf_; p++) { + auto s = std::to_string(p); + partTable->addColumn("ParT_Cpfcan_pt_" + s, + Cpfcan_pt_nCpf[p], + "transverse momentum of the " + s + ". cpf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Cpfcan_eta_" + s, + Cpfcan_eta_nCpf[p], + "pseudorapidity of the " + s + ". cpf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Cpfcan_phi_" + s, + Cpfcan_phi_nCpf[p], + "phi of the " + s + ". cpf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Cpfcan_e_" + s, + Cpfcan_e_nCpf[p], + "energy of the " + s + ". cpf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Cpfcan_distminsv_" + s, + Cpfcan_distminsv_nCpf[p], + "track 3D cartesian distance (signed) from the closest secondary vertex of the " + s + ". cpf", + nanoaod::FlatTable::FloatColumn, 10); + } + + // ============================================================== Npfs =================================================================== + for (unsigned int p = 0; p < n_npf_; p++) { + auto s = std::to_string(p); + partTable->addColumn("ParT_Npfcan_etarel_" + s, + Npfcan_etarel_nNpf[p], + "pseudorapidity relative to the jet for the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Npfcan_phirel_" + s, + Npfcan_phirel_nNpf[p], + "phi relative to the jet for the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Npfcan_pt_" + s, + Npfcan_pt_nNpf[p], + "transverse momentum of the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Npfcan_eta_" + s, + Npfcan_eta_nNpf[p], + "pseudorapidity of the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Npfcan_phi_" + s, + Npfcan_phi_nNpf[p], + "phi of the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_Npfcan_e_" + s, + Npfcan_e_nNpf[p], + "energy of the " + s + ". npf", + nanoaod::FlatTable::FloatColumn, 10); + } + + // ============================================================== SVs =================================================================== + for (unsigned int p = 0; p < n_sv_; p++) { + auto s = std::to_string(p); + // new for ParT + partTable->addColumn("ParT_sv_etarel_" + s, + sv_etarel_nSV[p], + "pseudorapidity relative to parent jet for the " + s + ". SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_phirel_" + s, + sv_phirel_nSV[p], + "DeltaPhi(sv, jet) for the " + s + ". SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_eta_" + s, + sv_eta_nSV[p], + "pseudorapidity of the " + s + ". SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_phi_" + s, + sv_phi_nSV[p], + "phi of the " + s + ". SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_e_" + s, + sv_e_nSV[p], + "energy of the " + s + ". SV", + nanoaod::FlatTable::FloatColumn, 10); + } + + + partTable->addColumn("ParT_sv_mass_4", + sv_mass_4, + "SV mass of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_pt_4", + sv_pt_4, + "SV pt of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_ntracks_4", + sv_ntracks_4, + "Number of tracks asociated to the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_chi2_4", + sv_chi2_4, + "chi2 of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_normchi2_4", + sv_normchi2_4, + "chi2/dof of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_dxy_4", + sv_dxy_4, + "2D impact parameter (flight distance) value of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_dxysig_4", + sv_dxysig_4, + "2D impact parameter (flight distance) significance of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_d3d_4", + sv_d3d_4, + "3D impact parameter (flight distance) value of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_d3dsig_4", + sv_d3dsig_4, + "3D impact parameter (flight distance) significance of the 4. SV", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_costhetasvpv_4", + sv_costhetasvpv_4, + "cosine of the angle between the 4. SV flight direction and the direction of the 4. SV momentum", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_deltaR_4", + sv_deltaR_4, + "pseudoangular distance between jet axis and the 4. SV direction", + nanoaod::FlatTable::FloatColumn, 10); + partTable->addColumn("ParT_sv_enratio_4", + sv_enratio_4, + "ratio of the 4. SV energy ratio to the jet energy", + nanoaod::FlatTable::FloatColumn, 10); + + iEvent.put(std::move(partTable), nameParT_); + +} + +// below OK +template< typename T> +void ParTTableProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { + edm::ParameterSetDescription desc; + desc.add("nameParT", "Jet"); + desc.add("idx_nameParT", "djIdx"); + desc.add("jets", edm::InputTag("slimmedJets")); + desc.add("vertices", edm::InputTag("offlineSlimmedPrimaryVertices")); + desc.add("candidates", edm::InputTag("packedPFCandidates")); + desc.add("secondary_vertices", edm::InputTag("slimmedSecondaryVertices")); + descriptions.addWithDefaultLabel(desc); +} + + +template< typename T> +float ParTTableProducer::mindistsvpfcand(const reco::TransientTrack track, const reco::VertexCompositePtrCandidateCollection svs_unsorted) { + + float mindist_ = 999.999; + float out_dist = 0.0; + for (unsigned int i=0; i result(true, dist.distance(VertexState(vertexPosition, vertexPositionErr), VertexState(refPoint, refPointErr))); + if (!result.first) {continue;} + + GlobalPoint impactPoint = tsos.globalPosition(); + GlobalVector IPVec(impactPoint.x() - vertex.x(), impactPoint.y() - vertex.y(), impactPoint.z() - vertex.z()); + double prod = IPVec.dot(direction); + double sign = (prod >= 0) ? 1. : -1.; + + if(result.second.value() < mindist_){ + out_dist = sign * result.second.value(); + mindist_ = result.second.value(); + } + } + return out_dist; +} + +typedef ParTTableProducer PatJetParTTableProducer; +//typedef ParTTableProducer GenJetParTTableProducer; + +DEFINE_FWK_MODULE(PatJetParTTableProducer); +//DEFINE_FWK_MODULE(GenJetParTTableProducer); diff --git a/python/addBTV.py b/python/addBTV.py index 914c0b9..9244c12 100644 --- a/python/addBTV.py +++ b/python/addBTV.py @@ -243,10 +243,10 @@ def get_DeepJet_outputs(): float, doc="DeepJet lepb tag probability", precision=10), - #btagDeepFlavC=Var("bDiscriminator('pfDeepFlavourJetTags:probc')", - # float, - # doc="DeepJet c tag probability", - # precision=10), # until 106X already included in nano + btagDeepFlavC=Var("bDiscriminator('pfDeepFlavourJetTags:probc')", + float, + doc="DeepJet c tag probability", + precision=10), # until 106X already included in nano btagDeepFlavUDS=Var("bDiscriminator('pfDeepFlavourJetTags:probuds')", float, doc="DeepJet uds tag probability", @@ -280,19 +280,19 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D precision=10), btagDeepB_b=Var("bDiscriminator('pfDeepCSVJetTags:probb')", float, - doc="DeepCSV b tag discriminator", + doc="DeepCSV Prob(b)", precision=10), btagDeepB_bb=Var("bDiscriminator('pfDeepCSVJetTags:probbb')", float, - doc="DeepCSV bb tag discriminator", + doc="DeepCSV Prob(bb)", precision=10), - #btagDeepC=Var("bDiscriminator('pfDeepCSVJetTags:probc')", - # float, - # doc="DeepCSV c btag discriminator", - # precision=10), # only necessary after 106X + btagDeepC=Var("bDiscriminator('pfDeepCSVJetTags:probc')", + float, + doc="DeepCSV Prob(c)", + precision=10), # only necessary after 106X btagDeepL=Var("bDiscriminator('pfDeepCSVJetTags:probudsg')", float, - doc="DeepCSV light btag discriminator", + doc="DeepCSV Prob(udsg)", precision=10), ) @@ -320,7 +320,11 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D CommonVars, HadronCountingVars if runOnMC else cms.PSet(), # hadrons from Generator only relevant for MC get_DeepCSV_vars() if ('DeepCSV' in keepInputs) else cms.PSet(), - get_DeepJet_outputs() # outputs are added in any case, inputs only if requested + get_DeepJet_outputs(), # outputs are added in any case, inputs only if requested + #btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')", + # float, + # doc="DeepCSV Prob(c)", + # precision=10), )) if ('DeepJet' in keepInputs): @@ -330,7 +334,10 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D jets = cms.InputTag("finalJets"), storeAK4Truth = cms.string(storeAK4Truth) ) - + if ('ParT' in keepInputs): + process.customAK4ConstituentsForParTTable = cms.EDProducer("PatJetParTTableProducer", + jets = cms.InputTag("finalJets") + ) # AK8 process.customFatJetExtTable = cms.EDProducer( @@ -350,10 +357,10 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D # btagDDCvBV2 = Var("bDiscriminator('pfMassIndependentDeepDoubleCvBV2JetTags:probHcc')",float,doc="DeepDoubleX V2 discriminator for H(Z)->cc vs H(Z)->bb",precision=10), #), # only necessary before 10_6_19 get_DDX_vars() if ('DDX' in keepInputs) else cms.PSet(), - btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')", - float, - doc="DeepCSV charm btag discriminator", - precision=10), + #btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')", + # float, + # doc="DeepCSV Prob(c)", + # precision=10), )) # Subjets @@ -368,10 +375,10 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D variables=cms.PSet( CommonVars, #HadronCountingVars if runOnMC else cms.PSet(), # only necessary before 106x - btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')", - float, - doc="DeepCSV charm btag discriminator", - precision=10), + #btagDeepC = Var("bDiscriminator('pfDeepCSVJetTags:probc')", + # float, + # doc="DeepCSV Prob(c)", + # precision=10), )) @@ -394,6 +401,8 @@ def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=['D process.customizeJetTask.add(process.customJetExtTable) if ('DeepJet' in keepInputs): process.customizeJetTask.add(process.customAK4ConstituentsForDeepJetTable) + if ('ParT' in keepInputs): + process.customizeJetTask.add(process.customAK4ConstituentsForParTTable) if addAK8: process.customizeJetTask.add(process.customFatJetExtTable) diff --git a/python/pfnano_cff.py b/python/pfnano_cff.py index d3a223f..f690abf 100644 --- a/python/pfnano_cff.py +++ b/python/pfnano_cff.py @@ -3,58 +3,76 @@ from PhysicsTools.PFNano.addBTV import add_BTV from PhysicsTools.NanoAOD.common_cff import Var -# keepInputs can take DeepCSV, DeepJet and DDX (any combination, or use empty placeholder list if no inputs are required) +# keepInputs can take DeepCSV, DeepJet, DDX and ParT (any combination, or use empty placeholder list if no inputs are required) def PFnano_customizeMC(process): addPFCands(process, True) add_BTV(process, True, keepInputs=['DeepCSV','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_add_DeepJet(process): addPFCands(process, True) add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_add_DeepJet_and_Truth(process): addPFCands(process, True) add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX'], storeAK4Truth="yes") - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + return process + +def PFnano_customizeMC_add_DeepJet_ParT_and_Truth(process): + addPFCands(process, True) + add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX','ParT'], storeAK4Truth="yes") + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_allPF(process): addPFCands(process, True, True) add_BTV(process, True, keepInputs=['DeepCSV','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_allPF_add_DeepJet(process): addPFCands(process, True, True) add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + return process + +def PFnano_customizeMC_allPF_add_DeepJet_and_Truth(process): + addPFCands(process, True, True) + add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX'], storeAK4Truth="yes") + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + return process + +def PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth(process): + addPFCands(process, True, True) + add_BTV(process, True, keepInputs=['DeepCSV','DeepJet','DDX','ParT'], storeAK4Truth="yes") + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_AK4JetsOnly(process): addPFCands(process, True, False, True) add_BTV(process, True, True, keepInputs=['DeepCSV']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_AK4JetsOnly_add_DeepJet(process): addPFCands(process, True, False, True) add_BTV(process, True, True, keepInputs=['DeepCSV','DeepJet']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_AK8JetsOnly(process): addPFCands(process, True, False, False, True) add_BTV(process, True, False, True, keepInputs=['DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_noInputs(process): add_BTV(process, True, keepInputs=[]) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process @@ -62,46 +80,58 @@ def PFnano_customizeMC_noInputs(process): def PFnano_customizeData(process): addPFCands(process, False) add_BTV(process, False, keepInputs=['DeepCSV','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_add_DeepJet(process): addPFCands(process, False) add_BTV(process, False, keepInputs=['DeepCSV','DeepJet','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + return process + +def PFnano_customizeData_add_DeepJet_ParT(process): + addPFCands(process, False) + add_BTV(process, False, keepInputs=['DeepCSV','DeepJet','DDX','ParT']) + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_allPF(process): addPFCands(process, False, True) add_BTV(process, False, keepInputs=['DeepCSV','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_allPF_add_DeepJet(process): addPFCands(process, False, True) add_BTV(process, False, keepInputs=['DeepCSV','DeepJet','DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + return process + +def PFnano_customizeData_allPF_add_DeepJet_ParT(process): + addPFCands(process, False, True) + add_BTV(process, False, keepInputs=['DeepCSV','DeepJet','DDX','ParT']) + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_AK4JetsOnly(process): addPFCands(process, False, False, True) add_BTV(process, False, True, keepInputs=['DeepCSV']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_AK4JetsOnly_add_DeepJet(process): addPFCands(process, False, False, True) add_BTV(process, False, True, keepInputs=['DeepCSV','DeepJet']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_AK8JetsOnly(process): addPFCands(process, False, False, False, True) add_BTV(process, False, False, True, keepInputs=['DDX']) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_noInputs(process): add_BTV(process, False, keepInputs=[]) - process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication + #process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process diff --git a/test/card_data_ULv2_with_ParT.yml b/test/card_data_ULv2_with_ParT.yml new file mode 100644 index 0000000..2d89fbb --- /dev/null +++ b/test/card_data_ULv2_with_ParT.yml @@ -0,0 +1,22 @@ +campaign: + name: 'test' # irrelevant + crab_template: template_crab.py + + # User specific + workArea: DataSingleMuon17C_ULv2v1_with_ParT_yml + storageSite: T2_DE_RWTH + outLFNDirBase: /store/user/anstein/PFNano + voGroup: dcms + + # Campaign specific + tag_extension: PFNanoFromMiniV2WithParT # Will get appended after the current tag + tag_mod: # Will modify name in-place for MC eg. "PFNanoAODv1" will replace MiniAODv2 -> PFNanoAODv1 + publication: True + config: nano_data_2017_ULv2_allPF_ParT_NANO.py + # Specify if running on data + data: True + # data: False + lumiMask: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions17/13TeV/Legacy_2017/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt + # datasets will take either a list of DAS names or a text file containing them + datasets: /SingleMuon/Run2017C-UL2017_MiniAODv2-v1/MINIAOD + \ No newline at end of file diff --git a/test/card_data_ULv2_with_ParT_for_resubmit.yml b/test/card_data_ULv2_with_ParT_for_resubmit.yml new file mode 100644 index 0000000..9d3be67 --- /dev/null +++ b/test/card_data_ULv2_with_ParT_for_resubmit.yml @@ -0,0 +1,23 @@ +campaign: + name: 'test' # irrelevant + crab_template: template_crab.py + + # User specific + workArea: DataDoubleMuon17F_recov_ULv2_with_ParT_yml + storageSite: T2_DE_RWTH + outLFNDirBase: /store/user/anstein/PFNano + voGroup: dcms + + # Campaign specific + tag_extension: PFNanoFromMiniV2WithParT # Will get appended after the current tag + tag_mod: # Will modify name in-place for MC eg. "PFNanoAODv1" will replace MiniAODv2 -> PFNanoAODv1 + publication: True + config: nano_data_2017_ULv2_allPF_ParT_NANO.py + # Specify if running on data + data: True + # data: False + # lumiMask: /afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions17/13TeV/Legacy_2017/Cert_294927-306462_13TeV_UL2017_Collisions17_GoldenJSON.txt + lumiMask: /afs/desy.de/user/a/anstein/private/pfnano_dev/CMSSW_10_6_30/src/PhysicsTools/PFNano/test/DataDoubleMuon17F_ULv2_with_ParT_yml/crab_DoubleMuon_Run2017F-UL2017_MiniAODv2-v1_MINIAOD/results/notFinishedLumis.json + # datasets will take either a list of DAS names or a text file containing them + datasets: /DoubleMuon/Run2017F-UL2017_MiniAODv2-v1/MINIAOD + \ No newline at end of file diff --git a/test/card_mc_ULv2.yml b/test/card_mc_ULv2.yml index 61c0bb6..1ccd707 100644 --- a/test/card_mc_ULv2.yml +++ b/test/card_mc_ULv2.yml @@ -3,20 +3,20 @@ campaign: crab_template: template_crab.py # User specific - workArea: mc_ULv2_yml + workArea: DYJetsToLL_ULv2_yml storageSite: T2_DE_RWTH outLFNDirBase: /store/user/anstein/PFNano voGroup: dcms # Campaign specific - tag_extension: PFtestNano # Will get appended after the current tag + tag_extension: PFNanoFromMiniV2 # Will get appended after the current tag tag_mod: # Will modify name in-place for MC eg. "PFNanoAODv1" will replace MiniAODv2 -> PFNanoAODv1 - publication: True - config: nano_mc_2017_ULv2_NANO.py + publication: False + config: nano_mc_2017_ULv2_allPF_NANO.py # Specify if running on data # data: True data: False lumiMask: # json file # datasets will take either a list of DAS names or a text file containing them - datasets: /TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM + datasets: /DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM \ No newline at end of file diff --git a/test/card_mc_ULv2_with_ParT.yml b/test/card_mc_ULv2_with_ParT.yml new file mode 100644 index 0000000..be9f54d --- /dev/null +++ b/test/card_mc_ULv2_with_ParT.yml @@ -0,0 +1,22 @@ +campaign: + name: 'test' # irrelevant + crab_template: template_crab.py + + # User specific + workArea: Test2_MC_DYJetsToLL_M-50_ULv2_with_ParT_yml + storageSite: T2_DE_RWTH + outLFNDirBase: /store/user/anstein/PFNano + voGroup: dcms + + # Campaign specific + tag_extension: PFNanoFromMiniV2WithParT # Will get appended after the current tag + tag_mod: # Will modify name in-place for MC eg. "PFNanoAODv1" will replace MiniAODv2 -> PFNanoAODv1 + publication: True + config: nano_mc_2017_ULv2_allPF_ParT_NANO.py + # Specify if running on data + # data: True + data: False + lumiMask: # json file + # datasets will take either a list of DAS names or a text file containing them + datasets: /DYJetsToLL_M-50_TuneCP5_13TeV-madgraphMLM-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM + \ No newline at end of file diff --git a/test/dataset_paths.py b/test/dataset_paths.py index bdca125..4dcd842 100644 --- a/test/dataset_paths.py +++ b/test/dataset_paths.py @@ -8,7 +8,7 @@ } txt_name = "doublemuon2017" -site = "T2_DE_RWTW" +site = 'T2_DE_RWTH' if len(sys.argv) > 1: txt_name = sys.argv[1] diff --git a/test/datasets/ULv2/data2017.txt b/test/datasets/ULv2/data2017.txt new file mode 100644 index 0000000..b7dc15c --- /dev/null +++ b/test/datasets/ULv2/data2017.txt @@ -0,0 +1,13 @@ +# https://cmsweb.cern.ch/das/request?view=list&limit=50&instance=prod/global&input=dataset=/*/*UL*MiniAODv2*/MINIAOD + +/DoubleMuon/Run2017B-UL2017_MiniAODv2-v1/MINIAOD +/DoubleMuon/Run2017C-UL2017_MiniAODv2-v1/MINIAOD +/DoubleMuon/Run2017D-UL2017_MiniAODv2-v1/MINIAOD +/DoubleMuon/Run2017E-UL2017_MiniAODv2-v2/MINIAOD +/DoubleMuon/Run2017F-UL2017_MiniAODv2-v1/MINIAOD + +/SingleMuon/Run2017B-UL2017_MiniAODv2-v1/MINIAOD +/SingleMuon/Run2017C-UL2017_MiniAODv2-v1/MINIAOD +/SingleMuon/Run2017D-UL2017_MiniAODv2-v1/MINIAOD +/SingleMuon/Run2017E-UL2017_MiniAODv2-v1/MINIAOD +/SingleMuon/Run2017F-UL2017_MiniAODv2-v1/MINIAOD diff --git a/test/datasets/ULv2/mc2017.txt b/test/datasets/ULv2/mc2017.txt new file mode 100644 index 0000000..1b4485b --- /dev/null +++ b/test/datasets/ULv2/mc2017.txt @@ -0,0 +1,20 @@ +# https://cmsweb.cern.ch/das/request?view=list&limit=50&instance=prod%2Fglobal&input=dataset%3D%2F*%2FRunIISummer20UL17*MiniAOD*v2-106X*%2FMINIAODSIM + +# V + jets (inclusive only) +/DYJetsToLL_M-50_TuneCP5_13TeV-madgraphMLM-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM +/WJetsToLNu_TuneCP5_13TeV-madgraphMLM-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM + +# TTbar & single top +/TTTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/TTToHadronic_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM +/ST_s-channel_4f_leptonDecays_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/ST_t-channel_antitop_4f_InclusiveDecays_TuneCP5_13TeV-powheg-madspin-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/ST_t-channel_top_4f_InclusiveDecays_TuneCP5_13TeV-powheg-madspin-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/ST_tW_antitop_5f_inclusiveDecays_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM +/ST_tW_top_5f_inclusiveDecays_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v2/MINIAODSIM + +# Diboson +/WW_TuneCP5_13TeV-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/WZ_TuneCP5_13TeV-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM +/ZZ_TuneCP5_13TeV-pythia8/RunIISummer20UL17MiniAODv2-106X_mc2017_realistic_v9-v1/MINIAODSIM diff --git a/test/nano_data_2017_ULv2_allPF_ParT_NANO.py b/test/nano_data_2017_ULv2_allPF_ParT_NANO.py new file mode 100644 index 0000000..5cf3840 --- /dev/null +++ b/test/nano_data_2017_ULv2_allPF_ParT_NANO.py @@ -0,0 +1,101 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: nano_data_2017_ULv2_allPF_ParT --data --eventcontent NANOAOD --datatier NANOAOD --step NANO --conditions 106X_dataRun2_v37 --era Run2_2017,run2_nanoAOD_106Xv2 --customise_commands=process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)));process.MessageLogger.cerr.FwkReport.reportEvery=100;process.NANOAODoutput.fakeNameForCrab=cms.untracked.bool(True) --nThreads 4 -n -1 --filein /store/data/Run2017B/SingleMuon/MINIAOD/UL2017_MiniAODv2-v1/260000/9032A966-8ED0-B645-97B6-A8EBC1D8D3B9.root --customise PhysicsTools/PFNano/pfnano_cff.PFnano_customizeData_allPF_add_DeepJet_ParT --no_exec +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run2_2017_cff import Run2_2017 +from Configuration.Eras.Modifier_run2_nanoAOD_106Xv2_cff import run2_nanoAOD_106Xv2 + +process = cms.Process('NANO',Run2_2017,run2_nanoAOD_106Xv2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('PhysicsTools.NanoAOD.nano_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('/store/data/Run2017B/SingleMuon/MINIAOD/UL2017_MiniAODv2-v1/260000/9032A966-8ED0-B645-97B6-A8EBC1D8D3B9.root'), + secondaryFileNames = cms.untracked.vstring() +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('nano_data_2017_ULv2_allPF_ParT nevts:-1'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.NANOAODoutput = cms.OutputModule("NanoAODOutputModule", + compressionAlgorithm = cms.untracked.string('LZMA'), + compressionLevel = cms.untracked.int32(9), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('NANOAOD'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('nano_data_2017_ULv2_allPF_ParT_NANO.root'), + outputCommands = process.NANOAODEventContent.outputCommands +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '106X_dataRun2_v37', '') + +# Path and EndPath definitions +process.nanoAOD_step = cms.Path(process.nanoSequence) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.NANOAODoutput_step = cms.EndPath(process.NANOAODoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.nanoAOD_step,process.endjob_step,process.NANOAODoutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads=cms.untracked.uint32(4) +process.options.numberOfStreams=cms.untracked.uint32(0) +process.options.numberOfConcurrentLuminosityBlocks=cms.untracked.uint32(1) + +# customisation of the process. + +# Automatic addition of the customisation function from PhysicsTools.NanoAOD.nano_cff +from PhysicsTools.NanoAOD.nano_cff import nanoAOD_customizeData + +#call to customisation function nanoAOD_customizeData imported from PhysicsTools.NanoAOD.nano_cff +process = nanoAOD_customizeData(process) + +# Automatic addition of the customisation function from PhysicsTools.PFNano.pfnano_cff +from PhysicsTools.PFNano.pfnano_cff import PFnano_customizeData_allPF_add_DeepJet_ParT + +#call to customisation function PFnano_customizeData_allPF_add_DeepJet_ParT imported from PhysicsTools.PFNano.pfnano_cff +process = PFnano_customizeData_allPF_add_DeepJet_ParT(process) + +# End of customisation functions + +# Customisation from command line + +process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)));process.MessageLogger.cerr.FwkReport.reportEvery=100;process.NANOAODoutput.fakeNameForCrab=cms.untracked.bool(True) +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/test/nano_mc_2017_ULv2_allPF_ParT_NANO.py b/test/nano_mc_2017_ULv2_allPF_ParT_NANO.py new file mode 100644 index 0000000..304c4d3 --- /dev/null +++ b/test/nano_mc_2017_ULv2_allPF_ParT_NANO.py @@ -0,0 +1,102 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: nano_mc_2017_ULv2_allPF_ParT --mc --eventcontent NANOAODSIM --datatier NANOAODSIM --step NANO --conditions 106X_mc2017_realistic_v9 --era Run2_2017,run2_nanoAOD_106Xv2 --customise_commands=process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)));process.MessageLogger.cerr.FwkReport.reportEvery=100;process.NANOAODSIMoutput.fakeNameForCrab=cms.untracked.bool(True) --nThreads 4 -n -1 --filein root://cmsdcadisk.fnal.gov:1094/dcache/uscmsdisk/store/mc/RunIISummer20UL17MiniAODv2/DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/MINIAODSIM/106X_mc2017_realistic_v9-v2/100000/05044CB0-D61E-BC4D-95B5-EBE372E35C6F.root --customise PhysicsTools/PFNano/pfnano_cff.PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth --no_exec +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Run2_2017_cff import Run2_2017 +from Configuration.Eras.Modifier_run2_nanoAOD_106Xv2_cff import run2_nanoAOD_106Xv2 + +process = cms.Process('NANO',Run2_2017,run2_nanoAOD_106Xv2) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('PhysicsTools.NanoAOD.nano_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + +# Input source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('root://cmsdcadisk.fnal.gov:1094/dcache/uscmsdisk/store/mc/RunIISummer20UL17MiniAODv2/DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/MINIAODSIM/106X_mc2017_realistic_v9-v2/100000/05044CB0-D61E-BC4D-95B5-EBE372E35C6F.root'), + secondaryFileNames = cms.untracked.vstring() +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('nano_mc_2017_ULv2_allPF_ParT nevts:-1'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.NANOAODSIMoutput = cms.OutputModule("NanoAODOutputModule", + compressionAlgorithm = cms.untracked.string('LZMA'), + compressionLevel = cms.untracked.int32(9), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('NANOAODSIM'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('nano_mc_2017_ULv2_allPF_ParT_NANO.root'), + outputCommands = process.NANOAODSIMEventContent.outputCommands +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '106X_mc2017_realistic_v9', '') + +# Path and EndPath definitions +process.nanoAOD_step = cms.Path(process.nanoSequenceMC) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.NANOAODSIMoutput_step = cms.EndPath(process.NANOAODSIMoutput) + +# Schedule definition +process.schedule = cms.Schedule(process.nanoAOD_step,process.endjob_step,process.NANOAODSIMoutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads=cms.untracked.uint32(4) +process.options.numberOfStreams=cms.untracked.uint32(0) +process.options.numberOfConcurrentLuminosityBlocks=cms.untracked.uint32(1) + +# customisation of the process. + +# Automatic addition of the customisation function from PhysicsTools.NanoAOD.nano_cff +from PhysicsTools.NanoAOD.nano_cff import nanoAOD_customizeMC + +#call to customisation function nanoAOD_customizeMC imported from PhysicsTools.NanoAOD.nano_cff +process = nanoAOD_customizeMC(process) + +# Automatic addition of the customisation function from PhysicsTools.PFNano.pfnano_cff +from PhysicsTools.PFNano.pfnano_cff import PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth + +#call to customisation function PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth imported from PhysicsTools.PFNano.pfnano_cff +process = PFnano_customizeMC_allPF_add_DeepJet_ParT_and_Truth(process) + +# End of customisation functions + +# Customisation from command line + +process.add_(cms.Service('InitRootHandlers', EnableIMT = cms.untracked.bool(False)));process.MessageLogger.cerr.FwkReport.reportEvery=100;process.NANOAODSIMoutput.fakeNameForCrab=cms.untracked.bool(True) +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion