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 using namespace std;
46 using namespace edm;
47 using namespace reco;
48 
51  consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<edm::InputTag>("stripClustersOld"));
53  consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<edm::InputTag>("pixelClustersOld"));
55  consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<edm::InputTag>("stripClustersNew"));
57  consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<edm::InputTag>("pixelClustersNew"));
58  produces<ClusterRemovalInfo>();
59 }
60 
62 
65  iEvent.getByToken(pixelClustersOld_, pixelClustersOld);
67  iEvent.getByToken(stripClustersOld_, stripClustersOld);
68 
70  iEvent.getByToken(pixelClustersNew_, pixelClustersNew);
72  iEvent.getByToken(stripClustersNew_, stripClustersNew);
73 
74  auto cri = std::make_unique<ClusterRemovalInfo>(pixelClustersOld, stripClustersOld);
75  ClusterRemovalInfo::Indices& pixelInd = cri->pixelIndices();
76  ClusterRemovalInfo::Indices& stripInd = cri->stripIndices();
77  stripInd.reserve(stripClustersNew->size());
78  pixelInd.reserve(pixelClustersNew->size());
79 
80  //const SiStripCluster * firstOffsetStripNew = & stripClustersNew->data().front();
81  for (edmNew::DetSetVector<SiStripCluster>::const_iterator itdetNew = stripClustersNew->begin();
82  itdetNew != stripClustersNew->end();
83  ++itdetNew) {
84  edmNew::DetSet<SiStripCluster> oldDSstripNew = *itdetNew;
85  if (oldDSstripNew.empty())
86  continue; // skip empty detsets
87  for (edmNew::DetSet<SiStripCluster>::const_iterator clNew = oldDSstripNew.begin(); clNew != oldDSstripNew.end();
88  ++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())
100  continue; // skip empty detsets
101  for (edmNew::DetSet<SiStripCluster>::const_iterator clOld = oldDSstripOld.begin(); clOld != oldDSstripOld.end();
102  ++clOld) {
103  uint16_t firstStripOld = clOld->firstStrip();
104  uint32_t idStripOld = itdetOld->id();
105  if (idStripNew == idStripOld && firstStripNew == firstStripOld) {
106  keyOld = ((&*clOld) - firstOffsetStripOld);
107  //cout << "old strip index=" << keyOld << endl;
108  break;
109  }
110  }
111  }
112  //assert(keyOld!=99999);
113  //cout << "push back strip index=" << keyOld << endl;
114  stripInd.push_back(keyOld);
115  }
116  }
117 
118  //const SiPixelCluster * firstOffsetPixelNew = & pixelClustersNew->data().front();
119  for (edmNew::DetSetVector<SiPixelCluster>::const_iterator itdetNew = pixelClustersNew->begin();
120  itdetNew != pixelClustersNew->end();
121  ++itdetNew) {
122  edmNew::DetSet<SiPixelCluster> oldDSpixelNew = *itdetNew;
123  if (oldDSpixelNew.empty())
124  continue; // skip empty detsets
125  for (edmNew::DetSet<SiPixelCluster>::const_iterator clNew = oldDSpixelNew.begin(); clNew != oldDSpixelNew.end();
126  ++clNew) {
127  int minPixelRowNew = clNew->minPixelRow();
128  //uint32_t keyNew = ((&*clNew) - firstOffsetPixelNew);
129  //cout << "new pixel index=" << keyNew << endl;
130  uint32_t keyOld = 99999;
131 
132  const SiPixelCluster* firstOffsetPixelOld = &pixelClustersOld->data().front();
133  edmNew::DetSetVector<SiPixelCluster>::const_iterator itdetOld = pixelClustersOld->find(oldDSpixelNew.detId());
134  if (itdetOld != pixelClustersOld->end()) {
135  edmNew::DetSet<SiPixelCluster> oldDSpixelOld = *itdetOld;
136  if (oldDSpixelOld.empty())
137  continue; // skip empty detsets
138  for (edmNew::DetSet<SiPixelCluster>::const_iterator clOld = oldDSpixelOld.begin(); clOld != oldDSpixelOld.end();
139  ++clOld) {
140  int minPixelRowOld = clOld->minPixelRow();
141  if (minPixelRowNew == minPixelRowOld) {
142  keyOld = ((&*clOld) - firstOffsetPixelOld);
143  //cout << "old pixel index=" << keyOld << endl;
144  break;
145  }
146  }
147  }
148  assert(keyOld != 99999);
149  //cout << "push back pixel index=" << keyOld << endl;
150  pixelInd.push_back(keyOld);
151  }
152  }
153 
154  //cout << "pixelInd size" << pixelInd.size() << endl;
155  //cout << "stripInd size" << stripInd.size() << endl;
156 
157  cri->setNewPixelClusters(
158  edm::OrphanHandle<SiPixelClusterCollectionNew>(pixelClustersNew.product(), pixelClustersNew.id()));
159  cri->setNewStripClusters(
160  edm::OrphanHandle<edmNew::DetSetVector<SiStripCluster> >(stripClustersNew.product(), stripClustersNew.id()));
161 
162  iEvent.put(std::move(cri));
163 }
164 
T getParameter(std::string const &) const
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersNew_
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
ProductID id() const
Definition: HandleBase.cc:13
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
data_type const * const_iterator
Definition: DetSetNew.h:31
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:70
std::vector< uint32_t > Indices
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
T const * product() const
Definition: Handle.h:69
id_type detId() const
Definition: DetSetNew.h:66
Pixel cluster – collection of neighboring pixels above threshold.
fixed size matrix
HLT enums.
iterator end()
Definition: DetSetNew.h:56
id_type id() const
Definition: DetSetNew.h:64
TopBottomClusterInfoProducer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersOld_
def move(src, dest)
Definition: eostools.py:511
iterator begin()
Definition: DetSetNew.h:54