![]() |
![]() |
00001 00009 #include "HLTrigger/Egamma/interface/HLTElectronPixelMatchFilter.h" 00010 00011 #include "DataFormats/Common/interface/Handle.h" 00012 00013 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h" 00014 00015 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00016 00017 #include "DataFormats/Common/interface/AssociationMap.h" 00018 00019 #include "DataFormats/CaloRecHit/interface/CaloCluster.h" 00020 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h" 00021 00022 #include "DataFormats/EgammaReco/interface/SuperCluster.h" 00023 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" 00024 #include "DataFormats/EgammaReco/interface/ElectronSeed.h" 00025 #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h" 00026 00027 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h" 00028 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h" 00029 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h" 00030 00031 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" 00032 00033 // 00034 // constructors and destructor 00035 // 00036 HLTElectronPixelMatchFilter::HLTElectronPixelMatchFilter(const edm::ParameterSet& iConfig) 00037 { 00038 candTag_ = iConfig.getParameter< edm::InputTag > ("candTag"); 00039 00040 L1IsoPixelSeedsTag_ = iConfig.getParameter< edm::InputTag > ("L1IsoPixelSeedsTag"); 00041 L1NonIsoPixelSeedsTag_ = iConfig.getParameter< edm::InputTag > ("L1NonIsoPixelSeedsTag"); 00042 00043 npixelmatchcut_ = iConfig.getParameter<double> ("npixelmatchcut"); 00044 ncandcut_ = iConfig.getParameter<int> ("ncandcut"); 00045 00046 doIsolated_ = iConfig.getParameter<bool> ("doIsolated"); 00047 00048 store_ = iConfig.getUntrackedParameter<bool> ("SaveTag",false) ; 00049 L1IsoCollTag_= iConfig.getParameter< edm::InputTag > ("L1IsoCand"); 00050 L1NonIsoCollTag_= iConfig.getParameter< edm::InputTag > ("L1NonIsoCand"); 00051 00052 //register your products 00053 produces<trigger::TriggerFilterObjectWithRefs>(); 00054 } 00055 00056 00057 HLTElectronPixelMatchFilter::~HLTElectronPixelMatchFilter(){} 00058 00059 00060 // ------------ method called to produce the data ------------ 00061 bool 00062 HLTElectronPixelMatchFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) 00063 { 00064 // The filter object 00065 using namespace trigger; 00066 std::auto_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct (new trigger::TriggerFilterObjectWithRefs(path(),module())); 00067 if( store_ ){filterproduct->addCollectionTag(L1IsoCollTag_);} 00068 if( store_ && !doIsolated_){filterproduct->addCollectionTag(L1NonIsoCollTag_);} 00069 // Ref to Candidate object to be recorded in filter object 00070 edm::Ref<reco::RecoEcalCandidateCollection> ref; 00071 00072 00073 edm::Handle<trigger::TriggerFilterObjectWithRefs> PrevFilterOutput; 00074 00075 iEvent.getByLabel (candTag_,PrevFilterOutput); 00076 00077 std::vector<edm::Ref<reco::RecoEcalCandidateCollection> > recoecalcands; 00078 PrevFilterOutput->getObjects(TriggerCluster, recoecalcands); 00079 00080 //get hold of the pixel seed - supercluster association map 00081 edm::Handle<reco::ElectronSeedCollection> L1IsoSeeds; 00082 iEvent.getByLabel (L1IsoPixelSeedsTag_,L1IsoSeeds); 00083 00084 edm::Handle<reco::ElectronSeedCollection> L1NonIsoSeeds; 00085 if(!doIsolated_){ 00086 iEvent.getByLabel (L1NonIsoPixelSeedsTag_,L1NonIsoSeeds); 00087 } 00088 00089 // look at all egammas, check cuts and add to filter object 00090 int n = 0; 00091 //std::cout<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"<<std::endl; 00092 for (unsigned int i=0; i<recoecalcands.size(); i++) { 00093 00094 ref = recoecalcands[i]; 00095 reco::SuperClusterRef recr2 = ref->superCluster(); 00096 00097 //std::cout<<"AA ref, e, eta, phi"<<&(*recr2)<<" "<<recr2->energy()<<" "<<recr2->eta()<<" "<<recr2->phi()<<std::endl; 00098 int nmatch = 0; 00099 00100 for(reco::ElectronSeedCollection::const_iterator it = L1IsoSeeds->begin(); 00101 it != L1IsoSeeds->end(); it++){ 00102 00103 edm::RefToBase<reco::CaloCluster> caloCluster = it->caloCluster() ; 00104 reco::SuperClusterRef scRef = caloCluster.castTo<reco::SuperClusterRef>() ; 00105 //std::cout<<"BB ref, e, eta, phi"<<&(*scRef)<<" "<<scRef->energy()<<" "<<scRef->eta()<<" "<<scRef->phi()<<std::endl; 00106 00107 if(&(*recr2) == &(*scRef)) { 00108 nmatch++; 00109 } 00110 } 00111 00112 if(!doIsolated_){ 00113 00114 for(reco::ElectronSeedCollection::const_iterator it = L1NonIsoSeeds->begin(); 00115 it != L1NonIsoSeeds->end(); it++){ 00116 edm::RefToBase<reco::CaloCluster> caloCluster = it->caloCluster() ; 00117 reco::SuperClusterRef scRef = caloCluster.castTo<reco::SuperClusterRef>() ; 00118 //std::cout<<"CC ref, e, eta, phi"<<&(*scRef)<<" "<<scRef->energy()<<" "<<scRef->eta()<<" "<<scRef->phi()<<std::endl; 00119 if(&(*recr2) == &(*scRef)) { 00120 nmatch++; 00121 } 00122 } 00123 00124 }//end if(!doIsolated_) 00125 00126 if ( nmatch >= npixelmatchcut_) { 00127 n++; 00128 filterproduct->addObject(TriggerCluster, ref); 00129 } 00130 00131 }//end of loop over candidates 00132 // std::cout<<"######################################################################"<<std::endl; 00133 // filter decision 00134 bool accept(n>=ncandcut_); 00135 00136 // put filter object into the Event 00137 iEvent.put(filterproduct); 00138 00139 return accept; 00140 } 00141 00142