Go to the documentation of this file.00001 #include "FWCore/Framework/interface/Frameworkfwd.h"
00002 #include "FWCore/Framework/interface/EDProducer.h"
00003 #include "FWCore/Framework/interface/Event.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "FWCore/Utilities/interface/InputTag.h"
00006
00007 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00008 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00009 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
00010 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
00011 #include "DataFormats/TrackerRecHit2D/interface/ProjectedSiStripRecHit2D.h"
00012 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00013 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
00014 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
00015 #include "DataFormats/Common/interface/Handle.h"
00016 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00017 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00018 #include "DataFormats/Common/interface/DetSetVector.h"
00019 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00020 #include "DataFormats/Provenance/interface/ProductID.h"
00021
00022 #include "DataFormats/TrackReco/interface/Track.h"
00023 #include "DataFormats/TrackerRecHit2D/interface/ClusterRemovalInfo.h"
00024
00025 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00026 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
00027 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00028
00029
00030
00031
00032 class TopBottomClusterInfoProducer : public edm::EDProducer {
00033 public:
00034 TopBottomClusterInfoProducer(const edm::ParameterSet& iConfig) ;
00035 ~TopBottomClusterInfoProducer() ;
00036 void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) ;
00037
00038 private:
00039 edm::InputTag stripClustersOld_, pixelClustersOld_;
00040 edm::InputTag stripClustersNew_, pixelClustersNew_;
00041 };
00042
00043
00044 using namespace std;
00045 using namespace edm;
00046 using namespace reco;
00047
00048 TopBottomClusterInfoProducer::TopBottomClusterInfoProducer(const ParameterSet& iConfig):
00049 stripClustersOld_(iConfig.getParameter<InputTag>("stripClustersOld")),
00050 pixelClustersOld_(iConfig.getParameter<InputTag>("pixelClustersOld")),
00051 stripClustersNew_(iConfig.getParameter<InputTag>("stripClustersNew")),
00052 pixelClustersNew_(iConfig.getParameter<InputTag>("pixelClustersNew"))
00053 {
00054 produces< ClusterRemovalInfo >();
00055 }
00056
00057
00058 TopBottomClusterInfoProducer::~TopBottomClusterInfoProducer()
00059 {
00060 }
00061
00062 void
00063 TopBottomClusterInfoProducer::produce(Event& iEvent, const EventSetup& iSetup)
00064 {
00065
00066 Handle<edmNew::DetSetVector<SiPixelCluster> > pixelClustersOld;
00067 iEvent.getByLabel(pixelClustersOld_, pixelClustersOld);
00068 Handle<edmNew::DetSetVector<SiStripCluster> > stripClustersOld;
00069 iEvent.getByLabel(stripClustersOld_, stripClustersOld);
00070
00071 Handle<edmNew::DetSetVector<SiPixelCluster> > pixelClustersNew;
00072 iEvent.getByLabel(pixelClustersNew_, pixelClustersNew);
00073 Handle<edmNew::DetSetVector<SiStripCluster> > stripClustersNew;
00074 iEvent.getByLabel(stripClustersNew_, stripClustersNew);
00075
00076 auto_ptr<ClusterRemovalInfo> cri(new ClusterRemovalInfo(pixelClustersOld, stripClustersOld));
00077 ClusterRemovalInfo::Indices& pixelInd = cri->pixelIndices();
00078 ClusterRemovalInfo::Indices& stripInd = cri->stripIndices();
00079 stripInd.reserve(stripClustersNew->size());
00080 pixelInd.reserve(pixelClustersNew->size());
00081
00082
00083 for (edmNew::DetSetVector<SiStripCluster>::const_iterator itdetNew = stripClustersNew->begin(); itdetNew != stripClustersNew->end(); ++itdetNew) {
00084 edmNew::DetSet<SiStripCluster> oldDSstripNew = *itdetNew;
00085 if (oldDSstripNew.empty()) continue;
00086 for (edmNew::DetSet<SiStripCluster>::const_iterator clNew = oldDSstripNew.begin(); clNew != oldDSstripNew.end(); ++clNew) {
00087 uint16_t firstStripNew = clNew->firstStrip();
00088 uint32_t idStripNew = clNew->geographicalId();
00089
00090
00091 uint32_t keyOld=99999;
00092
00093 const SiStripCluster * firstOffsetStripOld = & stripClustersOld->data().front();
00094 edmNew::DetSetVector<SiStripCluster>::const_iterator itdetOld = stripClustersOld->find(oldDSstripNew.detId());
00095 if (itdetOld != stripClustersOld->end()) {
00096 edmNew::DetSet<SiStripCluster> oldDSstripOld = *itdetOld;
00097 if (oldDSstripOld.empty()) continue;
00098 for (edmNew::DetSet<SiStripCluster>::const_iterator clOld = oldDSstripOld.begin(); clOld != oldDSstripOld.end(); ++clOld) {
00099 uint16_t firstStripOld = clOld->firstStrip();
00100 uint32_t idStripOld = clOld->geographicalId();
00101 if (idStripNew==idStripOld && firstStripNew==firstStripOld) {
00102 keyOld = ((&*clOld) - firstOffsetStripOld);
00103
00104 break;
00105 }
00106 }
00107 }
00108
00109
00110 stripInd.push_back(keyOld);
00111 }
00112 }
00113
00114
00115
00116 for (edmNew::DetSetVector<SiPixelCluster>::const_iterator itdetNew = pixelClustersNew->begin(); itdetNew != pixelClustersNew->end(); ++itdetNew) {
00117 edmNew::DetSet<SiPixelCluster> oldDSpixelNew = *itdetNew;
00118 if (oldDSpixelNew.empty()) continue;
00119 for (edmNew::DetSet<SiPixelCluster>::const_iterator clNew = oldDSpixelNew.begin(); clNew != oldDSpixelNew.end(); ++clNew) {
00120 int minPixelRowNew = clNew->minPixelRow();
00121
00122
00123 uint32_t keyOld=99999;
00124
00125 const SiPixelCluster * firstOffsetPixelOld = & pixelClustersOld->data().front();
00126 edmNew::DetSetVector<SiPixelCluster>::const_iterator itdetOld = pixelClustersOld->find(oldDSpixelNew.detId());
00127 if (itdetOld != pixelClustersOld->end()) {
00128 edmNew::DetSet<SiPixelCluster> oldDSpixelOld = *itdetOld;
00129 if (oldDSpixelOld.empty()) continue;
00130 for (edmNew::DetSet<SiPixelCluster>::const_iterator clOld = oldDSpixelOld.begin(); clOld != oldDSpixelOld.end(); ++clOld) {
00131 int minPixelRowOld = clOld->minPixelRow();
00132 if (minPixelRowNew==minPixelRowOld) {
00133 keyOld = ((&*clOld) - firstOffsetPixelOld);
00134
00135 break;
00136 }
00137 }
00138 }
00139 assert(keyOld!=99999);
00140
00141 pixelInd.push_back(keyOld);
00142 }
00143 }
00144
00145
00146
00147
00148 cri->setNewPixelClusters(edm::OrphanHandle<SiPixelClusterCollectionNew>(pixelClustersNew.product(),pixelClustersNew.id()));
00149 cri->setNewStripClusters(edm::OrphanHandle<edmNew::DetSetVector<SiStripCluster> >(stripClustersNew.product(),stripClustersNew.id()));
00150
00151 iEvent.put(cri);
00152 }
00153
00154 #include "FWCore/PluginManager/interface/ModuleDef.h"
00155 #include "FWCore/Framework/interface/MakerMacros.h"
00156 DEFINE_FWK_MODULE(TopBottomClusterInfoProducer);