diff --git a/Calibration/EcalAlCaRecoProducers/src/SelectedElectronFEDListProducer.cc b/Calibration/EcalAlCaRecoProducers/src/SelectedElectronFEDListProducer.cc index a168a05fd3199..2265ef6edd488 100644 --- a/Calibration/EcalAlCaRecoProducers/src/SelectedElectronFEDListProducer.cc +++ b/Calibration/EcalAlCaRecoProducers/src/SelectedElectronFEDListProducer.cc @@ -7,190 +7,190 @@ template< typename TEle, typename TCand> SelectedElectronFEDListProducer::SelectedElectronFEDListProducer(const edm::ParameterSet & iConfig){ - // input electron collection Tag - if(iConfig.existsAs >("electronTags")){ - electronTags_ = iConfig.getParameter>("electronTags"); - if(electronTags_.empty()) + // input electron collection Tag + if(iConfig.existsAs >("electronTags")){ + electronTags_ = iConfig.getParameter>("electronTags"); + if(electronTags_.empty()) throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] empty electron collection is given --> at least one \n"; - } - else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron collection are given --> need at least one \n"; - - // Consumes for the electron collection - LogDebug("SelectedElectronFEDListProducer")<<" Electron Collections"<::const_iterator itEleTag = electronTags_.begin(); itEleTag != electronTags_.end(); ++itEleTag){ - electronToken_.push_back(consumes(*itEleTag)); - LogDebug("SelectedElectronFEDListProducer")<<" Ele collection: "<<*(itEleTag)< >("recoEcalCandidateTags")){ - recoEcalCandidateTags_ = iConfig.getParameter>("recoEcalCandidateTags"); - if(recoEcalCandidateTags_.empty()) + } + else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron collection are given --> need at least one \n"; + + // Consumes for the electron collection + LogDebug("SelectedElectronFEDListProducer")<<" Electron Collections"<::const_iterator itEleTag = electronTags_.begin(); itEleTag != electronTags_.end(); ++itEleTag){ + electronToken_.push_back(consumes(*itEleTag)); + LogDebug("SelectedElectronFEDListProducer")<<" Ele collection: "<<*(itEleTag)< >("recoEcalCandidateTags")){ + recoEcalCandidateTags_ = iConfig.getParameter>("recoEcalCandidateTags"); + if(recoEcalCandidateTags_.empty()) throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] empty ecal candidate collections collection is given --> at least one \n"; - } - else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron reco ecal candidate collection are given --> need at least one \n"; - - // Consumes for the recoEcal candidate collection - for( std::vector::const_iterator itEcalCandTag = recoEcalCandidateTags_.begin(); itEcalCandTag != recoEcalCandidateTags_.end(); ++itEcalCandTag){ + } + else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron reco ecal candidate collection are given --> need at least one \n"; + + // Consumes for the recoEcal candidate collection + for( std::vector::const_iterator itEcalCandTag = recoEcalCandidateTags_.begin(); itEcalCandTag != recoEcalCandidateTags_.end(); ++itEcalCandTag){ recoEcalCandidateToken_.push_back(consumes(*itEcalCandTag)); LogDebug("SelectedElectronFEDListProducer")<<" Reco ecal candidate collection: "<<*(itEcalCandTag)<>("isGsfElectronCollection")){ + } + + // list of gsf collections + if(iConfig.existsAs>("isGsfElectronCollection")){ isGsfElectronCollection_ = iConfig.getParameter>("isGsfElectronCollection"); if(isGsfElectronCollection_.empty()) throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] empty electron flag collection --> at least one \n"; - } - else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron flag are given --> need at least one \n"; - - if(isGsfElectronCollection_.size() < electronTags_.size()) - throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] electron flag < electron collection --> need at equal number to understand which are Gsf and which not \n"; - - // take the beam spot Tag - if(iConfig.existsAs("beamSpot")) - beamSpotTag_ = iConfig.getParameter("beamSpot"); - else beamSpotTag_ = edm::InputTag("hltOnlineBeamSpot"); - - if(!(beamSpotTag_ == edm::InputTag(""))) beamSpotToken_ = consumes(beamSpotTag_); - - LogDebug("SelectedElectronFEDListProducer")<<" Beam Spot Tag "<("HBHERecHitTag")) - HBHERecHitTag_ = iConfig.getParameter("HBHERecHitTag"); - else HBHERecHitTag_ = edm::InputTag("hltHbhereco"); - - if(!(HBHERecHitTag_ == edm::InputTag(""))) hbheRecHitToken_ = consumes(HBHERecHitTag_); - - // raw data collector label - if(iConfig.existsAs("rawDataTag")) - rawDataTag_ = iConfig.getParameter("rawDataTag"); - else rawDataTag_ = edm::InputTag("rawDataCollector") ; - - if(!(rawDataTag_ == edm::InputTag(""))) rawDataToken_ = consumes(rawDataTag_); - - LogDebug("SelectedElectronFEDListProducer")<<" RawDataInput "< need at least one \n"; + + if(isGsfElectronCollection_.size() != electronTags_.size() or isGsfElectronCollection_.size() != recoEcalCandidateTags_.size()) + throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] electron flag , electron collection and reco ecal cand collection must have the same size ! \n"; + + // take the beam spot Tag + if(iConfig.existsAs("beamSpot")) + beamSpotTag_ = iConfig.getParameter("beamSpot"); + else beamSpotTag_ = edm::InputTag("hltOnlineBeamSpot"); + + if(!(beamSpotTag_ == edm::InputTag(""))) beamSpotToken_ = consumes(beamSpotTag_); + + LogDebug("SelectedElectronFEDListProducer")<<" Beam Spot Tag "<("HBHERecHitTag")) + HBHERecHitTag_ = iConfig.getParameter("HBHERecHitTag"); + else HBHERecHitTag_ = edm::InputTag("hltHbhereco"); + + if(!(HBHERecHitTag_ == edm::InputTag(""))) hbheRecHitToken_ = consumes(HBHERecHitTag_); + + // raw data collector label + if(iConfig.existsAs("rawDataTag")) + rawDataTag_ = iConfig.getParameter("rawDataTag"); + else rawDataTag_ = edm::InputTag("rawDataCollector") ; + + if(!(rawDataTag_ == edm::InputTag(""))) rawDataToken_ = consumes(rawDataTag_); + + LogDebug("SelectedElectronFEDListProducer")<<" RawDataInput "<>("addThisSelectedFEDs")){ + // add a set of selected feds + if(iConfig.existsAs>("addThisSelectedFEDs")){ addThisSelectedFEDs_ = iConfig.getParameter>("addThisSelectedFEDs"); if(addThisSelectedFEDs_.empty()) addThisSelectedFEDs_.push_back(-1); - } - else addThisSelectedFEDs_.push_back(-1); - - std::vector::const_iterator AddFed = addThisSelectedFEDs_.begin(); - for( ; AddFed !=addThisSelectedFEDs_.end() ; ++AddFed) - LogDebug("SelectedElectronFEDListProducer")<<" Additional FED: "<<*(AddFed)<::const_iterator AddFed = addThisSelectedFEDs_.begin(); + for( ; AddFed !=addThisSelectedFEDs_.end() ; ++AddFed) + LogDebug("SelectedElectronFEDListProducer")<<" Additional FED: "<<*(AddFed)<("ESLookupTable")) - ESLookupTable_ = iConfig.getParameter("ESLookupTable"); - else ESLookupTable_ = edm::FileInPath("EventFilter/ESDigiToRaw/data/ES_lookup_table.dat"); - - // output model label - if(iConfig.existsAs("outputLabelModule")) - outputLabelModule_ = iConfig.getParameter("outputLabelModule"); - else outputLabelModule_ = "streamElectronRawData" ; - - LogDebug("SelectedElectronFEDListProducer")<<" Output Label "<("dRStripRegion")) + if(iConfig.existsAs("ESLookupTable")) + ESLookupTable_ = iConfig.getParameter("ESLookupTable"); + else ESLookupTable_ = edm::FileInPath("EventFilter/ESDigiToRaw/data/ES_lookup_table.dat"); + + // output model label + if(iConfig.existsAs("outputLabelModule")) + outputLabelModule_ = iConfig.getParameter("outputLabelModule"); + else outputLabelModule_ = "streamElectronRawData" ; + + LogDebug("SelectedElectronFEDListProducer")<<" Output Label "<("dRStripRegion")) dRStripRegion_ = iConfig.getParameter("dRStripRegion"); - else dRStripRegion_ = 0.5 ; - - LogDebug("SelectedElectronFEDListProducer")<<" dRStripRegion "<("dRHcalRegion")) - dRHcalRegion_ = iConfig.getParameter("dRHcalRegion"); - else dRHcalRegion_ = 0.5 ; - + else dRStripRegion_ = 0.5 ; + + LogDebug("SelectedElectronFEDListProducer")<<" dRStripRegion "<("dRHcalRegion")) + dRHcalRegion_ = iConfig.getParameter("dRHcalRegion"); + else dRHcalRegion_ = 0.5 ; + // dPhi, dEta and maxZ for pixel dump - if(iConfig.existsAs("dPhiPixelRegion")) - dPhiPixelRegion_ = iConfig.getParameter("dPhiPixelRegion"); - else dPhiPixelRegion_ = 0.5 ; - - if(iConfig.existsAs("dEtaPixelRegion")) - dEtaPixelRegion_ = iConfig.getParameter("dEtaPixelRegion"); - else dEtaPixelRegion_ = 0.5 ; - - if(iConfig.existsAs("maxZPixelRegion")) - maxZPixelRegion_ = iConfig.getParameter("maxZPixelRegion"); - else maxZPixelRegion_ = 24. ; - - LogDebug("SelectedElectronFEDListProducer")<<" dPhiPixelRegion "<("dumpSelectedEcalFed")) - dumpSelectedEcalFed_ = iConfig.getParameter< bool >("dumpSelectedEcalFed"); - else dumpSelectedEcalFed_ = true ; - - if(iConfig.existsAs("dumpSelectedSiStripFed")) - dumpSelectedSiStripFed_ = iConfig.getParameter("dumpSelectedSiStripFed"); - else dumpSelectedSiStripFed_ = true ; - - if(iConfig.existsAs("dumpSelectedSiPixelFed")) + if(iConfig.existsAs("dPhiPixelRegion")) + dPhiPixelRegion_ = iConfig.getParameter("dPhiPixelRegion"); + else dPhiPixelRegion_ = 0.5 ; + + if(iConfig.existsAs("dEtaPixelRegion")) + dEtaPixelRegion_ = iConfig.getParameter("dEtaPixelRegion"); + else dEtaPixelRegion_ = 0.5 ; + + if(iConfig.existsAs("maxZPixelRegion")) + maxZPixelRegion_ = iConfig.getParameter("maxZPixelRegion"); + else maxZPixelRegion_ = 24. ; + + LogDebug("SelectedElectronFEDListProducer")<<" dPhiPixelRegion "<("dumpSelectedEcalFed")) + dumpSelectedEcalFed_ = iConfig.getParameter< bool >("dumpSelectedEcalFed"); + else dumpSelectedEcalFed_ = true ; + + if(iConfig.existsAs("dumpSelectedSiStripFed")) + dumpSelectedSiStripFed_ = iConfig.getParameter("dumpSelectedSiStripFed"); + else dumpSelectedSiStripFed_ = true ; + + if(iConfig.existsAs("dumpSelectedSiPixelFed")) dumpSelectedSiPixelFed_ = iConfig.getParameter("dumpSelectedSiPixelFed"); - else dumpSelectedSiPixelFed_ = true ; - - if(iConfig.existsAs("dumpSelectedHCALFed")) + else dumpSelectedSiPixelFed_ = true ; + + if(iConfig.existsAs("dumpSelectedHCALFed")) dumpSelectedHCALFed_ = iConfig.getParameter("dumpSelectedHCALFed"); - else dumpSelectedHCALFed_ = true ; - - LogDebug("SelectedElectronFEDListProducer")<<" DumpEcalFedList set to "<("dumpAllEcalFed")) - dumpAllEcalFed_ = iConfig.getParameter("dumpAllEcalFed"); - else dumpAllEcalFed_ = false ; - - if(iConfig.existsAs("dumpAllTrackerFed")) - dumpAllTrackerFed_ = iConfig.getParameter("dumpAllTrackerFed"); - else dumpAllTrackerFed_ = false ; - - if(iConfig.existsAs("dumpAllHCALFed")) - dumpAllHCALFed_ = iConfig.getParameter("dumpAllHCALFed"); - else dumpAllHCALFed_ = false ; - - LogDebug("SelectedElectronFEDListProducer")<<" DumpAllEcalFed "<("dumpAllEcalFed")) + dumpAllEcalFed_ = iConfig.getParameter("dumpAllEcalFed"); + else dumpAllEcalFed_ = false ; + if(iConfig.existsAs("dumpAllTrackerFed")) + dumpAllTrackerFed_ = iConfig.getParameter("dumpAllTrackerFed"); + else dumpAllTrackerFed_ = false ; + + if(iConfig.existsAs("dumpAllHCALFed")) + dumpAllHCALFed_ = iConfig.getParameter("dumpAllHCALFed"); + else dumpAllHCALFed_ = false ; - // initialize pre-shower fed id --> look up table - for (int i=0; i<2; ++i) for (int j=0; j<2; ++j) for (int k=0 ;k<40; ++k) for (int m=0; m<40; m++) ES_fedId_[i][j][k][m] = -1; + LogDebug("SelectedElectronFEDListProducer")<<" DumpAllEcalFed "< look up table + for (int i=0; i<2; ++i) for (int j=0; j<2; ++j) for (int k=0 ;k<40; ++k) for (int m=0; m<40; m++) ES_fedId_[i][j][k][m] = -1; - // read in look-up table - int nLines, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx; - std::ifstream ES_file; - ES_file.open(ESLookupTable_.fullPath().c_str()); - LogDebug("SelectedElectronFEDListProducer")<<" Look Up table for ES "<> nLines; - for (int i=0; i> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx ; - ES_fedId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = fed; + // read in look-up table + int nLines, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx; + std::ifstream ES_file; + ES_file.open(ESLookupTable_.fullPath().c_str()); + LogDebug("SelectedElectronFEDListProducer")<<" Look Up table for ES "<> nLines; + for (int i=0; i> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx ; + ES_fedId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = fed; } - } - else LogDebug("SelectedElectronFEDListProducer")<<" Look up table file can not be found in "<(outputLabelModule_); // produce exit collection + } + else LogDebug("SelectedElectronFEDListProducer")<<" Look up table file can not be found in "<(outputLabelModule_); // produce exit collection } template< typename TEle, typename TCand> SelectedElectronFEDListProducer::~SelectedElectronFEDListProducer(){ - - if(!electronTags_.empty()) electronTags_.clear() ; - if(!recoEcalCandidateTags_.empty()) recoEcalCandidateTags_.clear() ; - if(!recoEcalCandidateToken_.empty()) recoEcalCandidateToken_.clear(); - if(!electronToken_.empty()) electronToken_.clear(); - if(!fedList_.empty()) fedList_.clear() ; - if(!RawDataCollection_) delete RawDataCollection_ ; + + if(!electronTags_.empty()) electronTags_.clear() ; + if(!recoEcalCandidateTags_.empty()) recoEcalCandidateTags_.clear() ; + if(!recoEcalCandidateToken_.empty()) recoEcalCandidateToken_.clear(); + if(!electronToken_.empty()) electronToken_.clear(); + if(!fedList_.empty()) fedList_.clear() ; + if(!RawDataCollection_) delete RawDataCollection_ ; } template< typename TEle, typename TCand> @@ -209,71 +209,71 @@ void SelectedElectronFEDListProducer::produce(edm::Event & iEvent, c // Retrieve FED ids from cabling map and iterate through if(eventCounter_ ==0 ){ - - // get the hcal electronics map - edm::ESHandle pSetup; - iSetup.get().get(pSetup); - hcalReadoutMap_ = pSetup->getHcalMapping(); - - // get the ecal electronics map - edm::ESHandle ecalmapping; - iSetup.get().get(ecalmapping); - TheMapping_ = ecalmapping.product(); - - // get the calo geometry - edm::ESHandle caloGeometry; - iSetup.get().get(caloGeometry); - geometry_ = caloGeometry.product(); - - //ES geometry - geometryES_ = caloGeometry->getSubdetectorGeometry(DetId::Ecal,EcalPreshower); - - // pixel tracker cabling map - edm::ESTransientHandle pixelCablingMap; - iSetup.get().get(pixelCablingMap); - - PixelCabling_.reset(); - PixelCabling_ = pixelCablingMap->cablingTree(); - - edm::ESHandle trackerGeometry; - iSetup.get().get( trackerGeometry ); - - if(!pixelModuleVector_.empty()) pixelModuleVector_.clear(); - - // build the tracker pixel module map - std::vector::const_iterator itTracker = trackerGeometry->dets().begin(); - for( ; itTracker !=trackerGeometry->dets().end() ; ++itTracker){ - int subdet = (*itTracker)->geographicalId().subdetId(); - if(! (subdet == PixelSubdetector::PixelBarrel || subdet == PixelSubdetector::PixelEndcap) ) continue; - PixelModule module ; - module.x = (*itTracker)->position().x(); - module.y = (*itTracker)->position().y(); - module.z = (*itTracker)->position().z(); - module.Phi = normalizedPhi((*itTracker)->position().phi()) ; - module.Eta = (*itTracker)->position().eta() ; - module.DetId = (*itTracker)->geographicalId().rawId(); - const std::vector path2det = PixelCabling_->pathToDetUnit(module.DetId); - module.Fed = path2det[0].fed; - assert(module.Fed<40); - pixelModuleVector_.push_back(module); - } - std::sort(pixelModuleVector_.begin(),pixelModuleVector_.end()); - - edm::ESHandle SiStripCabling ; - iSetup.get().get(SiStripCabling); - StripRegionCabling_ = SiStripCabling.product(); + // get the hcal electronics map + edm::ESHandle pSetup; + iSetup.get().get(pSetup); + hcalReadoutMap_ = pSetup->getHcalMapping(); + + + // get the ecal electronics map + edm::ESHandle ecalmapping; + iSetup.get().get(ecalmapping); + TheMapping_ = ecalmapping.product(); + + // get the calo geometry + edm::ESHandle caloGeometry; + iSetup.get().get(caloGeometry); + geometry_ = caloGeometry.product(); + + //ES geometry + geometryES_ = caloGeometry->getSubdetectorGeometry(DetId::Ecal,EcalPreshower); + + // pixel tracker cabling map + edm::ESTransientHandle pixelCablingMap; + iSetup.get().get(pixelCablingMap); + + PixelCabling_.reset(); + PixelCabling_ = pixelCablingMap->cablingTree(); + + edm::ESHandle trackerGeometry; + iSetup.get().get( trackerGeometry ); + + if(!pixelModuleVector_.empty()) pixelModuleVector_.clear(); + + // build the tracker pixel module map + std::vector::const_iterator itTracker = trackerGeometry->dets().begin(); + for( ; itTracker !=trackerGeometry->dets().end() ; ++itTracker){ + int subdet = (*itTracker)->geographicalId().subdetId(); + if(! (subdet == PixelSubdetector::PixelBarrel || subdet == PixelSubdetector::PixelEndcap) ) continue; + PixelModule module ; + module.x = (*itTracker)->position().x(); + module.y = (*itTracker)->position().y(); + module.z = (*itTracker)->position().z(); + module.Phi = normalizedPhi((*itTracker)->position().phi()) ; + module.Eta = (*itTracker)->position().eta() ; + module.DetId = (*itTracker)->geographicalId().rawId(); + const std::vector path2det = PixelCabling_->pathToDetUnit(module.DetId); + module.Fed = path2det[0].fed; + assert(module.Fed<40); + pixelModuleVector_.push_back(module); + } + std::sort(pixelModuleVector_.begin(),pixelModuleVector_.end()); - cabling_ = StripRegionCabling_->getRegionCabling(); - regionDimension_ = StripRegionCabling_->regionDimensions(); + edm::ESHandle SiStripCabling ; + iSetup.get().get(SiStripCabling); + StripRegionCabling_ = SiStripCabling.product(); + + cabling_ = StripRegionCabling_->getRegionCabling(); + regionDimension_ = StripRegionCabling_->regionDimensions(); } // event by event analysis - + // Get event raw data edm::Handle rawdata; if(!(rawDataTag_ == edm::InputTag(""))) iEvent.getByToken(rawDataToken_,rawdata); - + // take the beam spot position edm::Handle beamSpot; if(!(beamSpotTag_ == edm::InputTag(""))) iEvent.getByToken(beamSpotToken_, beamSpot); @@ -317,227 +317,232 @@ void SelectedElectronFEDListProducer::produce(edm::Event & iEvent, c // iterator to electron and ecal candidate collections typename std::vector >::const_iterator itElectronColl = electronToken_.begin(); - std::vector::const_iterator itElectronCollFlag = isGsfElectronCollection_.begin(); + std::vector::const_iterator itElectronCollFlag = isGsfElectronCollection_.begin(); std::vector >::const_iterator itRecoEcalCandColl = recoEcalCandidateToken_.begin(); // if you want to dump just FED related to the triggering electron/s if( !dumpAllTrackerFed_ || !dumpAllEcalFed_ ){ - for( ; itRecoEcalCandColl != recoEcalCandidateToken_.end(); ++itRecoEcalCandColl){ - try { iEvent.getByToken(*itRecoEcalCandColl,triggerRecoEcalCandidateCollection); - if(triggerRecoEcalCandidateCollection.failedToGet()) continue ; - } - catch (cms::Exception &exception){ continue; } - - triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerCluster, recoEcalCandColl); - if(recoEcalCandColl.empty()) triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerPhoton, recoEcalCandColl); - if(recoEcalCandColl.empty()) triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerElectron, recoEcalCandColl); + // loop on the same time on ecal candidate and elctron collection and boolean for Gsf ones + for( ; itRecoEcalCandColl != recoEcalCandidateToken_.end() and itElectronColl != electronToken_.end() and itElectronCollFlag != isGsfElectronCollection_.end(); + ++itElectronColl , ++itElectronCollFlag, ++itRecoEcalCandColl){ - typename std::vector>::const_iterator itRecoEcalCand = recoEcalCandColl.begin(); // loop on recoEcalCandidate objects - - for( ; itRecoEcalCand != recoEcalCandColl.end() ; ++itRecoEcalCand){ - recoEcalCand = (*itRecoEcalCand); - reco::SuperClusterRef scRefRecoEcalCand = recoEcalCand->superCluster(); // take the supercluster in order to match with electron objects - - for( ; itElectronColl != electronToken_.end() && itElectronCollFlag != isGsfElectronCollection_.end(); ++itElectronColl , ++itElectronCollFlag){ // loop on electron collections - try { iEvent.getByToken(*itElectronColl,electrons); - if(electrons.failedToGet()) continue ; - } - catch (cms::Exception &exception){ continue; } + // get ecal candidate collection + try { iEvent.getByToken(*itRecoEcalCandColl,triggerRecoEcalCandidateCollection); + if(triggerRecoEcalCandidateCollection.failedToGet()) continue ; + } + catch (cms::Exception &exception){ continue; } + + // get gsf electron collection + try { iEvent.getByToken(*itElectronColl,electrons); + if(electrons.failedToGet()) continue ; + } + catch (cms::Exception &exception){ continue; } + + triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerCluster, recoEcalCandColl); + if(recoEcalCandColl.empty()) triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerPhoton, recoEcalCandColl); + if(recoEcalCandColl.empty()) triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerElectron, recoEcalCandColl); + + typename std::vector>::const_iterator itRecoEcalCand = recoEcalCandColl.begin(); // loop on recoEcalCandidate objects + // loop on the recoEcalCandidates + for( ; itRecoEcalCand != recoEcalCandColl.end() ; ++itRecoEcalCand){ + recoEcalCand = (*itRecoEcalCand); + reco::SuperClusterRef scRefRecoEcalCand = recoEcalCand->superCluster(); // take the supercluster in order to match with electron objects + typename TEleColl::const_iterator itEle = electrons->begin(); for( ; itEle!=electrons->end() ; ++itEle){ // loop on all the electrons inside a collection - // get electron supercluster and the associated hit -> detID - electron = (*itEle); - reco::SuperClusterRef scRef = electron.superCluster(); - if ( scRefRecoEcalCand != scRef ) continue ; // mathching + // get electron supercluster and the associated hit -> detID + electron = (*itEle); + reco::SuperClusterRef scRef = electron.superCluster(); + if ( scRefRecoEcalCand != scRef ) continue ; // mathching - const std::vector >& hits = scRef->hitsAndFractions(); - // start in dump the ecal FED associated to the electron - std::vector >::const_iterator itSChits = hits.begin(); - if(!dumpAllEcalFed_){ - for( ; itSChits!=hits.end() ; ++itSChits){ - if((*itSChits).first.subdetId()== EcalBarrel){ // barrel part - EBDetId idEBRaw ((*itSChits).first); - GlobalPoint point = geometry_->getPosition(idEBRaw); - int hitFED = FEDNumbering::MINECALFEDID + TheMapping_->GetFED(double(point.eta()),double(point.phi())*radTodeg); - if( hitFED < FEDNumbering::MINECALFEDID || hitFED > FEDNumbering::MAXECALFEDID ) continue; - - LogDebug("SelectedElectronFEDListProducer")<<" electron hit detID Barrel "<<(*itSChits).first.rawId()<<" eta "<getPosition(idEERaw); - int hitFED = FEDNumbering::MINECALFEDID + TheMapping_->GetFED(double(point.eta()),double(point.phi())*radTodeg); - if( hitFED < FEDNumbering::MINECALFEDID || hitFED > FEDNumbering::MAXECALFEDID ) continue; - - LogDebug("SelectedElectronFEDListProducer")<<" electron hit detID Endcap "<<(*itSChits).first.rawId()<<" eta "<(geometryES_))->getClosestCellInPlane(point,1); - ESDetId stripX = (tmpX == DetId(0)) ? ESDetId(0) : ESDetId(tmpX); - int hitFED = ES_fedId_[(3-stripX.zside())/2-1][stripX.plane()-1][stripX.six()-1][stripX.siy()-1]; - LogDebug("SelectedElectronFEDListProducer")<<" ES hit plane X (deiID) "< FEDNumbering::MAXPreShowerFEDID) continue; - if(hitFED < 0) continue; - if(!fedList_.empty()){ - if(std::find(fedList_.begin(),fedList_.end(),hitFED)==fedList_.end()) fedList_.push_back(hitFED); - } - else fedList_.push_back(hitFED); - - DetId tmpY = (dynamic_cast(geometryES_))->getClosestCellInPlane(point,2); - ESDetId stripY = (tmpY == DetId(0)) ? ESDetId(0) : ESDetId(tmpY); - hitFED = ES_fedId_[(3-stripY.zside())/2-1][stripY.plane()-1][stripY.six()-1][stripY.siy()-1]; - if(hitFED < FEDNumbering::MINPreShowerFEDID || hitFED > FEDNumbering::MAXPreShowerFEDID) continue; - LogDebug("SelectedElectronFEDListProducer")<<" ES hit plane Y (deiID) "< >& hits = scRef->hitsAndFractions(); + // start in dump the ecal FED associated to the electron + std::vector >::const_iterator itSChits = hits.begin(); + if(!dumpAllEcalFed_){ + for( ; itSChits!=hits.end() ; ++itSChits){ + if((*itSChits).first.subdetId()== EcalBarrel){ // barrel part + EBDetId idEBRaw ((*itSChits).first); + GlobalPoint point = geometry_->getPosition(idEBRaw); + int hitFED = FEDNumbering::MINECALFEDID + TheMapping_->GetFED(double(point.eta()),double(point.phi())*radTodeg); + if( hitFED < FEDNumbering::MINECALFEDID || hitFED > FEDNumbering::MAXECALFEDID ) continue; + + LogDebug("SelectedElectronFEDListProducer")<<" electron hit detID Barrel "<<(*itSChits).first.rawId()<<" eta "<begin(); - for( ; itHcalRecHit != hcalRecHitCollection->end() ; ++itHcalRecHit) { - HcalDetId recHitId(itHcalRecHit->id()); - const CaloCellGeometry* cellGeometry = geometry_->getSubdetectorGeometry(recHitId)->getGeometry(recHitId); - float dR = reco::deltaR(scRef->eta(),scRef->phi(),cellGeometry->getPosition().eta(),cellGeometry->getPosition().phi()); - if(dR <= dRHcalRegion_) { - const HcalElectronicsId electronicId = hcalReadoutMap_->lookup(recHitId); - int hitFED = electronicId.dccid() + FEDNumbering::MINHCALFEDID; - LogDebug("SelectedElectronFEDListProducer")<< " matched hcal recHit : HcalDetId "< FEDNumbering::MAXHCALFEDID) - continue; //first eighteen feds are for HBHE - if(hitFED < 0) - continue; - if(!fedList_.empty()) { - if(std::find(fedList_.begin(), fedList_.end(), hitFED) == fedList_.end()) - fedList_.push_back(hitFED); - } - else - fedList_.push_back(hitFED); - } - } - } // End Hcal - }// End Ecal - - // get the electron track - if( !dumpAllTrackerFed_ ){ - //loop on the region - if(dumpSelectedSiStripFed_){ - double eta ; - double phi ; - if(*itElectronCollFlag){ - eta = electron.gsfTrack()->eta(); - phi = electron.gsfTrack()->phi(); - } - else{ - eta = electron.track()->eta(); - phi = electron.track()->phi(); - } - for(uint32_t iCabling = 0; iCabling < cabling_.size(); iCabling++){ - SiStripRegionCabling::Position pos = StripRegionCabling_->position(iCabling); - double dphi=fabs(pos.second-phi); - if (dphi>acos(-1)) dphi=2*acos(-1)-dphi; - double R = sqrt(pow(pos.first-eta,2)+dphi*dphi); - if (R-sqrt(pow(regionDimension_.first/2,2)+pow(regionDimension_.second/2,2))>dRStripRegion_) continue; - //get vector of subdets within region - const SiStripRegionCabling::RegionCabling regSubdets = cabling_[iCabling]; - //cycle on subdets - for (uint32_t idet=0; idetsecond).size(); op++){ - int hitFED = (itFedMap->second)[op].fedId(); - if(hitFED < FEDNumbering::MINSiStripFEDID || hitFED > FEDNumbering::MAXSiStripFEDID) continue; - LogDebug("SelectedElectronFEDListProducer")<<" SiStrip (FedID) "<getPosition(idEERaw); + int hitFED = FEDNumbering::MINECALFEDID + TheMapping_->GetFED(double(point.eta()),double(point.phi())*radTodeg); + if( hitFED < FEDNumbering::MINECALFEDID || hitFED > FEDNumbering::MAXECALFEDID ) continue; + + LogDebug("SelectedElectronFEDListProducer")<<" electron hit detID Endcap "<<(*itSChits).first.rawId()<<" eta "<(geometryES_))->getClosestCellInPlane(point,1); + ESDetId stripX = (tmpX == DetId(0)) ? ESDetId(0) : ESDetId(tmpX); + int hitFED = ES_fedId_[(3-stripX.zside())/2-1][stripX.plane()-1][stripX.six()-1][stripX.siy()-1]; + LogDebug("SelectedElectronFEDListProducer")<<" ES hit plane X (deiID) "< FEDNumbering::MAXPreShowerFEDID) continue; + if(hitFED < 0) continue; + if(!fedList_.empty()){ + if(std::find(fedList_.begin(),fedList_.end(),hitFED)==fedList_.end()) fedList_.push_back(hitFED); + } + else fedList_.push_back(hitFED); + + DetId tmpY = (dynamic_cast(geometryES_))->getClosestCellInPlane(point,2); + ESDetId stripY = (tmpY == DetId(0)) ? ESDetId(0) : ESDetId(tmpY); + hitFED = ES_fedId_[(3-stripY.zside())/2-1][stripY.plane()-1][stripY.six()-1][stripY.siy()-1]; + if(hitFED < FEDNumbering::MINPreShowerFEDID || hitFED > FEDNumbering::MAXPreShowerFEDID) continue; + LogDebug("SelectedElectronFEDListProducer")<<" ES hit plane Y (deiID) "<begin(); + for( ; itHcalRecHit != hcalRecHitCollection->end() ; ++itHcalRecHit) { + HcalDetId recHitId(itHcalRecHit->id()); + const CaloCellGeometry* cellGeometry = geometry_->getSubdetectorGeometry(recHitId)->getGeometry(recHitId); + float dR = reco::deltaR(scRef->eta(),scRef->phi(),cellGeometry->getPosition().eta(),cellGeometry->getPosition().phi()); + if(dR <= dRHcalRegion_) { + const HcalElectronicsId electronicId = hcalReadoutMap_->lookup(recHitId); + int hitFED = electronicId.dccid() + FEDNumbering::MINHCALFEDID; + LogDebug("SelectedElectronFEDListProducer")<< " matched hcal recHit : HcalDetId "< FEDNumbering::MAXHCALFEDID) + continue; //first eighteen feds are for HBHE + if(hitFED < 0) + continue; + if(!fedList_.empty()) { + if(std::find(fedList_.begin(), fedList_.end(), hitFED) == fedList_.end()) + fedList_.push_back(hitFED); + } + else + fedList_.push_back(hitFED); + } + } + } // End Hcal + }// End Ecal + + // get the electron track + if( !dumpAllTrackerFed_ ){ + //loop on the region + if(dumpSelectedSiStripFed_){ + double eta ; + double phi ; + if(*itElectronCollFlag){ + eta = electron.gsfTrack()->eta(); + phi = electron.gsfTrack()->phi(); + } + else{ + eta = electron.track()->eta(); + phi = electron.track()->phi(); + } + for(uint32_t iCabling = 0; iCabling < cabling_.size(); iCabling++){ + SiStripRegionCabling::Position pos = StripRegionCabling_->position(iCabling); + double dphi=fabs(pos.second-phi); + if (dphi>acos(-1)) dphi=2*acos(-1)-dphi; + double R = sqrt(pow(pos.first-eta,2)+dphi*dphi); + if (R-sqrt(pow(regionDimension_.first/2,2)+pow(regionDimension_.second/2,2))>dRStripRegion_) continue; + //get vector of subdets within region + const SiStripRegionCabling::RegionCabling regSubdets = cabling_[iCabling]; + //cycle on subdets + for (uint32_t idet=0; idetsecond).size(); op++){ + int hitFED = (itFedMap->second)[op].fedId(); + if(hitFED < FEDNumbering::MINSiStripFEDID || hitFED > FEDNumbering::MAXSiStripFEDID) continue; + LogDebug("SelectedElectronFEDListProducer")<<" SiStrip (FedID) "<momentum(); - else momentum = electron.track()->momentum(); - PixelRegion region (momentum,dPhiPixelRegion_,dEtaPixelRegion_,maxZPixelRegion_); - - PixelModule lowerBound (normalizedPhi(region.vector.phi())-region.dPhi, region.vector.eta()-region.dEta); - PixelModule upperBound (normalizedPhi(region.vector.phi())+region.dPhi, region.vector.eta()+region.dEta); - - std::vector::const_iterator itUp, itDn ; - if(lowerBound.Phi >= -M_PI && upperBound.Phi <= M_PI ){ - itDn = std::lower_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),lowerBound); - itUp = std::upper_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),upperBound); - pixelFedDump(itDn,itUp,region); - } - else{ + } // end si strip + + if(dumpSelectedSiPixelFed_){ + math::XYZVector momentum; + if(*itElectronCollFlag) momentum = electron.gsfTrack()->momentum(); + else momentum = electron.track()->momentum(); + PixelRegion region (momentum,dPhiPixelRegion_,dEtaPixelRegion_,maxZPixelRegion_); + + PixelModule lowerBound (normalizedPhi(region.vector.phi())-region.dPhi, region.vector.eta()-region.dEta); + PixelModule upperBound (normalizedPhi(region.vector.phi())+region.dPhi, region.vector.eta()+region.dEta); + + std::vector::const_iterator itUp, itDn ; + if(lowerBound.Phi >= -M_PI && upperBound.Phi <= M_PI ){ + itDn = std::lower_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),lowerBound); + itUp = std::upper_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),upperBound); + pixelFedDump(itDn,itUp,region); + } + else{ if(lowerBound.Phi < -M_PI) lowerBound.Phi = lowerBound.Phi+2*M_PI; PixelModule phi_p(M_PI,region.vector.eta()-region.dEta); itDn = std::lower_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),lowerBound); itUp = std::upper_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),phi_p); pixelFedDump(itDn,itUp,region); - + if(upperBound.Phi < -M_PI) upperBound.Phi = upperBound.Phi-2*M_PI; PixelModule phi_m(-M_PI,region.vector.eta()-region.dEta); itDn = std::lower_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),phi_m); itUp = std::upper_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),upperBound); pixelFedDump(itDn,itUp,region); - } - } - }// end tracker analysis + } + } + }// end tracker analysis }// end loop on the electron candidate - } // end loop on the electron collection collection - } // end loop on the recoEcal candidate - } // end loop on the recoEcal candidate collection - } + } // end loop on the electron collection collection + } // end loop on the recoEcal candidate + } // end loop on the recoEcal candidate collection + // add a set of chosen FED for( unsigned int iFed = 0 ; iFed < addThisSelectedFEDs_.size() ; iFed++){ if(addThisSelectedFEDs_.at(iFed) == -1 ) continue ; fedList_.push_back(addThisSelectedFEDs_.at(iFed)); } - + // make the final raw data collection RawDataCollection_ = new FEDRawDataCollection(); std::sort(fedList_.begin(),fedList_.end()); std::vector::const_iterator itfedList = fedList_.begin(); for( ; itfedList!=fedList_.end() ; ++itfedList){ - LogDebug("SelectedElectronFEDListProducer")<<" fed point "<<*itfedList<<" "; - const FEDRawData& data = rawdata->FEDData(*itfedList); - if(data.size()>0){ - FEDRawData& fedData = RawDataCollection_->FEDData(*itfedList); - fedData.resize(data.size()); - memcpy(fedData.data(),data.data(),data.size()); + LogDebug("SelectedElectronFEDListProducer")<<" fed point "<<*itfedList<<" "; + const FEDRawData& data = rawdata->FEDData(*itfedList); + if(data.size()>0){ + FEDRawData& fedData = RawDataCollection_->FEDData(*itfedList); + fedData.resize(data.size()); + memcpy(fedData.data(),data.data(),data.size()); } } - + std::auto_ptr streamFEDRawProduct(RawDataCollection_); iEvent.put(streamFEDRawProduct,outputLabelModule_); eventCounter_ ++ ; @@ -546,14 +551,14 @@ void SelectedElectronFEDListProducer::produce(edm::Event & iEvent, c template< typename TEle, typename TCand> void SelectedElectronFEDListProducer::endJob(){ - LogDebug("SelectedElectronFEDListProducer")<<" End of the Job : Counted Events "< void SelectedElectronFEDListProducer::pixelFedDump( std::vector::const_iterator & itDn, - std::vector::const_iterator & itUp, - const PixelRegion & region){ - + std::vector::const_iterator & itUp, + const PixelRegion & region){ + for( ; itDn != itUp ; ++itDn){ float zmodule = itDn->z-((itDn->x-beamSpotPosition_.x())*region.cosphi+(itDn->y-beamSpotPosition_.y())*region.sinphi)*region.atantheta; if ( std::abs(zmodule) > region.maxZ ) continue; @@ -561,12 +566,12 @@ void SelectedElectronFEDListProducer::pixelFedDump( std::vector FEDNumbering::MAXSiPixelFEDID) continue; LogDebug("SelectedElectronFEDListProducer")<<" electron pixel hit "<DetId<<" hitFED "<