CMS 3D CMS Logo

SiStripClusterToDigiProducer.cc
Go to the documentation of this file.
6 
9 
13 
15 
17 #include <numeric>
18 
23 
27 
28 public:
29  explicit SiStripClusterToDigiProducer(const edm::ParameterSet& conf);
30  void produce(edm::Event&, const edm::EventSetup&) override;
31 
32 private:
33  void process(const ClusterCollection& input, std::vector<DetDigiCollection>& output_base);
34  void setDetId(const uint32_t id);
35  float gain(const uint16_t& strip) const { return gain_->getStripGain(strip, gainRange); }
36  uint16_t applyGain(const uint16_t& strip, const uint16_t& adc);
37 
43  uint32_t detId;
44 };
45 
47  token = consumes<ClusterCollection>(conf.getParameter<edm::InputTag>("ClusterProducer"));
49 
50  produces<DigiCollection>("ZeroSuppressed");
51  produces<DigiCollection>("VirginRaw");
52  produces<DigiCollection>("ProcessedRaw");
53  produces<DigiCollection>("ScopeMode");
54 }
55 
57  if (gainWatcher_.check(es)) {
58  gain_ = &es.getData(gainToken_);
59  }
60 
61  std::vector<DetDigiCollection> output_base;
63  event.getByToken(token, input);
64 
65  if (input.isValid())
66  process(*input, output_base);
67 
68  auto outputZS = std::make_unique<DigiCollection>(output_base);
69  auto outputVR = std::make_unique<DigiCollection>();
70  auto outputPR = std::make_unique<DigiCollection>();
71  auto outputSM = std::make_unique<DigiCollection>();
72 
73  event.put(std::move(outputZS), "ZeroSuppressed");
74  event.put(std::move(outputVR), "VirginRaw");
75  event.put(std::move(outputPR), "ProcessedRaw");
76  event.put(std::move(outputSM), "ScopeMode");
77 }
78 
80  std::vector<DetDigiCollection>& output_base) {
81  for (ClusterCollection::const_iterator it = input.begin(); it != input.end(); ++it) {
82  uint32_t detid = it->detId();
83 
84  setDetId(detid);
85  DetDigiCollection detDigis(detid);
86 
87  DetClusIter clus(it->begin()), endclus(it->end());
88  for (; clus != endclus; clus++) {
89  size_t istrip = 0;
90  size_t width = clus->amplitudes().size();
91  size_t firstStrip = clus->firstStrip();
92  uint16_t stripPos = firstStrip;
93  for (; istrip < width; ++istrip) {
94  detDigis.data.push_back(SiStripDigi(stripPos, applyGain(stripPos, clus->amplitudes()[istrip])));
95  stripPos++;
96  }
97  }
98 
99  if (!detDigis.empty())
100  output_base.push_back(detDigis);
101  }
102 }
103 
104 inline void SiStripClusterToDigiProducer::setDetId(const uint32_t id) {
105  gainRange = gain_->getRange(id);
106  detId = id;
107 }
108 
109 inline uint16_t SiStripClusterToDigiProducer::applyGain(const uint16_t& strip, const uint16_t& adc) {
110  if (adc > 255)
111  throw cms::Exception("Invalid Charge") << " digi at strip " << strip << " has ADC out of range " << adc;
112  if (adc > 253)
113  return adc; //saturated, do not scale
114  uint16_t charge = static_cast<uint16_t>(
115  adc * gain(strip) +
116  0.5); //NB: here we revert the gain applied at the clusterizer level. for this reason the adc counts are multiplied by gain and not divided
117  return (charge > 1022 ? 255 : (charge > 253 ? 254 : charge));
118 }
119 
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::DetSetVector< SiStripDigi >
SiStripDependentRecords.h
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
SiStripClusterToDigiProducer::gain_
const SiStripGain * gain_
Definition: SiStripClusterToDigiProducer.cc:42
input
static const std::string input
Definition: EdmProvDump.cc:48
SiStripClusterToDigiProducer::gainWatcher_
edm::ESWatcher< SiStripGainRcd > gainWatcher_
Definition: SiStripClusterToDigiProducer.cc:41
edm::ESWatcher< SiStripGainRcd >
SiStripGain.h
edm::DetSet< SiStripDigi >
SiStripGain
Definition: SiStripGain.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
SiStripClusterToDigiProducer::process
void process(const ClusterCollection &input, std::vector< DetDigiCollection > &output_base)
Definition: SiStripClusterToDigiProducer.cc:79
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
edmNew::DetSetVector::const_iterator
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetSetVectorNew.h:197
EDProducer.h
SiStripNoises.h
edm::Handle
Definition: AssociativeIterator.h:50
SiStripClusterToDigiProducer::SiStripClusterToDigiProducer
SiStripClusterToDigiProducer(const edm::ParameterSet &conf)
Definition: SiStripClusterToDigiProducer.cc:46
SiStripGain::getStripGain
static float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:77
edm::DetSet::empty
bool empty() const
Definition: DetSet.h:62
SiStripClusterToDigiProducer::DetClusterCollection
edmNew::DetSet< SiStripCluster > DetClusterCollection
Definition: SiStripClusterToDigiProducer.cc:21
MakerMacros.h
SiStripClusterToDigiProducer::ClusterCollection
edmNew::DetSetVector< SiStripCluster > ClusterCollection
Definition: SiStripClusterToDigiProducer.cc:20
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiStripClusterToDigiProducer
Definition: SiStripClusterToDigiProducer.cc:19
SiStripGain::getRange
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:75
SiStripClusterToDigiProducer::DigiCollection
edm::DetSetVector< SiStripDigi > DigiCollection
Definition: SiStripClusterToDigiProducer.cc:24
edmNew::DetSet
Definition: DetSetNew.h:22
SiStripClusterToDigiProducer::DetClusIter
edmNew::DetSet< SiStripCluster >::const_iterator DetClusIter
Definition: SiStripClusterToDigiProducer.cc:22
SiStripClusterToDigiProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: SiStripClusterToDigiProducer.cc:56
SiStripClusterToDigiProducer::gainToken_
edm::ESGetToken< SiStripGain, SiStripGainRcd > gainToken_
Definition: SiStripClusterToDigiProducer.cc:40
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripCluster.h
Event.h
SiStripClusterToDigiProducer::DetDigiIter
edm::DetSet< SiStripDigi >::const_iterator DetDigiIter
Definition: SiStripClusterToDigiProducer.cc:26
ModuleDef.h
SiStripClusterToDigiProducer::gain
float gain(const uint16_t &strip) const
Definition: SiStripClusterToDigiProducer.cc:35
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
edm::ESGetToken< SiStripGain, SiStripGainRcd >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
SiStripClusterToDigiProducer::DetDigiCollection
edm::DetSet< SiStripDigi > DetDigiCollection
Definition: SiStripClusterToDigiProducer.cc:25
edmNew::DetSetVector
Definition: DetSetNew.h:13
SiStripClusterToDigiProducer::detId
uint32_t detId
Definition: SiStripClusterToDigiProducer.cc:43
eostools.move
def move(src, dest)
Definition: eostools.py:511
SiStripClusterToDigiProducer::token
edm::EDGetTokenT< ClusterCollection > token
Definition: SiStripClusterToDigiProducer.cc:38
Frameworkfwd.h
ESWatcher.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripApvGain.h:28
Exception
Definition: hltDiff.cc:245
SiStripQuality.h
edm::DetSet::data
collection_type data
Definition: DetSet.h:80
SiStripClusterToDigiProducer::gainRange
SiStripApvGain::Range gainRange
Definition: SiStripClusterToDigiProducer.cc:39
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SiStripClusterToDigiProducer::setDetId
void setDetId(const uint32_t id)
Definition: SiStripClusterToDigiProducer.cc:104
SiStripDigi
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
SiStripClusterToDigiProducer::applyGain
uint16_t applyGain(const uint16_t &strip, const uint16_t &adc)
Definition: SiStripClusterToDigiProducer.cc:109
ParameterSet.h
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
DetSetVectorNew.h
edm::InputTag
Definition: InputTag.h:15
edmNew::DetSet::const_iterator
const data_type * const_iterator
Definition: DetSetNew.h:31
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31