CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTPixelMatchVarProducer.cc
Go to the documentation of this file.
1 
2 
8 
13 
16 
21 
24 
26 
28 public:
29 
32 
33  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
34  void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override;
35  std::array<float,4> calS2(const reco::ElectronSeed& seed,int charge)const;
36 
37 private:
38  // ----------member data ---------------------------
39 
42 
46 
48 
49 };
50 
52  recoEcalCandidateToken_(consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
53  pixelSeedsToken_(consumes<reco::ElectronSeedCollection>(config.getParameter<edm::InputTag>("pixelSeedsProducer"))),
54  dPhi1Para_(config.getParameter<edm::ParameterSet>("dPhi1SParams")),
55  dPhi2Para_(config.getParameter<edm::ParameterSet>("dPhi2SParams")),
56  dRZ2Para_(config.getParameter<edm::ParameterSet>("dRZ2SParams")),
57  productsToWrite_(config.getParameter<int>("productsToWrite"))
58 
59 {
60  //register your products
61  produces < reco::RecoEcalCandidateIsolationMap >("s2");
62  if(productsToWrite_>=1){
63  produces < reco::RecoEcalCandidateIsolationMap >("dPhi1BestS2");
64  produces < reco::RecoEcalCandidateIsolationMap >("dPhi2BestS2");
65  produces < reco::RecoEcalCandidateIsolationMap >("dzBestS2");
66  }
67 
68 
69 }
70 
72 {}
73 
75 
77  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltL1SeededRecoEcalCandidate"));
78  desc.add<edm::InputTag>(("pixelSeedsProducer"), edm::InputTag("electronPixelSeeds"));
79 
80  edm::ParameterSetDescription varParamDesc;
81  edm::ParameterSetDescription binParamDesc;
82 
83  std::auto_ptr<edm::ParameterDescriptionCases<std::string>> binDescCases;
84  binDescCases =
85  "AbsEtaClus" >>
86  (edm::ParameterDescription<double>("xMin",0.0,true) and
87  edm::ParameterDescription<double>("xMax",3.0,true) and
88  edm::ParameterDescription<int>("yMin",0,true) and
89  edm::ParameterDescription<int>("yMax",99999,true) and
90  edm::ParameterDescription<std::string>("funcType","pol0",true) and
91  edm::ParameterDescription<std::vector<double>>("funcParams",{0.},true)) or
92  "AbsEtaClusPhi" >>
93  (edm::ParameterDescription<double>("xMin",0.0,true) and
94  edm::ParameterDescription<double>("xMax",3.0,true) and
95  edm::ParameterDescription<int>("yMin",0,true) and
96  edm::ParameterDescription<int>("yMax",99999,true) and
97  edm::ParameterDescription<std::string>("funcType","pol0",true) and
98  edm::ParameterDescription<std::vector<double>>("funcParams",{0.},true)) or
99  "AbsEtaClusEt" >>
100  (edm::ParameterDescription<double>("xMin",0.0,true) and
101  edm::ParameterDescription<double>("xMax",3.0,true) and
102  edm::ParameterDescription<int>("yMin",0,true) and
103  edm::ParameterDescription<int>("yMax",99999,true) and
104  edm::ParameterDescription<std::string>("funcType","pol0",true) and
105  edm::ParameterDescription<std::vector<double>>("funcParams",{0.},true));
106 
107  binParamDesc.ifValue(edm::ParameterDescription<std::string>("binType","AbsEtaClus",true), binDescCases);
108 
109 
110  varParamDesc.addVPSet("bins",binParamDesc);
111  desc.add("dPhi1SParams",varParamDesc);
112  desc.add("dPhi2SParams",varParamDesc);
113  desc.add("dRZ2SParams",varParamDesc);
114  desc.add<int>("productsToWrite",0);
115  descriptions.add(("hltEgammaHLTPixelMatchVarProducer"), desc);
116 }
117 
119 
120  // Get the HLT filtered objects
122  iEvent.getByToken(recoEcalCandidateToken_,recoEcalCandHandle);
123 
124 
126  iEvent.getByToken(pixelSeedsToken_,pixelSeedsHandle);
127 
128  if(!recoEcalCandHandle.isValid() || !pixelSeedsHandle.isValid()) return;
129 
130  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dPhi1BestS2Map(new reco::RecoEcalCandidateIsolationMap(recoEcalCandHandle));
131  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dPhi2BestS2Map(new reco::RecoEcalCandidateIsolationMap(recoEcalCandHandle));
132  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> dzBestS2Map(new reco::RecoEcalCandidateIsolationMap(recoEcalCandHandle));
133  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> s2Map(new reco::RecoEcalCandidateIsolationMap(recoEcalCandHandle));
134 
135  for(unsigned int candNr = 0; candNr<recoEcalCandHandle->size(); candNr++) {
136 
137  reco::RecoEcalCandidateRef candRef(recoEcalCandHandle,candNr);
138  reco::SuperClusterRef candSCRef = candRef->superCluster();
139 
141  for(auto & seed : *pixelSeedsHandle){
142  edm::RefToBase<reco::CaloCluster> pixelClusterRef = seed.caloCluster() ;
143  reco::SuperClusterRef pixelSCRef = pixelClusterRef.castTo<reco::SuperClusterRef>() ;
144  if(&(*candSCRef) == &(*pixelSCRef)){
145 
146  std::array<float,4> s2Data = calS2(seed,-1);
147  std::array<float,4> s2DataPos = calS2(seed,+1);
148  if(s2Data[0]<bestS2[0]) bestS2=s2Data;
149  if(s2DataPos[0]<bestS2[0]) bestS2=s2DataPos;
150 
151  }
152  }
153 
154 
155  s2Map->insert(candRef,bestS2[0]);
156  if(productsToWrite_>=1){
157  dPhi1BestS2Map->insert(candRef,bestS2[1]);
158  dPhi2BestS2Map->insert(candRef,bestS2[2]);
159  dzBestS2Map->insert(candRef,bestS2[3]);
160  }
161 
162  }
163 
164  iEvent.put(s2Map,"s2");
165  if(productsToWrite_>=1){
166  iEvent.put(dPhi1BestS2Map,"dPhi1BestS2");
167  iEvent.put(dPhi2BestS2Map,"dPhi2BestS2");
168  iEvent.put(dzBestS2Map,"dzBestS2");
169  }
170 }
171 
173 {
174  const float dPhi1Const = dPhi1Para_(seed);
175  const float dPhi2Const = dPhi2Para_(seed);
176  const float dRZ2Const = dRZ2Para_(seed);
177 
178  float dPhi1 = (charge <0 ? seed.dPhi1() : seed.dPhi1Pos())/dPhi1Const;
179  float dPhi2 = (charge <0 ? seed.dPhi2() : seed.dPhi2Pos())/dPhi2Const;
180  float dRz2 = (charge <0 ? seed.dRz2() : seed.dRz2Pos())/dRZ2Const;
181 
182  float s2 = dPhi1*dPhi1+dPhi2*dPhi2+dRz2*dRz2;
183  return std::array<float,4>{{s2,dPhi1,dPhi2,dRz2}};
184 }
185 
186 
float dPhi1() const
Definition: ElectronSeed.h:79
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
egPM::Param< reco::ElectronSeed > dPhi2Para_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void produce(edm::StreamID sid, edm::Event &, const edm::EventSetup &) const override
egPM::Param< reco::ElectronSeed > dPhi1Para_
float dPhi1Pos() const
Definition: ElectronSeed.h:81
tuple s2
Definition: indexGen.py:106
egPM::Param< reco::ElectronSeed > dRZ2Para_
float dPhi2() const
Definition: ElectronSeed.h:74
int iEvent
Definition: GenABIO.cc:230
float dRz2Pos() const
Definition: ElectronSeed.h:75
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:75
std::array< float, 4 > calS2(const reco::ElectronSeed &seed, int charge) const
float dRz2() const
Definition: ElectronSeed.h:73
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::auto_ptr< ParameterDescriptionCases< T > > cases)
float dPhi2Pos() const
Definition: ElectronSeed.h:76
REF castTo() const
Definition: RefToBase.h:286
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
const edm::EDGetTokenT< reco::ElectronSeedCollection > pixelSeedsToken_
EgammaHLTPixelMatchVarProducer(const edm::ParameterSet &)