00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.h>
00019 #include <L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.h>
00020 #include <L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.h>
00021
00022 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00023
00024 #include <L1Trigger/CSCCommonTrigger/interface/CSCTriggerGeometry.h>
00025 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
00026 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
00027
00028
00029
00030
00031 const int CSCTriggerPrimitivesBuilder::min_endcap = CSCDetId::minEndcapId();
00032 const int CSCTriggerPrimitivesBuilder::max_endcap = CSCDetId::maxEndcapId();
00033 const int CSCTriggerPrimitivesBuilder::min_station = CSCDetId::minStationId();
00034 const int CSCTriggerPrimitivesBuilder::max_station = CSCDetId::maxStationId();
00035 const int CSCTriggerPrimitivesBuilder::min_sector =
00036 CSCTriggerNumbering::minTriggerSectorId();
00037 const int CSCTriggerPrimitivesBuilder::max_sector =
00038 CSCTriggerNumbering::maxTriggerSectorId();
00039 const int CSCTriggerPrimitivesBuilder::min_subsector =
00040 CSCTriggerNumbering::minTriggerSubSectorId();
00041 const int CSCTriggerPrimitivesBuilder::max_subsector =
00042 CSCTriggerNumbering::maxTriggerSubSectorId();
00043 const int CSCTriggerPrimitivesBuilder::min_chamber =
00044 CSCTriggerNumbering::minTriggerCscId();
00045 const int CSCTriggerPrimitivesBuilder::max_chamber =
00046 CSCTriggerNumbering::maxTriggerCscId();
00047
00048
00049
00050
00051 CSCTriggerPrimitivesBuilder::CSCTriggerPrimitivesBuilder(const edm::ParameterSet& conf) {
00052
00053
00054
00055 for (int endc = min_endcap; endc <= max_endcap; endc++) {
00056 for (int stat = min_station; stat <= max_station; stat++) {
00057 int numsubs = ((stat == 1) ? max_subsector : 1);
00058 for (int sect = min_sector; sect <= max_sector; sect++) {
00059 for (int subs = min_subsector; subs <= numsubs; subs++) {
00060 for (int cham = min_chamber; cham <= max_chamber; cham++) {
00061 if ((endc <= 0 || endc > MAX_ENDCAPS) ||
00062 (stat <= 0 || stat > MAX_STATIONS) ||
00063 (sect <= 0 || sect > MAX_SECTORS) ||
00064 (subs <= 0 || subs > MAX_SUBSECTORS) ||
00065 (cham <= 0 || stat > MAX_CHAMBERS)) {
00066 edm::LogError("CSCTriggerPrimitivesBuilder")
00067 << "+++ trying to instantiate TMB of illegal CSC id ["
00068 << " endcap = " << endc << " station = " << stat
00069 << " sector = " << sect << " subsector = " << subs
00070 << " chamber = " << cham << "]; skipping it... +++\n";
00071 continue;
00072 }
00073
00074
00075 tmb_[endc-1][stat-1][sect-1][subs-1][cham-1] =
00076 new CSCMotherboard(endc, stat, sect, subs, cham, conf);
00077 }
00078 }
00079 }
00080 }
00081 }
00082
00083
00084 m_minBX = conf.getParameter<int>("MinBX");
00085 m_maxBX = conf.getParameter<int>("MaxBX");
00086
00087
00088 m_muonportcard = new CSCMuonPortCard();
00089 }
00090
00091
00092
00093
00094 CSCTriggerPrimitivesBuilder::~CSCTriggerPrimitivesBuilder() {
00095 for (int endc = min_endcap; endc <= max_endcap; endc++) {
00096 for (int stat = min_station; stat <= max_station; stat++) {
00097 int numsubs = ((stat == 1) ? max_subsector : 1);
00098 for (int sect = min_sector; sect <= max_sector; sect++) {
00099 for (int subs = min_subsector; subs <= numsubs; subs++) {
00100 for (int cham = min_chamber; cham <= max_chamber; cham++) {
00101 delete tmb_[endc-1][stat-1][sect-1][subs-1][cham-1];
00102 }
00103 }
00104 }
00105 }
00106 }
00107 delete m_muonportcard;
00108 }
00109
00110
00111
00112
00113
00114 void CSCTriggerPrimitivesBuilder::setConfigParameters(const CSCL1TPParameters* conf) {
00115
00116
00117 for (int endc = min_endcap; endc <= max_endcap; endc++) {
00118 for (int stat = min_station; stat <= max_station; stat++) {
00119 int numsubs = ((stat == 1) ? max_subsector : 1);
00120 for (int sect = min_sector; sect <= max_sector; sect++) {
00121 for (int subs = min_subsector; subs <= numsubs; subs++) {
00122 for (int cham = min_chamber; cham <= max_chamber; cham++) {
00123 CSCMotherboard* tmb = tmb_[endc-1][stat-1][sect-1][subs-1][cham-1];
00124 tmb->setConfigParameters(conf);
00125 }
00126 }
00127 }
00128 }
00129 }
00130 }
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 void CSCTriggerPrimitivesBuilder::build(const CSCWireDigiCollection* wiredc,
00142 const CSCComparatorDigiCollection* compdc,
00143 CSCALCTDigiCollection& oc_alct,
00144 CSCCLCTDigiCollection& oc_clct,
00145 CSCCorrelatedLCTDigiCollection& oc_lct,
00146 CSCCorrelatedLCTDigiCollection& oc_sorted_lct) {
00147
00148 CSCTriggerGeomManager* theGeom = CSCTriggerGeometry::get();
00149
00150 for (int endc = min_endcap; endc <= max_endcap; endc++) {
00151 for (int stat = min_station; stat <= max_station; stat++) {
00152 int numsubs = ((stat == 1) ? max_subsector : 1);
00153 for (int sect = min_sector; sect <= max_sector; sect++) {
00154 for (int subs = min_subsector; subs <= numsubs; subs++) {
00155 for (int cham = min_chamber; cham <= max_chamber; cham++) {
00156 CSCMotherboard* tmb = tmb_[endc-1][stat-1][sect-1][subs-1][cham-1];
00157
00158
00159 if (tmb != 0 &&
00160 theGeom->chamber(endc, stat, sect, subs, cham) != 0) {
00161 std::vector<CSCCorrelatedLCTDigi> lctV = tmb->run(wiredc,compdc);
00162
00163 std::vector<CSCALCTDigi> alctV = tmb->alct->getALCTs();
00164 std::vector<CSCCLCTDigi> clctV = tmb->clct->getCLCTs();
00165
00166
00167
00168 if (alctV.empty() && clctV.empty() && lctV.empty()) continue;
00169
00170
00171 int ring =
00172 CSCTriggerNumbering::ringFromTriggerLabels(stat, cham);
00173 int chid =
00174 CSCTriggerNumbering::chamberFromTriggerLabels(sect, subs,
00175 stat, cham);
00176
00177 CSCDetId detid(endc, stat, ring, chid, 0);
00178
00179
00180 if (!lctV.empty()) {
00181 LogTrace("L1CSCTrigger")
00182 << "Put " << lctV.size() << " LCT digi"
00183 << ((lctV.size() > 1) ? "s " : " ") << "in collection\n";
00184 oc_lct.put(std::make_pair(lctV.begin(),lctV.end()), detid);
00185 }
00186
00187
00188 if (!alctV.empty()) {
00189 LogTrace("L1CSCTrigger")
00190 << "Put " << alctV.size() << " ALCT digi"
00191 << ((alctV.size() > 1) ? "s " : " ") << "in collection\n";
00192 oc_alct.put(std::make_pair(alctV.begin(),alctV.end()), detid);
00193 }
00194
00195
00196 if (!clctV.empty()) {
00197 LogTrace("L1CSCTrigger")
00198 << "Put " << clctV.size() << " CLCT digi"
00199 << ((clctV.size() > 1) ? "s " : " ") << "in collection\n";
00200 oc_clct.put(std::make_pair(clctV.begin(),clctV.end()), detid);
00201 }
00202 }
00203 }
00204 }
00205 }
00206 }
00207 }
00208
00209
00210 m_muonportcard->loadDigis(oc_lct);
00211
00212 std::vector<csctf::TrackStub> result;
00213 for(int bx = m_minBX; bx <= m_maxBX; ++bx)
00214 for(int e = min_endcap; e <= max_endcap; ++e)
00215 for(int st = min_station; st <= max_station; ++st)
00216 for(int se = min_sector; se <= max_sector; ++se)
00217 {
00218 if(st == 1)
00219 {
00220 std::vector<csctf::TrackStub> subs1, subs2;
00221 subs1 = m_muonportcard->sort(e, st, se, 1, bx);
00222 subs2 = m_muonportcard->sort(e, st, se, 2, bx);
00223 result.insert(result.end(), subs1.begin(), subs1.end());
00224 result.insert(result.end(), subs2.begin(), subs2.end());
00225 }
00226 else
00227 {
00228 std::vector<csctf::TrackStub> sector;
00229 sector = m_muonportcard->sort(e, st, se, 0, bx);
00230 result.insert(result.end(), sector.begin(), sector.end());
00231 }
00232 }
00233
00234 std::vector<csctf::TrackStub>::const_iterator itr = result.begin();
00235 for (; itr != result.end(); itr++) {
00236 oc_sorted_lct.insertDigi(CSCDetId(itr->getDetId().rawId()), *(itr->getDigi()));
00237 LogDebug("L1CSCTrigger")
00238 << "MPC " << *(itr->getDigi()) << " found in ME"
00239 << ((itr->endcap() == 1) ? "+" : "-") << itr->station() << "/"
00240 << CSCDetId(itr->getDetId().rawId()).ring() << "/"
00241 << CSCDetId(itr->getDetId().rawId()).chamber()
00242 << " (sector " << itr->sector()
00243 << " trig id. " << itr->cscid() << ")" << "\n";
00244 }
00245 }