Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDProducer.h"
00027
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 #include "FWCore/Utilities/interface/InputTag.h"
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032
00033
00034 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00035 #include "FWCore/Framework/interface/EventSetup.h"
00036 #include "DataFormats/Common/interface/Handle.h"
00037 #include "FWCore/Framework/interface/ESHandle.h"
00038
00039 #include "DataFormats/TrackReco/interface/Track.h"
00040 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00041 #include "DataFormats/TrackReco/interface/TrackExtra.h"
00042
00043 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00044 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00045 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00046 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00047 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00048 #include "TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h"
00049 #include "TrackingTools/TrackAssociator/interface/TrackAssociatorParameters.h"
00050 #include "TrackingTools/TrackAssociator/interface/TrackDetMatchInfo.h"
00051
00052 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00053 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00054 #include "DataFormats/DetId/interface/DetIdCollection.h"
00055
00056 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00057 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00058 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
00059
00060 #include "AnalysisDataFormats/SUSYBSMObjects/interface/HSCPIsolation.h"
00061 #include "DataFormats/Common/interface/ValueMap.h"
00062 #include "DataFormats/Math/interface/deltaR.h"
00063 #include <iostream>
00064
00065
00066
00067
00068
00069 using namespace susybsm;
00070 using namespace edm;
00071
00072 class ProduceIsolationMap : public edm::EDProducer {
00073 public:
00074 explicit ProduceIsolationMap(const edm::ParameterSet&);
00075 ~ProduceIsolationMap();
00076 virtual void produce(edm::Event&, const edm::EventSetup&);
00077 private:
00078 edm::InputTag TKLabel_;
00079 edm::InputTag EBrecHitsLabel_;
00080 edm::InputTag EErecHitsLabel_;
00081 edm::InputTag HCALrecHitsLabel_;
00082 edm::InputTag inputCollection_;
00083 double TKIsolationPtcut_;
00084 double IsolationConeDR_;
00085 TrackDetectorAssociator trackAssociator_;
00086 TrackAssociatorParameters parameters_;
00087
00088 };
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 ProduceIsolationMap::ProduceIsolationMap(const edm::ParameterSet& iConfig)
00103 {
00104 TKLabel_ = iConfig.getParameter< edm::InputTag > ("TKLabel");
00105 inputCollection_ = iConfig.getParameter< edm::InputTag > ("inputCollection");
00106 TKIsolationPtcut_ = iConfig.getParameter< double > ("TkIsolationPtCut");
00107 IsolationConeDR_ = iConfig.getParameter< double > ("IsolationConeDR");
00108
00109
00110
00111 edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
00112 parameters_.loadParameters( parameters );
00113 trackAssociator_.useDefaultPropagator();
00114
00115
00116 produces<ValueMap<HSCPIsolation> >();
00117 }
00118
00119
00120 ProduceIsolationMap::~ProduceIsolationMap()
00121 {
00122 }
00123
00124 void
00125 ProduceIsolationMap::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00126 {
00127 using namespace edm;
00128 using namespace std;
00129
00130 using reco::TrackCollection;
00131
00132 Handle<TrackCollection> TKHandle;
00133 iEvent.getByLabel(TKLabel_,TKHandle);
00134 if(!TKHandle.isValid() ){ edm::LogError("ProduceIsolationMap") << "TK Tracks collection not found"; return; }
00135
00136
00137 auto_ptr<ValueMap<HSCPIsolation> > trackHSCPIsolMap(new ValueMap<HSCPIsolation> );
00138 ValueMap<HSCPIsolation>::Filler filler(*trackHSCPIsolMap);
00139
00140
00141 Handle<TrackCollection> tkTracks;
00142 iEvent.getByLabel(inputCollection_,tkTracks);
00143 std::vector<HSCPIsolation> IsolationInfoColl(tkTracks->size());
00144
00145 int TkIndex=0;
00146 for(TrackCollection::const_iterator itTrack = tkTracks->begin(); itTrack != tkTracks->end(); ++itTrack, TkIndex++) {
00147 TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *itTrack, parameters_, TrackDetectorAssociator::InsideOut);
00148
00149
00150 if(info.ecalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_ECAL_Energy(info.coneEnergy(IsolationConeDR_, TrackDetMatchInfo::EcalRecHits));}
00151 if(info.hcalRecHits.size()>0){IsolationInfoColl[TkIndex].Set_HCAL_Energy(info.coneEnergy(IsolationConeDR_, TrackDetMatchInfo::HcalRecHits));}
00152
00153
00154
00155 double SumPt = 0;
00156 double Count = 0;
00157 double CountHighPt = 0;
00158 for(TrackCollection::const_iterator itTrack2 = TKHandle->begin(); itTrack2 != TKHandle->end(); ++itTrack2){
00159 if(fabs(itTrack->pt()-itTrack2->pt())<0.1 && fabs(itTrack->eta()-itTrack2->eta())<0.05)continue;
00160 float dR = deltaR(itTrack->momentum(), itTrack2->momentum());
00161 if(dR>IsolationConeDR_)continue;
00162 SumPt+= itTrack2->pt();
00163 Count++;
00164 if(itTrack2->pt()<TKIsolationPtcut_)continue;
00165 CountHighPt++;
00166 }
00167 IsolationInfoColl[TkIndex].Set_TK_CountHighPt(CountHighPt);
00168 IsolationInfoColl[TkIndex].Set_TK_Count (Count);
00169 IsolationInfoColl[TkIndex].Set_TK_SumEt (SumPt);
00170 }
00171
00172 filler.insert(tkTracks, IsolationInfoColl.begin(), IsolationInfoColl.end());
00173 filler.fill();
00174 iEvent.put(trackHSCPIsolMap);
00175 }
00176
00177 DEFINE_FWK_MODULE(ProduceIsolationMap);