CMS 3D CMS Logo

TopBottomClusterInfoProducer.cc
Go to the documentation of this file.
6 
21 
24 
28 //
29 // class decleration
30 //
31 
33 public:
36  void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override ;
37 
38 private:
43 };
44 
45 
46 using namespace std;
47 using namespace edm;
48 using namespace reco;
49 
51 {
52  pixelClustersOld_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<edm::InputTag>("stripClustersOld"));
53  stripClustersOld_ = consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<edm::InputTag>("pixelClustersOld"));
54  pixelClustersNew_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<edm::InputTag>("stripClustersNew"));
55  stripClustersNew_ = consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<edm::InputTag>("pixelClustersNew"));
56  produces< ClusterRemovalInfo >();
57 }
58 
59 
61 {
62 }
63 
64 void
66 {
67 
69  iEvent.getByToken(pixelClustersOld_, pixelClustersOld);
71  iEvent.getByToken(stripClustersOld_, stripClustersOld);
72 
74  iEvent.getByToken(pixelClustersNew_, pixelClustersNew);
76  iEvent.getByToken(stripClustersNew_, stripClustersNew);
77 
78  auto cri = std::make_unique<ClusterRemovalInfo>(pixelClustersOld, stripClustersOld);
79  ClusterRemovalInfo::Indices& pixelInd = cri->pixelIndices();
80  ClusterRemovalInfo::Indices& stripInd = cri->stripIndices();
81  stripInd.reserve(stripClustersNew->size());
82  pixelInd.reserve(pixelClustersNew->size());
83 
84  //const SiStripCluster * firstOffsetStripNew = & stripClustersNew->data().front();
85  for (edmNew::DetSetVector<SiStripCluster>::const_iterator itdetNew = stripClustersNew->begin(); itdetNew != stripClustersNew->end(); ++itdetNew) {
86  edmNew::DetSet<SiStripCluster> oldDSstripNew = *itdetNew;
87  if (oldDSstripNew.empty()) continue; // skip empty detsets
88  for (edmNew::DetSet<SiStripCluster>::const_iterator clNew = oldDSstripNew.begin(); clNew != oldDSstripNew.end(); ++clNew) {
89  uint16_t firstStripNew = clNew->firstStrip();
90  uint32_t idStripNew = itdetNew->id();
91  //uint32_t keyNew = ((&*clNew) - firstOffsetStripNew);
92  //cout << "new strip index=" << keyNew << endl;
93  uint32_t keyOld=99999;
94 
95  const SiStripCluster * firstOffsetStripOld = & stripClustersOld->data().front();
96  edmNew::DetSetVector<SiStripCluster>::const_iterator itdetOld = stripClustersOld->find(itdetNew->id());
97  if (itdetOld != stripClustersOld->end()) {
98  edmNew::DetSet<SiStripCluster> oldDSstripOld = *itdetOld;
99  if (oldDSstripOld.empty()) continue; // skip empty detsets
100  for (edmNew::DetSet<SiStripCluster>::const_iterator clOld = oldDSstripOld.begin(); clOld != oldDSstripOld.end(); ++clOld) {
101  uint16_t firstStripOld = clOld->firstStrip();
102  uint32_t idStripOld = itdetOld->id();
103  if (idStripNew==idStripOld && firstStripNew==firstStripOld) {
104  keyOld = ((&*clOld) - firstOffsetStripOld);
105  //cout << "old strip index=" << keyOld << endl;
106  break;
107  }
108  }
109  }
110  //assert(keyOld!=99999);
111  //cout << "push back strip index=" << keyOld << endl;
112  stripInd.push_back(keyOld);
113  }
114  }
115 
116 
117  //const SiPixelCluster * firstOffsetPixelNew = & pixelClustersNew->data().front();
118  for (edmNew::DetSetVector<SiPixelCluster>::const_iterator itdetNew = pixelClustersNew->begin(); itdetNew != pixelClustersNew->end(); ++itdetNew) {
119  edmNew::DetSet<SiPixelCluster> oldDSpixelNew = *itdetNew;
120  if (oldDSpixelNew.empty()) continue; // skip empty detsets
121  for (edmNew::DetSet<SiPixelCluster>::const_iterator clNew = oldDSpixelNew.begin(); clNew != oldDSpixelNew.end(); ++clNew) {
122  int minPixelRowNew = clNew->minPixelRow();
123  //uint32_t keyNew = ((&*clNew) - firstOffsetPixelNew);
124  //cout << "new pixel index=" << keyNew << endl;
125  uint32_t keyOld=99999;
126 
127  const SiPixelCluster * firstOffsetPixelOld = & pixelClustersOld->data().front();
128  edmNew::DetSetVector<SiPixelCluster>::const_iterator itdetOld = pixelClustersOld->find(oldDSpixelNew.detId());
129  if (itdetOld != pixelClustersOld->end()) {
130  edmNew::DetSet<SiPixelCluster> oldDSpixelOld = *itdetOld;
131  if (oldDSpixelOld.empty()) continue; // skip empty detsets
132  for (edmNew::DetSet<SiPixelCluster>::const_iterator clOld = oldDSpixelOld.begin(); clOld != oldDSpixelOld.end(); ++clOld) {
133  int minPixelRowOld = clOld->minPixelRow();
134  if (minPixelRowNew==minPixelRowOld) {
135  keyOld = ((&*clOld) - firstOffsetPixelOld);
136  //cout << "old pixel index=" << keyOld << endl;
137  break;
138  }
139  }
140  }
141  assert(keyOld!=99999);
142  //cout << "push back pixel index=" << keyOld << endl;
143  pixelInd.push_back(keyOld);
144  }
145  }
146 
147  //cout << "pixelInd size" << pixelInd.size() << endl;
148  //cout << "stripInd size" << stripInd.size() << endl;
149 
150  cri->setNewPixelClusters(edm::OrphanHandle<SiPixelClusterCollectionNew>(pixelClustersNew.product(),pixelClustersNew.id()));
151  cri->setNewStripClusters(edm::OrphanHandle<edmNew::DetSetVector<SiStripCluster> >(stripClustersNew.product(),stripClustersNew.id()));
152 
153  iEvent.put(std::move(cri));
154 }
155 
T getParameter(std::string const &) const
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersNew_
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
data_type const * const_iterator
Definition: DetSetNew.h:30
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClustersOld_
id_type id(size_t cell) const
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClustersNew_
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool empty() const
Definition: DetSetNew.h:90
std::vector< uint32_t > Indices
T const * product() const
Definition: Handle.h:74
id_type detId() const
Definition: DetSetNew.h:84
Pixel cluster – collection of neighboring pixels above threshold.
fixed size matrix
HLT enums.
iterator end()
Definition: DetSetNew.h:70
id_type id() const
Definition: DetSetNew.h:81
TopBottomClusterInfoProducer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersOld_
def move(src, dest)
Definition: eostools.py:511
iterator begin()
Definition: DetSetNew.h:67