CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PhotonCoreProducer Class Reference
Inheritance diagram for PhotonCoreProducer:
edm::stream::EDProducer<>

Public Member Functions

 PhotonCoreProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 ~PhotonCoreProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void fillPhotonCollection (edm::Event &evt, edm::EventSetup const &es, const edm::Handle< reco::SuperClusterCollection > &scHandle, const edm::Handle< reco::ConversionCollection > &conversionHandle, const edm::Handle< reco::ElectronSeedCollection > &pixelSeeds, reco::PhotonCoreCollection &outputCollection, int &iSC)
 
reco::ConversionRef solveAmbiguity (const edm::Handle< reco::ConversionCollection > &conversionHandle, reco::SuperClusterRef &sc)
 

Private Attributes

edm::ParameterSet conf_
 
edm::EDGetTokenT
< reco::ConversionCollection
conversionProducer_
 
bool endcapOnly_
 
double minSCEt_
 
std::string PhotonCoreCollection_
 
edm::EDGetTokenT
< reco::ElectronSeedCollection
pixelSeedProducer_
 
bool risolveAmbiguity_
 
edm::EDGetTokenT
< reco::SuperClusterCollection
scHybridBarrelProducer_
 
edm::EDGetTokenT
< reco::SuperClusterCollection
scIslandEndcapProducer_
 
bool validConversions_
 
bool validPixelSeeds_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Author
Nancy Marinelli, U. of Notre Dame, US

Definition at line 28 of file PhotonCoreProducer.cc.

Constructor & Destructor Documentation

PhotonCoreProducer::PhotonCoreProducer ( const edm::ParameterSet ps)

Definition at line 64 of file PhotonCoreProducer.cc.

References conf_, conversionProducer_, endcapOnly_, edm::ParameterSet::getParameter(), minSCEt_, PhotonCoreCollection_, pixelSeedProducer_, risolveAmbiguity_, scHybridBarrelProducer_, scIslandEndcapProducer_, and AlCaHLTBitMon_QueryRunRegistry::string.

65  : conf_(config)
66 
67 {
68  // use onfiguration file to setup input/output collection names
70  consumes<reco::SuperClusterCollection>(conf_.getParameter<edm::InputTag>("scHybridBarrelProducer"));
72  consumes<reco::SuperClusterCollection>(conf_.getParameter<edm::InputTag>("scIslandEndcapProducer"));
73  conversionProducer_ = consumes<reco::ConversionCollection>(conf_.getParameter<edm::InputTag>("conversionProducer"));
74  PhotonCoreCollection_ = conf_.getParameter<std::string>("photonCoreCollection");
75  pixelSeedProducer_ = consumes<reco::ElectronSeedCollection>(conf_.getParameter<edm::InputTag>("pixelSeedProducer"));
76  minSCEt_ = conf_.getParameter<double>("minSCEt");
77  risolveAmbiguity_ = conf_.getParameter<bool>("risolveConversionAmbiguity");
78  endcapOnly_ = conf_.getParameter<bool>("endcapOnly");
79 
80  // Register the product
81  produces<reco::PhotonCoreCollection>(PhotonCoreCollection_);
82 }
edm::EDGetTokenT< reco::ConversionCollection > conversionProducer_
edm::ParameterSet conf_
edm::EDGetTokenT< reco::ElectronSeedCollection > pixelSeedProducer_
edm::EDGetTokenT< reco::SuperClusterCollection > scHybridBarrelProducer_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
tuple config
parse the configuration file
edm::EDGetTokenT< reco::SuperClusterCollection > scIslandEndcapProducer_
std::string PhotonCoreCollection_
PhotonCoreProducer::~PhotonCoreProducer ( )
override

Definition at line 84 of file PhotonCoreProducer.cc.

84 {}

Member Function Documentation

void PhotonCoreProducer::fillPhotonCollection ( edm::Event evt,
edm::EventSetup const &  es,
const edm::Handle< reco::SuperClusterCollection > &  scHandle,
const edm::Handle< reco::ConversionCollection > &  conversionHandle,
const edm::Handle< reco::ElectronSeedCollection > &  pixelSeeds,
reco::PhotonCoreCollection outputCollection,
int &  iSC 
)
private

Definition at line 149 of file PhotonCoreProducer.cc.

References reco::PhotonCore::addConversion(), reco::PhotonCore::addElectronPixelSeed(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::key(), minSCEt_, risolveAmbiguity_, reco::PhotonCore::setParentSuperCluster(), solveAmbiguity(), validConversions_, and validPixelSeeds_.

Referenced by produce().

155  {
156  for (unsigned int lSC = 0; lSC < scHandle->size(); lSC++) {
157  // get SuperClusterRef
158  reco::SuperClusterRef scRef(reco::SuperClusterRef(scHandle, lSC));
159  iSC++;
160  //const reco::SuperCluster* pClus=&(*scRef);
161 
162  // SC energy preselection
163  if (scRef->energy() / cosh(scRef->eta()) <= minSCEt_)
164  continue;
165 
166  reco::PhotonCore newCandidate(scRef);
167  newCandidate.setParentSuperCluster(scRef);
168  if (validConversions_) {
169  if (risolveAmbiguity_) {
170  reco::ConversionRef bestRef = solveAmbiguity(conversionHandle, scRef);
171  if (bestRef.isNonnull())
172  newCandidate.addConversion(bestRef);
173 
174  } else {
175  for (unsigned int icp = 0; icp < conversionHandle->size(); icp++) {
176  reco::ConversionRef cpRef(reco::ConversionRef(conversionHandle, icp));
177  if (cpRef->caloCluster().empty())
178  continue;
179  if (!(scRef.id() == cpRef->caloCluster()[0].id() && scRef.key() == cpRef->caloCluster()[0].key()))
180  continue;
181  if (!cpRef->isConverted())
182  continue;
183  newCandidate.addConversion(cpRef);
184  }
185 
186  } // solve or not the ambiguity of many conversion candidates
187  }
188 
189  if (validPixelSeeds_) {
190  for (unsigned int icp = 0; icp < pixelSeedHandle->size(); icp++) {
191  reco::ElectronSeedRef cpRef(reco::ElectronSeedRef(pixelSeedHandle, icp));
192  if (!cpRef->isEcalDriven())
193  continue;
194  if (!(scRef.id() == cpRef->caloCluster().id() && scRef.key() == cpRef->caloCluster().key()))
195  continue;
196  newCandidate.addElectronPixelSeed(cpRef);
197  }
198  }
199 
200  outputPhotonCoreCollection.push_back(newCandidate);
201  }
202 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
reco::ConversionRef solveAmbiguity(const edm::Handle< reco::ConversionCollection > &conversionHandle, reco::SuperClusterRef &sc)
void PhotonCoreProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 86 of file PhotonCoreProducer.cc.

References printConversionInfo::conversionHandle, conversionProducer_, endcapOnly_, fillPhotonCollection(), edm::Event::getByToken(), eostools::move(), PhotonCoreCollection_, pixelSeedProducer_, edm::Event::put(), scHybridBarrelProducer_, scIslandEndcapProducer_, validConversions_, and validPixelSeeds_.

86  {
87  using namespace edm;
88  // nEvt_++;
89 
90  reco::PhotonCoreCollection outputPhotonCoreCollection;
91  auto outputPhotonCoreCollection_p = std::make_unique<reco::PhotonCoreCollection>();
92 
93  // Get the Barrel Super Cluster collection
94  bool validBarrelSCHandle = true;
95  if (endcapOnly_) {
96  validBarrelSCHandle = false;
97  }
98 
100  theEvent.getByToken(scHybridBarrelProducer_, scBarrelHandle);
101  if (!endcapOnly_ && !scBarrelHandle.isValid()) {
102  edm::LogError("PhotonCoreProducer") << "Error! Can't get the scHybridBarrelProducer";
103  validBarrelSCHandle = false;
104  }
105 
106  // Get the Endcap Super Cluster collection
107  bool validEndcapSCHandle = true;
109  theEvent.getByToken(scIslandEndcapProducer_, scEndcapHandle);
110  if (!scEndcapHandle.isValid()) {
111  edm::LogError("PhotonCoreProducer") << "Error! Can't get the scIslandEndcapProducer";
112  validEndcapSCHandle = false;
113  }
114 
116  validConversions_ = true;
118  theEvent.getByToken(conversionProducer_, conversionHandle);
119  if (!conversionHandle.isValid()) {
120  //edm::LogError("PhotonCoreProducer") << "Error! Can't get the product "<< conversionProducer_.label() << "\n" ;
121  validConversions_ = false;
122  }
123 
124  // Get ElectronPixelSeeds
125  validPixelSeeds_ = true;
126  Handle<reco::ElectronSeedCollection> pixelSeedHandle;
127  reco::ElectronSeedCollection pixelSeeds;
128  theEvent.getByToken(pixelSeedProducer_, pixelSeedHandle);
129  if (!pixelSeedHandle.isValid()) {
130  validPixelSeeds_ = false;
131  }
132  // if ( validPixelSeeds_) pixelSeeds = *(pixelSeedHandle.product());
133 
134  int iSC = 0; // index in photon collection
135  // Loop over barrel and endcap SC collections and fill the photon collection
136  if (validBarrelSCHandle)
138  theEvent, theEventSetup, scBarrelHandle, conversionHandle, pixelSeedHandle, outputPhotonCoreCollection, iSC);
139  if (validEndcapSCHandle)
141  theEvent, theEventSetup, scEndcapHandle, conversionHandle, pixelSeedHandle, outputPhotonCoreCollection, iSC);
142 
143  // put the product in the event
144  edm::LogInfo("PhotonCoreProducer") << " Put in the event " << iSC << " Photon Candidates \n";
145  outputPhotonCoreCollection_p->assign(outputPhotonCoreCollection.begin(), outputPhotonCoreCollection.end());
146  theEvent.put(std::move(outputPhotonCoreCollection_p), PhotonCoreCollection_);
147 }
edm::EDGetTokenT< reco::ConversionCollection > conversionProducer_
edm::EDGetTokenT< reco::ElectronSeedCollection > pixelSeedProducer_
void fillPhotonCollection(edm::Event &evt, edm::EventSetup const &es, const edm::Handle< reco::SuperClusterCollection > &scHandle, const edm::Handle< reco::ConversionCollection > &conversionHandle, const edm::Handle< reco::ElectronSeedCollection > &pixelSeeds, reco::PhotonCoreCollection &outputCollection, int &iSC)
Log< level::Error, false > LogError
def move
Definition: eostools.py:511
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
edm::EDGetTokenT< reco::SuperClusterCollection > scHybridBarrelProducer_
Log< level::Info, false > LogInfo
std::vector< PhotonCore > PhotonCoreCollection
collectin of PhotonCore objects
Definition: PhotonCoreFwd.h:9
edm::EDGetTokenT< reco::SuperClusterCollection > scIslandEndcapProducer_
std::string PhotonCoreCollection_
reco::ConversionRef PhotonCoreProducer::solveAmbiguity ( const edm::Handle< reco::ConversionCollection > &  conversionHandle,
reco::SuperClusterRef sc 
)
private

only one track reconstructed. Pick the one with best E/P

Definition at line 204 of file PhotonCoreProducer.cc.

References edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::key(), AlCaHLTBitMon_ParallelJobs::p, mathSSE::sqrt(), and tracks.

Referenced by fillPhotonCollection().

205  {
206  std::multimap<reco::ConversionRef, double> convMap;
207  for (unsigned int icp = 0; icp < conversionHandle->size(); icp++) {
208  reco::ConversionRef cpRef(reco::ConversionRef(conversionHandle, icp));
209 
210  if (!(scRef.id() == cpRef->caloCluster()[0].id() && scRef.key() == cpRef->caloCluster()[0].key()))
211  continue;
212  if (!cpRef->isConverted())
213  continue;
214  double like = cpRef->MVAout();
215  convMap.insert(std::make_pair(cpRef, like));
216  }
217 
218  std::multimap<reco::ConversionRef, double>::iterator iMap;
219  double max_lh = -1.;
220  reco::ConversionRef bestRef;
221  // std::cout << " Pick up the best conv " << std::endl;
222  for (iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
223  double like = iMap->second;
224  if (like > max_lh) {
225  max_lh = like;
226  bestRef = iMap->first;
227  }
228  }
229 
230  //std::cout << " Best conv like " << max_lh << std::endl;
231 
232  float ep = 0;
233  if (max_lh < 0) {
234  // std::cout << " Candidates with only one track " << std::endl;
236  float epMin = 999;
237 
238  for (iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
239  reco::ConversionRef convRef = iMap->first;
240  // std::vector<reco::TrackRef> tracks = convRef->tracks();
241  const std::vector<edm::RefToBase<reco::Track> > tracks = convRef->tracks();
242  float px = tracks[0]->innerMomentum().x();
243  float py = tracks[0]->innerMomentum().y();
244  float pz = tracks[0]->innerMomentum().z();
245  float p = sqrt(px * px + py * py + pz * pz);
246  ep = fabs(1. - convRef->caloCluster()[0]->energy() / p);
247  // std::cout << " 1-E/P = " << ep << std::endl;
248  if (ep < epMin) {
249  epMin = ep;
250  bestRef = iMap->first;
251  }
252  }
253  // std::cout << " Best conv 1-E/P " << ep << std::endl;
254  }
255 
256  return bestRef;
257 }
auto const & tracks
cannot be loose
T sqrt(T t)
Definition: SSEVec.h:19

Member Data Documentation

edm::ParameterSet PhotonCoreProducer::conf_
private

Definition at line 55 of file PhotonCoreProducer.cc.

Referenced by PhotonCoreProducer().

edm::EDGetTokenT<reco::ConversionCollection> PhotonCoreProducer::conversionProducer_
private

Definition at line 50 of file PhotonCoreProducer.cc.

Referenced by PhotonCoreProducer(), and produce().

bool PhotonCoreProducer::endcapOnly_
private

Definition at line 58 of file PhotonCoreProducer.cc.

Referenced by PhotonCoreProducer(), and produce().

double PhotonCoreProducer::minSCEt_
private

Definition at line 53 of file PhotonCoreProducer.cc.

Referenced by fillPhotonCollection(), and PhotonCoreProducer().

std::string PhotonCoreProducer::PhotonCoreCollection_
private

Definition at line 47 of file PhotonCoreProducer.cc.

Referenced by PhotonCoreProducer(), and produce().

edm::EDGetTokenT<reco::ElectronSeedCollection> PhotonCoreProducer::pixelSeedProducer_
private

Definition at line 51 of file PhotonCoreProducer.cc.

Referenced by PhotonCoreProducer(), and produce().

bool PhotonCoreProducer::risolveAmbiguity_
private

Definition at line 57 of file PhotonCoreProducer.cc.

Referenced by fillPhotonCollection(), and PhotonCoreProducer().

edm::EDGetTokenT<reco::SuperClusterCollection> PhotonCoreProducer::scHybridBarrelProducer_
private

Definition at line 48 of file PhotonCoreProducer.cc.

Referenced by PhotonCoreProducer(), and produce().

edm::EDGetTokenT<reco::SuperClusterCollection> PhotonCoreProducer::scIslandEndcapProducer_
private

Definition at line 49 of file PhotonCoreProducer.cc.

Referenced by PhotonCoreProducer(), and produce().

bool PhotonCoreProducer::validConversions_
private

Definition at line 54 of file PhotonCoreProducer.cc.

Referenced by fillPhotonCollection(), and produce().

bool PhotonCoreProducer::validPixelSeeds_
private

Definition at line 56 of file PhotonCoreProducer.cc.

Referenced by fillPhotonCollection(), and produce().