Go to the documentation of this file.00001
00012 #include "HLTrigger/special/interface/HLTPixlMBForAlignmentFilter.h"
00013
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "FWCore/Framework/interface/EventSetup.h"
00016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00017
00018 #include "DataFormats/Common/interface/Handle.h"
00019
00020 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00021 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
00022
00023 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00024
00025 #include "DataFormats/TrackReco/interface/Track.h"
00026 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00027
00028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00029
00030
00031
00032
00033
00034 HLTPixlMBForAlignmentFilter::HLTPixlMBForAlignmentFilter(const edm::ParameterSet& iConfig) :
00035 pixlTag_ (iConfig.getParameter<edm::InputTag>("pixlTag")),
00036 min_Pt_ (iConfig.getParameter<double>("MinPt")),
00037 min_trks_ (iConfig.getParameter<unsigned int>("MinTrks")),
00038 min_sep_ (iConfig.getParameter<double>("MinSep")),
00039 min_isol_ (iConfig.getParameter<double>("MinIsol"))
00040
00041 {
00042 LogDebug("") << "MinPt cut " << min_Pt_ << "pixl: " << pixlTag_.encode();
00043 LogDebug("") << "Requesting : " << min_trks_ << " tracks from same vertex ";
00044 LogDebug("") << "Requesting tracks from same vertex eta-phi separation by " << min_sep_;
00045 LogDebug("") << "Requesting track to be isolated within cone of " << min_isol_;
00046
00047 produces<trigger::TriggerFilterObjectWithRefs>();
00048 }
00049
00050 HLTPixlMBForAlignmentFilter::~HLTPixlMBForAlignmentFilter()
00051 {
00052 }
00053
00054
00055
00056
00057
00058
00059 bool HLTPixlMBForAlignmentFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00060 {
00061 using namespace std;
00062 using namespace edm;
00063 using namespace reco;
00064 using namespace trigger;
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 Handle<RecoChargedCandidateCollection> tracks;
00077
00078 iEvent.getByLabel(pixlTag_,tracks);
00079
00080
00081
00082 vector<double> etastore;
00083 vector<double> phistore;
00084 vector<double> ptstore;
00085 vector<int> itstore;
00086 bool accept = false;
00087 RecoChargedCandidateCollection::const_iterator apixl(tracks->begin());
00088 RecoChargedCandidateCollection::const_iterator epixl(tracks->end());
00089 RecoChargedCandidateCollection::const_iterator ipixl, jpixl;
00090 int itrk = 0;
00091 double zvtxfit = 0.0;
00092 double zvtxfit2 = 0.0;
00093 if (tracks->size() >= min_trks_) {
00094 etastore.clear();
00095 phistore.clear();
00096 itstore.clear();
00097 for (ipixl=apixl; ipixl!=epixl; ipixl++){
00098 const double& ztrk1 = ipixl->vz();
00099 const double& etatrk1 = ipixl->momentum().eta();
00100 const double& phitrk1 = ipixl->momentum().phi();
00101 const double& pttrk1 = ipixl->pt();
00102 zvtxfit = zvtxfit + ztrk1;
00103 zvtxfit2 = zvtxfit2 + ztrk1*ztrk1;
00104 if (pttrk1 > min_Pt_) {
00105
00106
00107 etastore.push_back(etatrk1);
00108 phistore.push_back(phitrk1);
00109 ptstore.push_back(pttrk1);
00110 itstore.push_back(itrk);
00111 }
00112 itrk++;
00113 }
00114
00115 zvtxfit = zvtxfit/itrk;
00116 zvtxfit2 = zvtxfit2/itrk;
00117 zvtxfit2 = sqrt(zvtxfit2 - zvtxfit*zvtxfit);
00118
00119 vector<int> locisol;
00120 if (itstore.size() > 1) {
00121
00122 locisol.clear();
00123 for (unsigned int i=0; i<itstore.size(); i++) {
00124 int nincone=0;
00125
00126 for (ipixl=apixl; ipixl!=epixl; ipixl++){
00127 double phidist=std::abs( phistore.at(i) - ipixl->momentum().phi() );
00128 double etadist=std::abs( etastore.at(i) - ipixl->momentum().eta() );
00129 double trkdist = sqrt(phidist*phidist + etadist*etadist);
00130 if (trkdist < min_isol_) nincone++;
00131 }
00132
00133 if (nincone < 2) locisol.push_back(i);
00134 }
00135 }
00136
00137 vector<int> itsep;
00138 for (unsigned int i=0; i<locisol.size(); i++) {
00139
00140 itsep.clear();
00141 itsep.push_back(locisol.at(i));
00142 for (unsigned int j=i+1; j<locisol.size(); j++) {
00143
00144 double phidist = phistore.at(locisol.at(i))-phistore.at(locisol.at(j));
00145 double etadist = etastore.at(locisol.at(i))-etastore.at(locisol.at(j));
00146 double dist = sqrt(phidist*phidist + etadist*etadist);
00147 if (dist > min_sep_) {
00148 if (itsep.size() == 1) {
00149 itsep.push_back(locisol.at(j));
00150 } else {
00151 bool is_separated = true;
00152 for (unsigned int k=0; k<itsep.size(); k++){
00153
00154 double phisep = phistore.at(itsep.at(k))-phistore.at(locisol.at(j));
00155 double etasep = etastore.at(itsep.at(k))-etastore.at(locisol.at(j));
00156 double sep = sqrt(phisep*phisep + etasep*etasep);
00157 if (sep < min_sep_) {
00158
00159 is_separated = false;
00160 break;
00161 }
00162 }
00163 if (is_separated) itsep.push_back(locisol.at(j));
00164 }
00165 }
00166 if (itsep.size() >= min_trks_) {
00167 accept = true;
00168 break;
00169 }
00170 }
00171 if (accept) {
00172 break;
00173 }
00174 }
00175
00176
00177
00178
00179 auto_ptr<TriggerFilterObjectWithRefs> filterobject (new TriggerFilterObjectWithRefs(path(),module()));
00180
00181 if (accept) {
00182 for (unsigned int ipos=0; ipos < itsep.size(); ipos++) {
00183 int iaddr=itstore.at(itsep.at(ipos));
00184 filterobject->addObject(TriggerTrack,RecoChargedCandidateRef(tracks,iaddr));
00185 }
00186
00187 }
00188
00189 iEvent.put(filterobject);
00190 }
00191
00192
00193
00194
00195
00196
00197 return accept;
00198
00199 }