CMS 3D CMS Logo

PreMixingCSCWorker.cc
Go to the documentation of this file.
3 
7 
8 // Specialize put for CSC strip
9 template <>
11  auto merged = std::make_unique<CSCStripDigiCollection>();
12  for(const auto& elem: *accumulated_) {
13  // The layerId
14  const CSCDetId& layerId = elem.first;
15 
16  // Get the iterators over the digis associated with this LayerId
17  const CSCStripDigiCollection::Range& range = elem.second;
18 
19  std::vector<CSCStripDigi> NewDigiList;
20 
21  std::vector<int> StripList;
22  std::vector<CSCStripDigiCollection::const_iterator> StripPointer;
23 
24  for(CSCStripDigiCollection::const_iterator dtdigi=range.first; dtdigi!=range.second; ++dtdigi){
25  StripList.push_back( (*dtdigi).getStrip() );
26  StripPointer.push_back( dtdigi );
27  }
28 
29  int PrevStrip = -1;
30  std::vector<int> DuplicateList;
31 
32  std::vector<CSCStripDigiCollection::const_iterator>::const_iterator StripPtr = StripPointer.begin();
33 
34  for( std::vector<int>::const_iterator istrip = StripList.begin(); istrip !=StripList.end(); ++istrip) {
35 
36  const int CurrentStrip = *(istrip);
37 
38  if(CurrentStrip > PrevStrip) {
39  PrevStrip = CurrentStrip;
40 
41  int dupl_count;
42  dupl_count = std::count(StripList.begin(), StripList.end(), CurrentStrip);
43  if(dupl_count > 1) {
44  std::vector<int>::const_iterator duplicate = istrip;
45  ++duplicate;
46  std::vector<CSCStripDigiCollection::const_iterator>::const_iterator DuplPointer = StripPtr;
47  ++DuplPointer;
48  for( ; duplicate!=StripList.end(); ++duplicate) {
49  if( (*duplicate) == CurrentStrip ) {
50  DuplicateList.push_back(CurrentStrip);
51 
52  std::vector<int> pileup_adc = (**DuplPointer).getADCCounts();
53  std::vector<int> signal_adc = (**StripPtr).getADCCounts();
54 
55  std::vector<int>::const_iterator minplace;
56 
57  minplace = std::min_element(pileup_adc.begin(), pileup_adc.end());
58 
59  int minvalue = (*minplace);
60 
61  std::vector<int> new_adc;
62 
63  std::vector<int>::const_iterator newsig = signal_adc.begin();
64 
65  for(std::vector<int>::const_iterator ibin = pileup_adc.begin(); ibin!=pileup_adc.end(); ++ibin) {
66  new_adc.push_back((*newsig)+(*ibin)-minvalue);
67 
68  ++newsig;
69  }
70 
71  CSCStripDigi newDigi(CurrentStrip, new_adc);
72  NewDigiList.push_back(newDigi);
73  }
74  ++DuplPointer;
75  }
76  }
77  else { NewDigiList.push_back(**StripPtr); }
78  } // if strips monotonically increasing... Haven't hit duplicates yet
79  else { // reached end of signal digis, or there was no overlap
80  PrevStrip = 1000; // now into pileup signals, stop looking forward for duplicates
81 
82  // check if this digi was in the duplicate list
83  int check;
84  check = std::count(DuplicateList.begin(), DuplicateList.end(), CurrentStrip);
85  if(check == 0) NewDigiList.push_back(**StripPtr);
86  }
87  ++StripPtr;
88  }
89 
90  CSCStripDigiCollection::Range stripRange(NewDigiList.begin(), NewDigiList.end());
91 
92  merged->put(stripRange, layerId);
93  }
94 
95  iEvent.put(std::move(merged), collectionDM_);
96  accumulated_.reset();
97 }
98 
99 // CSC has three digi collections
101 public:
103  stripWorker_(ps.getParameter<edm::ParameterSet>("strip"), producer, iC),
104  wireWorker_(ps.getParameter<edm::ParameterSet>("wire"), producer, iC),
105  comparatorWorker_(ps.getParameter<edm::ParameterSet>("comparator"), producer, iC) {}
106  ~PreMixingCSCWorker() override = default;
107 
108  void initializeEvent(edm::Event const& iEvent, edm::EventSetup const& iSetup) override {}
109 
110  void addSignals(edm::Event const& iEvent, edm::EventSetup const& iSetup) override {
111  stripWorker_.addSignals(iEvent, iSetup);
112  wireWorker_.addSignals(iEvent, iSetup);
113  comparatorWorker_.addSignals(iEvent, iSetup);
114  }
115 
116  void addPileups(PileUpEventPrincipal const& pep, edm::EventSetup const& iSetup) override {
117  stripWorker_.addPileups(pep, iSetup);
118  wireWorker_.addPileups(pep, iSetup);
119  comparatorWorker_.addPileups(pep, iSetup);
120  }
121 
122  void put(edm::Event& iEvent, edm::EventSetup const& iSetup, std::vector<PileupSummaryInfo> const& ps, int bunchSpacing) override {
123  stripWorker_.put(iEvent);
124  wireWorker_.put(iEvent);
125  comparatorWorker_.put(iEvent);
126  }
127 private:
131 };
132 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
void put(edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
std::unique_ptr< DigiCollection > accumulated_
void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
void put(edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
int iEvent
Definition: GenABIO.cc:230
PreMixingMuonWorker< CSCStripDigiCollection > stripWorker_
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
void initializeEvent(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
PreMixingCSCWorker(const edm::ParameterSet &ps, edm::ProducerBase &producer, edm::ConsumesCollector &&iC)
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:18
PreMixingMuonWorker< CSCWireDigiCollection > wireWorker_
std::vector< CSCStripDigi >::const_iterator const_iterator
HLT enums.
std::pair< const_iterator, const_iterator > Range
def check(config)
Definition: trackerTree.py:14
#define DEFINE_PREMIXING_WORKER(TYPE)
PreMixingMuonWorker< CSCComparatorDigiCollection > comparatorWorker_
def move(src, dest)
Definition: eostools.py:511