CMS 3D CMS Logo

ShallowClustersProducer.cc
Go to the documentation of this file.
17 
19 public:
21 
22 private:
25  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
26 
27  struct moduleVars {
28  moduleVars(uint32_t, const TrackerTopology*);
30  uint32_t module;
31  };
32 
33  struct NearDigis {
37  float etaX() const { return ((left + right) / max) / 2.; }
38  float eta() const { return right > left ? max / (max + right) : left / (left + max); }
39  float etaasymm() const { return right > left ? (right - max) / (right + max) : (max - left) / (max + left); }
40  float outsideasymm() const { return (last - first) / (last + first); }
41  };
42 
47 };
48 
51 
53  : Prefix(iConfig.getParameter<std::string>("Prefix")),
55  siStripClusterInfo_(consumesCollector()) {
56  produces<std::vector<unsigned>>(Prefix + "number");
57  produces<std::vector<unsigned>>(Prefix + "width");
58  produces<std::vector<float>>(Prefix + "variance");
59  produces<std::vector<float>>(Prefix + "barystrip");
60  produces<std::vector<float>>(Prefix + "middlestrip");
61  produces<std::vector<unsigned>>(Prefix + "charge");
62  produces<std::vector<float>>(Prefix + "noise");
63  produces<std::vector<float>>(Prefix + "ston");
64  produces<std::vector<unsigned>>(Prefix + "seedstrip");
65  produces<std::vector<unsigned>>(Prefix + "seedindex");
66  produces<std::vector<unsigned>>(Prefix + "seedcharge");
67  produces<std::vector<float>>(Prefix + "seednoise");
68  produces<std::vector<float>>(Prefix + "seedgain");
69  produces<std::vector<unsigned>>(Prefix + "qualityisbad");
70 
71  produces<std::vector<float>>(Prefix + "rawchargeC");
72  produces<std::vector<float>>(Prefix + "rawchargeL");
73  produces<std::vector<float>>(Prefix + "rawchargeR");
74  produces<std::vector<float>>(Prefix + "rawchargeLL");
75  produces<std::vector<float>>(Prefix + "rawchargeRR");
76  produces<std::vector<float>>(Prefix + "eta");
77  produces<std::vector<float>>(Prefix + "foldedeta");
78  produces<std::vector<float>>(Prefix + "etaX");
79  produces<std::vector<float>>(Prefix + "etaasymm");
80  produces<std::vector<float>>(Prefix + "outsideasymm");
81  produces<std::vector<float>>(Prefix + "neweta");
82  produces<std::vector<float>>(Prefix + "newetaerr");
83 
84  produces<std::vector<unsigned>>(Prefix + "detid");
85  produces<std::vector<int>>(Prefix + "subdetid");
86  produces<std::vector<int>>(Prefix + "module");
87  produces<std::vector<int>>(Prefix + "side");
88  produces<std::vector<int>>(Prefix + "layerwheel");
89  produces<std::vector<int>>(Prefix + "stringringrod");
90  produces<std::vector<int>>(Prefix + "petal");
91  produces<std::vector<int>>(Prefix + "stereo");
92 
93  theClustersToken_ = consumes<edmNew::DetSetVector<SiStripCluster>>(iConfig.getParameter<edm::InputTag>("Clusters"));
94  theDigisToken_ = consumes<edm::DetSetVector<SiStripProcessedRawDigi>>(edm::InputTag("siStripProcessedRawDigis", ""));
95 }
96 
98  //Retrieve tracker topology from geometry
100  const TrackerTopology* const tTopo = tTopoHandle.product();
101 
103 
104  auto number = std::make_unique<std::vector<unsigned>>(7, 0);
105  auto width = std::make_unique<std::vector<unsigned>>();
106  auto variance = std::make_unique<std::vector<float>>();
107  auto barystrip = std::make_unique<std::vector<float>>();
108  auto middlestrip = std::make_unique<std::vector<float>>();
109  auto charge = std::make_unique<std::vector<unsigned>>();
110  auto noise = std::make_unique<std::vector<float>>();
111  auto ston = std::make_unique<std::vector<float>>();
112  auto seedstrip = std::make_unique<std::vector<unsigned>>();
113  auto seedindex = std::make_unique<std::vector<unsigned>>();
114  auto seedcharge = std::make_unique<std::vector<unsigned>>();
115  auto seednoise = std::make_unique<std::vector<float>>();
116  auto seedgain = std::make_unique<std::vector<float>>();
117  auto qualityisbad = std::make_unique<std::vector<unsigned>>();
118 
119  auto rawchargeC = std::make_unique<std::vector<float>>();
120  auto rawchargeL = std::make_unique<std::vector<float>>();
121  auto rawchargeR = std::make_unique<std::vector<float>>();
122  auto rawchargeLL = std::make_unique<std::vector<float>>();
123  auto rawchargeRR = std::make_unique<std::vector<float>>();
124  auto etaX = std::make_unique<std::vector<float>>();
125  auto eta = std::make_unique<std::vector<float>>();
126  auto foldedeta = std::make_unique<std::vector<float>>();
127  auto etaasymm = std::make_unique<std::vector<float>>();
128  auto outsideasymm = std::make_unique<std::vector<float>>();
129  auto neweta = std::make_unique<std::vector<float>>();
130  auto newetaerr = std::make_unique<std::vector<float>>();
131 
132  auto detid = std::make_unique<std::vector<unsigned>>();
133  auto subdetid = std::make_unique<std::vector<int>>();
134  auto side = std::make_unique<std::vector<int>>();
135  auto module = std::make_unique<std::vector<int>>();
136  auto layerwheel = std::make_unique<std::vector<int>>();
137  auto stringringrod = std::make_unique<std::vector<int>>();
138  auto petal = std::make_unique<std::vector<int>>();
139  auto stereo = std::make_unique<std::vector<int>>();
140 
142  // iEvent.getByLabel(theClustersLabel, clusters);
143  iEvent.getByToken(theClustersToken_, clusters);
144 
146  // iEvent.getByLabel("siStripProcessedRawDigis", "", rawProcessedDigis);
147  iEvent.getByToken(theDigisToken_, rawProcessedDigis);
148 
150  for (; itClusters != clusters->end(); ++itClusters) {
151  uint32_t id = itClusters->id();
152  const moduleVars moduleV(id, tTopo);
153  for (edmNew::DetSet<SiStripCluster>::const_iterator cluster = itClusters->begin(); cluster != itClusters->end();
154  ++cluster) {
155  siStripClusterInfo_.setCluster(*cluster, id);
157  const NearDigis digis = rawProcessedDigis.isValid() ? NearDigis(info, *rawProcessedDigis) : NearDigis(info);
158 
159  (number->at(0))++;
160  (number->at(moduleV.subdetid))++;
161  width->push_back(cluster->amplitudes().size());
162  barystrip->push_back(cluster->barycenter());
163  variance->push_back(info.variance());
164  middlestrip->push_back(info.firstStrip() + info.width() / 2.0);
165  charge->push_back(info.charge());
166  noise->push_back(info.noiseRescaledByGain());
167  ston->push_back(info.signalOverNoise());
168  seedstrip->push_back(info.maxStrip());
169  seedindex->push_back(info.maxIndex());
170  seedcharge->push_back(info.maxCharge());
171  seednoise->push_back(info.stripNoisesRescaledByGain().at(info.maxIndex()));
172  seedgain->push_back(info.stripGains().at(info.maxIndex()));
173  qualityisbad->push_back(info.IsAnythingBad());
174 
175  rawchargeC->push_back(digis.max);
176  rawchargeL->push_back(digis.left);
177  rawchargeR->push_back(digis.right);
178  rawchargeLL->push_back(digis.Lleft);
179  rawchargeRR->push_back(digis.Rright);
180  etaX->push_back(digis.etaX());
181  eta->push_back(digis.eta());
182  etaasymm->push_back(digis.etaasymm());
183  outsideasymm->push_back(digis.outsideasymm());
184  neweta->push_back((digis.last - digis.first) / info.charge());
185  newetaerr->push_back((sqrt(digis.last + digis.first)) / pow(info.charge(), 1.5));
186 
187  detid->push_back(id);
188  subdetid->push_back(moduleV.subdetid);
189  side->push_back(moduleV.side);
190  module->push_back(moduleV.module);
191  layerwheel->push_back(moduleV.layerwheel);
192  stringringrod->push_back(moduleV.stringringrod);
193  petal->push_back(moduleV.petal);
194  stereo->push_back(moduleV.stereo);
195  }
196  }
197 
198  iEvent.put(std::move(number), Prefix + "number");
199  iEvent.put(std::move(width), Prefix + "width");
200  iEvent.put(std::move(variance), Prefix + "variance");
201  iEvent.put(std::move(barystrip), Prefix + "barystrip");
202  iEvent.put(std::move(middlestrip), Prefix + "middlestrip");
203  iEvent.put(std::move(charge), Prefix + "charge");
204  iEvent.put(std::move(noise), Prefix + "noise");
205  iEvent.put(std::move(ston), Prefix + "ston");
206  iEvent.put(std::move(seedstrip), Prefix + "seedstrip");
207  iEvent.put(std::move(seedindex), Prefix + "seedindex");
208  iEvent.put(std::move(seedcharge), Prefix + "seedcharge");
209  iEvent.put(std::move(seednoise), Prefix + "seednoise");
210  iEvent.put(std::move(seedgain), Prefix + "seedgain");
211  iEvent.put(std::move(qualityisbad), Prefix + "qualityisbad");
212 
213  iEvent.put(std::move(rawchargeC), Prefix + "rawchargeC");
214  iEvent.put(std::move(rawchargeL), Prefix + "rawchargeL");
215  iEvent.put(std::move(rawchargeR), Prefix + "rawchargeR");
216  iEvent.put(std::move(rawchargeLL), Prefix + "rawchargeLL");
217  iEvent.put(std::move(rawchargeRR), Prefix + "rawchargeRR");
218  iEvent.put(std::move(etaX), Prefix + "etaX");
219  iEvent.put(std::move(eta), Prefix + "eta");
220  iEvent.put(std::move(foldedeta), Prefix + "foldedeta");
221  iEvent.put(std::move(etaasymm), Prefix + "etaasymm");
222  iEvent.put(std::move(outsideasymm), Prefix + "outsideasymm");
223  iEvent.put(std::move(neweta), Prefix + "neweta");
224  iEvent.put(std::move(newetaerr), Prefix + "newetaerr");
225 
226  iEvent.put(std::move(detid), Prefix + "detid");
227  iEvent.put(std::move(subdetid), Prefix + "subdetid");
228  iEvent.put(std::move(module), Prefix + "module");
229  iEvent.put(std::move(side), Prefix + "side");
230  iEvent.put(std::move(layerwheel), Prefix + "layerwheel");
231  iEvent.put(std::move(stringringrod), Prefix + "stringringrod");
232  iEvent.put(std::move(petal), Prefix + "petal");
233  iEvent.put(std::move(stereo), Prefix + "stereo");
234 }
235 
237  max = info.maxCharge();
238  left = info.maxIndex() > uint16_t(0) ? info.stripCharges()[info.maxIndex() - 1] : 0;
239  Lleft = info.maxIndex() > uint16_t(1) ? info.stripCharges()[info.maxIndex() - 2] : 0;
240  right = unsigned(info.maxIndex() + 1) < info.stripCharges().size() ? info.stripCharges()[info.maxIndex() + 1] : 0;
241  Rright = unsigned(info.maxIndex() + 2) < info.stripCharges().size() ? info.stripCharges()[info.maxIndex() + 2] : 0;
242  first = info.stripCharges()[0];
243  last = info.stripCharges()[info.width() - 1];
244 }
245 
247  const edm::DetSetVector<SiStripProcessedRawDigi>& rawProcessedDigis) {
248  edm::DetSetVector<SiStripProcessedRawDigi>::const_iterator digiframe = rawProcessedDigis.find(info.detId());
249  if (digiframe != rawProcessedDigis.end()) {
250  max = digiframe->data.at(info.maxStrip()).adc();
251  left = info.maxStrip() > uint16_t(0) ? digiframe->data.at(info.maxStrip() - 1).adc() : 0;
252  Lleft = info.maxStrip() > uint16_t(1) ? digiframe->data.at(info.maxStrip() - 2).adc() : 0;
253  right = unsigned(info.maxStrip() + 1) < digiframe->data.size() ? digiframe->data.at(info.maxStrip() + 1).adc() : 0;
254  Rright = unsigned(info.maxStrip() + 2) < digiframe->data.size() ? digiframe->data.at(info.maxStrip() + 2).adc() : 0;
255  first = digiframe->data.at(info.firstStrip()).adc();
256  last = digiframe->data.at(info.firstStrip() + info.width() - 1).adc();
257  } else {
258  *this = NearDigis(info);
259  }
260 }
261 
263  SiStripDetId subdet(detid);
264  subdetid = subdet.subDetector();
265  if (SiStripDetId::TIB == subdetid) {
266  module = tTopo->tibModule(detid);
267  side = tTopo->tibIsZMinusSide(detid) ? -1 : 1;
268  layerwheel = tTopo->tibLayer(detid);
269  stringringrod = tTopo->tibString(detid);
270  stereo = tTopo->tibIsStereo(detid) ? 1 : 0;
271  } else if (SiStripDetId::TID == subdetid) {
272  module = tTopo->tidModule(detid);
273  side = tTopo->tidIsZMinusSide(detid) ? -1 : 1;
274  layerwheel = tTopo->tidWheel(detid);
275  stringringrod = tTopo->tidRing(detid);
276  stereo = tTopo->tidIsStereo(detid) ? 1 : 0;
277  } else if (SiStripDetId::TOB == subdetid) {
278  module = tTopo->tobModule(detid);
279  side = tTopo->tobIsZMinusSide(detid) ? -1 : 1;
280  layerwheel = tTopo->tobLayer(detid);
281  stringringrod = tTopo->tobRod(detid);
282  stereo = tTopo->tobIsStereo(detid) ? 1 : 0;
283  } else if (SiStripDetId::TEC == subdetid) {
284  module = tTopo->tecModule(detid);
285  side = tTopo->tecIsZMinusSide(detid) ? -1 : 1;
286  layerwheel = tTopo->tecWheel(detid);
287  stringringrod = tTopo->tecRing(detid);
288  petal = tTopo->tecPetalNumber(detid);
289  stereo = tTopo->tecIsStereo(detid) ? 1 : 0;
290  } else {
291  module = 0;
292  side = 0;
293  layerwheel = -1;
294  stringringrod = -1;
295  petal = -1;
296  }
297 }
unsigned int tecPetalNumber(const DetId &id) const
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
unsigned int tobLayer(const DetId &id) const
static const TGPicture * info(bool iBackgroundIsBlack)
iterator find(det_id_type id)
Definition: DetSetVector.h:255
void setCluster(const SiStripCluster &cluster, int detId)
bool tobIsZMinusSide(const DetId &id) const
static constexpr auto TID
Definition: SiStripDetId.h:39
unsigned int tibModule(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
ShallowClustersProducer(const edm::ParameterSet &)
bool tibIsZMinusSide(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int tibString(const DetId &id) const
SubDetector subDetector() const
Definition: SiStripDetId.h:109
bool tecIsZMinusSide(const DetId &id) const
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
data_type const * const_iterator
Definition: DetSetNew.h:31
moduleVars(uint32_t, const TrackerTopology *)
unsigned int tecRing(const DetId &id) const
ring id
bool tibIsStereo(const DetId &id) const
const_iterator end(bool update=false) const
bool tidIsZMinusSide(const DetId &id) const
bool tobIsStereo(const DetId &id) const
unsigned int tidModule(const DetId &id) const
unsigned int tecModule(const DetId &id) const
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
size_type size() const
Return the number of contained DetSets.
Definition: DetSetVector.h:250
T sqrt(T t)
Definition: SSEVec.h:23
id_type id(size_t cell) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static constexpr auto TOB
Definition: SiStripDetId.h:40
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:316
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:19
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator begin(bool update=false) const
bool tecIsStereo(const DetId &id) const
unsigned int tobRod(const DetId &id) const
static constexpr auto TIB
Definition: SiStripDetId.h:38
bool isValid() const
Definition: HandleBase.h:70
bool tidIsStereo(const DetId &id) const
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > theClustersToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripProcessedRawDigi > > theDigisToken_
SiStripClusterInfo siStripClusterInfo_
unsigned int tidRing(const DetId &id) const
unsigned int tibLayer(const DetId &id) const
unsigned int tobModule(const DetId &id) const
void initEvent(const edm::EventSetup &iSetup)
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
def move(src, dest)
Definition: eostools.py:511
static constexpr auto TEC
Definition: SiStripDetId.h:41
uint16_t *__restrict__ uint16_t const *__restrict__ adc