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.
5 
8 
12 
14 
16 #include "boost/foreach.hpp"
17 #include <numeric>
18 
20 
24 
25 
29 
30 
31 public:
32 
34  void produce(edm::Event&, const edm::EventSetup&);
35 
36 private:
37 
38  void process(const ClusterCollection& input, std::vector<DetDigiCollection>& output_base);
39  void initialize(const edm::EventSetup& es);
40  void setDetId(const uint32_t id);
41  float gain(const uint16_t& strip) const { return gainHandle->getStripGain( strip, gainRange ); }
42  uint16_t applyGain(const uint16_t& strip,const uint16_t& adc );
43 
47  uint32_t gain_cache_id, detId;
48 
49 };
50 
51 
54  : _inputTag( conf.getParameter<edm::InputTag>("ClusterProducer") ){
55 
56  produces< DigiCollection > ("ZeroSuppressed");
57  produces< DigiCollection > ("VirginRaw" );
58  produces< DigiCollection > ("ProcessedRaw" );
59  produces< DigiCollection > ("ScopeMode" );
60 
61 }
62 
65 
66  initialize(es);
67 
68  std::vector<DetDigiCollection> output_base;
70  event.getByLabel(_inputTag,input);
71 
72  if(input.isValid())
73  process(*input, output_base);
74 
75 
76  std::auto_ptr< DigiCollection > outputZS(new DigiCollection(output_base) );
77  std::auto_ptr< DigiCollection > outputVR(new DigiCollection() );
78  std::auto_ptr< DigiCollection > outputPR(new DigiCollection() );
79  std::auto_ptr< DigiCollection > outputSM(new DigiCollection() );
80 
81  event.put( outputZS, "ZeroSuppressed");
82  event.put( outputVR, "VirginRaw" );
83  event.put( outputPR, "ProcessedRaw" );
84  event.put( outputSM, "ScopeMode" );
85 }
86 
88 process(const ClusterCollection& input, std::vector<DetDigiCollection>& output_base) {
89 
90  for(ClusterCollection::const_iterator it = input.begin(); it!=input.end(); ++it) {
91 
92  uint32_t detid=it->detId();
93 
94  setDetId(detid);
95  DetDigiCollection detDigis(detid);
96 
97  DetClusIter clus(it->begin()), endclus(it->end());
98  for(;clus!=endclus;clus++){
99  size_t istrip = 0;
100  size_t width = clus->amplitudes().size();
101  size_t firstStrip = clus->firstStrip();
102  uint16_t stripPos=firstStrip;
103  for(;istrip<width;++istrip){
104  detDigis.data.push_back( SiStripDigi( stripPos, applyGain(stripPos,clus->amplitudes()[istrip]) ) );
105  stripPos++;
106  }
107  }
108 
109  if (detDigis.size())
110  output_base.push_back(detDigis);
111  }
112 }
113 
116  uint32_t g_cache_id = es.get<SiStripGainRcd>().cacheIdentifier();
117 
118  if(g_cache_id != gain_cache_id) {
119  es.get<SiStripGainRcd>().get( gainHandle );
120  gain_cache_id = g_cache_id;
121  }
122 }
123 
124 
125 inline
127 setDetId(const uint32_t id) {
128  gainRange = gainHandle->getRange(id);
129  detId = id;
130 }
131 
132 inline
134 applyGain(const uint16_t& strip,const uint16_t& adc ) {
135 
136  if(adc > 255) throw cms::Exception("Invalid Charge") << " digi at strip " << strip << " has ADC out of range " << adc;
137  if(adc > 253) return adc; //saturated, do not scale
138  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
139  return ( charge > 1022 ? 255 :
140  ( charge > 253 ? 254 : charge ));
141 }
142 
143 
144 
int adc(sample_type sample)
get the ADC sample (12 bits)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
edm::DetSetVector< SiStripDigi > DigiCollection
const_iterator begin() const
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
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:25
edm::ESHandle< SiStripGain > gainHandle
double charge(const std::vector< uint8_t > &Ampls)
float gain(const uint16_t &strip) const
void initialize(const edm::EventSetup &es)
size_type size() const
Definition: DetSet.h:64
std::pair< ContainerIterator, ContainerIterator > Range
void produce(edm::Event &, const edm::EventSetup &)
edm::DetSet< SiStripDigi > DetDigiCollection
const_iterator end() const
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 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:79
collection_type::const_iterator const_iterator
Definition: DetSet.h:34
edm::DetSet< SiStripDigi >::const_iterator DetDigiIter