00001 #include "DataFormats/Math/interface/deltaR.h"
00002 #include "DataFormats/PatCandidates/interface/Flags.h"
00003 #include "DataFormats/Common/interface/TriggerResults.h"
00004 #include "DataFormats/PatCandidates/interface/Electron.h"
00005 #include "TopQuarkAnalysis/Examples/plugins/TopElecAnalyzer.h"
00006 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
00007
00008 TopElecAnalyzer::TopElecAnalyzer(const edm::ParameterSet& cfg):
00009 elecs_(cfg.getParameter<edm::InputTag>("input"))
00010 {
00011 edm::Service<TFileService> fs;
00012
00013 nrElec_ = fs->make<TH1I>("NrElec", "Nr_{Elec}", 10, 0 , 10 );
00014 ptElec_ = fs->make<TH1F>("ptElec", "pt_{Elec}", 100, 0.,300.);
00015 enElec_ = fs->make<TH1F>("enElec", "en_{Elec}", 100, 0.,300.);
00016 etaElec_= fs->make<TH1F>("etaElec", "eta_{Elec}", 100, -3., 3.);
00017 phiElec_= fs->make<TH1F>("phiElec", "phi_{Elec}", 100, -5., 5.);
00018 dptElec_= fs->make<TH1F>("dptElec", "dpt_{Elec}", 100, -2., 2.);
00019 denElec_= fs->make<TH1F>("denElec", "den_{Elec}", 100, -2., 2.);
00020 genElec_= fs->make<TH1F>("genElec", "gen_{Elec}", 100, -2., 2.);
00021 trgElec_= fs->make<TH1F>("trgElec", "trg_{Elec}", 100, -1., 1.);
00022
00023 CountInSize_T=fs->make<TH2D>("NumDepoInIsoConeVsConeSize_T","NumDepoInIsoConeVsConeSize_T",30,0.04,0.34,50,0.,50.);
00024 CountInSize_E=fs->make<TH2D>("NumDepoInIsoConeVsConeSize_E","NumDepoInIsoConeVsConeSize_E",30,0.04,0.34,50,0.,50.);
00025 CountInSize_H=fs->make<TH2D>("NumDepoInIsoConeVsConeSize_H","NumDepoInIsoConeVsConeSize_H",30,0.04,0.34,50,0.,50.);
00026
00027 DepoInSize_T =fs->make<TH2D>("AmountDepoInIsoConeVsConeSize_T","AmountDepoInIsoConeVsConeSize_T",30,0.04,0.34,50,0.,50.);
00028 DepoInSize_E =fs->make<TH2D>("AmountDepoInIsoConeVsConeSize_E","AmountDepoInIsoConeVsConeSize_E",30,0.04,0.34,50,0.,50.);
00029 DepoInSize_H =fs->make<TH2D>("AmountDepoInIsoConeVsConeSize_H","AmountDepoInIsoConeVsConeSize_H",30,0.04,0.34,50,0.,50.);
00030
00031 Count_Threshold_T=fs->make<TH2D>("NumDepoInIsoConeVsConeSize_Threshold_T","NumDepoInIsoConeVsConeSize_Threshold_T",30,0.04,0.34,50,0.,50.);
00032 Count_Threshold_E=fs->make<TH2D>("NumDepoInIsoConeVsConeSize_Threshold_E","NumDepoInIsoConeVsConeSize_Threshold_E",30,0.04,0.34,50,0.,50.);
00033 Count_Threshold_H=fs->make<TH2D>("NumDepoInIsoConeVsConeSize_Threshold_H","NumDepoInIsoConeVsConeSize_Threshold_H",30,0.04,0.34,50,0.,50.);
00034
00035 Depo_Threshold_T=fs->make<TH2D>("AmountDepoInIsoConeVsConeSize_Threshold_T","AmountDepoInIsoConeVsConeSize_Threshold_T",30,0.04,0.34,50,0.,50.);
00036 Depo_Threshold_E=fs->make<TH2D>("AmountDepoInIsoConeVsConeSize_Threshold_E","AmountDepoInIsoConeVsConeSize_Threshold_E",30,0.04,0.34,50,0.,50.);
00037 Depo_Threshold_H=fs->make<TH2D>("AmountDepoInIsoConeVsConeSize_Threshold_H","AmountDepoInIsoConeVsConeSize_Threshold_H",30,0.04,0.34,50,0.,50.);
00038 }
00039
00040 TopElecAnalyzer::~TopElecAnalyzer()
00041 {
00042 }
00043
00044 void
00045 TopElecAnalyzer::analyze(const edm::Event& evt, const edm::EventSetup& setup)
00046 {
00047 edm::Handle<std::vector<pat::Electron> > elecs;
00048 evt.getByLabel(elecs_, elecs);
00049
00050 nrElec_->Fill( elecs->size() );
00051 for( std::vector<pat::Electron>::const_iterator elec=elecs->begin();
00052 elec!=elecs->end(); ++elec){
00053
00054
00055
00056 ptElec_ ->Fill( elec->pt() );
00057 enElec_ ->Fill( elec->energy());
00058 etaElec_->Fill( elec->eta() );
00059 phiElec_->Fill( elec->phi() );
00060
00061
00062
00063
00064 if(pat::Flags::test(*elec, pat::Flags::Isolation::Tracker)){
00065 std::cout << "Electron is Tracker Isolated" << std::endl;
00066 }
00067
00068
00069
00070
00071
00072
00073 edm::Handle<edm::TriggerResults> triggerBits;
00074 evt.getByLabel("TriggerResults",triggerBits);
00075
00076 unsigned bit = 0;
00077 if(triggerBits.isValid()){
00078 std::cout << "Trigger Bit [" << bit << "] = " << triggerBits->at(bit).accept() << std::endl;
00079 }
00080
00081
00082
00083
00084 int trigIdx =-1 ;
00085 double minDR=-1.;
00086 const std::vector<pat::TriggerPrimitive> trig = elec->triggerMatches();
00087 for(unsigned idx = 0; idx<trig.size(); ++idx){
00088 std::cout << "Trigger Match: " << trig[idx].filterName() << std::endl;
00089 double dR=deltaR(trig[idx].eta(), trig[idx].phi(), elec->eta(), elec->phi());
00090 if( minDR<0 || dR<minDR ){
00091 minDR=dR;
00092 trigIdx=idx;
00093 }
00094 }
00095 if(trigIdx>=0){
00096 trgElec_->Fill((trig[trigIdx].pt()-elec->pt())/elec->pt());
00097 }
00098
00099
00100
00101
00102 const std::vector<pat::Electron::IdPair> electronIDs = elec->electronIDs();
00103 for(unsigned idx=0; idx<electronIDs.size(); ++idx){
00104 std::cout << ::std::setw( 25 ) << ::std::left << electronIDs[idx].first << ":" << electronIDs[idx].second << std::endl;
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 bool track=true, gsfTrack=true, superClus=true, genMatch=true;
00122
00123 if(!elec->track()){
00124 track=false;
00125 std::cout << "TrackRef : is not valid" << std::endl;
00126 }
00127 if(!elec->gsfTrack()){
00128 gsfTrack=false;
00129 std::cout << "gsfTrackRef : is not valid" << std::endl;
00130 }
00131 if(!elec->superCluster()){
00132 superClus=false;
00133 std::cout << "superCluster : is not valid" << std::endl;
00134 }
00135 if(!elec->genLepton()){
00136 genMatch=false;
00137 std::cout << "genMatchRef : is not valid" << std::endl;
00138 }
00139
00140 if(gsfTrack && track ){
00141 dptElec_->Fill( (elec->track()->pt() - elec->gsfTrack()->pt())/elec->gsfTrack()->pt() );
00142 }
00143 if(gsfTrack && superClus){
00144 denElec_->Fill( (elec->superCluster()->energy()- elec->gsfTrack()->pt())/elec->gsfTrack()->pt() );
00145 }
00146
00147 if(elec->genLepton()){
00148 genElec_->Fill( (elec->gsfTrack()->pt() - elec->genLepton()->pt())/elec->genLepton()->pt() );
00149 }
00150
00151
00152
00153
00154
00155 const reco::IsoDeposit *TID=0;
00156 TID = elec->trackerIsoDeposit();
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 double radius=0.0;
00174 for(int i=0;i<6;i++)
00175 {
00176
00177 radius+=0.05;
00178 CountInSize_T->Fill(radius,TID->depositAndCountWithin(radius).second);
00179 DepoInSize_T ->Fill(radius,TID->depositAndCountWithin(radius).first);
00180
00181
00182 double Threshold=0.3;
00183 Count_Threshold_T->Fill(radius,TID->depositAndCountWithin(radius,reco::IsoDeposit::Vetos(),Threshold).second);
00184 Depo_Threshold_T ->Fill(radius,TID->depositAndCountWithin(radius,reco::IsoDeposit::Vetos(),Threshold).first);
00185
00186 }
00187
00188
00189
00190
00191 const reco::IsoDeposit *EID=0;
00192 const reco::IsoDeposit *HID=0;
00193 EID = elec->ecalIsoDeposit();
00194 HID = elec->hcalIsoDeposit();
00195
00196
00197
00198
00199
00200
00201
00202
00203 for(int i=1;i<30;i++)
00204 {
00205
00206 double radius=i/100;
00207 CountInSize_E->Fill(radius,EID->depositAndCountWithin(radius).second);
00208 DepoInSize_E ->Fill(radius,EID->depositAndCountWithin(radius).first);
00209
00210 CountInSize_H->Fill(radius,HID->depositAndCountWithin(radius).second);
00211 DepoInSize_H ->Fill(radius,HID->depositAndCountWithin(radius).first);
00212
00213
00214 double Threshold=0.3;
00215 Count_Threshold_E->Fill(radius,EID->depositAndCountWithin(radius,reco::IsoDeposit::Vetos(),Threshold).second);
00216 Depo_Threshold_E ->Fill(radius,EID->depositAndCountWithin(radius,reco::IsoDeposit::Vetos(),Threshold).first);
00217
00218 Count_Threshold_H->Fill(radius,HID->depositAndCountWithin(radius,reco::IsoDeposit::Vetos(),Threshold).second);
00219 Depo_Threshold_H ->Fill(radius,HID->depositAndCountWithin(radius,reco::IsoDeposit::Vetos(),Threshold).first);
00220
00221 }
00222
00223 }
00224 }
00225
00226 void TopElecAnalyzer::beginJob(const edm::EventSetup&)
00227 {
00228 }
00229
00230 void TopElecAnalyzer::endJob()
00231 {
00232 }
00233