37 if (EGamma_ && Muon_) {
39 " Wrong configuration : EGamma and Muon should not be true at the same time." ;
79 consumesMany<EcalListOfFEDS>();
80 produces<EcalListOfFEDS>(OutputLabel_);
90 desc.
add<
bool>(
"debug",
false);
92 desc.
add<
bool>(
"EGamma",
false);
93 desc.
add<
bool>(
"Muon",
false);
94 desc.
add<
bool>(
"Jets",
false);
97 desc.
add<
bool>(
"EM_doIsolated",
true);
98 desc.
add<
bool>(
"EM_doNonIsolated",
true);
99 desc.
add<
double>(
"EM_regionEtaMargin",0.25);
100 desc.
add<
double>(
"EM_regionPhiMargin",0.40);
101 desc.
add<
double>(
"Ptmin_iso",0.);
102 desc.
add<
double>(
"Ptmin_noniso",0.);
103 desc.
add<
double>(
"MU_regionEtaMargin",1.0);
104 desc.
add<
double>(
"MU_regionPhiMargin",1.0);
105 desc.
add<
double>(
"Ptmin_muon",0.);
107 desc.
add<
double>(
"JETS_regionEtaMargin",1.0);
108 desc.
add<
double>(
"JETS_regionPhiMargin",1.0);
109 desc.
add<
double>(
"Ptmin_jets",0.);
113 desc.
add<
bool>(
"JETS_doCentral",
true);
114 desc.
add<
bool>(
"JETS_doForward",
true);
115 desc.
add<
bool>(
"JETS_doTau",
true);
117 descriptions.
add((
"hltEcalListOfFEDSProducer"), desc);
126 *TheMapping = *TheMapping_;
130 auto productAddress = std::make_unique<EcalListOfFEDS>();
132 std::vector<int> feds;
137 std::vector< edm::Handle<EcalListOfFEDS> > FEDs_Done;
138 std::vector<int> Done;
140 unsigned int nDone = FEDs_Done.size();
141 if (debug_)
std::cout <<
" ECAL unpacking module has already run " << nDone <<
" times. " << std::endl;
142 for (
unsigned int id=0;
id < nDone;
id++) {
144 if( Pi0ListToIgnore_.label() == FEDs_Done[
id].provenance()->moduleLabel() ){
continue;}
145 std::vector<int> done = FEDs_Done[
id]-> GetList();
146 for (
int jd=0; jd < (
int)done.size(); jd++) {
150 if (debug_)
std::cout <<
" For this event, " << Done.size() <<
" ECAL FEDs have already been unpacked." << std::endl;
155 Egamma(e, iSetup, Done, feds);
160 Muon(e, iSetup, Done, feds);
165 Jets(e, iSetup, Done, feds);
168 if ( !EGamma_ && !Muon_ && ! Jets_) {
169 for (
int i=1;
i <= 54;
i++) {
170 if (
std::find(Done.begin(), Done.end(),
i) == Done.end())
175 int nf = (
int)feds.size();
176 for (
int i=0;
i <nf;
i++) {
178 if (debug_)
std::cout <<
"Will unpack FED " << feds[
i] << std::endl;
181 if (debug_ && nf < 1 )
182 std::cout <<
" Warning : no ECAL FED to unpack for Run " << e.
id().
run() <<
" Event " << e.
id().
event() << std::endl;
184 productAddress.get() -> SetList(feds);
192 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Egamma" << std::endl;
201 if (EMdoNonIsolated_)
202 e.
getByToken(EMl1TagNonIsolated_, emNonIsolColl);
210 for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin();
211 emItr != emIsolColl->end() ;++emItr ){
213 float pt = emItr ->
pt();
214 if (pt < Ptmin_iso_ )
continue;
215 if (debug_)
std::cout <<
" Here is an L1 isoEM candidate of pt " << pt << std::endl;
217 int etaIndex = emItr->gctEmCand()->etaIndex() ;
218 int phiIndex = emItr->gctEmCand()->phiIndex() ;
225 std::vector<int> feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_);
226 for (
int i=0;
i < (
int)feds.size();
i++) {
227 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
228 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
233 if (EMdoNonIsolated_) {
235 for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin();
236 emItr != emNonIsolColl->end() ;++emItr ){
238 float pt = emItr ->
pt();
239 if (debug_)
std::cout <<
" Here is an L1 nonisoEM candidate of pt " << pt << std::endl;
240 if (pt < Ptmin_noniso_ )
continue;
242 int etaIndex = emItr->gctEmCand()->etaIndex() ;
243 int phiIndex = emItr->gctEmCand()->phiIndex() ;
251 std::vector<int> feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_);
252 for (
int i=0;
i < (
int)feds.size();
i++) {
253 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
254 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
265 for (
int i=0;
i < (
int)FEDs.size();
i++) {
266 std::cout <<
"Egamma: unpack FED " << FEDs[
i] << std::endl;
268 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
279 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Muon" << std::endl;
286 for (L1MuonParticleCollection::const_iterator it=muColl->begin(); it != muColl->end(); it++) {
288 double pt = (*it).pt();
289 double eta = (*it).eta();
290 double phi = (*it).phi();
292 if (debug_)
std::cout <<
" here is a L1 muon Seed with (eta,phi) = " <<
293 eta <<
" " << phi <<
" and pt " << pt << std::endl;
294 if (pt < Ptmin_muon_ )
continue;
296 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, MUregionEtaMargin_, MUregionPhiMargin_);
298 for (
int i=0;
i < (
int)feds.size();
i++) {
299 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
300 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
306 for (
int i=0;
i < (
int)FEDs.size();
i++) {
307 std::cout <<
"Muons: unpack FED " << FEDs[
i] << std::endl;
309 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
320 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Jets" << std::endl;
323 if (JETSdoCentral_) {
327 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
329 double pt = it ->
pt();
331 double phi = it -> phi();
333 if (debug_)
std::cout <<
" here is a L1 CentralJet Seed with (eta,phi) = " <<
334 eta <<
" " << phi <<
" and pt " << pt << std::endl;
336 if (pt < Ptmin_jets_ )
continue;
338 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
340 for (
int i=0;
i < (
int)feds.size();
i++) {
341 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
342 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
347 if (JETSdoForward_) {
351 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
353 double pt = it ->
pt();
355 double phi = it -> phi();
357 if (debug_)
std::cout <<
" here is a L1 ForwardJet Seed with (eta,phi) = " <<
358 eta <<
" " << phi <<
" and pt " << pt << std::endl;
359 if (pt < Ptmin_jets_ )
continue;
361 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
363 for (
int i=0;
i < (
int)feds.size();
i++) {
364 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
365 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
374 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
376 double pt = it ->
pt();
378 double phi = it -> phi();
380 if (debug_)
std::cout <<
" here is a L1 TauJet Seed with (eta,phi) = " <<
381 eta <<
" " << phi <<
" and pt " << pt << std::endl;
382 if (pt < Ptmin_jets_ )
continue;
384 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
386 for (
int i=0;
i < (
int)feds.size();
i++) {
387 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
388 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
397 for (
int i=0;
i < (
int)FEDs.size();
i++) {
398 std::cout <<
"Jets: unpack FED " << FEDs[
i] << std::endl;
400 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
407 double phiHigh,
double etamargin,
double phimargin) {
409 std::vector<int> FEDs;
414 if (debug_)
std::cout <<
" etaLow etaHigh phiLow phiHigh " << etaLow <<
" " <<
415 etaHigh <<
" " << phiLow <<
" " << phiHigh << std::endl;
418 etaHigh += etamargin;
419 double phiMinus = phiLow - phimargin;
420 double phiPlus = phiHigh + phimargin;
423 double dd = fabs(phiPlus-phiMinus);
424 if (debug_)
std::cout <<
" dd = " << dd << std::endl;
425 if (dd > 2.*
Geom::pi() ) all =
true;
428 while (phiMinus < 0) { phiMinus += 2.*
Geom::pi() ; }
431 double dphi = phiPlus - phiMinus;
432 if (dphi < 0) dphi += 2.*
Geom::pi() ;
433 if (debug_)
std::cout <<
"dphi = " << dphi << std::endl;
435 int fed_low1 = TheMapping -> GetFED(etaLow,phiMinus*180./
Geom::pi());
436 int fed_low2 = TheMapping -> GetFED(etaLow,phiPlus*180./
Geom::pi());
437 if (debug_)
std::cout <<
"fed_low1 fed_low2 " << fed_low1 <<
" " << fed_low2 << std::endl;
438 if (fed_low1 == fed_low2) all =
true;
439 int fed_hi1 = TheMapping -> GetFED(etaHigh,phiMinus*180./
Geom::pi());
440 int fed_hi2 = TheMapping -> GetFED(etaHigh,phiPlus*180./
Geom::pi());
441 if (debug_)
std::cout <<
"fed_hi1 fed_hi2 " << fed_hi1 <<
" " << fed_hi2 << std::endl;
442 if (fed_hi1 == fed_hi2) all =
true;
447 if (debug_)
std::cout <<
" unpack everything in phi ! " << std::endl;
452 if (debug_)
std::cout <<
" with margins : " << etaLow <<
" " << etaHigh <<
" " <<
453 phiMinus <<
" " << phiPlus << std::endl;
458 FEDs = TheMapping -> GetListofFEDs(ecalregion);
T getParameter(std::string const &) const
EventNumber_t event() const
~EcalListOfFEDSProducer() override
T getUntrackedParameter(std::string const &, T const &) const
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
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)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void Egamma(edm::Event &e, const edm::EventSetup &es, std::vector< int > &done, std::vector< int > &FEDs)
void produce(edm::Event &e, const edm::EventSetup &c) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void Jets(edm::Event &e, const edm::EventSetup &es, std::vector< int > &done, std::vector< int > &FEDs)
EcalListOfFEDSProducer(const edm::ParameterSet &pset)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< int > ListOfFEDS(double etaLow, double etaHigh, double phiLow, double phiHigh, double etamargin, double phimargin)
double emJetPhiBinLowEdge(unsigned int phiIndex) const
T const * product() const
double emJetPhiBinHighEdge(unsigned int phiIndex) const