CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PreMixingCSCWorker.cc
Go to the documentation of this file.
4 
8 
9 // Specialize put for CSC strip
10 template <>
12  auto merged = std::make_unique<CSCStripDigiCollection>();
13  for (const auto &elem : *accumulated_) {
14  // The layerId
15  const CSCDetId &layerId = elem.first;
16 
17  // Get the iterators over the digis associated with this LayerId
18  const CSCStripDigiCollection::Range &range = elem.second;
19 
20  std::vector<CSCStripDigi> NewDigiList;
21 
22  std::vector<int> StripList;
23  std::vector<CSCStripDigiCollection::const_iterator> StripPointer;
24 
25  for (CSCStripDigiCollection::const_iterator dtdigi = range.first; dtdigi != range.second; ++dtdigi) {
26  StripList.push_back((*dtdigi).getStrip());
27  StripPointer.push_back(dtdigi);
28  }
29 
30  int PrevStrip = -1;
31  std::vector<int> DuplicateList;
32 
33  std::vector<CSCStripDigiCollection::const_iterator>::const_iterator StripPtr = StripPointer.begin();
34 
35  for (std::vector<int>::const_iterator istrip = StripList.begin(); istrip != StripList.end(); ++istrip) {
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  } else {
77  NewDigiList.push_back(**StripPtr);
78  }
79  } // if strips monotonically increasing... Haven't hit duplicates yet
80  else { // reached end of signal digis, or there was no overlap
81  PrevStrip = 1000; // now into pileup signals, stop looking forward for
82  // duplicates
83 
84  // check if this digi was in the duplicate list
85  int check;
86  check = std::count(DuplicateList.begin(), DuplicateList.end(), CurrentStrip);
87  if (check == 0)
88  NewDigiList.push_back(**StripPtr);
89  }
90  ++StripPtr;
91  }
92 
93  CSCStripDigiCollection::Range stripRange(NewDigiList.begin(), NewDigiList.end());
94 
95  merged->put(stripRange, layerId);
96  }
97 
99  accumulated_.reset();
100 }
101 
102 // CSC has three digi collections
104 public:
106  : stripWorker_(ps.getParameter<edm::ParameterSet>("strip"), producesCollector, iC),
107  wireWorker_(ps.getParameter<edm::ParameterSet>("wire"), producesCollector, iC),
108  comparatorWorker_(ps.getParameter<edm::ParameterSet>("comparator"), producesCollector, iC) {}
109  ~PreMixingCSCWorker() override = default;
110 
111  void initializeEvent(edm::Event const &iEvent, edm::EventSetup const &iSetup) override {}
112 
113  void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override {
114  stripWorker_.addSignals(iEvent, iSetup);
115  wireWorker_.addSignals(iEvent, iSetup);
116  comparatorWorker_.addSignals(iEvent, iSetup);
117  }
118 
119  void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override {
120  stripWorker_.addPileups(pep, iSetup);
121  wireWorker_.addPileups(pep, iSetup);
122  comparatorWorker_.addPileups(pep, iSetup);
123  }
124 
126  edm::EventSetup const &iSetup,
127  std::vector<PileupSummaryInfo> const &ps,
128  int bunchSpacing) override {
129  stripWorker_.put(iEvent);
130  wireWorker_.put(iEvent);
131  comparatorWorker_.put(iEvent);
132  }
133 
134 private:
138 };
139 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void put(edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
std::unique_ptr< DigiCollection > accumulated_
void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
const uint16_t range(const Frame &aFrame)
void put(edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
int iEvent
Definition: GenABIO.cc:224
PreMixingMuonWorker< CSCStripDigiCollection > stripWorker_
PreMixingCSCWorker(const edm::ParameterSet &ps, edm::ProducesCollector producesCollector, edm::ConsumesCollector &&iC)
def move
Definition: eostools.py:511
void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
void initializeEvent(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
PreMixingMuonWorker< CSCWireDigiCollection > wireWorker_
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
~PreMixingCSCWorker() override=default
#define DEFINE_PREMIXING_WORKER(TYPE)
PreMixingMuonWorker< CSCComparatorDigiCollection > comparatorWorker_