Skip to content

Commit

Permalink
Merge pull request cms-sw#13 from bainbrid/tidy_up
Browse files Browse the repository at this point in the history
WIP: tidy up + new vars
  • Loading branch information
Mauro Verzetti authored Oct 5, 2018
2 parents 555bc2d + b81504e commit 8ec700b
Show file tree
Hide file tree
Showing 6 changed files with 529 additions and 155 deletions.
121 changes: 121 additions & 0 deletions interface/ElectronNtuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ElectronNtuple {
void fill_gsf_trk(const reco::GsfTrackRef trk, const reco::BeamSpot &spot);
void fill_preid(const reco::PreId &preid, const reco::BeamSpot &spot, const int num_gsf);
void fill_ele(const reco::GsfElectronRef ele, float mvaid_v1=-2, float mvaid_v2=-2);
void fill_supercluster(const reco::GsfElectronRef ele);
void fill_ktf_trk(const reco::TrackRef trk, const reco::BeamSpot &spot);
void fill_GSF_ECAL_cluster_info(
const reco::PFClusterRef cluster,
Expand Down Expand Up @@ -289,6 +290,126 @@ class ElectronNtuple {
// float pfecal_correctedEnergy[NECAL_PFCLUSTERS] = {0};
// float pfecal_deta_impact[NECAL_PFCLUSTERS] = {0};

//


float core_shFracHits_ = -1.;

// Track-Cluster matching //////////

float match_SC_EoverP_ = -1.;

float match_SC_dEta_ = -1.;
float match_SC_dPhi_ = -1.;

float match_seed_EoverP_ = -1.;
float match_seed_EoverPout_ = -1.;

float match_seed_dEta_ = -1.;
float match_seed_dPhi_ = -1.;
float match_seed_dEta_vtx_ = -1.;

float match_eclu_EoverP_ = -1.;

float match_eclu_dEta_ = -1.;
float match_eclu_dPhi_ = -1.;

// Fiducial flags (booleans) //////////

int fiducial_isEB_ = -1;
int fiducial_isEE_ = -1;

int fiducial_isGap_ = -1;
int fiducial_isEBEEGap_ = -1;
int fiducial_isEBGap_ = -1;
int fiducial_isEBEtaGap_ = -1;
int fiducial_isEBPhiGap_ = -1;
int fiducial_isEEGap_ = -1;
int fiducial_isEEDeeGap_ = -1;
int fiducial_isEERingGap_ = -1;

// Shower shape //////////

float shape_sigmaEtaEta_ = -1.;
float shape_sigmaIetaIeta_ = -1.;
float shape_sigmaIphiIphi_ = -1.;

float shape_e1x5_ = -1.;
float shape_e2x5Max_ = -1.;
float shape_e5x5_ = -1.;

float shape_r9_ = -1.;

float shape_HoverE_ = -1.;
float shape_HoverEBc_ = -1.;

float shape_hcalDepth1_ = -1.;
float shape_hcalDepth2_ = -1.;
float shape_hcalDepth1Bc_ = -1.;
float shape_hcalDepth2Bc_ = -1.;
int shape_nHcalTowersBc_ = -1;

float shape_eLeft_ = -1.;
float shape_eRight_ = -1.;
float shape_eTop_ = -1.;
float shape_eBottom_ = -1.;

// full 5x5

float shape_full5x5_sigmaEtaEta_ = -1.;
float shape_full5x5_sigmaIetaIeta_ = -1.;
float shape_full5x5_sigmaIphiIphi_ = -1.;
float shape_full5x5_circularity_ = -1.;

float shape_full5x5_e1x5_ = -1.;
float shape_full5x5_e2x5Max_ = -1.;
float shape_full5x5_e5x5_ = -1.;

float shape_full5x5_r9_ = -1.;

float shape_full5x5_HoverE_ = -1.;
float shape_full5x5_HoverEBc_ = -1.;

float shape_full5x5_hcalDepth1_ = -1.;
float shape_full5x5_hcalDepth2_ = -1.;
float shape_full5x5_hcalDepth1Bc_ = -1.;
float shape_full5x5_hcalDepth2Bc_ = -1.;

float shape_full5x5_eLeft_ = -1.;
float shape_full5x5_eRight_ = -1.;
float shape_full5x5_eTop_ = -1.;
float shape_full5x5_eBottom_ = -1.;

// Isolation variables //////////
// Conversion rejection //////////
// PFlow info //////////
// Preselection and ambiguity //////////
// Corrections //////////
// ???

// Brem fractions and classification //////////

float brem_frac_ = -1.;
float brem_fracTrk_ = -1.;
float brem_fracSC_ = -1.;
int brem_N_ = -1;

// SuperClusters //////////

float sc_etaWidth_ = -1.;
float sc_phiWidth_ = -1.;

float sc_ps_EoverEraw_ = -1.;
float sc_E_ = -1.;
float sc_Et_ = -1.;

float sc_eta_ = -1.;
float sc_phi_ = -1.;

float sc_RawE_ = -1.;
int sc_Nclus_ = -1;


};

#endif
47 changes: 23 additions & 24 deletions plugins/TrackerElectronsFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class TrackerElectronsFeatures: public edm::EDAnalyzer {
bool check_from_B_;
bool hit_association_;
double dr_max_; //for DR Matching only
double fake_prescale_;
double fake_multiplier_;

const edm::EDGetTokenT< double > rho_;
Expand Down Expand Up @@ -156,7 +155,6 @@ TrackerElectronsFeatures::TrackerElectronsFeatures(const ParameterSet& cfg):
check_from_B_{cfg.getParameter<bool>("checkFromB")},
hit_association_{cfg.getParameter<bool>("hitAssociation")},
dr_max_{cfg.getParameter<double>("drMax")},
fake_prescale_{cfg.getParameter<double>("prescaleFakes")},
fake_multiplier_{cfg.getParameter<double>("fakesMultiplier")},
rho_{consumes< double >(cfg.getParameter<edm::InputTag>("rho"))},
preid_{consumes< vector<reco::PreId> >(cfg.getParameter<edm::InputTag>("preId"))},
Expand Down Expand Up @@ -285,20 +283,24 @@ TrackerElectronsFeatures::analyze(const Event& iEvent, const EventSetup& iSetup)
iEvent.getByToken(associator_, associator);
reco2sim = associator->associateRecoToSim(ele_seeds, tracking_particles);
}
/*std::cout << "DEBUG"
<< " preids: " << preids->size() << endl
<< " trk: " << ntrks
<< " pf_ktf_tracks: " << pf_ktf_tracks->size() << endl
<< " seeds: " << ele_seeds->size() << endl
<< " cands: " << trk_candidates->size() << endl
<< " gsf: " << gsf_tracks->size()
<< std::endl; //*/

// std::cout << "[TrackerElectronsFeatures::analyze]" << std::endl
// << " ele_seeds->size(): " << ele_seeds->size() << std::endl
// << " preids->size(): " << preids->size() << std::endl
// << " trk_candidates->size(): " << trk_candidates->size() << std::endl
// << " gsf_tracks->size(): " << gsf_tracks->size() << std::endl
// << " pf_gsf_tracks->size(): " << pf_gsf_tracks->size() << std::endl
// << " ged_electron_cores->size(): " << ged_electron_cores->size() << std::endl
// << " ged_electrons->size(): " << ged_electrons->size() << std::endl
// << std::endl;

//assert(gsf_tracks->size() == preids->size()); //this is bound to fail, but better check

std::map<reco::TrackRef, reco::PFRecTrackRef> trk2pftrk;
for(size_t i=0; i<pf_ktf_tracks->size(); i++) {
reco::PFRecTrackRef pftrk(pf_ktf_tracks, i);
//it = find (myvector.begin(), myvector.end(), 30);
//if (it != myvector.end())
if(trk2pftrk.find(pftrk->trackRef()) != trk2pftrk.end()) assert(false);

trk2pftrk.insert(pair<reco::TrackRef, reco::PFRecTrackRef>(pftrk->trackRef(), pftrk));
Expand Down Expand Up @@ -723,20 +725,17 @@ TrackerElectronsFeatures::analyze(const Event& iEvent, const EventSetup& iSetup)
}


//(prescaled) fill the backgrounds
//fill other electron quantities
for(size_t& seed_idx : other_tracks) {
if(gRandom->Rndm() >= fake_prescale_) continue; //the smaller the few tracks are kept

//@@ RB, use below instead of using fake_prescale_ above, to balance real/fake?
// std::vector<int> indices;
// int nfakes = 0;
// while ( nfakes < fake_multiplier_ ) {
// int index = int( gRandom->Rndm() * other_tracks.size() );
// if ( indices.find(index) != indices.end() ) { continue; }
// indices.push_back(index);
// nfakes++;
// size_t& seed_idx = other_tracks[index];
// fill the backgrounds (prescaled according to 'fakesMultiplier' configurable)
// fill other electron quantities
std::vector<int> indices;
unsigned int nfakes = 0;
while ( nfakes < other_tracks.size() && nfakes < fake_multiplier_ ) {

int index = int( gRandom->Rndm() * other_tracks.size() );
if ( std::find( indices.begin(), indices.end(), index ) != indices.end() ) { continue; }
indices.push_back(index);
nfakes++;
size_t& seed_idx = other_tracks[index];

ntuple_.reset();
ntuple_.set_rho(*rho);
Expand Down
3 changes: 1 addition & 2 deletions python/TrackerElectronsFeatures_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
isMC = cms.bool(True),
printPfBlock = cms.bool(False),
disableAssociation = cms.bool(False),
prescaleFakes = cms.double(0.08),
fakesMultiplier = cms.double(1.),
fakesMultiplier = cms.double(3.),
checkFromB = cms.bool(True),
rho = cms.InputTag('fixedGridRhoFastjetAllTmp'),
beamspot = cms.InputTag("offlineBeamSpot"),
Expand Down
48 changes: 24 additions & 24 deletions python/samples/BtoKee.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@
# 'file:/vols/cms/bainbrid/BParking/pick0.root', # gen ele +GSFtrk -GEDele
# 'file:/vols/cms/bainbrid/BParking/pick1.root', # gen ele +GSFtrk +PFBlockECAL -PFCand -GEDele
# 'file:/vols/cms/bainbrid/BParking/pick2.root', # gen ele +GSFtrk +PFBlockECAL +PFCand +GEDele
# 'file:/vols/cms/bainbrid/BParking/BtoKee_RAW.root',
base+'BToKee_PUMix_10.root',
base+'BToKee_PUMix_100.root',
base+'BToKee_PUMix_101.root',
base+'BToKee_PUMix_102.root',
base+'BToKee_PUMix_103.root',
base+'BToKee_PUMix_104.root',
base+'BToKee_PUMix_105.root',
base+'BToKee_PUMix_106.root',
base+'BToKee_PUMix_107.root',
base+'BToKee_PUMix_108.root',
base+'BToKee_PUMix_109.root',
base+'BToKee_PUMix_11.root',
base+'BToKee_PUMix_110.root',
base+'BToKee_PUMix_111.root',
base+'BToKee_PUMix_112.root',
base+'BToKee_PUMix_113.root',
base+'BToKee_PUMix_114.root',
base+'BToKee_PUMix_115.root',
base+'BToKee_PUMix_116.root',
base+'BToKee_PUMix_117.root',
base+'BToKee_PUMix_118.root',
base+'BToKee_PUMix_119.root',
base+'BToKee_PUMix_120.root',
'file:/vols/cms/bainbrid/BParking/BtoKee_RAW.root',
# base+'BToKee_PUMix_10.root',
# base+'BToKee_PUMix_100.root',
# base+'BToKee_PUMix_101.root',
# base+'BToKee_PUMix_102.root',
# base+'BToKee_PUMix_103.root',
# base+'BToKee_PUMix_104.root',
# base+'BToKee_PUMix_105.root',
# base+'BToKee_PUMix_106.root',
# base+'BToKee_PUMix_107.root',
# base+'BToKee_PUMix_108.root',
# base+'BToKee_PUMix_109.root',
# base+'BToKee_PUMix_11.root',
# base+'BToKee_PUMix_110.root',
# base+'BToKee_PUMix_111.root',
# base+'BToKee_PUMix_112.root',
# base+'BToKee_PUMix_113.root',
# base+'BToKee_PUMix_114.root',
# base+'BToKee_PUMix_115.root',
# base+'BToKee_PUMix_116.root',
# base+'BToKee_PUMix_117.root',
# base+'BToKee_PUMix_118.root',
# base+'BToKee_PUMix_119.root',
# base+'BToKee_PUMix_120.root',
]
else :
import sys
Expand Down
Loading

0 comments on commit 8ec700b

Please sign in to comment.