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