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 26 of file DataMixingSiStripWorker.cc.

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

standard constructor

Definition at line 29 of file DataMixingSiStripWorker.cc.

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

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  // declare the products to produce
38 
39  SistripLabelSig_ = ps.getParameter<edm::InputTag>("SistripLabelSig");
40  SiStripPileInputTag_ = ps.getParameter<edm::InputTag>("SiStripPileInputTag");
41 
42  SiStripDigiCollectionDM_ = ps.getParameter<std::string>("SiStripDigiCollectionDM");
43 
46 
47 
48 
49  // clear local storage for this event
50  SiHitStorage_.clear();
51 
52  }
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 56 of file DataMixingSiStripWorker.cc.

56  {
57  }

Member Function Documentation

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

Definition at line 89 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().

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

Definition at line 61 of file DataMixingSiStripWorker.cc.

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

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

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

Definition at line 146 of file DataMixingSiStripWorker.cc.

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

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

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