Skip to content

Commit

Permalink
release v0, for EXO meeting 02 Oct 2019
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Jensen committed Sep 29, 2019
1 parent 86eea24 commit 1152681
Show file tree
Hide file tree
Showing 9 changed files with 390 additions and 287 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,26 @@ These instructions are pulled from:
* `git cms-addpkg EgammaAnalysis/ElectronTools`
* `rm EgammaAnalysis/ElectronTools/data -rf`
* `git clone [email protected]:cms-data/EgammaAnalysis-ElectronTools.git EgammaAnalysis/ElectronTools/data`
* `scram build`

### Then install the ExcitedTau package
* `cd CMSSW_10_2_10/src`
* `git clone https://github.com/fojensen/ExcitedTau`
* `cd ExcitedTau/`
* `scram build`

### run on a test file:
### Do a test run on a signal file:
* `cmsRun excitingAnalyzer_cfg.py isSignalMC=True >& log &`

## To submit jobs/datasets to CRAB:
datasetsBkg.py and datasetSig.py contain the datasets which will be submitted to crab.
`python datasetsBkg.py`
`python datasetSig.py`
`datasetsBkg.py` and `datasetSig.py` contain entries which will eventually be submitted to crab.

`python datasetsBkg.py`
`python datasetSig.py`
generates JSON files to give to the submission script `submitToCrab.py`.

Comment/uncomment the appropriate line for signal or background:
`https://github.com/fojensen/ExcitedTau/blob/master/submitToCrab.py#L4-L5`, then run
`https://github.com/fojensen/ExcitedTau/blob/master/submitToCrab.py#L4-L5`, then run:
`python submitToCrab.py`
If you actually want to submit, uncomment the following line
`https://github.com/fojensen/ExcitedTau/blob/master/submitToCrab.py#L36`
Expand Down
5 changes: 3 additions & 2 deletions analyzers/src/ElectronProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ bool ElectronProducer::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
//https://twiki.cern.ch/CMS/EgammaIDRecipesRun2
for (auto i = electrons->begin(); i != electrons->end(); ++i) {
const double eta = std::abs(i->eta());
//const double eta = std::abs(i->superCluster.eta());
if (i->pt()>=minpt && eta<maxeta) {
if (eta<1.44||eta>=1.56) {
//if (eta<1.479||eta>=1.653) {
if (i->electronID("mvaEleID-Fall17-iso-V1-wp90")) {
goodElectrons->push_back(*i);
}
}
//}
}
}

Expand Down
14 changes: 7 additions & 7 deletions analyzers/src/EventAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EventAnalyzer : public edm::EDAnalyzer {

TTree * tree;
unsigned int nPhotons, nElectrons, nMuons, nTaus;
unsigned int BTags[3], NJets;
int nBJets[3], NJets;
unsigned int nJets, nVertices;
double MET_pt, MET_phi, metSignificance;
double xsWeight;
Expand All @@ -55,11 +55,11 @@ EventAnalyzer::EventAnalyzer(const edm::ParameterSet& iConfig)
tree->Branch("nElectrons", &nElectrons, "nElectrons/b");
tree->Branch("nMuons", &nMuons, "nMuons/b");
tree->Branch("nTaus", &nTaus, "nTaus/b");
tree->Branch("nJets", &nJets, "nJets/b");
tree->Branch("nJets", &nJets, "nJets/I");
tree->Branch("MET_pt", &MET_pt, "MET_pt/D");
tree->Branch("MET_phi", &MET_phi, "MET_phi/D");
tree->Branch("metSignificance", &metSignificance, "metSignificance/D");
tree->Branch("BTags", BTags, "BTags[3]/b");
tree->Branch("nBJets", nBJets, "nBJets[3]/I");
tree->Branch("nVertices", &nVertices, "nVertices/b");
xsWeight = iConfig.getParameter<double>("xsWeight");
tree->Branch("xsWeight", &xsWeight, "xsWeight/D");
Expand Down Expand Up @@ -97,13 +97,13 @@ void EventAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe
MET_phi = met->at(0).phi();
metSignificance = met->at(0).metSignificance();

BTags[0] = BTags[1] = BTags[2] = 0;
nBJets[0] = nBJets[1] = nBJets[2] = 0;
for (auto i = jets->begin(); i != jets->end(); ++i) {
//https://twiki.cern.ch/twiki/bin/viewauth/CMS/BtagRecommendation102X
const float disc = i->bDiscriminator("pfDeepCSVJetTags:probb")+i->bDiscriminator("pfDeepCSVJetTags:probbb");
if (disc>=0.1241) ++BTags[0];
if (disc>=0.4184) ++BTags[1];
if (disc>=0.7527) ++BTags[2];
if (disc>=0.1241) ++nBJets[0];
if (disc>=0.4184) ++nBJets[1];
if (disc>=0.7527) ++nBJets[2];
}

tree->Fill();
Expand Down
119 changes: 46 additions & 73 deletions analyzers/src/LeptonPairProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ class LeptonPairProducer : public edm::stream::EDProducer<> {
double maxeta_tau, minpt_tau;
double maxeta_photon, minpt_photon;
TTree * tree;
bool haveTriplet, havePair, havePhoton;
bool havePair, havePhoton;
double deltapt, deltaphi;
double gendr_tau, gendr_lepton;
bool isMC;
};

LeptonPairProducer::LeptonPairProducer(const edm::ParameterSet& iConfig)
Expand All @@ -71,18 +70,14 @@ LeptonPairProducer::LeptonPairProducer(const edm::ParameterSet& iConfig)

edm::Service<TFileService> fs;
tree = fs->make<TTree>("tree", "tree");
tree->Branch("haveTriplet", &haveTriplet, "haveTriplet/O");
tree->Branch("havePair", &havePair, "havePair/O");
tree->Branch("havePhoton", &havePhoton, "havePhoton/O");
tree->Branch("deltaphi", &deltaphi, "deltaphi/D");
tree->Branch("deltapt", &deltapt, "deltapt/D");

isMC = iConfig.getParameter<bool>("isMC");
if (isMC) {
genVisTauToken_ = consumes<pat::CompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("genVisTauCollection"));
tree->Branch("gendr_tau", &gendr_tau, "gendr_tau/D");
tree->Branch("gendr_lepton", &gendr_lepton, "gendr_lepton/D");
}
//gen matching
genVisTauToken_ = consumes<pat::CompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("genVisTauCollection"));
tree->Branch("gendr_tau", &gendr_tau, "gendr_tau/D");
tree->Branch("gendr_lepton", &gendr_lepton, "gendr_lepton/D");
}

void LeptonPairProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
Expand All @@ -91,7 +86,7 @@ void LeptonPairProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet
auto collinearTaus = std::make_unique<std::vector<pat::CompositeCandidate>>();
auto photonsOut = std::make_unique<std::vector<pat::PackedCandidate>>();

haveTriplet = havePair = havePhoton = false;
havePair = havePhoton = false;
deltaphi = deltapt = -9.;

edm::Handle<edm::View<reco::Candidate>> taus;
Expand All @@ -107,64 +102,43 @@ void LeptonPairProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet
pat::PackedCandidate lepton_vis;
pat::PackedCandidate photon;

havePair = false;
for (auto i = taus->begin(); i != taus->end(); ++i) {
if (i->pt()>=minpt_tau && std::abs(i->eta())<maxeta_tau) {
for (auto j = leptons->begin(); j != leptons->end(); ++j) {
if (j->pt()>=minpt_lepton && std::abs(j->eta())<maxeta_lepton) {
if (i->charge()*j->charge()==q1q2) {
for (auto k = photonsIn->begin(); k != photonsIn->end(); ++k) {
if (k->pt()>=minpt_photon && std::abs(k->eta())<maxeta_photon) {
if (reco::deltaR(*i, *j)>=0.4 && reco::deltaR(*i, *k)>=0.4 && reco::deltaR(*j, *k)>=0.4) {
tau_vis.setP4(i->p4());
tau_vis.setCharge(i->charge());
tau_vis.setPdgId(i->pdgId());
lepton_vis.setP4(j->p4());
lepton_vis.setCharge(j->charge());
lepton_vis.setPdgId(j->pdgId());
photon.setP4(k->p4());
photon.setCharge(k->charge());
photon.setPdgId(k->pdgId());
haveTriplet = true;
havePair = true;
havePhoton = true;
break;
}
}
if (reco::deltaR(*i, *j)>=0.4) {
tau_vis.setP4(i->p4());
tau_vis.setCharge(i->charge());
tau_vis.setPdgId(i->pdgId());
lepton_vis.setP4(j->p4());
lepton_vis.setCharge(j->charge());
lepton_vis.setPdgId(j->pdgId());
havePair = true;
break;
}
}
}
}
}
}

if (!haveTriplet) {
for (auto i = taus->begin(); i != taus->end(); ++i) {
if (i->pt()>=minpt_tau && std::abs(i->eta())<maxeta_tau) {
for (auto j = leptons->begin(); j != leptons->end(); ++j) {
if (j->pt()>=minpt_lepton && std::abs(j->eta())<maxeta_lepton) {
if (i->charge()*j->charge()==q1q2) {
if (reco::deltaR(*i, *j)>=0.4) {
tau_vis.setP4(i->p4());
tau_vis.setCharge(i->charge());
tau_vis.setPdgId(i->pdgId());
lepton_vis.setP4(j->p4());
lepton_vis.setCharge(j->charge());
lepton_vis.setPdgId(j->pdgId());
havePair = true;
break;
}
}
}
}
}
}
for (auto i = photonsIn->begin(); i != photonsIn->end(); ++i) {
if (i->pt()>=minpt_photon && std::abs(i->eta())<maxeta_photon) {

havePhoton = false;
for (auto i = photonsIn->begin(); i != photonsIn->end(); ++i) {
if (i->pt()>=minpt_photon && std::abs(i->eta())<maxeta_photon) {
if (havePair && reco::deltaR(tau_vis, *i)>=0.4 && reco::deltaR(lepton_vis, *i)>=0.4) {
photon.setP4(i->p4());
photon.setCharge(i->charge());
photon.setPdgId(i->pdgId());
havePhoton = true;
break;
} else {
photon.setP4(i->p4());
photon.setCharge(i->charge());
photon.setPdgId(i->pdgId());
havePhoton = true;
break;
}
}
}
Expand All @@ -174,22 +148,20 @@ void LeptonPairProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet
gendr_tau = gendr_lepton = 9.;
if (havePair) {

if (isMC) {
edm::Handle<pat::CompositeCandidateCollection> genVisTaus;
iEvent.getByToken(genVisTauToken_, genVisTaus);
for (auto i = genVisTaus->begin(); i != genVisTaus->end(); ++i) {
const int id = std::abs(i->pdgId());
if (std::abs(tau_vis.pdgId())==id) {
if (reco::deltaR(*i, tau_vis)<gendr_tau) {
gendr_tau = reco::deltaR(*i, tau_vis);
}
}
if (std::abs(lepton_vis.pdgId())==id) {
if (reco::deltaR(*i, lepton_vis)<gendr_lepton) {
gendr_lepton = reco::deltaR(*i, lepton_vis);
}
edm::Handle<pat::CompositeCandidateCollection> genVisTaus;
iEvent.getByToken(genVisTauToken_, genVisTaus);
for (auto i = genVisTaus->begin(); i != genVisTaus->end(); ++i) {
const int id = std::abs(i->pdgId());
if (std::abs(tau_vis.pdgId())==id) {
if (reco::deltaR(*i, tau_vis)<gendr_tau) {
gendr_tau = reco::deltaR(*i, tau_vis);
}
}
if (std::abs(lepton_vis.pdgId())==id) {
if (reco::deltaR(*i, lepton_vis)<gendr_lepton) {
gendr_lepton = reco::deltaR(*i, lepton_vis);
}
}
}

edm::Handle<std::vector<pat::MET>> met;
Expand All @@ -207,10 +179,11 @@ void LeptonPairProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet
const double nu0mag = MET.pt() * (cos0M-cos1M*cos01) / (1.-cos01*cos01);
const double nu1mag = (MET.pt()*cos1M) - (nu0mag*cos01);

//It has been verified analytically that the expressions above are the same as the expressions below by trig function manipulation
// const double nu0mag = METpt*sin(METphi-lepton_vis.phi())/sin(tau_vis.phi()-lepton_vis.phi());
// const double nu1mag = METpt*sin(METphi-tau_vis.phi())/sin(lepton_vis.phi()-tau_vis.phi());
//
//It has been verified analytically that the expressions above are the same as the
//expressions below by trig function manipulation
//const double nu0mag = METpt*sin(METphi-lepton_vis.phi())/sin(tau_vis.phi()-lepton_vis.phi());
//const double nu1mag = METpt*sin(METphi-tau_vis.phi())/sin(lepton_vis.phi()-tau_vis.phi());

reco::LeafCandidate tau_inv = reco::LeafCandidate(0, PolarLorentzVector(0., 0., 0., 0.));
PolarLorentzVector nu0_v;
nu0_v.SetEta(tau_vis.eta());
Expand Down Expand Up @@ -239,10 +212,10 @@ void LeptonPairProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet
const PolarLorentzVector lepton_v = lepton_vis.polarP4()+lepton_inv.polarP4();
lepton_col.setP4(lepton_v);

/* const PolarLorentzVector inv = tau_inv.polarP4()+lepton_inv.polarP4();
/*const PolarLorentzVector inv = tau_inv.polarP4()+lepton_inv.polarP4();
std::cout << " *** " << std::endl;
std::cout << "cos01: " << cos01 << " cos0M: " << cos0M << " cos1M: " << cos1M << std::endl;
// std::cout << "tau_inv_mag: " << tau_inv_mag << " lepton_inv_mag: " << lepton_inv_mag << std::endl;
//std::cout << "tau_inv_mag: " << tau_inv_mag << " lepton_inv_mag: " << lepton_inv_mag << std::endl;
std::cout << "MET: " << " px: " << met->at(0).px() << " py: " << met->at(0).py() << " pt: " << met->at(0).pt() << " phi: " << met->at(0).phi() << std::endl;
std::cout << "inv: " << " px: " << inv.px() << " py: " << inv.py() << " pt: " << inv.pt() << " phi: " << inv.phi() << std::endl;
std::cout << "tau_vis: " << " px: " << tau_vis.px() << " py: " << tau_vis.py() << " pt: " << tau_vis.pt() << " phi: " << tau_vis.phi() << " eta: " << tau_vis.eta() << std::endl;
Expand Down
5 changes: 3 additions & 2 deletions analyzers/src/PhotonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ bool PhotonProducer::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
//https://twiki.cern.ch/CMS/EgammaIDRecipesRun2
for (auto i = photons->begin(); i != photons->end(); ++i) {
const double eta = std::abs(i->eta());
//const double eta = std::abs(i->superCluster().eta());
if (i->pt()>=minpt && eta<maxeta) {
if (eta<1.44||eta>=1.56) {
//if (eta<1.479||eta>=1.653) {
if (i->passElectronVeto()) {
if (i->photonID("mvaPhoID-RunIIFall17-v1p1-wp90")) {
goodPhotons->push_back(*i);
}
}
}
//}
}
}
const size_t nPhotons = goodPhotons->size();
Expand Down
Loading

0 comments on commit 1152681

Please sign in to comment.