51 #define M_PI 3.14159265358979323846 70 void endJob()
override;
74 int convertPhiToHW(
double iphi,
int steps);
75 int convertEtaToHW(
double ieta,
double minEta,
double maxEta,
int steps);
76 int convertPtToHW(
double ipt,
int maxPt,
double step);
142 BXVectorInputProducer::BXVectorInputProducer(
const ParameterSet& iConfig)
152 produces<BXVector<l1t::EGamma>>();
153 produces<BXVector<l1t::Muon>>();
154 produces<BXVector<l1t::Tau>>();
155 produces<BXVector<l1t::Jet>>();
156 produces<BXVector<l1t::EtSum>>();
162 maxNumMuCands_ = iConfig.
getParameter<
unsigned int>(
"maxMuCand");
163 maxNumJetCands_ = iConfig.
getParameter<
unsigned int>(
"maxJetCand");
164 maxNumEGCands_ = iConfig.
getParameter<
unsigned int>(
"maxEGCand");
165 maxNumTauCands_ = iConfig.
getParameter<
unsigned int>(
"maxTauCand");
167 jetEtThreshold_ = iConfig.
getParameter<
double>(
"jetEtThreshold");
168 tauEtThreshold_ = iConfig.
getParameter<
double>(
"tauEtThreshold");
169 egEtThreshold_ = iConfig.
getParameter<
double>(
"egEtThreshold");
170 muEtThreshold_ = iConfig.
getParameter<
double>(
"muEtThreshold");
173 emptyBxTrailer_ = iConfig.
getParameter<
int>(
"emptyBxTrailer");
183 BXVectorInputProducer::~BXVectorInputProducer()
200 LogDebug(
"l1t|Global") <<
"BXVectorInputProducer::produce function called...\n";
203 std::vector<l1t::Muon> muonVec;
204 std::vector<l1t::EGamma> egammaVec;
205 std::vector<l1t::Tau> tauVec;
206 std::vector<l1t::Jet> jetVec;
207 std::vector<l1t::EtSum> etsumVec;
210 int bxFirst = bxFirst_;
211 int bxLast = bxLast_;
220 std::vector<int> mu_cands_index;
221 std::vector<int> eg_cands_index;
222 std::vector<int> tau_cands_index;
230 if( iEvent.
getByToken(egToken, inputEgammas) ){
232 for(std::vector<l1t::EGamma>::const_iterator eg = inputEgammas->begin(bx); eg != inputEgammas->end(bx); ++eg) {
234 if(eg->hwPt()>egEtThreshold_ && egammaVec.size() < maxNumEGCands_ ) {
235 egammaVec.push_back((*eg));
241 LogTrace(
"l1t|Global") <<
">>> input EG collection not found!" << std::endl;
248 for(std::vector<l1t::Muon>::const_iterator
mu = inputMuons->begin(bx);
mu != inputMuons->end(bx); ++
mu) {
250 if(
mu->hwPt()>muEtThreshold_ && muonVec.size() < maxNumMuCands_ ) {
251 muonVec.push_back((*
mu));
257 LogTrace(
"l1t|Global") <<
">>> input Mu collection not found!" << std::endl;
265 for(std::vector<l1t::Tau>::const_iterator
tau = inputTaus->begin(bx);
tau != inputTaus->end(bx); ++
tau) {
267 if(
tau->hwPt()>tauEtThreshold_ && tauVec.size() < maxNumTauCands_ ) {
268 tauVec.push_back((*
tau));
274 LogTrace(
"l1t|Global") <<
">>> input tau collection not found!" << std::endl;
282 for(std::vector<l1t::Jet>::const_iterator
jet = inputJets->begin(bx);
jet != inputJets->end(bx); ++
jet) {
284 if(
jet->hwPt()>jetEtThreshold_ && jetVec.size() < maxNumJetCands_ ) {
285 jetVec.push_back((*
jet));
291 LogTrace(
"l1t|Global") <<
">>> input jet collection not found!" << std::endl;
297 if( iEvent.
getByToken(etsumToken, inputEtsums) ){
299 for(std::vector<l1t::EtSum>::const_iterator etsum = inputEtsums->begin(bx); etsum != inputEtsums->end(bx); ++etsum) {
301 etsumVec.push_back((*etsum));
306 LogTrace(
"l1t|Global") <<
">>> input etsum collection not found!" << std::endl;
311 LogTrace(
"l1t|Global") <<
"Event " << eventCnt_ <<
" EmptyBxEvt " << emptyBxEvt_ <<
" emptyBxTrailer " << emptyBxTrailer_ <<
" diff " << (emptyBxEvt_ - eventCnt_) << std::endl;
315 for(
int iMu=0; iMu<
int(muonVec_bxm2.size()); iMu++ ){
316 muons->push_back(-2, muonVec_bxm2[iMu]);
318 for(
int iMu=0; iMu<
int(muonVec_bxm1.size()); iMu++ ){
319 muons->push_back(-1, muonVec_bxm1[iMu]);
321 for(
int iMu=0; iMu<
int(muonVec_bx0.size()); iMu++ ){
322 muons->push_back(0, muonVec_bx0[iMu]);
324 for(
int iMu=0; iMu<
int(muonVec_bxp1.size()); iMu++ ){
325 muons->push_back(1, muonVec_bxp1[iMu]);
327 if(emptyBxTrailer_<=(emptyBxEvt_ - eventCnt_)) {
328 for(
int iMu=0; iMu<
int(muonVec.size()); iMu++ ){
329 muons->push_back(2, muonVec[iMu]);
337 for(
int iEG=0; iEG<
int(egammaVec_bxm2.size()); iEG++ ){
338 egammas->push_back(-2, egammaVec_bxm2[iEG]);
340 for(
int iEG=0; iEG<
int(egammaVec_bxm1.size()); iEG++ ){
341 egammas->push_back(-1, egammaVec_bxm1[iEG]);
343 for(
int iEG=0; iEG<
int(egammaVec_bx0.size()); iEG++ ){
344 egammas->push_back(0, egammaVec_bx0[iEG]);
346 for(
int iEG=0; iEG<
int(egammaVec_bxp1.size()); iEG++ ){
347 egammas->push_back(1, egammaVec_bxp1[iEG]);
349 if(emptyBxTrailer_<=(emptyBxEvt_ - eventCnt_)) {
350 for(
int iEG=0; iEG<
int(egammaVec.size()); iEG++ ){
351 egammas->push_back(2, egammaVec[iEG]);
359 for(
int iTau=0; iTau<
int(tauVec_bxm2.size()); iTau++ ){
360 taus->push_back(-2, tauVec_bxm2[iTau]);
362 for(
int iTau=0; iTau<
int(tauVec_bxm1.size()); iTau++ ){
363 taus->push_back(-1, tauVec_bxm1[iTau]);
365 for(
int iTau=0; iTau<
int(tauVec_bx0.size()); iTau++ ){
366 taus->push_back(0, tauVec_bx0[iTau]);
368 for(
int iTau=0; iTau<
int(tauVec_bxp1.size()); iTau++ ){
369 taus->push_back(1, tauVec_bxp1[iTau]);
371 if(emptyBxTrailer_<=(emptyBxEvt_ - eventCnt_)) {
372 for(
int iTau=0; iTau<
int(tauVec.size()); iTau++ ){
373 taus->push_back(2, tauVec[iTau]);
381 for(
int iJet=0; iJet<
int(jetVec_bxm2.size()); iJet++ ){
382 jets->push_back(-2, jetVec_bxm2[iJet]);
384 for(
int iJet=0; iJet<
int(jetVec_bxm1.size()); iJet++ ){
385 jets->push_back(-1, jetVec_bxm1[iJet]);
387 for(
int iJet=0; iJet<
int(jetVec_bx0.size()); iJet++ ){
388 jets->push_back(0, jetVec_bx0[iJet]);
390 for(
int iJet=0; iJet<
int(jetVec_bxp1.size()); iJet++ ){
391 jets->push_back(1, jetVec_bxp1[iJet]);
393 if(emptyBxTrailer_<=(emptyBxEvt_ - eventCnt_)) {
394 for(
int iJet=0; iJet<
int(jetVec.size()); iJet++ ){
395 jets->push_back(2, jetVec[iJet]);
403 for(
int iETsum=0; iETsum<
int(etsumVec_bxm2.size()); iETsum++ ){
404 etsums->push_back(-2, etsumVec_bxm2[iETsum]);
406 for(
int iETsum=0; iETsum<
int(etsumVec_bxm1.size()); iETsum++ ){
407 etsums->push_back(-1, etsumVec_bxm1[iETsum]);
409 for(
int iETsum=0; iETsum<
int(etsumVec_bx0.size()); iETsum++ ){
410 etsums->push_back(0, etsumVec_bx0[iETsum]);
412 for(
int iETsum=0; iETsum<
int(etsumVec_bxp1.size()); iETsum++ ){
413 etsums->push_back(1, etsumVec_bxp1[iETsum]);
415 if(emptyBxTrailer_<=(emptyBxEvt_ - eventCnt_)) {
416 for(
int iETsum=0; iETsum<
int(etsumVec.size()); iETsum++ ){
417 etsums->push_back(2, etsumVec[iETsum]);
432 muonVec_bxm2 = muonVec_bxm1;
433 egammaVec_bxm2 = egammaVec_bxm1;
434 tauVec_bxm2 = tauVec_bxm1;
435 jetVec_bxm2 = jetVec_bxm1;
436 etsumVec_bxm2 = etsumVec_bxm1;
438 muonVec_bxm1 = muonVec_bx0;
439 egammaVec_bxm1 = egammaVec_bx0;
440 tauVec_bxm1 = tauVec_bx0;
441 jetVec_bxm1 = jetVec_bx0;
442 etsumVec_bxm1 = etsumVec_bx0;
444 muonVec_bx0 = muonVec_bxp1;
445 egammaVec_bx0 = egammaVec_bxp1;
446 tauVec_bx0 = tauVec_bxp1;
447 jetVec_bx0 = jetVec_bxp1;
448 etsumVec_bx0 = etsumVec_bxp1;
450 muonVec_bxp1 = muonVec;
451 egammaVec_bxp1 = egammaVec;
452 tauVec_bxp1 = tauVec;
453 jetVec_bxp1 = jetVec;
454 etsumVec_bxp1 = etsumVec;
466 BXVectorInputProducer::endJob() {
473 LogDebug(
"l1t|Global") <<
"BXVectorInputProducer::beginRun function called...\n";
485 int BXVectorInputProducer::convertPhiToHW(
double iphi,
int steps){
488 if( iphi < 0 ) iphi += 2*
M_PI;
489 if( iphi > phiMax) iphi -=
phiMax;
491 int hwPhi =
int( (iphi/phiMax)*steps + 0.00001 );
495 int BXVectorInputProducer::convertEtaToHW(
double ieta,
double minEta,
double maxEta,
int steps){
497 double binWidth = (maxEta -
minEta)/steps;
500 if(ieta < minEta)
return 99999;
501 if(ieta > maxEta)
return 99999;
503 int binNum = (
int)(ieta/binWidth);
504 if(ieta<0.) binNum--;
512 int BXVectorInputProducer::convertPtToHW(
double ipt,
int maxPt,
double step){
514 int hwPt =
int( ipt/step + 0.0001 );
516 if( hwPt > maxPt ) hwPt =
maxPt;
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)