CMS 3D CMS Logo

CSCTFTrackBuilder.cc
Go to the documentation of this file.
2 
4 
8 
11 
15 #include <sstream>
16 #include <cstdlib>
17 
19  bool TMB07,
20  const L1MuTriggerScales* scales,
21  const L1MuTriggerPtScale* ptScale) {
22  m_minBX = pset.getParameter<int>("MinBX");
23  m_maxBX = pset.getParameter<int>("MaxBX");
24 
25  for (int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e) {
27  // All SPs work with the same configuration (impossible to make it more exclusive in this framework)
28  my_SPs[e - 1][s - 1] = new CSCTFSectorProcessor(e, s, pset, TMB07, scales, ptScale);
29  }
30  }
31 }
32 
34  //my_dtrc->initialize(c);
35  for (int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e) {
37  my_SPs[e - 1][s - 1]->initialize(c);
38  }
39  }
40 }
41 
43  for (int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e) {
45  delete my_SPs[e - 1][s - 1];
46  my_SPs[e - 1][s - 1] = nullptr;
47  }
48  }
49 }
50 
53  const CSCTriggerContainer<csctf::TrackStub>* dtstubss, //const L1MuDTChambPhContainer* dttrig,
54  L1CSCTrackCollection* trkcoll,
56  std::vector<csc::L1Track> trks;
58 
60 
61  for (Citer = lcts->begin(); Citer != lcts->end(); Citer++) {
62  CSCCorrelatedLCTDigiCollection::const_iterator Diter = (*Citer).second.first;
63  CSCCorrelatedLCTDigiCollection::const_iterator Dend = (*Citer).second.second;
64 
65  for (; Diter != Dend; Diter++) {
66  csctf::TrackStub theStub((*Diter), (*Citer).first);
67  stub_list.push_back(theStub);
68  }
69  }
70 
71  // Now we append the track stubs the the DT Sector Collector
72  // after processing from the DT Receiver.
73 
74  // CSCTriggerContainer<csctf::TrackStub> dtstubs = my_dtrc->process(dttrig);
75  // stub_list.push_many(dtstubs);
76  stub_list.push_many(*dtstubss);
77 
78  // run each sector processor in the TF
79  for (int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e) {
81  CSCTriggerContainer<csctf::TrackStub> current_e_s = stub_list.get(e, s);
82  int spReturnValue = my_SPs[e - 1][s - 1]->run(current_e_s);
83  if (spReturnValue == -1) //Major Error, returning with empty Coll's
84  {
85  trkcoll->clear();
86  stubs_to_dt->clear();
87  return;
88  } else if (spReturnValue) {
89  std::vector<csc::L1Track> theTracks = my_SPs[e - 1][s - 1]->tracks().get();
90  trks.insert(trks.end(), theTracks.begin(), theTracks.end());
91  }
92  stubs_to_dt->push_many(my_SPs[e - 1][s - 1]->dtStubs()); // send stubs whether or not we find a track!!!
93  }
94  }
95 
96  // Now to combine tracks with their track stubs and send them off.
97  trkcoll->resize(trks.size());
98  std::vector<csc::L1Track>::const_iterator titr = trks.begin();
99  L1CSCTrackCollection::iterator tcitr = trkcoll->begin();
100 
101  for (; titr != trks.end(); titr++) {
102  tcitr->first = (*titr);
103  std::vector<csctf::TrackStub> possible_stubs = my_SPs[titr->endcap() - 1][titr->sector() - 1]->filteredStubs();
104  std::vector<csctf::TrackStub>::const_iterator tkstbs = possible_stubs.begin();
105 
106  int me1ID = titr->me1ID();
107  int me2ID = titr->me2ID();
108  int me3ID = titr->me3ID();
109  int me4ID = titr->me4ID();
110  int mb1ID = titr->mb1ID();
111  int me1delay = titr->me1Tbin();
112  int me2delay = titr->me2Tbin();
113  int me3delay = titr->me3Tbin();
114  int me4delay = titr->me4Tbin();
115  int mb1delay = titr->mb1Tbin();
116  // BX analyzer: some stub could be delayed by BXA so that all the stubs will run through the core at the same BX;
117  // then there is a rule of "second earlies LCT": resulting track will be placed at BX of the "second earliest LCT";
118  // in the end there are two parameters in place: the delay by BXA w.r.t to the last LCT and track tbin assignment
119  std::map<int, std::list<int> > timeline;
120  if (me1ID)
121  timeline[me1delay].push_back(1);
122  if (me2ID)
123  timeline[me2delay].push_back(2);
124  if (me3ID)
125  timeline[me3delay].push_back(3);
126  if (me4ID)
127  timeline[me4delay].push_back(4);
128  int earliest_tbin = 0, second_earliest_tbin = 0;
129  for (int bx = 7; bx >= 0; bx--) {
130  std::list<int>::const_iterator iter = timeline[bx].begin();
131  while (iter != timeline[bx].end()) {
132  if (earliest_tbin == 0)
133  earliest_tbin = bx;
134  else if (second_earliest_tbin == 0)
135  second_earliest_tbin = bx;
136  iter++;
137  }
138  }
139  // Core's input was loaded in a relative time window BX=[0-7)
140  // To relate it to time window of tracks (centred at BX=0) we introduce a shift:
141  int shift = (m_maxBX + m_minBX) / 2 - m_minBX + m_minBX;
142  int me1Tbin = titr->bx() - me1delay + second_earliest_tbin + shift;
143  int me2Tbin = titr->bx() - me2delay + second_earliest_tbin + shift;
144  int me3Tbin = titr->bx() - me3delay + second_earliest_tbin + shift;
145  int me4Tbin = titr->bx() - me4delay + second_earliest_tbin + shift;
146  int mb1Tbin = titr->bx() - mb1delay + second_earliest_tbin + shift;
147 
148  for (; tkstbs != possible_stubs.end(); tkstbs++) {
149  switch (tkstbs->station()) {
150  case 1:
151  if ((tkstbs->getMPCLink() +
152  (3 * (CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(tkstbs->getDetId().rawId())) - 1))) ==
153  me1ID &&
154  me1ID != 0 && me1Tbin == tkstbs->BX()) {
155  tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
156  }
157  break;
158  case 2:
159  if (tkstbs->getMPCLink() == me2ID && me2ID != 0 && me2Tbin == tkstbs->BX()) {
160  tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
161  }
162  break;
163  case 3:
164  if (tkstbs->getMPCLink() == me3ID && me3ID != 0 && me3Tbin == tkstbs->BX()) {
165  tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
166  }
167  break;
168  case 4:
169  if (tkstbs->getMPCLink() == me4ID && me4ID != 0 && me4Tbin == tkstbs->BX()) {
170  tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
171  }
172  break;
173  case 5:
174  if (tkstbs->getMPCLink() == mb1ID && mb1ID != 0 && mb1Tbin == tkstbs->BX()) {
176  }
177  break;
178  default:
179  edm::LogWarning("CSCTFTrackBuilder::buildTracks()")
180  << "SERIOUS ERROR: STATION " << tkstbs->station() << " NOT IN RANGE [1,5]\n";
181  };
182  }
183  tcitr++; // increment to next track in the collection
184  }
185 }
CSCTriggerContainer::clear
void clear()
Definition: CSCTriggerContainer.h:57
MessageLogger.h
CSCTFTrackBuilder::m_minBX
int m_minBX
Definition: CSCTFTrackBuilder.h:39
ESHandle.h
CSCTFSectorProcessor
KK.
Definition: CSCTFSectorProcessor.h:26
CSCTFSectorProcessor::tracks
CSCTriggerContainer< csc::L1Track > tracks() const
Definition: CSCTFSectorProcessor.h:45
CSCTFTrackBuilder::initialize
void initialize(const edm::EventSetup &c)
Definition: CSCTFTrackBuilder.cc:33
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
CSCTriggerNumbering::triggerSubSectorFromLabels
static int triggerSubSectorFromLabels(int station, int chamber)
Definition: CSCTriggerNumbering.cc:105
CSCTriggerNumbering::maxTriggerSectorId
static int maxTriggerSectorId()
Definition: CSCTriggerNumbering.h:112
CSCTriggerContainer::push_many
void push_many(const std::vector< T > &data)
Definition: CSCTriggerContainer.h:52
L1CSCTrackCollection
std::vector< L1CSCTrack > L1CSCTrackCollection
Definition: L1CSCTrackCollection.h:8
csctf::TrackStub
Definition: TrackStub.h:22
end
#define end
Definition: vmac.h:39
CSCDetId.h
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
alignCSCRings.s
s
Definition: alignCSCRings.py:92
L1MuTriggerPtScale
Definition: L1MuTriggerPtScale.h:33
CSCDetId::minEndcapId
static int minEndcapId()
Definition: CSCDetId.h:219
CSCTriggerNumbering.h
CSCTFSectorProcessor::run
int run(const CSCTriggerContainer< csctf::TrackStub > &)
Definition: CSCTFSectorProcessor.cc:684
edm::LogWarning
Definition: MessageLogger.h:141
L1MuCSCTFConfiguration.h
edm::ParameterSet
Definition: ParameterSet.h:36
CSCTFTrackBuilder::m_maxBX
int m_maxBX
Definition: CSCTFTrackBuilder.h:39
CSCTriggerContainer.h
CSCDetId
Definition: CSCDetId.h:26
CSCTFTrackBuilder::~CSCTFTrackBuilder
~CSCTFTrackBuilder()
Definition: CSCTFTrackBuilder.cc:42
CSCTriggerNumbering::minTriggerSectorId
static int minTriggerSectorId()
Definition: CSCTriggerNumbering.h:113
edm::EventSetup
Definition: EventSetup.h:57
CSCDetId::maxEndcapId
static int maxEndcapId()
Definition: CSCDetId.h:220
CSCCorrelatedLCTDigiCollection
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
L1MuDTChambPhContainer.h
ptScale
const std::vector< double > ptScale
Definition: Utilities.cc:33
L1MuTriggerScales
Definition: L1MuTriggerScales.h:33
CSCTFTrackBuilder::buildTracks
void buildTracks(const CSCCorrelatedLCTDigiCollection *, const CSCTriggerContainer< csctf::TrackStub > *, L1CSCTrackCollection *, CSCTriggerContainer< csctf::TrackStub > *)
Definition: CSCTFTrackBuilder.cc:51
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
CSCTFSectorProcessor.h
CSCTriggerContainer< csctf::TrackStub >
CSCTriggerContainer::push_back
void push_back(const T &data)
Definition: CSCTriggerContainer.h:51
L1MuCSCTFConfigurationRcd.h
CSCTFSectorProcessor::filteredStubs
std::vector< csctf::TrackStub > filteredStubs() const
Definition: CSCTFSectorProcessor.h:46
CSCTFTrackBuilder::my_SPs
CSCTFSectorProcessor * my_SPs[nEndcaps][nSectors]
Definition: CSCTFTrackBuilder.h:38
DigiContainerIterator
Definition: MuonDigiCollection.h:30
CSCTFSectorProcessor::initialize
void initialize(const edm::EventSetup &c)
KK.
Definition: CSCTFSectorProcessor.cc:182
CSCTFTrackBuilder.h
CSCTriggerContainer::get
std::vector< T > get() const
Definition: CSCTriggerContainer.h:83
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
CSCTFTrackBuilder::CSCTFTrackBuilder
CSCTFTrackBuilder(const edm::ParameterSet &pset, bool TMB07, const L1MuTriggerScales *scales, const L1MuTriggerPtScale *ptScale)
Definition: CSCTFTrackBuilder.cc:18
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37