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, ModuleCallingContext const *)
 
void addSiStripSignals (const edm::Event &e)
 
 DataMixingSiStripWorker ()
 
 DataMixingSiStripWorker (const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
 
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_
 
SiGlobalIndex SiHitStorage_
 
std::string SiStripDigiCollectionDM_
 
edm::EDGetTokenT
< edm::DetSetVector
< SiStripDigi > > 
SiStripDigiPToken_
 
edm::EDGetTokenT
< edm::DetSetVector
< SiStripDigi > > 
SiStripDigiToken_
 
edm::InputTag SistripLabelSig_
 
edm::InputTag SiStripPileInputTag_
 

Detailed Description

Definition at line 38 of file DataMixingSiStripWorker.h.

Member Typedef Documentation

Definition at line 69 of file DataMixingSiStripWorker.h.

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

Definition at line 70 of file DataMixingSiStripWorker.h.

Constructor & Destructor Documentation

DataMixingSiStripWorker::DataMixingSiStripWorker ( )

Definition at line 27 of file DataMixingSiStripWorker.cc.

27 { }
DataMixingSiStripWorker::DataMixingSiStripWorker ( const edm::ParameterSet ps,
edm::ConsumesCollector &&  iC 
)
explicit

standard constructor

Definition at line 30 of file DataMixingSiStripWorker.cc.

References edm::ParameterSet::getParameter(), SiHitStorage_, SiStripDigiCollectionDM_, SiStripDigiPToken_, SiStripDigiToken_, SistripLabelSig_, SiStripPileInputTag_, and AlCaHLTBitMon_QueryRunRegistry::string.

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  // declare the products to produce
39 
40  SistripLabelSig_ = ps.getParameter<edm::InputTag>("SistripLabelSig");
41  SiStripPileInputTag_ = ps.getParameter<edm::InputTag>("SiStripPileInputTag");
42 
43  SiStripDigiCollectionDM_ = ps.getParameter<std::string>("SiStripDigiCollectionDM");
44 
47 
48 
49 
50  // clear local storage for this event
51  SiHitStorage_.clear();
52 
53  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > SiStripDigiToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > SiStripDigiPToken_
DataMixingSiStripWorker::~DataMixingSiStripWorker ( )
virtual

Default destructor

Definition at line 57 of file DataMixingSiStripWorker.cc.

57  {
58  }

Member Function Documentation

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

Definition at line 90 of file DataMixingSiStripWorker.cc.

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

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

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

Definition at line 62 of file DataMixingSiStripWorker.cc.

References begin, end, edm::Event::getByToken(), input, LogDebug, edm::DetSetVector< T >::reserve(), SiHitStorage_, and SiStripDigiToken_.

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

62  {
63  // fill in maps of hits
64 
65  Handle< edm::DetSetVector<SiStripDigi> > input;
66 
67  if( e.getByToken(SiStripDigiToken_,input) ) {
68  OneDetectorMap LocalMap;
69 
70  //loop on all detsets (detectorIDs) inside the input collection
72  for (; DSViter!=input->end();DSViter++){
73 
74 #ifdef DEBUG
75  LogDebug("DataMixingSiStripWorker") << "Processing DetID " << DSViter->id;
76 #endif
77 
78  LocalMap.clear();
79  LocalMap.reserve((DSViter->data).size());
80  LocalMap.insert(LocalMap.end(),(DSViter->data).begin(),(DSViter->data).end());
81 
82  SiHitStorage_.insert( SiGlobalIndex::value_type( DSViter->id, LocalMap ) );
83  }
84 
85  }
86  } // end of addSiStripSignals
#define LogDebug(id)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
void reserve(size_t s)
Definition: DetSetVector.h:154
std::vector< SiStripDigi > OneDetectorMap
static std::string const input
Definition: EdmProvDump.cc:43
#define end
Definition: vmac.h:37
Container::value_type value_type
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:365
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > SiStripDigiToken_
#define begin
Definition: vmac.h:30
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108
void DataMixingSiStripWorker::putSiStrip ( edm::Event e)

Definition at line 147 of file DataMixingSiStripWorker.cc.

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

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

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

Definition at line 61 of file DataMixingSiStripWorker.h.

Referenced by DataMixingSiStripWorker(), and putSiStrip().

edm::EDGetTokenT<edm::DetSetVector<SiStripDigi> > edm::DataMixingSiStripWorker::SiStripDigiPToken_
private

Definition at line 64 of file DataMixingSiStripWorker.h.

Referenced by DataMixingSiStripWorker().

edm::EDGetTokenT<edm::DetSetVector<SiStripDigi> > edm::DataMixingSiStripWorker::SiStripDigiToken_
private

Definition at line 63 of file DataMixingSiStripWorker.h.

Referenced by addSiStripSignals(), and DataMixingSiStripWorker().

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

Definition at line 59 of file DataMixingSiStripWorker.h.

Referenced by DataMixingSiStripWorker().

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

Definition at line 60 of file DataMixingSiStripWorker.h.

Referenced by addSiStripPileups(), and DataMixingSiStripWorker().