CMS 3D CMS Logo

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