CMS 3D CMS Logo

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

#include <DataMixingSiStripWorker.h>

Classes

class  StrictWeakOrdering
 

Public Member Functions

void addSiStripPileups (const int bcr, const edm::EventPrincipal *, unsigned int EventId)
 
void addSiStripSignals (const edm::Event &e)
 
 DataMixingSiStripWorker ()
 
 DataMixingSiStripWorker (const edm::ParameterSet &ps)
 
void putSiStrip (edm::Event &e)
 
virtual ~DataMixingSiStripWorker ()
 

Private Types

typedef std::vector< SiStripDigiOneDetectorMap
 
typedef std::map< uint32_t,
OneDetectorMap
SiGlobalIndex
 

Private Attributes

std::string label_
 
Selectorsel_
 
SiGlobalIndex SiHitStorage_
 
std::string SiStripDigiCollectionDM_
 
edm::InputTag SistripLabelSig_
 
edm::InputTag SiStripPileInputTag_
 

Detailed Description

Definition at line 36 of file DataMixingSiStripWorker.h.

Member Typedef Documentation

Definition at line 62 of file DataMixingSiStripWorker.h.

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

Definition at line 63 of file DataMixingSiStripWorker.h.

Constructor & Destructor Documentation

DataMixingSiStripWorker::DataMixingSiStripWorker ( )

Definition at line 26 of file DataMixingSiStripWorker.cc.

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

standard constructor

Definition at line 29 of file DataMixingSiStripWorker.cc.

References edm::ParameterSet::getParameter(), label_, sel_, SiHitStorage_, SiStripDigiCollectionDM_, SistripLabelSig_, and SiStripPileInputTag_.

29  :
30  label_(ps.getParameter<std::string>("Label"))
31 
32  {
33 
34  // get the subdetector names
35  // this->getSubdetectorNames(); //something like this may be useful to check what we are supposed to do...
36 
37  // create input selector
38  if (label_.size()>0){
39  sel_=new Selector( ModuleLabelSelector(label_));
40  }
41  else {
42  sel_=new Selector( MatchAllSelector());
43  }
44 
45  // declare the products to produce
46 
47  SistripLabelSig_ = ps.getParameter<edm::InputTag>("SistripLabelSig");
48  SiStripPileInputTag_ = ps.getParameter<edm::InputTag>("SiStripPileInputTag");
49 
50  SiStripDigiCollectionDM_ = ps.getParameter<std::string>("SiStripDigiCollectionDM");
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
DataMixingSiStripWorker::~DataMixingSiStripWorker ( )
virtual

Default destructor

Definition at line 59 of file DataMixingSiStripWorker.cc.

References sel_.

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

Member Function Documentation

void DataMixingSiStripWorker::addSiStripPileups ( const int  bcr,
const edm::EventPrincipal ep,
unsigned int  EventId 
)

Definition at line 94 of file DataMixingSiStripWorker.cc.

References begin, edm::DetSetVector< T >::begin(), end, edm::DetSetVector< T >::end(), edm::EventPrincipal::id(), LaserDQM_cfg::input, edm::DetSetVector< T >::insert(), LogDebug, SiHitStorage_, and SiStripPileInputTag_.

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

94  {
95  LogDebug("DataMixingSiStripWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
96 
97  // fill in maps of hits; same code as addSignals, except now applied to the pileup events
98 
99  boost::shared_ptr<Wrapper<edm::DetSetVector<SiStripDigi> > const> inputPTR =
100  getProductByTag<edm::DetSetVector<SiStripDigi> >(*ep, SiStripPileInputTag_ );
101 
102  if(inputPTR ) {
103 
104  const edm::DetSetVector<SiStripDigi> *input = const_cast< edm::DetSetVector<SiStripDigi> * >(inputPTR->product());
105 
106  // Handle< edm::DetSetVector<SiStripDigi> > input;
107 
108  // if( e->getByLabel(Sistripdigi_collectionPile_.label(),SistripLabelPile_.label(),input) ) {
109 
110  OneDetectorMap LocalMap;
111 
112  //loop on all detsets (detectorIDs) inside the input collection
114  for (; DSViter!=input->end();DSViter++){
115 
116 #ifdef DEBUG
117  LogDebug("DataMixingSiStripWorker") << "Pileups: Processing DetID " << DSViter->id;
118 #endif
119 
120  // find correct local map (or new one) for this detector ID
121 
122  SiGlobalIndex::const_iterator itest;
123 
124  itest = SiHitStorage_.find(DSViter->id);
125 
126  if(itest!=SiHitStorage_.end()) { // this detID already has hits, add to existing map
127 
128  LocalMap = itest->second;
129 
130  // fill in local map with extra channels
131  LocalMap.insert(LocalMap.end(),(DSViter->data).begin(),(DSViter->data).end());
132  std::stable_sort(LocalMap.begin(),LocalMap.end(),DataMixingSiStripWorker::StrictWeakOrdering());
133  SiHitStorage_[DSViter->id]=LocalMap;
134 
135  }
136  else{ // fill local storage with this information, put in global collection
137 
138  LocalMap.clear();
139  LocalMap.reserve((DSViter->data).size());
140  LocalMap.insert(LocalMap.end(),(DSViter->data).begin(),(DSViter->data).end());
141 
142  SiHitStorage_.insert( SiGlobalIndex::value_type( DSViter->id, LocalMap ) );
143  }
144  }
145  }
146  }
#define LogDebug(id)
EventID const & id() const
std::vector< SiStripDigi > OneDetectorMap
#define end
Definition: vmac.h:38
Container::value_type value_type
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
void insert(detset const &s)
Insert the given DetSet.
Definition: DetSetVector.h:234
#define begin
Definition: vmac.h:31
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:341
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
void DataMixingSiStripWorker::addSiStripSignals ( const edm::Event e)

Definition at line 66 of file DataMixingSiStripWorker.cc.

References begin, end, edm::Event::getByLabel(), LaserDQM_cfg::input, edm::DetSetVector< T >::insert(), LogDebug, SiHitStorage_, and SistripLabelSig_.

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

66  {
67  // fill in maps of hits
68 
69  Handle< edm::DetSetVector<SiStripDigi> > input;
70 
71  if( e.getByLabel(SistripLabelSig_,input) ) {
72  OneDetectorMap LocalMap;
73 
74  //loop on all detsets (detectorIDs) inside the input collection
76  for (; DSViter!=input->end();DSViter++){
77 
78 #ifdef DEBUG
79  LogDebug("DataMixingSiStripWorker") << "Processing DetID " << DSViter->id;
80 #endif
81 
82  LocalMap.clear();
83  LocalMap.reserve((DSViter->data).size());
84  LocalMap.insert(LocalMap.end(),(DSViter->data).begin(),(DSViter->data).end());
85 
86  SiHitStorage_.insert( SiGlobalIndex::value_type( DSViter->id, LocalMap ) );
87  }
88 
89  }
90  } // end of addSiStripSignals
#define LogDebug(id)
std::vector< SiStripDigi > OneDetectorMap
#define end
Definition: vmac.h:38
Container::value_type value_type
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
void insert(detset const &s)
Insert the given DetSet.
Definition: DetSetVector.h:234
#define begin
Definition: vmac.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
void DataMixingSiStripWorker::putSiStrip ( edm::Event e)

Definition at line 150 of file DataMixingSiStripWorker.cc.

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

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

150  {
151 
152  // collection of Digis to put in the event
153  std::vector< edm::DetSet<SiStripDigi> > vSiStripDigi;
154 
155  // loop through our collection of detectors, merging hits and putting new ones in the output
156 
157  // big loop over Detector IDs:
158 
159  for(SiGlobalIndex::const_iterator IDet = SiHitStorage_.begin();
160  IDet != SiHitStorage_.end(); IDet++) {
161 
162  edm::DetSet<SiStripDigi> SSD(IDet->first); // Make empty collection with this detector ID
163 
164  OneDetectorMap LocalMap = IDet->second;
165 
166  //counter variables
167  int formerStrip = -1;
168  int currentStrip;
169  int ADCSum = 0;
170 
171  OneDetectorMap::const_iterator iLocalchk;
172  OneDetectorMap::const_iterator iLocal = LocalMap.begin();
173  for(;iLocal != LocalMap.end(); ++iLocal) {
174 
175  currentStrip = iLocal->strip();
176 
177  if (currentStrip == formerStrip) { // we have to add these digis together
178  ADCSum+=iLocal->adc(); // on every element...
179  }
180  else{
181  if(formerStrip!=-1){
182  if (ADCSum > 511) ADCSum = 255;
183  else if (ADCSum > 253 && ADCSum < 512) ADCSum = 254;
184  SiStripDigi aHit(formerStrip, ADCSum);
185  SSD.push_back( aHit );
186  }
187  // save pointers for next iteration
188  formerStrip = currentStrip;
189  ADCSum = iLocal->adc();
190  }
191 
192  iLocalchk = iLocal;
193  if((++iLocalchk) == LocalMap.end()) { //make sure not to lose the last one
194  if (ADCSum > 511) ADCSum = 255;
195  else if (ADCSum > 253 && ADCSum < 512) ADCSum = 254;
196  SSD.push_back( SiStripDigi(formerStrip, ADCSum) );
197  } // end of loop over one detector
198 
199  }
200  // stick this into the global vector of detector info
201  vSiStripDigi.push_back(SSD);
202 
203  } // end of big loop over all detector IDs
204 
205  // put the collection of digis in the event
206  LogInfo("DataMixingSiStripWorker") << "total # Merged strips: " << vSiStripDigi.size() ;
207 
208  // make new digi collection
209 
210  std::auto_ptr< edm::DetSetVector<SiStripDigi> > MySiStripDigis(new edm::DetSetVector<SiStripDigi>(vSiStripDigi) );
211 
212  // put collection
213 
214  e.put( MySiStripDigis, SiStripDigiCollectionDM_ );
215 
216  // clear local storage for this event
217  SiHitStorage_.clear();
218  }
std::vector< SiStripDigi > OneDetectorMap
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12

Member Data Documentation

std::string edm::DataMixingSiStripWorker::label_
private
Selector* edm::DataMixingSiStripWorker::sel_
private

Definition at line 70 of file DataMixingSiStripWorker.h.

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

SiGlobalIndex edm::DataMixingSiStripWorker::SiHitStorage_
private
std::string edm::DataMixingSiStripWorker::SiStripDigiCollectionDM_
private

Definition at line 58 of file DataMixingSiStripWorker.h.

Referenced by DataMixingSiStripWorker(), and putSiStrip().

edm::InputTag edm::DataMixingSiStripWorker::SistripLabelSig_
private

Definition at line 56 of file DataMixingSiStripWorker.h.

Referenced by addSiStripSignals(), and DataMixingSiStripWorker().

edm::InputTag edm::DataMixingSiStripWorker::SiStripPileInputTag_
private

Definition at line 57 of file DataMixingSiStripWorker.h.

Referenced by addSiStripPileups(), and DataMixingSiStripWorker().