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
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 #include "DataFormats/Common/interface/Handle.h"
00033 #include "FWCore/Framework/interface/ESHandle.h"
00034
00035 #include "DataFormats/TrackReco/interface/Track.h"
00036 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00037 #include "DataFormats/TrackReco/interface/TrackExtra.h"
00038
00039 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00040 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00041
00042 #include "TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h"
00043 #include "TrackingTools/TrackAssociator/interface/TrackAssociatorParameters.h"
00044 #include "TrackingTools/TrackAssociator/interface/TrackDetMatchInfo.h"
00045
00046 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00047 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00048 #include "DataFormats/DetId/interface/DetIdCollection.h"
00049
00050 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00051 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00052 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
00053
00054
00055
00056
00057
00058 class HighPtTrackEcalDetIdProducer : public edm::EDProducer {
00059 public:
00060 explicit HighPtTrackEcalDetIdProducer(const edm::ParameterSet&);
00061 ~HighPtTrackEcalDetIdProducer();
00062 void beginRun(edm::Run&, const edm::EventSetup&);
00063 void produce(edm::Event&, const edm::EventSetup&);
00064 private:
00065
00066 edm::InputTag inputCollection_;
00067 const CaloTopology* caloTopology_;
00068 TrackDetectorAssociator trackAssociator_;
00069 TrackAssociatorParameters parameters_;
00070 double ptcut_;
00071
00072 };
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 HighPtTrackEcalDetIdProducer::HighPtTrackEcalDetIdProducer(const edm::ParameterSet& iConfig)
00087 {
00088 inputCollection_ = iConfig.getParameter< edm::InputTag >("inputCollection"); ptcut_= iConfig.getParameter< double >("TrackPt");
00089
00090 produces< DetIdCollection >() ;
00091
00092 edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
00093 parameters_.loadParameters( parameters );
00094 trackAssociator_.useDefaultPropagator();
00095
00096 }
00097
00098
00099 HighPtTrackEcalDetIdProducer::~HighPtTrackEcalDetIdProducer()
00100 {
00101
00102
00103
00104
00105 }
00106
00107
00108
00109
00110
00111
00112 void
00113 HighPtTrackEcalDetIdProducer::beginRun(edm::Run & run, const edm::EventSetup & iSetup)
00114 {
00115 edm::ESHandle<CaloTopology> theCaloTopology;
00116 iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
00117 caloTopology_ = &(*theCaloTopology);
00118 }
00119
00120
00121 void
00122 HighPtTrackEcalDetIdProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00123 {
00124 using namespace edm;
00125 using reco::TrackCollection;
00126
00127 Handle<TrackCollection> tkTracks;
00128 iEvent.getByLabel(inputCollection_,tkTracks);
00129 std::auto_ptr< DetIdCollection > interestingDetIdCollection( new DetIdCollection() ) ;
00130 for(TrackCollection::const_iterator itTrack = tkTracks->begin();
00131 itTrack != tkTracks->end();
00132 ++itTrack) {
00133 if(itTrack->pt()>ptcut_){
00134 TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *itTrack, parameters_, TrackDetectorAssociator::InsideOut);
00135 if(info.crossedEcalIds.size()==0) break;
00136
00137 if(info.crossedEcalIds.size()>0){
00138 DetId centerId = info.crossedEcalIds.front();
00139
00140 const CaloSubdetectorTopology* topology = caloTopology_->getSubdetectorTopology(DetId::Ecal,centerId.subdetId());
00141 const std::vector<DetId>& ids = topology->getWindow(centerId, 5, 5);
00142 for ( std::vector<DetId>::const_iterator id = ids.begin(); id != ids.end(); ++id )
00143 if(std::find(interestingDetIdCollection->begin(), interestingDetIdCollection->end(), *id)
00144 == interestingDetIdCollection->end())
00145 interestingDetIdCollection->push_back(*id);
00146 }
00147 }
00148
00149 }
00150 iEvent.put(interestingDetIdCollection);
00151
00152 }
00153
00154 DEFINE_FWK_MODULE(HighPtTrackEcalDetIdProducer);