Go to the documentation of this file.00001 #include "L1Trigger/RPCTrigger/interface/RPCTrigger.h"
00002
00003
00004 #include "CondFormats/DataRecord/interface/L1RPCConfigRcd.h"
00005 #include "CondFormats/L1TObjects/interface/L1RPCConfig.h"
00006
00007 #include "CondFormats/DataRecord/interface/L1RPCConeBuilderRcd.h"
00008 #include "CondFormats/RPCObjects/interface/L1RPCConeBuilder.h"
00009
00010 #include "CondFormats/DataRecord/interface/L1RPCHwConfigRcd.h"
00011 #include "CondFormats/RPCObjects/interface/L1RPCHwConfig.h"
00012
00013 #include "CondFormats/DataRecord/interface/L1RPCBxOrConfigRcd.h"
00014 #include "CondFormats/L1TObjects/interface/L1RPCBxOrConfig.h"
00015
00016
00017
00018
00019
00020
00021
00022 #include "L1Trigger/RPCTrigger/interface/MuonsGrabber.h"
00023
00024
00025 RPCTrigger::RPCTrigger(const edm::ParameterSet& iConfig):
00026 m_trigConfig(0),m_pacTrigger(0)
00027 {
00028 produces<std::vector<L1MuRegionalCand> >("RPCb");
00029 produces<std::vector<L1MuRegionalCand> >("RPCf");
00030
00031 produces<std::vector<RPCDigiL1Link> >("RPCb");
00032 produces<std::vector<RPCDigiL1Link> >("RPCf");
00033
00034 m_firstRun = true;
00035 m_cacheID = 0;
00036
00037
00038 m_triggerDebug = iConfig.getUntrackedParameter<int>("RPCTriggerDebug",0);
00039
00040
00041
00042 if ( m_triggerDebug != 1){
00043 m_triggerDebug = 0;
00044 }
00045
00046
00047 m_label = iConfig.getParameter<std::string>("label");
00048 }
00049
00050
00051
00052
00053 RPCTrigger::~RPCTrigger(){
00054 if (m_pacTrigger != 0) delete m_pacTrigger;
00055 if (m_trigConfig != 0) delete m_trigConfig;
00056 }
00057
00058
00059
00060 void
00061 RPCTrigger::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00062 {
00063
00064
00065
00066 if ( m_triggerDebug == 1) MuonsGrabber::Instance().startNewEvent(iEvent.id().event(), iEvent.bunchCrossing());
00067
00068 if (m_firstRun){
00069
00070 m_cacheID = iSetup.get<L1RPCConfigRcd>().cacheIdentifier();
00071 m_firstRun = false;
00072 edm::ESHandle<L1RPCConfig> conf;
00073 iSetup.get<L1RPCConfigRcd>().get(conf);
00074 const L1RPCConfig *rpcconf = conf.product();
00075
00076
00077 m_pacManager.init(rpcconf);
00078 m_trigConfig = new RPCBasicTrigConfig(&m_pacManager);
00079 m_trigConfig->setDebugLevel(m_triggerDebug);
00080 m_pacTrigger = new RPCPacTrigger(m_trigConfig);
00081 if ( m_triggerDebug == 1) MuonsGrabber::Instance().setRPCBasicTrigConfig(m_trigConfig);
00082
00083
00084 }
00085
00086 if (m_cacheID != iSetup.get<L1RPCConfigRcd>().cacheIdentifier()) {
00087
00088
00089 m_cacheID = iSetup.get<L1RPCConfigRcd>().cacheIdentifier();
00090
00091 edm::ESHandle<L1RPCConfig> conf;
00092 iSetup.get<L1RPCConfigRcd>().get(conf);
00093 const L1RPCConfig *rpcconf = conf.product();
00094
00095 m_pacManager.init(rpcconf);
00096 delete m_trigConfig;
00097 m_trigConfig = new RPCBasicTrigConfig(&m_pacManager);
00098 m_trigConfig->setDebugLevel(m_triggerDebug);
00099
00100 delete m_pacTrigger;
00101 m_pacTrigger = new RPCPacTrigger(m_trigConfig);
00102
00103 if ( m_triggerDebug == 1) MuonsGrabber::Instance().setRPCBasicTrigConfig(m_trigConfig);
00104
00105
00106 }
00107
00108
00109
00110 edm::Handle<RPCDigiCollection> rpcDigis;
00111
00112
00113 iEvent.getByLabel(m_label, rpcDigis);
00114
00115 std::auto_ptr<std::vector<L1MuRegionalCand> > candBarell(new std::vector<L1MuRegionalCand>);
00116 std::auto_ptr<std::vector<L1MuRegionalCand> > candForward(new std::vector<L1MuRegionalCand>);
00117 if (!rpcDigis.isValid())
00118 {
00119 LogDebug("RPCTrigger")
00120 << "\nWarning: RPCDigiCollection with input tag " << m_label
00121 << "\nrequested in configuration, but not found in the event. Emulator will produce empty collection \n ";
00122
00123 iEvent.put(candBarell, "RPCb");
00124 iEvent.put(candForward, "RPCf");
00125
00126 return;
00127 }
00128
00129
00130 if (rpcDigis->begin() == rpcDigis->end() )
00131 {
00132 LogDebug("RPCTrigger")
00133 << "\nWarning: RPCDigiCollection with input tag " << m_label
00134 << "\n seems to be empty for this event. Emulator will run on empty collection ";
00135
00136 }
00137
00138
00139
00140 std::auto_ptr<std::vector<RPCDigiL1Link> > brlLinks(new std::vector<RPCDigiL1Link>);
00141 std::auto_ptr<std::vector<RPCDigiL1Link> > fwdLinks(new std::vector<RPCDigiL1Link>);
00142
00143 for (int iBx = -1; iBx < 2; ++ iBx) {
00144
00145 L1RpcLogConesVec ActiveCones;
00146
00147 edm::ESHandle<L1RPCConeBuilder> coneBuilder;
00148 iSetup.get<L1RPCConeBuilderRcd>().get(coneBuilder);
00149
00150 edm::ESHandle<L1RPCConeDefinition> l1RPCConeDefinition;
00151 iSetup.get<L1RPCConeDefinitionRcd>().get(l1RPCConeDefinition);
00152
00153 edm::ESHandle<L1RPCHwConfig> hwConfig;
00154 iSetup.get<L1RPCHwConfigRcd>().get(hwConfig);
00155
00156 edm::ESHandle<L1RPCBxOrConfig> bxOrConfig;
00157 iSetup.get<L1RPCBxOrConfigRcd>().get(bxOrConfig);
00158
00159
00160
00161 ActiveCones = m_theLinksystemFromES.getConesFromES(rpcDigis, coneBuilder, l1RPCConeDefinition, bxOrConfig, hwConfig, iBx);
00162
00163 edm::ESHandle<L1RPCHsbConfig> hsbConfig;
00164 iSetup.get<L1RPCHsbConfigRcd>().get(hsbConfig);
00165
00166 L1RpcTBMuonsVec2 finalMuons = m_pacTrigger->runEvent(ActiveCones, hsbConfig);
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 std::vector<RPCDigiL1Link> dlBrl;
00187 std::vector<RPCDigiL1Link> dlFwd;
00188 std::vector<L1MuRegionalCand> RPCb = giveFinallCandindates(finalMuons[0],1, iBx, rpcDigis, dlBrl);
00189 std::vector<L1MuRegionalCand> RPCf = giveFinallCandindates(finalMuons[1],3, iBx, rpcDigis, dlFwd);
00190
00191
00192 brlLinks->insert(brlLinks->end(), dlBrl.begin(), dlBrl.end() );
00193 fwdLinks->insert(fwdLinks->end(), dlFwd.begin(), dlFwd.end() );
00194
00195 candBarell->insert(candBarell->end(), RPCb.begin(), RPCb.end());
00196 candForward->insert(candForward->end(), RPCf.begin(), RPCf.end());
00197
00198 if ( m_triggerDebug == 1) MuonsGrabber::Instance().writeDataForRelativeBX(iBx);
00199 }
00200
00201 iEvent.put(fwdLinks, "RPCf");
00202 iEvent.put(brlLinks, "RPCb");
00203 iEvent.put(candBarell, "RPCb");
00204 iEvent.put(candForward, "RPCf");
00205
00206 }
00208
00215
00216 std::vector<L1MuRegionalCand> RPCTrigger::giveFinallCandindates(const L1RpcTBMuonsVec& finalMuons, int type, int bx,
00217 edm::Handle<RPCDigiCollection> rpcDigis, std::vector<RPCDigiL1Link> & retRPCDigiLink)
00218 {
00219
00220 std::vector<L1MuRegionalCand> RPCCand;
00221
00222 for(unsigned int iMu = 0; iMu < finalMuons.size(); iMu++)
00223 {
00224
00225 if (finalMuons[iMu].getPtCode()==0){
00226 continue;
00227 }
00228
00229 RPCDigiL1Link newDigiLink;
00230
00231
00232
00233 RPCMuon::TDigiLinkVec digiIVec = finalMuons[iMu].getDigiIdxVec();
00234
00235 short int digiIndex = 0;
00236 RPCDigiCollection::DigiRangeIterator detUnitIt;
00237 for (detUnitIt=rpcDigis->begin();
00238 detUnitIt!=rpcDigis->end();
00239 ++detUnitIt)
00240 {
00241
00242 const RPCDetId& id = (*detUnitIt).first;
00243 uint32_t rawId = id.rawId();
00244 const RPCDigiCollection::Range& range = (*detUnitIt).second;
00245
00246
00247 for (RPCDigiCollection::const_iterator digiIt = range.first;
00248 digiIt!=range.second;
00249 ++digiIt)
00250 {
00251 ++digiIndex;
00252
00253 RPCMuon::TDigiLinkVec::iterator it = digiIVec.begin();
00254 for(;it!=digiIVec.end();++it) {
00255 if (digiIndex==it->m_digiIdx) {
00256 newDigiLink.setLink(it->m_layer+1, rawId, digiIt->strip(), digiIt->bx() );
00257
00258
00259 }
00260 }
00261 }
00262 }
00263 retRPCDigiLink.push_back(newDigiLink);
00264
00265
00266 L1MuRegionalCand l1Cand;
00267
00268 l1Cand.setBx(bx);
00269
00270
00271 l1Cand.setQualityPacked(finalMuons[iMu].getQuality());
00272 l1Cand.setPtPacked(finalMuons[iMu].getPtCode());
00273
00274 l1Cand.setType(type);
00275
00276 int charge=finalMuons[iMu].getSign();
00277
00278 if (charge == 0)
00279 l1Cand.setChargePacked(1);
00280 else
00281 l1Cand.setChargePacked(0);
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300 int phiPacked = finalMuons[iMu].getPhiAddr();
00301 l1Cand.setPhiPacked(phiPacked);
00302
00303
00304
00305
00306
00307 signed short etaAddr = finalMuons[iMu].getEtaAddr();
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 l1Cand.setEtaPacked(etaAddr);
00318 l1Cand.setChargeValid(true);
00319
00320
00321
00322
00323
00324
00325
00326
00327 RPCCand.push_back(l1Cand);
00328
00329 LogDebug("RPCTrigger") << "Found muonf of pt "
00330 << finalMuons[iMu].getPtCode()
00331 << " bx " << l1Cand.bx()
00332 << " L1Charge " << l1Cand.charge_packed()
00333 << " ql " << l1Cand.quality()
00334 << " fp " << finalMuons[iMu].getFiredPlanes()
00335 << " b/f " << l1Cand.type_idx()
00336 << " phi " << l1Cand.phi_packed()
00337 << " eta " << l1Cand.eta_packed()
00338
00339 << " killed " << finalMuons[iMu].wasKilled();
00340
00341
00342 }
00343
00344 return RPCCand;
00345 }
00346