CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Attributes
edm::DataMixingSiPixelWorker Class Reference

#include <DataMixingSiPixelWorker.h>

Public Member Functions

void addSiPixelPileups (const int bcr, edm::EventPrincipal *, unsigned int EventId)
 
void addSiPixelSignals (const edm::Event &e)
 
 DataMixingSiPixelWorker ()
 
 DataMixingSiPixelWorker (const edm::ParameterSet &ps)
 
void putSiPixel (edm::Event &e)
 
virtual ~DataMixingSiPixelWorker ()
 

Private Types

typedef std::multimap< int,
PixelDigi
OneDetectorMap
 
typedef std::map< uint32_t,
OneDetectorMap
SiGlobalIndex
 

Private Attributes

std::string label_
 
edm::InputTag pixeldigi_collectionPile_
 
edm::InputTag pixeldigi_collectionSig_
 
std::string PixelDigiCollectionDM_
 
Selectorsel_
 
SiGlobalIndex SiHitStorage_
 

Detailed Description

Definition at line 36 of file DataMixingSiPixelWorker.h.

Member Typedef Documentation

typedef std::multimap<int, PixelDigi> edm::DataMixingSiPixelWorker::OneDetectorMap
private

Definition at line 62 of file DataMixingSiPixelWorker.h.

typedef std::map<uint32_t, OneDetectorMap> edm::DataMixingSiPixelWorker::SiGlobalIndex
private

Definition at line 63 of file DataMixingSiPixelWorker.h.

Constructor & Destructor Documentation

DataMixingSiPixelWorker::DataMixingSiPixelWorker ( )

Definition at line 27 of file DataMixingSiPixelWorker.cc.

DataMixingSiPixelWorker::DataMixingSiPixelWorker ( const edm::ParameterSet ps)
explicit

standard constructor

Definition at line 30 of file DataMixingSiPixelWorker.cc.

References edm::ParameterSet::getParameter(), label_, pixeldigi_collectionPile_, pixeldigi_collectionSig_, PixelDigiCollectionDM_, sel_, and SiHitStorage_.

30  :
31  label_(ps.getParameter<std::string>("Label"))
32 
33  {
34 
35  // get the subdetector names
36  // this->getSubdetectorNames(); //something like this may be useful to check what we are supposed to do...
37 
38  // create input selector
39  if (label_.size()>0){
40  sel_=new Selector( ModuleLabelSelector(label_));
41  }
42  else {
43  sel_=new Selector( MatchAllSelector());
44  }
45 
46  // declare the products to produce
47 
48  pixeldigi_collectionSig_ = ps.getParameter<edm::InputTag>("pixeldigiCollectionSig");
49  pixeldigi_collectionPile_ = ps.getParameter<edm::InputTag>("pixeldigiCollectionPile");
50  PixelDigiCollectionDM_ = ps.getParameter<std::string>("PixelDigiCollectionDM");
51 
52  // clear local storage for this event
53  SiHitStorage_.clear();
54 
55  }
T getParameter(std::string const &) const
Functor that operates on &lt;T&gt;
Definition: Selector.h:25
DataMixingSiPixelWorker::~DataMixingSiPixelWorker ( )
virtual

Default destructor

Definition at line 59 of file DataMixingSiPixelWorker.cc.

References sel_.

59  {
60  delete sel_;
61  sel_=0;
62  }

Member Function Documentation

void DataMixingSiPixelWorker::addSiPixelPileups ( const int  bcr,
edm::EventPrincipal ep,
unsigned int  EventId 
)

Definition at line 102 of file DataMixingSiPixelWorker.cc.

References begin, edm::DetSetVector< T >::begin(), end, edm::DetSetVector< T >::end(), edm::EventPrincipal::id(), collect_tpl::input, LogDebug, pixeldigi_collectionPile_, and SiHitStorage_.

Referenced by edm::DataMixingModule::addPileups().

102  {
103 
104  LogDebug("DataMixingSiPixelWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
105 
106  // fill in maps of hits; same code as addSignals, except now applied to the pileup events
107 
108  boost::shared_ptr<Wrapper<edm::DetSetVector<PixelDigi> > const> inputPTR =
109  getProductByTag<edm::DetSetVector<PixelDigi> >(*ep, pixeldigi_collectionPile_ );
110 
111  if(inputPTR ) {
112 
113  const edm::DetSetVector<PixelDigi> *input = const_cast< edm::DetSetVector<PixelDigi> * >(inputPTR->product());
114 
115 
116 
117  // Handle< edm::DetSetVector<PixelDigi> > input;
118 
119  // if( e->getByLabel(pixeldigi_collectionPile_,input) ) {
120 
121  //loop on all detsets (detectorIDs) inside the input collection
123  for (; DSViter!=input->end();DSViter++){
124 
125 #ifdef DEBUG
126  LogDebug("DataMixingSiPixelWorker") << "Pileups: Processing DetID " << DSViter->id;
127 #endif
128 
129  uint32_t detID = DSViter->id;
133 
134  // find correct local map (or new one) for this detector ID
135 
136  SiGlobalIndex::const_iterator itest;
137 
138  itest = SiHitStorage_.find(detID);
139 
140  if(itest!=SiHitStorage_.end()) { // this detID already has hits, add to existing map
141 
142  OneDetectorMap LocalMap = itest->second;
143 
144  // fill in local map with extra channels
145  for (icopy=begin; icopy!=end; icopy++) {
146  LocalMap.insert(OneDetectorMap::value_type( (icopy->channel()), *icopy ));
147  }
148 
149  SiHitStorage_[detID]=LocalMap;
150 
151  }
152  else{ // fill local storage with this information, put in global collection
153 
154  OneDetectorMap LocalMap;
155 
156  for (icopy=begin; icopy!=end; icopy++) {
157  LocalMap.insert(OneDetectorMap::value_type( (icopy->channel()), *icopy ));
158  }
159 
160  SiHitStorage_.insert( SiGlobalIndex::value_type( detID, LocalMap ) );
161  }
162 
163  }
164  }
165  }
#define LogDebug(id)
EventID const & id() const
Container::value_type value_type
#define end
Definition: vmac.h:38
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:352
tuple input
Definition: collect_tpl.py:10
std::multimap< int, PixelDigi > OneDetectorMap
#define begin
Definition: vmac.h:31
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:337
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:105
void DataMixingSiPixelWorker::addSiPixelSignals ( const edm::Event e)

Definition at line 66 of file DataMixingSiPixelWorker.cc.

References begin, end, edm::Event::getByLabel(), edm::EventBase::id(), collect_tpl::input, LogDebug, pixeldigi_collectionSig_, and SiHitStorage_.

Referenced by edm::DataMixingModule::addSignals().

66  {
67  // fill in maps of hits
68 
69  LogDebug("DataMixingSiPixelWorker")<<"===============> adding MC signals for "<<e.id();
70 
71  Handle< edm::DetSetVector<PixelDigi> > input;
72 
73  if( e.getByLabel(pixeldigi_collectionSig_,input) ) {
74 
75  //loop on all detsets (detectorIDs) inside the input collection
76  edm::DetSetVector<PixelDigi>::const_iterator DSViter=input->begin();
77  for (; DSViter!=input->end();DSViter++){
78 
79 #ifdef DEBUG
80  LogDebug("DataMixingSiPixelWorker") << "Processing DetID " << DSViter->id;
81 #endif
82 
83  uint32_t detID = DSViter->id;
87 
88  OneDetectorMap LocalMap;
89 
90  for (icopy=begin; icopy!=end; icopy++) {
91  LocalMap.insert(OneDetectorMap::value_type( (icopy->channel()), *icopy ));
92  }
93 
94  SiHitStorage_.insert( SiGlobalIndex::value_type( detID, LocalMap ) );
95  }
96 
97  }
98  } // end of addSiPixelSignals
#define LogDebug(id)
Container::value_type value_type
#define end
Definition: vmac.h:38
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:352
tuple input
Definition: collect_tpl.py:10
std::multimap< int, PixelDigi > OneDetectorMap
edm::EventID id() const
Definition: EventBase.h:56
#define begin
Definition: vmac.h:31
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:105
void DataMixingSiPixelWorker::putSiPixel ( edm::Event e)

Definition at line 169 of file DataMixingSiPixelWorker.cc.

References ecalMGPA::adc(), PixelDigiCollectionDM_, edm::DetSet< T >::push_back(), edm::Event::put(), and SiHitStorage_.

Referenced by edm::DataMixingModule::put().

169  {
170 
171  // collection of Digis to put in the event
172 
173  std::vector< edm::DetSet<PixelDigi> > vPixelDigi;
174 
175  // loop through our collection of detectors, merging hits and putting new ones in the output
176 
177  // big loop over Detector IDs:
178 
179  for(SiGlobalIndex::const_iterator IDet = SiHitStorage_.begin();
180  IDet != SiHitStorage_.end(); IDet++) {
181 
182  edm::DetSet<PixelDigi> SPD(IDet->first); // Make empty collection with this detector ID
183 
184  OneDetectorMap LocalMap = IDet->second;
185 
186  //counter variables
187  int formerPixel = -1;
188  int currentPixel;
189  int ADCSum = 0;
190 
191 
192  OneDetectorMap::const_iterator iLocalchk;
193 
194  for(OneDetectorMap::const_iterator iLocal = LocalMap.begin();
195  iLocal != LocalMap.end(); ++iLocal) {
196 
197  currentPixel = iLocal->first;
198 
199  if (currentPixel == formerPixel) { // we have to add these digis together
200  ADCSum+=(iLocal->second).adc();
201  }
202  else{
203  if(formerPixel!=-1){ // ADC info stolen from SiStrips...
204  if (ADCSum > 511) ADCSum = 255;
205  else if (ADCSum > 253 && ADCSum < 512) ADCSum = 254;
206  PixelDigi aHit(formerPixel, ADCSum);
207  SPD.push_back( aHit );
208  }
209  // save pointers for next iteration
210  formerPixel = currentPixel;
211  ADCSum = (iLocal->second).adc();
212  }
213 
214  iLocalchk = iLocal;
215  if((++iLocalchk) == LocalMap.end()) { //make sure not to lose the last one
216  if (ADCSum > 511) ADCSum = 255;
217  else if (ADCSum > 253 && ADCSum < 512) ADCSum = 254;
218  SPD.push_back( PixelDigi(formerPixel, ADCSum) );
219  }
220 
221  }// end of loop over one detector
222 
223  // stick this into the global vector of detector info
224  vPixelDigi.push_back(SPD);
225 
226  } // end of big loop over all detector IDs
227 
228  // put the collection of digis in the event
229  LogInfo("DataMixingSiPixelWorker") << "total # Merged Pixels: " << vPixelDigi.size() ;
230 
231  // make new digi collection
232 
233  std::auto_ptr< edm::DetSetVector<PixelDigi> > MyPixelDigis(new edm::DetSetVector<PixelDigi>(vPixelDigi) );
234 
235  // put collection
236 
237  e.put( MyPixelDigis, PixelDigiCollectionDM_ );
238 
239  // clear local storage for this event
240  SiHitStorage_.clear();
241  }
int adc(sample_type sample)
get the ADC sample (12 bits)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
std::multimap< int, PixelDigi > OneDetectorMap

Member Data Documentation

std::string edm::DataMixingSiPixelWorker::label_
private
edm::InputTag edm::DataMixingSiPixelWorker::pixeldigi_collectionPile_
private

Definition at line 57 of file DataMixingSiPixelWorker.h.

Referenced by addSiPixelPileups(), and DataMixingSiPixelWorker().

edm::InputTag edm::DataMixingSiPixelWorker::pixeldigi_collectionSig_
private

Definition at line 56 of file DataMixingSiPixelWorker.h.

Referenced by addSiPixelSignals(), and DataMixingSiPixelWorker().

std::string edm::DataMixingSiPixelWorker::PixelDigiCollectionDM_
private

Definition at line 58 of file DataMixingSiPixelWorker.h.

Referenced by DataMixingSiPixelWorker(), and putSiPixel().

Selector* edm::DataMixingSiPixelWorker::sel_
private

Definition at line 70 of file DataMixingSiPixelWorker.h.

Referenced by DataMixingSiPixelWorker(), and ~DataMixingSiPixelWorker().

SiGlobalIndex edm::DataMixingSiPixelWorker::SiHitStorage_
private