CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripClusterToDigiProducer.cc
Go to the documentation of this file.
6 
9 
13 
15 
17 #include "boost/foreach.hpp"
18 #include <numeric>
19 
21 
25 
26 
30 
31 
32 public:
33 
35  void produce(edm::Event&, const edm::EventSetup&) override;
36 
37 private:
38 
39  void process(const ClusterCollection& input, std::vector<DetDigiCollection>& output_base);
40  void initialize(const edm::EventSetup& es);
41  void setDetId(const uint32_t id);
42  float gain(const uint16_t& strip) const { return gainHandle->getStripGain( strip, gainRange ); }
43  uint16_t applyGain(const uint16_t& strip,const uint16_t& adc );
44 
48  uint32_t gain_cache_id, detId;
49 
50 };
51 
52 
55  : _inputTag( conf.getParameter<edm::InputTag>("ClusterProducer") ){
56 
57  produces< DigiCollection > ("ZeroSuppressed");
58  produces< DigiCollection > ("VirginRaw" );
59  produces< DigiCollection > ("ProcessedRaw" );
60  produces< DigiCollection > ("ScopeMode" );
61 
62 }
63 
66 
67  initialize(es);
68 
69  std::vector<DetDigiCollection> output_base;
71  event.getByLabel(_inputTag,input);
72 
73  if(input.isValid())
74  process(*input, output_base);
75 
76 
77  std::auto_ptr< DigiCollection > outputZS(new DigiCollection(output_base) );
78  std::auto_ptr< DigiCollection > outputVR(new DigiCollection() );
79  std::auto_ptr< DigiCollection > outputPR(new DigiCollection() );
80  std::auto_ptr< DigiCollection > outputSM(new DigiCollection() );
81 
82  event.put( outputZS, "ZeroSuppressed");
83  event.put( outputVR, "VirginRaw" );
84  event.put( outputPR, "ProcessedRaw" );
85  event.put( outputSM, "ScopeMode" );
86 }
87 
89 process(const ClusterCollection& input, std::vector<DetDigiCollection>& output_base) {
90 
91  for(ClusterCollection::const_iterator it = input.begin(); it!=input.end(); ++it) {
92 
93  uint32_t detid=it->detId();
94 
95  setDetId(detid);
96  DetDigiCollection detDigis(detid);
97 
98  DetClusIter clus(it->begin()), endclus(it->end());
99  for(;clus!=endclus;clus++){
100  size_t istrip = 0;
101  size_t width = clus->amplitudes().size();
102  size_t firstStrip = clus->firstStrip();
103  uint16_t stripPos=firstStrip;
104  for(;istrip<width;++istrip){
105  detDigis.data.push_back( SiStripDigi( stripPos, applyGain(stripPos,clus->amplitudes()[istrip]) ) );
106  stripPos++;
107  }
108  }
109 
110  if (detDigis.size())
111  output_base.push_back(detDigis);
112  }
113 }
114 
117  uint32_t g_cache_id = es.get<SiStripGainRcd>().cacheIdentifier();
118 
119  if(g_cache_id != gain_cache_id) {
120  es.get<SiStripGainRcd>().get( gainHandle );
121  gain_cache_id = g_cache_id;
122  }
123 }
124 
125 
126 inline
128 setDetId(const uint32_t id) {
129  gainRange = gainHandle->getRange(id);
130  detId = id;
131 }
132 
133 inline
135 applyGain(const uint16_t& strip,const uint16_t& adc ) {
136 
137  if(adc > 255) throw cms::Exception("Invalid Charge") << " digi at strip " << strip << " has ADC out of range " << adc;
138  if(adc > 253) return adc; //saturated, do not scale
139  uint16_t charge = static_cast<uint16_t>( adc*gain(strip) + 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
140  return ( charge > 1022 ? 255 :
141  ( charge > 253 ? 254 : charge ));
142 }
143 
144 
145 
int adc(sample_type sample)
get the ADC sample (12 bits)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
edm::DetSetVector< SiStripDigi > DigiCollection
edmNew::DetSet< SiStripCluster > DetClusterCollection
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
uint16_t applyGain(const uint16_t &strip, const uint16_t &adc)
data_type const * const_iterator
Definition: DetSetNew.h:30
edm::ESHandle< SiStripGain > gainHandle
double charge(const std::vector< uint8_t > &Ampls)
float gain(const uint16_t &strip) const
static std::string const input
Definition: EdmProvDump.cc:44
void initialize(const edm::EventSetup &es)
size_type size() const
Definition: DetSet.h:63
std::pair< ContainerIterator, ContainerIterator > Range
edm::DetSet< SiStripDigi > DetDigiCollection
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
tuple conf
Definition: dbtoconf.py:185
edmNew::DetSetVector< SiStripCluster > ClusterCollection
void produce(edm::Event &, const edm::EventSetup &) override
void process(const ClusterCollection &input, std::vector< DetDigiCollection > &output_base)
edmNew::DetSet< SiStripCluster >::const_iterator DetClusIter
const T & get() const
Definition: EventSetup.h:55
SiStripClusterToDigiProducer(const edm::ParameterSet &conf)
collection_type data
Definition: DetSet.h:78
const_iterator end(bool update=true) const
const_iterator begin(bool update=true) const
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
edm::DetSet< SiStripDigi >::const_iterator DetDigiIter