1 #ifndef RecoEgamma_EgammaHLTProducers_HLTCaloObjInRegionsProducer_h_ 2 #define RecoEgamma_EgammaHLTProducers_HLTCaloObjInRegionsProducer_h_ 58 EtaPhiRegion(
float iEta,
float iPhi,
float iDR,
float iDEta,
float iDPhi):
59 centreEta_(iEta),centrePhi_(iPhi),maxDeltaR2_(iDR*iDR),
60 maxDEta_(iDEta),maxDPhi_(iDPhi){}
63 return reco::deltaR2(eta,phi,centreEta_,centrePhi_)<maxDeltaR2_ ||
72 virtual void getEtaPhiRegions(
const edm::Event&,std::vector<EtaPhiRegion>&)
const=0;
88 minEt_(para.getParameter<double>(
"minEt")),
89 maxEt_(para.getParameter<double>(
"maxEt")),
90 maxDeltaR_(para.getParameter<double>(
"maxDeltaR")),
91 maxDEta_(para.getParameter<double>(
"maxDEta")),
92 maxDPhi_(para.getParameter<double>(
"maxDPhi")),
93 token_(consumesColl.consumes<T1>(para.getParameter<
edm::InputTag>(
"inputColl"))){}
95 void getEtaPhiRegions(
const edm::Event&,std::vector<EtaPhiRegion>&)
const override;
96 template<
typename T2>
static typename T2::const_iterator
beginIt(
const T2&
coll){
return coll.begin();}
97 template<
typename T2>
static typename T2::const_iterator
endIt(
const T2&
coll){
return coll.end();}
104 template<
typename CaloObjType,
121 static std::unique_ptr<CaloObjCollType>
124 const std::vector<EtaPhiRegion>& regions);
132 template<
typename CaloObjType,
typename CaloObjCollType>
135 const std::vector<edm::ParameterSet> etaPhiRegions = para.
getParameter<std::vector<edm::ParameterSet>>(
"etaPhiRegions");
136 for(
auto&
pset : etaPhiRegions){
138 etaPhiRegionData_.emplace_back(createEtaPhiRegionData(type,
pset,consumesCollector()));
141 outputProductNames_=para.
getParameter<std::vector<std::string>>(
"outputProductNames");
142 inputCollTags_=para.
getParameter<std::vector<edm::InputTag>>(
"inputCollTags");
143 if(outputProductNames_.size()!=inputCollTags_.size()){
144 throw cms::Exception(
"InvalidConfiguration") <<
" error outputProductNames and inputCollTags must be the same size, they are "<<outputProductNames_.size()<<
" vs "<<inputCollTags_.size();
146 for (
unsigned int collNr=0; collNr<inputCollTags_.size(); collNr++) {
147 inputTokens_.push_back(consumes<CaloObjCollType>(inputCollTags_[collNr]));
148 produces<CaloObjCollType> (outputProductNames_[collNr]);
152 template<
typename CaloObjType,
typename CaloObjCollType>
156 std::vector<std::string> outputProductNames;
157 outputProductNames.push_back(
"EcalRegionalRecHitsEB");
158 desc.
add<std::vector<std::string>>(
"outputProductNames", outputProductNames);
159 std::vector<edm::InputTag> inputColls;
161 desc.
add<std::vector<edm::InputTag>>(
"inputCollTags", inputColls);
162 std::vector<edm::ParameterSet> etaPhiRegions;
172 etaPhiRegions.push_back(ecalCandPSet);
177 etaPhiRegionDesc.
add<
double>(
"minEt");
178 etaPhiRegionDesc.
add<
double>(
"maxEt");
179 etaPhiRegionDesc.
add<
double>(
"maxDeltaR");
180 etaPhiRegionDesc.
add<
double>(
"maxDEta");
181 etaPhiRegionDesc.
add<
double>(
"maxDPhi");
183 desc.
addVPSet(
"etaPhiRegions",etaPhiRegionDesc,etaPhiRegions);
189 template<
typename CaloObjType,
typename CaloObjCollType>
196 std::vector<EtaPhiRegion> regions;
197 std::for_each(etaPhiRegionData_.begin(),etaPhiRegionData_.end(),
198 [&
event,®ions](
const std::unique_ptr<EtaPhiRegionDataBase>&
input)
199 {
input->getEtaPhiRegions(event,regions);}
202 for(
size_t inputCollNr=0;inputCollNr<inputTokens_.size();inputCollNr++){
204 event.getByToken(inputTokens_[inputCollNr],inputColl);
207 edm::LogError(
"ProductNotFound")<<
"could not get a handle on the "<<
typeid(CaloObjCollType).
name() <<
" named "<< inputCollTags_[inputCollNr].encode() << std::endl;
210 auto outputColl = makeFilteredColl(inputColl,caloGeomHandle,regions);
215 template<
typename CaloObjType,
typename CaloObjCollType>
216 std::unique_ptr<CaloObjCollType>
220 const std::vector<EtaPhiRegion>& regions)
223 auto outputColl = std::make_unique<CaloObjCollType>();
224 if(!inputColl->empty()){
226 if(!regions.empty()){
227 for(
const CaloObjType&
obj : *inputColl){
229 if(objGeom==
nullptr){
233 edm::LogError(
"HLTCaloObjInRegionsProducer") <<
"for an object of type "<<
typeid(CaloObjType).
name()<<
" the geometry returned null for id "<<
DetId(
obj.id()).rawId()<<
" in HLTCaloObjsInRegion, this shouldnt be possible and something has gone wrong, auto accepting hit";
239 for(
const auto& region : regions){
240 if(region(eta,phi)) {
256 template<
typename CaloObjType,
typename CaloObjCollType>
262 if(type==
"L1EGamma"){
264 }
else if(type==
"L1Jet"){
266 }
else if(type==
"L1Muon"){
268 }
else if(type==
"L1Tau"){
270 }
else if(type==
"RecoEcalCandidate"){
272 }
else if(type==
"RecoChargedCandidate"){
274 }
else if(type==
"Electron"){
278 throw cms::Exception(
"InvalidConfig") <<
" type "<<type<<
" is not recognised, this means the rec-hit you think you are keeping may not be and you should fix this error as it can lead to hard to find efficiency loses"<<std::endl;
283 template<
typename CandCollType>
287 event.getByToken(token_,cands);
289 for(
auto candIt = beginIt(*cands);candIt!=endIt(*cands);++candIt){
290 if(candIt->et() >= minEt_ && (maxEt_<0 || candIt->et() < maxEt_)){
291 regions.push_back(
EtaPhiRegion(candIt->eta(),candIt->phi(),
const_iterator end(int bx) const
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
std::string defaultModuleLabel()
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
std::vector< edm::EDGetTokenT< CaloObjCollType > > inputTokens_
std::vector< edm::InputTag > inputCollTags_
EtaPhiRegionDataBase * createEtaPhiRegionData(const std::string &, const edm::ParameterSet &, edm::ConsumesCollector &&)
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
Geom::Phi< T > phi() const
def setup(process, global_tag, zero_tesla=False)
~HLTCaloObjInRegionsProducer() override
static BXVector< T2 >::const_iterator beginIt(const BXVector< T2 > &coll)
static T2::const_iterator beginIt(const T2 &coll)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
static std::string const input
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< std::string > outputProductNames_
static std::unique_ptr< CaloObjCollType > makeFilteredColl(const edm::Handle< CaloObjCollType > &inputColl, const edm::ESHandle< CaloGeometry > &caloGeomHandle, const std::vector< EtaPhiRegion > ®ions)
static T2::const_iterator endIt(const T2 &coll)
void addParameter(std::string const &name, T const &value)
bool operator()(float eta, float phi) const
Abs< T >::type abs(const T &t)
EtaPhiRegionData(const edm::ParameterSet ¶, edm::ConsumesCollector &consumesColl)
SubDetector subDetGeom[21]
ParameterDescriptionBase * add(U const &iLabel, T const &value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
HLTCaloObjInRegionsProducer(const edm::ParameterSet &ps)
double deltaPhi(double phi1, double phi2)
edm::EDGetTokenT< T1 > token_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
static BXVector< T2 >::const_iterator endIt(const BXVector< T2 > &coll)
void getEtaPhiRegions(const edm::Event &, std::vector< EtaPhiRegion > &) const override
const_iterator begin(int bx) const
EtaPhiRegion(float iEta, float iPhi, float iDR, float iDEta, float iDPhi)
std::vector< std::unique_ptr< EtaPhiRegionDataBase > > etaPhiRegionData_
void produce(edm::Event &, const edm::EventSetup &) override