40 if (EGamma_ && Muon_) {
42 " Wrong configuration : EGamma and Muon should not be true at the same time." ;
82 consumesMany<ESListOfFEDS>();
83 produces<ESListOfFEDS>(OutputLabel_);
93 desc.
add<
bool>(
"debug",
false);
94 desc.
add<
bool>(
"EGamma",
true);
95 desc.
add<
bool>(
"Muon",
false);
96 desc.
add<
bool>(
"Jets",
false);
99 desc.
add<
bool>(
"EM_doIsolated",
true);
100 desc.
add<
bool>(
"EM_doNonIsolated",
true);
101 desc.
add<
double>(
"EM_regionEtaMargin", 0.25);
102 desc.
add<
double>(
"EM_regionPhiMargin", 0.40);
103 desc.
add<
double>(
"Ptmin_iso", 5.0);
104 desc.
add<
double>(
"Ptmin_noniso", 5.0);
105 desc.
add<
double>(
"MU_regionEtaMargin", 1.0);
106 desc.
add<
double>(
"MU_regionPhiMargin", 1.0);
107 desc.
add<
double>(
"Ptmin_muon", 0.);
109 desc.
add<
double>(
"JETS_regionEtaMargin", 1.0);
110 desc.
add<
double>(
"JETS_regionPhiMargin", 1.0);
111 desc.
add<
double>(
"Ptmin_jets", 50.);
115 desc.
add<
bool>(
"JETS_doCentral",
true);
116 desc.
add<
bool>(
"JETS_doForward",
true);
117 desc.
add<
bool>(
"JETS_doTau",
true);
119 descriptions.
add((
"hltESListOfFEDSProducer"), desc);
129 *TheMapping = *TheMapping_;
133 auto productAddress = std::make_unique<ESListOfFEDS>();
134 std::vector<int> feds;
137 std::vector<int> Done;
140 Egamma(e, iSetup, Done, feds);
154 if ( !EGamma_ && !Muon_ && ! Jets_) {
155 for (
int i=1;
i <= 54;
i++) {
156 if (
std::find(Done.begin(), Done.end(),
i) == Done.end())
162 int nf = (
int)feds.size();
163 for (
int i=0;
i <nf;
i++) {
165 if (debug_)
std::cout <<
"Will unpack FED " << feds[
i] << std::endl;
168 if (debug_ && nf < 1 )
169 std::cout <<
" Warning : no ECAL FED to unpack for Run " << e.
id().
run() <<
" Event " << e.
id().
event() << std::endl;
172 std::vector<int> es_feds = TheESMapping->GetListofFEDs(feds);
175 std::vector< edm::Handle<ESListOfFEDS> > esFEDs_Done;
177 unsigned int esnDone = esFEDs_Done.size();
180 std::cout<<
int(es_feds.size())<<
" feds requested, and ESunpacking have already been done "<<esnDone<<
" times."<<std::endl;
183 for(
int i=0;
i<
int(esFEDs_Done.size());
i++){
184 std::vector<int> done = esFEDs_Done[
i]-> GetList();
185 for(
int n=0;
n<
int(done.size());
n++){
186 for(
int j=0; j<
int(es_feds.size());j++){
187 std::vector<int>::iterator it =
find(es_feds.begin(),es_feds.end(),done[
n]);
188 if( it != es_feds.end()){
197 std::cout<<
"ESListofFEDSProducer: new ES_list will be put into event: total "<<
int(es_feds.size())<<std::endl;
198 for(
int j=0; j<
int(es_feds.size());j++){
206 productAddress.get() -> SetList(es_feds);
215 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Egamma" << std::endl;
223 if (EMdoNonIsolated_)
224 e.
getByToken(EMl1TagNonIsolated_, emNonIsolColl);
232 for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin();
233 emItr != emIsolColl->end() ;++emItr ){
235 float pt = emItr ->
pt();
236 if (pt < Ptmin_iso_ )
continue;
237 if (debug_)
std::cout <<
" Here is an L1 isoEM candidate of pt " << pt << std::endl;
239 int etaIndex = emItr->gctEmCand()->etaIndex() ;
240 int phiIndex = emItr->gctEmCand()->phiIndex() ;
247 std::vector<int> feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_);
248 for (
int i=0;
i < (
int)feds.size();
i++) {
249 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
250 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
255 if (EMdoNonIsolated_) {
257 for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin();
258 emItr != emNonIsolColl->end() ;++emItr ){
260 float pt = emItr ->
pt();
261 if (debug_)
std::cout <<
" Here is an L1 nonisoEM candidate of pt " << pt << std::endl;
262 if (pt < Ptmin_noniso_ )
continue;
264 int etaIndex = emItr->gctEmCand()->etaIndex() ;
265 int phiIndex = emItr->gctEmCand()->phiIndex() ;
273 std::vector<int> feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_);
274 for (
int i=0;
i < (
int)feds.size();
i++) {
275 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
276 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
284 for (
int i=0;
i < (
int)FEDs.size();
i++) {
285 std::cout <<
"Egamma: unpack FED " << FEDs[
i] << std::endl;
287 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
296 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Muon" << std::endl;
302 for (L1MuonParticleCollection::const_iterator it=muColl->begin(); it != muColl->end(); it++) {
305 double pt = (*it).pt();
306 double eta = (*it).eta();
307 double phi = (*it).phi();
309 if (debug_)
std::cout <<
" here is a L1 muon Seed with (eta,phi) = " <<
310 eta <<
" " << phi <<
" and pt " << pt << std::endl;
311 if (pt < Ptmin_muon_ )
continue;
313 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, MUregionEtaMargin_, MUregionPhiMargin_);
315 for (
int i=0;
i < (
int)feds.size();
i++) {
316 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
317 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
323 for (
int i=0;
i < (
int)FEDs.size();
i++) {
324 std::cout <<
"Muons: unpack FED " << FEDs[
i] << std::endl;
326 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
337 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Jets" << std::endl;
340 if (JETSdoCentral_) {
345 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
347 double pt = it ->
pt();
349 double phi = it -> phi();
351 if (debug_)
std::cout <<
" here is a L1 CentralJet Seed with (eta,phi) = " <<
352 eta <<
" " << phi <<
" and pt " << pt << std::endl;
353 if (pt < Ptmin_jets_ )
continue;
355 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
357 for (
int i=0;
i < (
int)feds.size();
i++) {
358 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
359 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
364 if (JETSdoForward_) {
369 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
371 double pt = it ->
pt();
373 double phi = it -> phi();
375 if (debug_)
std::cout <<
" here is a L1 ForwardJet Seed with (eta,phi) = " <<
376 eta <<
" " << phi <<
" and pt " << pt << std::endl;
377 if (pt < Ptmin_jets_ )
continue;
379 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
381 for (
int i=0;
i < (
int)feds.size();
i++) {
382 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
383 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
393 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
395 double pt = it ->
pt();
397 double phi = it -> phi();
399 if (debug_)
std::cout <<
" here is a L1 TauJet Seed with (eta,phi) = " <<
400 eta <<
" " << phi <<
" and pt " << pt << std::endl;
401 if (pt < Ptmin_jets_ )
continue;
403 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
405 for (
int i=0;
i < (
int)feds.size();
i++) {
406 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
407 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
414 for (
int i=0;
i < (
int)FEDs.size();
i++) {
415 std::cout <<
"Jets: unpack FED " << FEDs[
i] << std::endl;
417 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
425 double phiHigh,
double etamargin,
double phimargin)
428 std::vector<int> FEDs;
433 if (debug_)
std::cout <<
" etaLow etaHigh phiLow phiHigh " << etaLow <<
" " <<
434 etaHigh <<
" " << phiLow <<
" " << phiHigh << std::endl;
437 etaHigh += etamargin;
438 double phiMinus = phiLow - phimargin;
439 double phiPlus = phiHigh + phimargin;
442 double dd = fabs(phiPlus-phiMinus);
443 if (debug_)
std::cout <<
" dd = " << dd << std::endl;
444 if (dd > 2.*
Geom::pi() ) all =
true;
447 while (phiMinus < 0) { phiMinus += 2.*
Geom::pi() ; }
450 double dphi = phiPlus - phiMinus;
451 if (dphi < 0) dphi += 2.*
Geom::pi() ;
452 if (debug_)
std::cout <<
"dphi = " << dphi << std::endl;
454 int fed_low1 = TheMapping -> GetFED(etaLow,phiMinus*180./
Geom::pi());
455 int fed_low2 = TheMapping -> GetFED(etaLow,phiPlus*180./
Geom::pi());
456 if (debug_)
std::cout <<
"fed_low1 fed_low2 " << fed_low1 <<
" " << fed_low2 << std::endl;
457 if (fed_low1 == fed_low2) all =
true;
458 int fed_hi1 = TheMapping -> GetFED(etaHigh,phiMinus*180./
Geom::pi());
459 int fed_hi2 = TheMapping -> GetFED(etaHigh,phiPlus*180./
Geom::pi());
460 if (debug_)
std::cout <<
"fed_hi1 fed_hi2 " << fed_hi1 <<
" " << fed_hi2 << std::endl;
461 if (fed_hi1 == fed_hi2) all =
true;
466 if (debug_)
std::cout <<
" unpack everything in phi ! " << std::endl;
471 if (debug_)
std::cout <<
" with margins : " << etaLow <<
" " << etaHigh <<
" " <<
472 phiMinus <<
" " << phiPlus << std::endl;
477 FEDs = TheMapping -> GetListofFEDs(ecalregion);
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
~ESListOfFEDSProducer() override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
double etaBinHighEdge(unsigned int etaIndex, bool central=true) const
void Muon(edm::Event &e, const edm::EventSetup &es, std::vector< int > &done, std::vector< int > &FEDs)
double etaBinLowEdge(unsigned int etaIndex, bool central=true) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void getManyByType(std::vector< Handle< PROD >> &results) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
ESListOfFEDSProducer(const edm::ParameterSet &pset)
std::vector< int > ListOfFEDS(double etaLow, double etaHigh, double phiLow, double phiHigh, double etamargin, double phimargin)
void Jets(edm::Event &e, const edm::EventSetup &es, std::vector< int > &done, std::vector< int > &FEDs)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void Egamma(edm::Event &e, const edm::EventSetup &es, std::vector< int > &done, std::vector< int > &FEDs)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double emJetPhiBinLowEdge(unsigned int phiIndex) const
T const * product() const
void produce(edm::Event &e, const edm::EventSetup &c) override
double emJetPhiBinHighEdge(unsigned int phiIndex) const