CMS 3D CMS Logo

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

#include <InitialGrouping.h>

Inheritance diagram for InitialGrouping:
MotherGrouping

Public Member Functions

void finish () override
 
 InitialGrouping (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 
void initialise (const edm::EventSetup &iEventSetup) override
 
void run (edm::Event &iEvent, const edm::EventSetup &iEventSetup, const DTDigiCollection &digis, MuonPathPtrs &outMpath) override
 
 ~InitialGrouping () override
 
- Public Member Functions inherited from MotherGrouping
 MotherGrouping (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 
virtual ~MotherGrouping ()
 

Private Member Functions

bool isEqualComb2Previous (DTPrimitives &ptr)
 
void mixChannels (int sl, int pathId, MuonPathPtrs &outMpath)
 
bool notEnoughDataInChannels (void)
 
void resetPrvTDCTStamp (void)
 
void selectInChannels (int baseCh)
 
void setInChannels (const DTDigiCollection *digi, int sl)
 

Private Attributes

DTPrimitives channelIn_ [cmsdt::NUM_LAYERS][cmsdt::NUM_CH_PER_LAYER]
 
DTPrimitives chInDummy_
 
int currentBaseChannel_
 
bool debug_
 
DTPrimitives muxInChannels_ [cmsdt::NUM_CELLS_PER_BLOCK]
 
int prevTDCTimeStamps_ [4]
 

Detailed Description

Definition at line 61 of file InitialGrouping.h.

Constructor & Destructor Documentation

InitialGrouping::InitialGrouping ( const edm::ParameterSet pset,
edm::ConsumesCollector iC 
)

Definition at line 14 of file InitialGrouping.cc.

References channelIn_, chInDummy_, debug_, edm::ParameterSet::getUntrackedParameter(), LogDebug, cmsdt::NUM_CH_PER_LAYER, and NUM_LAYERS.

15  : MotherGrouping(pset, iC), currentBaseChannel_(-1) {
16  // Obtention of parameters
17  debug_ = pset.getUntrackedParameter<bool>("debug");
18  if (debug_)
19  LogDebug("InitialGrouping") << "InitialGrouping: constructor";
20 
21  // Initialisation of channelIn array
22  chInDummy_.push_back(DTPrimitive());
23  for (int lay = 0; lay < NUM_LAYERS; lay++) {
24  for (int ch = 0; ch < NUM_CH_PER_LAYER; ch++) {
25  channelIn_[lay][ch] = {chInDummy_};
26  channelIn_[lay][ch].clear();
27  }
28  }
29 }
T getUntrackedParameter(std::string const &, T const &) const
DTPrimitives channelIn_[cmsdt::NUM_LAYERS][cmsdt::NUM_CH_PER_LAYER]
MotherGrouping(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
DTPrimitives chInDummy_
constexpr int NUM_CH_PER_LAYER
Definition: constants.h:218
#define LogDebug(id)
InitialGrouping::~InitialGrouping ( )
override

Definition at line 31 of file InitialGrouping.cc.

References debug_, and LogDebug.

31  {
32  if (debug_)
33  LogDebug("InitialGrouping") << "InitialGrouping: destructor";
34 }
#define LogDebug(id)

Member Function Documentation

void InitialGrouping::finish ( )
overridevirtual

Reimplemented from MotherGrouping.

Definition at line 78 of file InitialGrouping.cc.

Referenced by progressbar.ProgressBar::__next__().

78 { return; };
void InitialGrouping::initialise ( const edm::EventSetup iEventSetup)
overridevirtual

Reimplemented from MotherGrouping.

Definition at line 39 of file InitialGrouping.cc.

References debug_, and LogDebug.

39  {
40  if (debug_)
41  LogDebug("InitialGrouping") << "InitialGrouping::initialiase";
42 }
#define LogDebug(id)
bool InitialGrouping::isEqualComb2Previous ( DTPrimitives ptr)
private

Definition at line 201 of file InitialGrouping.cc.

References mps_fire::i, dqmiolumiharvest::j, NUM_LAYERS, and prevTDCTimeStamps_.

Referenced by mixChannels().

201  {
202  bool answer = true;
203 
204  for (int i = 0; i < NUM_LAYERS; i++) {
205  if (prevTDCTimeStamps_[i] != dtPrims[i].tdcTimeStamp()) {
206  answer = false;
207  for (int j = 0; j < NUM_LAYERS; j++) {
208  prevTDCTimeStamps_[j] = dtPrims[j].tdcTimeStamp();
209  }
210  break;
211  }
212  }
213  return answer;
214 }
int prevTDCTimeStamps_[4]
void InitialGrouping::mixChannels ( int  sl,
int  pathId,
MuonPathPtrs outMpath 
)
private

Definition at line 216 of file InitialGrouping.cc.

References dtamgrouping::CELL_HORIZONTAL_LAYOUTS, dtamgrouping::CHANNELS_PATH_ARRANGEMENTS, currentBaseChannel_, data, debug_, relativeConstraints::empty, mps_fire::i, isEqualComb2Previous(), mps_monitormerge::items, phase1PixelTopology::layer, LogDebug, eostools::move(), muxInChannels_, NUM_LAYERS, and push_back().

Referenced by run().

216  {
217  if (debug_)
218  LogDebug("InitialGrouping") << "[InitialGrouping::mixChannel] begin";
219  DTPrimitives data[4];
220 
221  // Real amount of values extracted from each channel.
222  int numPrimsPerLayer[4] = {0, 0, 0, 0};
223  unsigned int canal;
224  int channelEmptyCnt = 0;
225  for (int layer = 0; layer <= 3; layer++) {
226  canal = CHANNELS_PATH_ARRANGEMENTS[pathId][layer];
227  if (muxInChannels_[canal].empty())
228  channelEmptyCnt++;
229  }
230 
231  if (channelEmptyCnt >= 2)
232  return;
233  //
234 
235  // We extract the number of elements necesary from each channel as the combination requires
236  for (int layer = 0; layer < NUM_LAYERS; layer++) {
237  canal = CHANNELS_PATH_ARRANGEMENTS[pathId][layer];
238  unsigned int maxPrimsToBeRetrieved = muxInChannels_[canal].size();
239  /*
240  If the number of primitives is zero, in order to avoid that only one
241  empty channel avoids mixing data from the other three, we, at least,
242  consider one dummy element from this channel.
243  In other cases, where two or more channels has zero elements, the final
244  combination will be not analyzable (the condition for being analyzable is
245  that it has at least three good TDC time values, not dummy), so it will
246  be discarded and not sent to the analyzer.
247  */
248  if (maxPrimsToBeRetrieved == 0)
249  maxPrimsToBeRetrieved = 1;
250 
251  for (unsigned int items = 0; items < maxPrimsToBeRetrieved; items++) {
252  auto dtpAux = DTPrimitive();
253  if (!muxInChannels_[canal].empty())
254  dtpAux = DTPrimitive(&(muxInChannels_[canal].at(items)));
255 
256  /*
257  I won't allow a whole loop cycle. When a DTPrimitive has an invalid
258  time-stamp (TDC value = -1) it means that the buffer is empty or the
259  buffer has reached the last element within the configurable time window.
260  In this case the loop is broken, but only if there is, at least, one
261  DTPrim (even invalid) on the outgoing array. This is mandatory to cope
262  with the idea explained in the previous comment block
263  */
264  if (dtpAux.tdcTimeStamp() < 0 && items > 0)
265  break;
266 
267  // In this new schema, if the hit corresponds with the SL over which
268  // you are doing the mixings, it is sent to the intermediate mixing
269  // buffer. In the opposite case, a blank and invalid copy is sent to
270  // allow them mixing to be complete, as it was done in the one SL case.
271 
272  // This is a kind of quick solution in which there will be no few cases
273  // where you will have invalid mixings. Because of that, the verification
274  // that is done later, where the segment is analysed to check whether it
275  // can be analysed is essential.
276  if (dtpAux.superLayerId() == supLayer)
277  data[layer].push_back(dtpAux); // values are 0, 1, 2
278  else
279  data[layer].push_back(DTPrimitive());
280  numPrimsPerLayer[layer]++;
281  }
282  }
283 
284  if (debug_)
285  LogDebug("InitialGrouping") << "[InitialGrouping::mixChannels] filled data";
286 
287  // Here we do the different combinations and send them to the output FIFO.
288  DTPrimitives ptrPrimitive;
289  int chIdx[4];
290  for (chIdx[0] = 0; chIdx[0] < numPrimsPerLayer[0]; chIdx[0]++) {
291  for (chIdx[1] = 0; chIdx[1] < numPrimsPerLayer[1]; chIdx[1]++) {
292  for (chIdx[2] = 0; chIdx[2] < numPrimsPerLayer[2]; chIdx[2]++) {
293  for (chIdx[3] = 0; chIdx[3] < numPrimsPerLayer[3]; chIdx[3]++) {
294  // We build a copy of the object so that we can manipulate each one
295  // in each thread of the process independently, allowing us also to
296  // delete them whenever it is necessary, without relying upon a
297  // unique reference all over the code.
298 
299  for (int i = 0; i < NUM_LAYERS; i++) {
300  ptrPrimitive.push_back((data[i])[chIdx[i]]);
301  if (debug_)
302  LogDebug("InitialGrouping")
303  << "[InitialGrouping::mixChannels] reading " << ptrPrimitive[i].tdcTimeStamp();
304  }
305 
306  auto ptrMuonPath = std::make_shared<MuonPath>(ptrPrimitive);
307  ptrMuonPath->setCellHorizontalLayout(CELL_HORIZONTAL_LAYOUTS[pathId]);
308 
309  /*
310  This new version of this code is redundant with PathAnalyzer code,
311  where every MuonPath not analyzable is discarded.
312  I insert this discarding mechanism here, as well, to avoid inserting
313  not-analyzable MuonPath into the candidate FIFO.
314  Equivalent code must be removed in the future from PathAnalyzer, but
315  it the mean time, at least during the testing state, I'll preserve
316  both.
317  Code in the PathAnalyzer should be doing nothing now.
318  */
319  if (debug_)
320  LogDebug("InitialGrouping") << "[InitialGrouping::mixChannels] muonPath is analyzable? " << ptrMuonPath;
321  if (ptrMuonPath->isAnalyzable()) {
322  if (debug_)
323  LogDebug("InitialGrouping") << "[InitialGrouping::mixChannels] YES";
324  /*
325  This is a very simple filter because, during the tests, it has been
326  detected that many consecutive MuonPaths are duplicated mainly due
327  to buffers empty (or dummy) that give a TDC time-stamp = -1
328  With this filter, I'm removing those consecutive identical
329  combinations.
330 
331  If duplicated combinations are not consecutive, they won't be
332  detected here
333  */
334  if (!isEqualComb2Previous(ptrPrimitive)) {
335  if (debug_)
336  LogDebug("InitialGrouping") << "[InitialGrouping::mixChannels] isNOT equal to previous";
337  ptrMuonPath->setBaseChannelId(currentBaseChannel_);
338  outMuonPath.push_back(std::move(ptrMuonPath));
339  }
340  ptrPrimitive.clear();
341  }
342  }
343  }
344  }
345  }
346  for (int layer = 0; layer < NUM_LAYERS; layer++) {
347  data[layer].clear();
348  }
349 }
constexpr int CELL_HORIZONTAL_LAYOUTS[8][4]
bool isEqualComb2Previous(DTPrimitives &ptr)
DTPrimitives muxInChannels_[cmsdt::NUM_CELLS_PER_BLOCK]
constexpr std::array< uint8_t, layerIndexSize > layer
def move
Definition: eostools.py:511
constexpr int CHANNELS_PATH_ARRANGEMENTS[8][4]
deadvectors[0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::vector< DTPrimitive > DTPrimitives
Definition: DTprimitive.h:53
#define LogDebug(id)
bool InitialGrouping::notEnoughDataInChannels ( void  )
private

Definition at line 174 of file InitialGrouping.cc.

References muxInChannels_, and or.

Referenced by run().

174  {
175  // Empty layer indicators
176  bool lEmpty[4];
177 
178  lEmpty[0] = muxInChannels_[0].empty();
179 
180  lEmpty[1] = muxInChannels_[1].empty() && muxInChannels_[2].empty();
181 
182  lEmpty[2] = muxInChannels_[3].empty() && muxInChannels_[4].empty() && muxInChannels_[5].empty();
183 
184  lEmpty[3] =
185  muxInChannels_[6].empty() && muxInChannels_[7].empty() && muxInChannels_[8].empty() && muxInChannels_[9].empty();
186 
187  // If there are at least two empty layers, you cannot link it to a possible trace
188  if ((lEmpty[0] && lEmpty[1]) or (lEmpty[0] && lEmpty[2]) or (lEmpty[0] && lEmpty[3]) or (lEmpty[1] && lEmpty[2]) or
189  (lEmpty[1] && lEmpty[3]) or (lEmpty[2] && lEmpty[3])) {
190  return true;
191  } else {
192  return false;
193  }
194 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
DTPrimitives muxInChannels_[cmsdt::NUM_CELLS_PER_BLOCK]
void InitialGrouping::resetPrvTDCTStamp ( void  )
private

Definition at line 196 of file InitialGrouping.cc.

References mps_fire::i, NUM_LAYERS, and prevTDCTimeStamps_.

Referenced by run().

196  {
197  for (int i = 0; i < NUM_LAYERS; i++)
198  prevTDCTimeStamps_[i] = -1;
199 }
int prevTDCTimeStamps_[4]
void InitialGrouping::run ( edm::Event iEvent,
const edm::EventSetup iEventSetup,
const DTDigiCollection digis,
MuonPathPtrs outMpath 
)
overridevirtual

Reimplemented from MotherGrouping.

Definition at line 44 of file InitialGrouping.cc.

References currentBaseChannel_, debug_, LogDebug, mixChannels(), notEnoughDataInChannels(), cmsdt::NUM_SUPERLAYERS, resetPrvTDCTStamp(), selectInChannels(), setInChannels(), and cmsdt::TOTAL_BTI.

47  {
48  // This function returns the analyzable mpath collection back to the the main function
49  // so it can be fitted. This is in fact doing the so-called grouping.
50 
51  for (int supLayer = 0; supLayer < NUM_SUPERLAYERS; supLayer++) { // for each SL:
52  if (debug_)
53  LogDebug("InitialGrouping") << "InitialGrouping::run Reading SL" << supLayer;
54  setInChannels(&digis, supLayer);
55 
56  for (int baseCh = 0; baseCh < TOTAL_BTI; baseCh++) {
57  currentBaseChannel_ = baseCh;
58  selectInChannels(currentBaseChannel_); //map a number of wires for a given base channel
60  continue;
61 
62  if (debug_)
63  LogDebug("InitialGrouping") << "InitialGrouping::run --> now check pathId";
64  for (int pathId = 0; pathId < 8; pathId++) {
66  if (debug_)
67  LogDebug("InitialGrouping") << "[InitialGrouping::run] mixChannels calling";
68  mixChannels(supLayer, pathId, mpaths);
69  if (debug_)
70  LogDebug("InitialGrouping") << "[InitialGrouping::run] mixChannels end";
71  }
72  }
73  }
74  if (debug_)
75  LogDebug("InitialGrouping") << "[InitialGrouping::run] end";
76 }
void selectInChannels(int baseCh)
constexpr int NUM_SUPERLAYERS
Definition: constants.h:223
void resetPrvTDCTStamp(void)
constexpr int TOTAL_BTI
Definition: constants.h:217
bool notEnoughDataInChannels(void)
void setInChannels(const DTDigiCollection *digi, int sl)
#define LogDebug(id)
void mixChannels(int sl, int pathId, MuonPathPtrs &outMpath)
void InitialGrouping::selectInChannels ( int  baseCh)
private

Definition at line 118 of file InitialGrouping.cc.

References channelIn_, chInDummy_, muxInChannels_, and cmsdt::NUM_CH_PER_LAYER.

Referenced by run().

118  {
119  // Channels are labeled following next schema:
120  // Input Muxer Indexes
121  // ---------------------------------
122  // | 6 | 7 | 8 | 9 |
123  // ---------------------------------
124  // | 3 | 4 | 5 |
125  // -------------------------
126  // | 1 | 2 |
127  // -----------------
128  // | 0 |
129  // ---------
130 
131  // ****** LAYER 0 ******
132  muxInChannels_[0] = channelIn_[0][baseChannel];
133 
134  // ****** LAYER 1 ******
135  muxInChannels_[1] = channelIn_[1][baseChannel];
136 
137  if (baseChannel + 1 < NUM_CH_PER_LAYER)
138  muxInChannels_[2] = channelIn_[1][baseChannel + 1];
139  else
141 
142  // ****** LAYER 2 ******
143  if (baseChannel - 1 >= 0)
144  muxInChannels_[3] = channelIn_[2][baseChannel - 1];
145  else
147 
148  muxInChannels_[4] = channelIn_[2][baseChannel];
149 
150  if (baseChannel + 1 < NUM_CH_PER_LAYER)
151  muxInChannels_[5] = channelIn_[2][baseChannel + 1];
152  else
154 
155  // ****** LAYER 3 ******
156  if (baseChannel - 1 >= 0)
157  muxInChannels_[6] = channelIn_[3][baseChannel - 1];
158  else
160 
161  muxInChannels_[7] = channelIn_[3][baseChannel];
162 
163  if (baseChannel + 1 < NUM_CH_PER_LAYER)
164  muxInChannels_[8] = channelIn_[3][baseChannel + 1];
165  else
167 
168  if (baseChannel + 2 < NUM_CH_PER_LAYER)
169  muxInChannels_[9] = channelIn_[3][baseChannel + 2];
170  else
172 }
DTPrimitives channelIn_[cmsdt::NUM_LAYERS][cmsdt::NUM_CH_PER_LAYER]
DTPrimitives muxInChannels_[cmsdt::NUM_CELLS_PER_BLOCK]
DTPrimitives chInDummy_
constexpr int NUM_CH_PER_LAYER
Definition: constants.h:218
void InitialGrouping::setInChannels ( const DTDigiCollection digi,
int  sl 
)
private

Definition at line 83 of file InitialGrouping.cc.

References channelIn_, debug_, DTLayerId::layer(), phase1PixelTopology::layer, LogDebug, cmsdt::NUM_CH_PER_LAYER, NUM_LAYERS, DetId::rawId(), edm::second(), and DTSuperLayerId::superlayer().

Referenced by run().

83  {
84  // before setting channels we need to clear
85  for (int lay = 0; lay < NUM_LAYERS; lay++) {
86  for (int ch = 0; ch < NUM_CH_PER_LAYER; ch++) {
87  channelIn_[lay][ch].clear();
88  }
89  }
90 
91  // now fill with those primitives that makes sense:
92  for (const auto &dtLayerId_It : *digis) {
93  const DTLayerId dtLId = dtLayerId_It.first;
94  if (dtLId.superlayer() != sl + 1)
95  continue; //skip digis not in SL...
96 
97  for (DTDigiCollection::const_iterator digiIt = (dtLayerId_It.second).first; digiIt != (dtLayerId_It.second).second;
98  ++digiIt) {
99  int layer = dtLId.layer() - 1;
100  int wire = (*digiIt).wire() - 1;
101  int digiTIME = (*digiIt).time();
102  int digiTIMEPhase2 = digiTIME;
103 
104  if (debug_)
105  LogDebug("InitialGrouping") << "[InitialGrouping::setInChannels] SL" << sl << " L" << layer << " : " << wire
106  << " " << digiTIMEPhase2;
107  auto dtpAux = DTPrimitive();
108  dtpAux.setTDCTimeStamp(digiTIMEPhase2);
109  dtpAux.setChannelId(wire);
110  dtpAux.setLayerId(layer); // L=0,1,2,3
111  dtpAux.setSuperLayerId(sl); // SL=0,1,2
112  dtpAux.setCameraId(dtLId.rawId());
113  channelIn_[layer][wire].push_back(dtpAux);
114  }
115  }
116 }
DTPrimitives channelIn_[cmsdt::NUM_LAYERS][cmsdt::NUM_CH_PER_LAYER]
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
constexpr std::array< uint8_t, layerIndexSize > layer
U second(std::pair< T, U > const &p)
int superlayer() const
Return the superlayer number (deprecated method name)
constexpr int NUM_CH_PER_LAYER
Definition: constants.h:218
std::vector< DigiType >::const_iterator const_iterator
#define LogDebug(id)

Member Data Documentation

DTPrimitives InitialGrouping::channelIn_[cmsdt::NUM_LAYERS][cmsdt::NUM_CH_PER_LAYER]
private

Definition at line 92 of file InitialGrouping.h.

Referenced by InitialGrouping(), selectInChannels(), and setInChannels().

DTPrimitives InitialGrouping::chInDummy_
private

Definition at line 93 of file InitialGrouping.h.

Referenced by InitialGrouping(), and selectInChannels().

int InitialGrouping::currentBaseChannel_
private

Definition at line 95 of file InitialGrouping.h.

Referenced by mixChannels(), and run().

bool InitialGrouping::debug_
private
DTPrimitives InitialGrouping::muxInChannels_[cmsdt::NUM_CELLS_PER_BLOCK]
private

Definition at line 91 of file InitialGrouping.h.

Referenced by mixChannels(), notEnoughDataInChannels(), and selectInChannels().

int InitialGrouping::prevTDCTimeStamps_[4]
private

Definition at line 94 of file InitialGrouping.h.

Referenced by isEqualComb2Previous(), and resetPrvTDCTStamp().