42 using namespace l1extra;
56 if (EGamma_ && Muon_) {
58 " Wrong configuration : EGamma and Muon should not be true at the same time." ;
101 produces<ESListOfFEDS>(OutputLabel_);
126 *TheMapping = *TheMapping_;
131 std::auto_ptr<ESListOfFEDS> productAddress(
new ESListOfFEDS);
133 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);
207 e.
put(productAddress,OutputLabel_);
217 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Egamma" << std::endl;
226 if (EMdoNonIsolated_)
227 e.
getByLabel(EMl1TagNonIsolated_, emNonIsolColl);
235 for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin();
236 emItr != emIsolColl->end() ;++emItr ){
238 float pt = emItr -> pt();
239 if (pt < Ptmin_iso_ )
continue;
240 if (debug_)
std::cout <<
" Here is an L1 isoEM candidate of pt " << pt << std::endl;
242 int etaIndex = emItr->gctEmCand()->etaIndex() ;
243 int phiIndex = emItr->gctEmCand()->phiIndex() ;
245 double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
246 double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
247 double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
248 double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
250 std::vector<int> feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_);
251 for (
int i=0;
i < (int)feds.size();
i++) {
252 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
253 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
261 if (EMdoNonIsolated_) {
263 for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin();
264 emItr != emNonIsolColl->end() ;++emItr ){
266 float pt = emItr -> pt();
267 if (debug_)
std::cout <<
" Here is an L1 nonisoEM candidate of pt " << pt << std::endl;
268 if (pt < Ptmin_noniso_ )
continue;
270 int etaIndex = emItr->gctEmCand()->etaIndex() ;
271 int phiIndex = emItr->gctEmCand()->phiIndex() ;
274 double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
275 double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
276 double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
277 double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
279 std::vector<int> feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_);
280 for (
int i=0;
i < (int)feds.size();
i++) {
281 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
282 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
293 for (
int i=0;
i < (int)FEDs.size();
i++) {
294 std::cout <<
"Egamma: unpack FED " << FEDs[
i] << std::endl;
296 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
309 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Muon" << std::endl;
317 for (L1MuonParticleCollection::const_iterator it=muColl->begin(); it != muColl->end(); it++) {
320 double pt = (*it).pt();
321 double eta = (*it).eta();
322 double phi = (*it).phi();
324 if (debug_)
std::cout <<
" here is a L1 muon Seed with (eta,phi) = " <<
325 eta <<
" " << phi <<
" and pt " << pt << std::endl;
326 if (pt < Ptmin_muon_ )
continue;
328 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, MUregionEtaMargin_, MUregionPhiMargin_);
330 for (
int i=0;
i < (int)feds.size();
i++) {
331 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
332 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
338 for (
int i=0;
i < (int)FEDs.size();
i++) {
339 std::cout <<
"Muons: unpack FED " << FEDs[
i] << std::endl;
341 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
356 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Jets" << std::endl;
363 if (JETSdoCentral_) {
368 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
370 double pt = it -> pt();
374 if (debug_)
std::cout <<
" here is a L1 CentralJet Seed with (eta,phi) = " <<
375 eta <<
" " << phi <<
" and pt " << pt << std::endl;
384 if (pt < Ptmin_jets_ )
continue;
386 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
388 for (
int i=0;
i < (int)feds.size();
i++) {
389 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
390 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
395 if (JETSdoForward_) {
400 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
402 double pt = it -> pt();
406 if (debug_)
std::cout <<
" here is a L1 ForwardJet Seed with (eta,phi) = " <<
407 eta <<
" " << phi <<
" and pt " << pt << std::endl;
408 if (pt < Ptmin_jets_ )
continue;
410 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
412 for (
int i=0;
i < (int)feds.size();
i++) {
413 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
414 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
424 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
426 double pt = it -> pt();
430 if (debug_)
std::cout <<
" here is a L1 TauJet Seed with (eta,phi) = " <<
431 eta <<
" " << phi <<
" and pt " << pt << std::endl;
432 if (pt < Ptmin_jets_ )
continue;
434 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
436 for (
int i=0;
i < (int)feds.size();
i++) {
437 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
438 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
447 for (
int i=0;
i < (int)FEDs.size();
i++) {
448 std::cout <<
"Jets: unpack FED " << FEDs[
i] << std::endl;
450 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
460 double phiHigh,
double etamargin,
double phimargin)
463 std::vector<int>
FEDs;
468 if (debug_)
std::cout <<
" etaLow etaHigh phiLow phiHigh " << etaLow <<
" " <<
469 etaHigh <<
" " << phiLow <<
" " << phiHigh << std::endl;
472 etaHigh += etamargin;
473 double phiMinus = phiLow - phimargin;
474 double phiPlus = phiHigh + phimargin;
477 double dd = fabs(phiPlus-phiMinus);
478 if (debug_)
std::cout <<
" dd = " << dd << std::endl;
479 if (dd > 2.*
Geom::pi() ) all =
true;
482 while (phiMinus < 0) { phiMinus += 2.*
Geom::pi() ; }
485 double dphi = phiPlus - phiMinus;
486 if (dphi < 0) dphi += 2.*
Geom::pi() ;
487 if (debug_)
std::cout <<
"dphi = " << dphi << std::endl;
489 int fed_low1 = TheMapping -> GetFED(etaLow,phiMinus*180./
Geom::pi());
490 int fed_low2 = TheMapping -> GetFED(etaLow,phiPlus*180./
Geom::pi());
491 if (debug_)
std::cout <<
"fed_low1 fed_low2 " << fed_low1 <<
" " << fed_low2 << std::endl;
492 if (fed_low1 == fed_low2) all =
true;
493 int fed_hi1 = TheMapping -> GetFED(etaHigh,phiMinus*180./
Geom::pi());
494 int fed_hi2 = TheMapping -> GetFED(etaHigh,phiPlus*180./
Geom::pi());
495 if (debug_)
std::cout <<
"fed_hi1 fed_hi2 " << fed_hi1 <<
" " << fed_hi2 << std::endl;
496 if (fed_hi1 == fed_hi2) all =
true;
501 if (debug_)
std::cout <<
" unpack everything in phi ! " << std::endl;
506 if (debug_)
std::cout <<
" with margins : " << etaLow <<
" " << etaHigh <<
" " <<
507 phiMinus <<
" " << phiPlus << std::endl;
512 FEDs = TheMapping -> GetListofFEDs(ecalregion);
void getManyByType(std::vector< Handle< PROD > > &results) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void Muon(edm::Event &e, const edm::EventSetup &es, std::vector< int > &done, std::vector< int > &FEDs)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
ESListOfFEDSProducer(const edm::ParameterSet &pset)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void Egamma(edm::Event &e, const edm::EventSetup &es, std::vector< int > &done, std::vector< int > &FEDs)
T const * product() const
void produce(edm::Event &e, const edm::EventSetup &c)
virtual ~ESListOfFEDSProducer()