Go to the documentation of this file.00001
00009 #include "HLTrigger/Egamma/interface/HLTEgammaL1MatchFilterPairs.h"
00010
00011
00012
00013 #include "DataFormats/Common/interface/Handle.h"
00014
00015 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00016
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018
00019
00020
00021 #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h"
00022 #include "CondFormats/DataRecord/interface/L1CaloGeometryRecord.h"
00023
00024 #include "FWCore/Framework/interface/ESHandle.h"
00025 #include "FWCore/Framework/interface/EventSetup.h"
00026
00027 #include <vector>
00028
00029 #define TWOPI 6.283185308
00030
00031
00032
00033 HLTEgammaL1MatchFilterPairs::HLTEgammaL1MatchFilterPairs(const edm::ParameterSet& iConfig)
00034 {
00035 candIsolatedTag_ = iConfig.getParameter< edm::InputTag > ("candIsolatedTag");
00036 l1IsolatedTag_ = iConfig.getParameter< edm::InputTag > ("l1IsolatedTag");
00037 candNonIsolatedTag_ = iConfig.getParameter< edm::InputTag > ("candNonIsolatedTag");
00038 l1NonIsolatedTag_ = iConfig.getParameter< edm::InputTag > ("l1NonIsolatedTag");
00039 L1SeedFilterTag_ = iConfig.getParameter< edm::InputTag > ("L1SeedFilterTag");
00040
00041 AlsoNonIsolatedFirst_ = iConfig.getParameter<bool>("AlsoNonIsolatedFirst");
00042 AlsoNonIsolatedSecond_ = iConfig.getParameter<bool>("AlsoNonIsolatedSecond");
00043
00044 region_eta_size_ = iConfig.getParameter<double> ("region_eta_size");
00045 region_eta_size_ecap_ = iConfig.getParameter<double> ("region_eta_size_ecap");
00046 region_phi_size_ = iConfig.getParameter<double> ("region_phi_size");
00047 barrel_end_ = iConfig.getParameter<double> ("barrel_end");
00048 endcap_end_ = iConfig.getParameter<double> ("endcap_end");
00049
00050
00051 produces<trigger::TriggerFilterObjectWithRefs>();
00052 }
00053
00054 HLTEgammaL1MatchFilterPairs::~HLTEgammaL1MatchFilterPairs(){}
00055
00056
00057
00058 bool
00059 HLTEgammaL1MatchFilterPairs::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00060 {
00061
00062 using namespace trigger;
00063 using namespace l1extra;
00064 std::auto_ptr<trigger::TriggerFilterObjectWithRefs> filterobject (new trigger::TriggerFilterObjectWithRefs(path(),module()));
00065 std::vector < std::pair< edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> > > thePairs;
00066
00067 edm::Handle<reco::RecoEcalCandidateCollection> recoIsolecalcands;
00068 iEvent.getByLabel(candIsolatedTag_,recoIsolecalcands);
00069 edm::Handle<reco::RecoEcalCandidateCollection> recoNonIsolecalcands;
00070 iEvent.getByLabel(candNonIsolatedTag_,recoNonIsolecalcands);
00071
00072
00073 for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand1= recoIsolecalcands->begin(); recoecalcand1!=recoIsolecalcands->end(); recoecalcand1++) {
00074 edm::Ref<reco::RecoEcalCandidateCollection> ref1 = edm::Ref<reco::RecoEcalCandidateCollection>(recoIsolecalcands, distance(recoIsolecalcands->begin(),recoecalcand1) );
00075 for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand2= recoIsolecalcands->begin(); recoecalcand2!=recoIsolecalcands->end(); recoecalcand2++) {
00076 edm::Ref<reco::RecoEcalCandidateCollection> ref2 = edm::Ref<reco::RecoEcalCandidateCollection>(recoIsolecalcands, distance(recoIsolecalcands->begin(),recoecalcand2) );
00077 if( &(*ref1) != &(*ref2) ) {thePairs.push_back(std::pair< edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> > (ref1,ref2) );}
00078 }
00079 if (AlsoNonIsolatedSecond_){
00080 for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand2= recoNonIsolecalcands->begin(); recoecalcand2!=recoNonIsolecalcands->end(); recoecalcand2++) {
00081 edm::Ref<reco::RecoEcalCandidateCollection> ref2 = edm::Ref<reco::RecoEcalCandidateCollection>(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(),recoecalcand2) );
00082 if( &(*ref1) != &(*ref2) ) {thePairs.push_back(std::pair< edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> > (ref1,ref2) );}
00083 }
00084 }
00085 }
00086
00087
00088
00089 if (AlsoNonIsolatedFirst_){
00090 for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand1= recoNonIsolecalcands->begin(); recoecalcand1!=recoNonIsolecalcands->end(); recoecalcand1++) {
00091 edm::Ref<reco::RecoEcalCandidateCollection> ref1 = edm::Ref<reco::RecoEcalCandidateCollection>(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(),recoecalcand1) );
00092 for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand2= recoIsolecalcands->begin(); recoecalcand2!=recoIsolecalcands->end(); recoecalcand2++) {
00093 edm::Ref<reco::RecoEcalCandidateCollection> ref2 = edm::Ref<reco::RecoEcalCandidateCollection>(recoIsolecalcands, distance(recoIsolecalcands->begin(),recoecalcand2) );
00094 if( &(*ref1) != &(*ref2) ) {thePairs.push_back(std::pair< edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> > (ref1,ref2) );}
00095 }
00096 if (AlsoNonIsolatedSecond_){
00097 for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand2= recoNonIsolecalcands->begin(); recoecalcand2!=recoNonIsolecalcands->end(); recoecalcand2++) {
00098 edm::Ref<reco::RecoEcalCandidateCollection> ref2 = edm::Ref<reco::RecoEcalCandidateCollection>(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(),recoecalcand2) );
00099 if( &(*ref1) != &(*ref2) ) {thePairs.push_back(std::pair< edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> > (ref1,ref2) );}
00100 }
00101 }
00102 }
00103 }
00104
00105
00106
00107 edm::ESHandle<L1CaloGeometry> l1CaloGeom ;
00108 iSetup.get<L1CaloGeometryRecord>().get(l1CaloGeom) ;
00109
00110
00111
00112 int n(0);
00113
00114 edm::Handle<trigger::TriggerFilterObjectWithRefs> L1SeedOutput;
00115 iEvent.getByLabel (L1SeedFilterTag_,L1SeedOutput);
00116
00117 std::vector<l1extra::L1EmParticleRef > l1EGIso;
00118 L1SeedOutput->getObjects(TriggerL1IsoEG, l1EGIso);
00119 std::vector<l1extra::L1EmParticleRef > l1EGNonIso;
00120 L1SeedOutput->getObjects(TriggerL1NoIsoEG, l1EGNonIso);
00121
00122
00123
00124
00125
00126
00127
00128 std::vector < std::pair< edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> > >::iterator pairsIt;
00129 for (pairsIt = thePairs.begin(); pairsIt != thePairs.end(); pairsIt++){
00130
00131
00132
00133
00134 if ( CheckL1Matching(pairsIt->first,l1EGIso,l1EGNonIso) && CheckL1Matching(pairsIt->second,l1EGIso,l1EGNonIso) ){
00135 filterobject->addObject(TriggerCluster, pairsIt->first);
00136 filterobject->addObject(TriggerCluster, pairsIt->second);
00137 n++;
00138 }
00139 }
00140
00141
00142
00143
00144 bool accept(n>=1);
00145
00146
00147 iEvent.put(filterobject);
00148
00149 return accept;
00150 }
00151
00152 bool HLTEgammaL1MatchFilterPairs::CheckL1Matching(edm::Ref<reco::RecoEcalCandidateCollection>ref,std::vector<l1extra::L1EmParticleRef >& l1EGIso,std::vector<l1extra::L1EmParticleRef >& l1EGNonIso){
00153
00154 for (unsigned int i=0; i<l1EGIso.size(); i++) {
00155
00156 double etaBinLow = 0.;
00157 double etaBinHigh = 0.;
00158 if(fabs(ref->eta()) < barrel_end_){
00159 etaBinLow = l1EGIso[i]->eta() - region_eta_size_/2.;
00160 etaBinHigh = etaBinLow + region_eta_size_;
00161 }
00162 else{
00163 etaBinLow = l1EGIso[i]->eta() - region_eta_size_ecap_/2.;
00164 etaBinHigh = etaBinLow + region_eta_size_ecap_;
00165 }
00166
00167 float deltaphi=fabs(ref->phi() -l1EGIso[i]->phi());
00168 if(deltaphi>TWOPI) deltaphi-=TWOPI;
00169 if(deltaphi>TWOPI/2.) deltaphi=TWOPI-deltaphi;
00170
00171 if(ref->eta() < etaBinHigh && ref->eta() > etaBinLow && deltaphi <region_phi_size_/2. ) {return true;}
00172
00173 }
00174
00175 for (unsigned int i=0; i<l1EGNonIso.size(); i++) {
00176
00177 double etaBinLow = 0.;
00178 double etaBinHigh = 0.;
00179 if(fabs(ref->eta()) < barrel_end_){
00180 etaBinLow = l1EGNonIso[i]->eta() - region_eta_size_/2.;
00181 etaBinHigh = etaBinLow + region_eta_size_;
00182 }
00183 else{
00184 etaBinLow = l1EGNonIso[i]->eta() - region_eta_size_ecap_/2.;
00185 etaBinHigh = etaBinLow + region_eta_size_ecap_;
00186 }
00187
00188 float deltaphi=fabs(ref->phi() - l1EGNonIso[i]->phi());
00189 if(deltaphi>TWOPI) deltaphi-=TWOPI;
00190 if(deltaphi>TWOPI/2.) deltaphi=TWOPI-deltaphi;
00191
00192 if(ref->eta() < etaBinHigh && ref->eta() > etaBinLow && deltaphi <region_phi_size_/2. ) {return true;}
00193
00194 }
00195
00196 return false;
00197 }