38 using namespace l1extra;
51 if (EGamma_ && Muon_) {
53 " Wrong configuration : EGamma and Muon should not be true at the same time." ;
94 produces<EcalListOfFEDS>(OutputLabel_);
116 *TheMapping = *TheMapping_;
122 std::vector<int> feds;
127 std::vector< edm::Handle<EcalListOfFEDS> > FEDs_Done;
128 std::vector<int> Done;
130 unsigned int nDone = FEDs_Done.size();
131 if (debug_)
std::cout <<
" ECAL unpacking module has already run " << nDone <<
" times. " << std::endl;
132 for (
unsigned int id=0;
id < nDone;
id++) {
134 if( Pi0ListToIgnore_.label() == FEDs_Done[id].provenance()->moduleLabel() ){
continue;}
135 std::vector<int>
done = FEDs_Done[id]-> GetList();
136 for (
int jd=0; jd < (int)done.size(); jd++) {
140 if (debug_)
std::cout <<
" For this event, " << Done.size() <<
" ECAL FEDs have already been unpacked." << std::endl;
145 Egamma(e, iSetup, Done, feds);
150 Muon(e, iSetup, Done, feds);
155 Jets(e, iSetup, Done, feds);
158 if ( !EGamma_ && !Muon_ && ! Jets_) {
159 for (
int i=1;
i <= 54;
i++) {
160 if (
std::find(Done.begin(), Done.end(),
i) == Done.end())
165 int nf = (int)feds.size();
166 for (
int i=0;
i <nf;
i++) {
168 if (debug_)
std::cout <<
"Will unpack FED " << feds[
i] << std::endl;
171 if (debug_ && nf < 1 )
172 std::cout <<
" Warning : no ECAL FED to unpack for Run " << e.
id().
run() <<
" Event " << e.
id().
event() << std::endl;
175 productAddress.get() -> SetList(feds);
176 e.
put(productAddress,OutputLabel_);
185 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Egamma" << std::endl;
194 if (EMdoNonIsolated_)
195 e.
getByLabel(EMl1TagNonIsolated_, emNonIsolColl);
203 for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin();
204 emItr != emIsolColl->end() ;++emItr ){
206 float pt = emItr -> pt();
207 if (pt < Ptmin_iso_ )
continue;
208 if (debug_)
std::cout <<
" Here is an L1 isoEM candidate of pt " << pt << std::endl;
210 int etaIndex = emItr->gctEmCand()->etaIndex() ;
211 int phiIndex = emItr->gctEmCand()->phiIndex() ;
213 double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
214 double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
215 double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
216 double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
218 std::vector<int> feds = ListOfFEDS(etaLow, etaHigh, phiLow, phiHigh, EMregionEtaMargin_, EMregionPhiMargin_);
219 for (
int i=0;
i < (int)feds.size();
i++) {
220 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
221 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
229 if (EMdoNonIsolated_) {
231 for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin();
232 emItr != emNonIsolColl->end() ;++emItr ){
234 float pt = emItr -> pt();
235 if (debug_)
std::cout <<
" Here is an L1 nonisoEM candidate of pt " << pt << std::endl;
236 if (pt < Ptmin_noniso_ )
continue;
238 int etaIndex = emItr->gctEmCand()->etaIndex() ;
239 int phiIndex = emItr->gctEmCand()->phiIndex() ;
242 double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
243 double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
244 double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
245 double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( 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]);
261 for (
int i=0;
i < (int)FEDs.size();
i++) {
262 std::cout <<
"Egamma: unpack FED " << FEDs[
i] << std::endl;
264 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
277 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Muon" << std::endl;
285 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;
324 if (debug_)
std::cout << std::endl << std::endl <<
" enter in EcalListOfFEDSProducer::Jets" << std::endl;
331 if (JETSdoCentral_) {
336 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
338 double pt = it -> pt();
342 if (debug_)
std::cout <<
" here is a L1 CentralJet Seed with (eta,phi) = " <<
343 eta <<
" " << phi <<
" and pt " << pt << std::endl;
352 if (pt < Ptmin_jets_ )
continue;
354 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
356 for (
int i=0;
i < (int)feds.size();
i++) {
357 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
358 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
363 if (JETSdoForward_) {
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 ForwardJet Seed with (eta,phi) = " <<
375 eta <<
" " << phi <<
" and pt " << pt << std::endl;
376 if (pt < Ptmin_jets_ )
continue;
378 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
380 for (
int i=0;
i < (int)feds.size();
i++) {
381 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
382 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
392 for (L1JetParticleCollection::const_iterator it=jetColl->begin(); it != jetColl->end(); it++) {
394 double pt = it -> pt();
398 if (debug_)
std::cout <<
" here is a L1 TauJet Seed with (eta,phi) = " <<
399 eta <<
" " << phi <<
" and pt " << pt << std::endl;
400 if (pt < Ptmin_jets_ )
continue;
402 std::vector<int> feds = ListOfFEDS(eta, eta, phi-epsilon, phi+epsilon, JETSregionEtaMargin_, JETSregionPhiMargin_);
404 for (
int i=0;
i < (int)feds.size();
i++) {
405 if (
std::find(FEDs.begin(), FEDs.end(), feds[
i]) == FEDs.end() &&
406 std::find(done.begin(), done.end(), feds[
i]) == done.end() ) FEDs.push_back(feds[
i]);
415 for (
int i=0;
i < (int)FEDs.size();
i++) {
416 std::cout <<
"Jets: unpack FED " << FEDs[
i] << std::endl;
418 std::cout <<
"Number of FEDS is " << FEDs.size() << std::endl;
428 double phiHigh,
double etamargin,
double phimargin)
431 std::vector<int>
FEDs;
436 if (debug_)
std::cout <<
" etaLow etaHigh phiLow phiHigh " << etaLow <<
" " <<
437 etaHigh <<
" " << phiLow <<
" " << phiHigh << std::endl;
440 etaHigh += etamargin;
441 double phiMinus = phiLow - phimargin;
442 double phiPlus = phiHigh + phimargin;
445 double dd = fabs(phiPlus-phiMinus);
446 if (debug_)
std::cout <<
" dd = " << dd << std::endl;
447 if (dd > 2.*
Geom::pi() ) all =
true;
450 while (phiMinus < 0) { phiMinus += 2.*
Geom::pi() ; }
453 double dphi = phiPlus - phiMinus;
454 if (dphi < 0) dphi += 2.*
Geom::pi() ;
455 if (debug_)
std::cout <<
"dphi = " << dphi << std::endl;
457 int fed_low1 = TheMapping -> GetFED(etaLow,phiMinus*180./
Geom::pi());
458 int fed_low2 = TheMapping -> GetFED(etaLow,phiPlus*180./
Geom::pi());
459 if (debug_)
std::cout <<
"fed_low1 fed_low2 " << fed_low1 <<
" " << fed_low2 << std::endl;
460 if (fed_low1 == fed_low2) all =
true;
461 int fed_hi1 = TheMapping -> GetFED(etaHigh,phiMinus*180./
Geom::pi());
462 int fed_hi2 = TheMapping -> GetFED(etaHigh,phiPlus*180./
Geom::pi());
463 if (debug_)
std::cout <<
"fed_hi1 fed_hi2 " << fed_hi1 <<
" " << fed_hi2 << std::endl;
464 if (fed_hi1 == fed_hi2) all =
true;
469 if (debug_)
std::cout <<
" unpack everything in phi ! " << std::endl;
474 if (debug_)
std::cout <<
" with margins : " << etaLow <<
" " << etaHigh <<
" " <<
475 phiMinus <<
" " << phiPlus << std::endl;
480 FEDs = TheMapping -> GetListofFEDs(ecalregion);
void getManyByType(std::vector< Handle< PROD > > &results) const
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void produce(edm::Event &e, const edm::EventSetup &c)
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)
void Egamma(edm::Event &e, const edm::EventSetup &es, std::vector< int > &done, std::vector< int > &FEDs)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual ~EcalListOfFEDSProducer()
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void Jets(edm::Event &e, const edm::EventSetup &es, std::vector< int > &done, std::vector< int > &FEDs)
EcalListOfFEDSProducer(const edm::ParameterSet &pset)
T const * product() const
std::vector< int > ListOfFEDS(double etaLow, double etaHigh, double phiLow, double phiHigh, double etamargin, double phimargin)