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 initialize(const edm::EventSetup& es);
35  void setDetId(const uint32_t id);
36  float gain(const uint16_t& strip) const { return gainHandle->getStripGain(strip, gainRange); }
37  uint16_t applyGain(const uint16_t& strip, const uint16_t& adc);
38 
42  uint32_t gain_cache_id, detId;
43 };
44 
46  token = consumes<ClusterCollection>(conf.getParameter<edm::InputTag>("ClusterProducer"));
47 
48  produces<DigiCollection>("ZeroSuppressed");
49  produces<DigiCollection>("VirginRaw");
50  produces<DigiCollection>("ProcessedRaw");
51  produces<DigiCollection>("ScopeMode");
52 }
53 
55  initialize(es);
56 
57  std::vector<DetDigiCollection> output_base;
59  event.getByToken(token, input);
60 
61  if (input.isValid())
62  process(*input, output_base);
63 
64  auto outputZS = std::make_unique<DigiCollection>(output_base);
65  auto outputVR = std::make_unique<DigiCollection>();
66  auto outputPR = std::make_unique<DigiCollection>();
67  auto outputSM = std::make_unique<DigiCollection>();
68 
69  event.put(std::move(outputZS), "ZeroSuppressed");
70  event.put(std::move(outputVR), "VirginRaw");
71  event.put(std::move(outputPR), "ProcessedRaw");
72  event.put(std::move(outputSM), "ScopeMode");
73 }
74 
76  std::vector<DetDigiCollection>& output_base) {
77  for (ClusterCollection::const_iterator it = input.begin(); it != input.end(); ++it) {
78  uint32_t detid = it->detId();
79 
80  setDetId(detid);
81  DetDigiCollection detDigis(detid);
82 
83  DetClusIter clus(it->begin()), endclus(it->end());
84  for (; clus != endclus; clus++) {
85  size_t istrip = 0;
86  size_t width = clus->amplitudes().size();
87  size_t firstStrip = clus->firstStrip();
88  uint16_t stripPos = firstStrip;
89  for (; istrip < width; ++istrip) {
90  detDigis.data.push_back(SiStripDigi(stripPos, applyGain(stripPos, clus->amplitudes()[istrip])));
91  stripPos++;
92  }
93  }
94 
95  if (!detDigis.empty())
96  output_base.push_back(detDigis);
97  }
98 }
99 
101  uint32_t g_cache_id = es.get<SiStripGainRcd>().cacheIdentifier();
102 
103  if (g_cache_id != gain_cache_id) {
105  gain_cache_id = g_cache_id;
106  }
107 }
108 
109 inline void SiStripClusterToDigiProducer::setDetId(const uint32_t id) {
111  detId = id;
112 }
113 
114 inline uint16_t SiStripClusterToDigiProducer::applyGain(const uint16_t& strip, const uint16_t& adc) {
115  if (adc > 255)
116  throw cms::Exception("Invalid Charge") << " digi at strip " << strip << " has ADC out of range " << adc;
117  if (adc > 253)
118  return adc; //saturated, do not scale
119  uint16_t charge = static_cast<uint16_t>(
120  adc * gain(strip) +
121  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
122  return (charge > 1022 ? 255 : (charge > 253 ? 254 : charge));
123 }
124 
edm::DetSetVector< SiStripDigi >
SiStripDependentRecords.h
ecalMGPA::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:11
SiStripGainRcd
Definition: SiStripDependentRecords.h:29
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
input
static const std::string input
Definition: EdmProvDump.cc:48
ESHandle.h
SiStripGain.h
edm::DetSet< SiStripDigi >
edm::EDGetTokenT
Definition: EDGetToken.h:33
SiStripClusterToDigiProducer::process
void process(const ClusterCollection &input, std::vector< DetDigiCollection > &output_base)
Definition: SiStripClusterToDigiProducer.cc:75
SiStripClusterToDigiProducer::gainHandle
edm::ESHandle< SiStripGain > gainHandle
Definition: SiStripClusterToDigiProducer.cc:41
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
SiStripClusterToDigiProducer::initialize
void initialize(const edm::EventSetup &es)
Definition: SiStripClusterToDigiProducer.cc:100
edmNew::DetSetVector::const_iterator
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetSetVectorNew.h:231
EDProducer.h
SiStripNoises.h
edm::Handle
Definition: AssociativeIterator.h:50
SiStripClusterToDigiProducer::SiStripClusterToDigiProducer
SiStripClusterToDigiProducer(const edm::ParameterSet &conf)
Definition: SiStripClusterToDigiProducer.cc:45
SiStripGain::getStripGain
static float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:73
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
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
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:71
SiStripClusterToDigiProducer::DigiCollection
edm::DetSetVector< SiStripDigi > DigiCollection
Definition: SiStripClusterToDigiProducer.cc:24
edm::ESHandle< SiStripGain >
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:54
SiStripClusterToDigiProducer::gain_cache_id
uint32_t gain_cache_id
Definition: SiStripClusterToDigiProducer.cc:42
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::ParameterSet
Definition: ParameterSet.h:36
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:36
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
get
#define get
SiStripClusterToDigiProducer::DetDigiCollection
edm::DetSet< SiStripDigi > DetDigiCollection
Definition: SiStripClusterToDigiProducer.cc:25
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
edmNew::DetSetVector
Definition: DetSetNew.h:13
SiStripClusterToDigiProducer::detId
uint32_t detId
Definition: SiStripClusterToDigiProducer.cc:42
eostools.move
def move(src, dest)
Definition: eostools.py:511
SiStripClusterToDigiProducer::token
edm::EDGetTokenT< ClusterCollection > token
Definition: SiStripClusterToDigiProducer.cc:39
Frameworkfwd.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripApvGain.h:28
Exception
Definition: hltDiff.cc:246
SiStripQuality.h
edm::DetSet::data
collection_type data
Definition: DetSet.h:80
SiStripClusterToDigiProducer::gainRange
SiStripApvGain::Range gainRange
Definition: SiStripClusterToDigiProducer.cc:40
SiStripClusterToDigiProducer::setDetId
void setDetId(const uint32_t id)
Definition: SiStripClusterToDigiProducer.cc:109
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:114
ParameterSet.h
event
Definition: event.py:1
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