CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PhotonCoreProducer Class Reference

#include <PhotonCoreProducer.h>

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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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::ConversionCollectionconversionProducer_
 
double minSCEt_
 
std::string PhotonCoreCollection_
 
edm::EDGetTokenT< reco::ElectronSeedCollectionpixelSeedProducer_
 
bool risolveAmbiguity_
 
edm::EDGetTokenT< reco::SuperClusterCollectionscHybridBarrelProducer_
 
edm::EDGetTokenT< reco::SuperClusterCollectionscIslandEndcapProducer_
 
bool validConversions_
 
bool validPixelSeeds_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Author
Nancy Marinelli, U. of Notre Dame, US

Definition at line 30 of file PhotonCoreProducer.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file PhotonCoreProducer.cc.

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

19  : conf_(config)
20 
21 {
22  // use onfiguration file to setup input/output collection names
24  consumes<reco::SuperClusterCollection>(conf_.getParameter<edm::InputTag>("scHybridBarrelProducer"));
26  consumes<reco::SuperClusterCollection>(conf_.getParameter<edm::InputTag>("scIslandEndcapProducer"));
27  conversionProducer_ = consumes<reco::ConversionCollection>(conf_.getParameter<edm::InputTag>("conversionProducer"));
28  PhotonCoreCollection_ = conf_.getParameter<std::string>("photonCoreCollection");
29  pixelSeedProducer_ = consumes<reco::ElectronSeedCollection>(conf_.getParameter<edm::InputTag>("pixelSeedProducer"));
30  minSCEt_ = conf_.getParameter<double>("minSCEt");
31  risolveAmbiguity_ = conf_.getParameter<bool>("risolveConversionAmbiguity");
32 
33  // Register the product
34  produces<reco::PhotonCoreCollection>(PhotonCoreCollection_);
35 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::ConversionCollection > conversionProducer_
edm::ParameterSet conf_
edm::EDGetTokenT< reco::ElectronSeedCollection > pixelSeedProducer_
Definition: config.py:1
edm::EDGetTokenT< reco::SuperClusterCollection > scHybridBarrelProducer_
edm::EDGetTokenT< reco::SuperClusterCollection > scIslandEndcapProducer_
std::string PhotonCoreCollection_
PhotonCoreProducer::~PhotonCoreProducer ( )
override

Definition at line 37 of file PhotonCoreProducer.cc.

37 {}

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 98 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().

104  {
105  for (unsigned int lSC = 0; lSC < scHandle->size(); lSC++) {
106  // get SuperClusterRef
107  reco::SuperClusterRef scRef(reco::SuperClusterRef(scHandle, lSC));
108  iSC++;
109  //const reco::SuperCluster* pClus=&(*scRef);
110 
111  // SC energy preselection
112  if (scRef->energy() / cosh(scRef->eta()) <= minSCEt_)
113  continue;
114 
115  reco::PhotonCore newCandidate(scRef);
116  newCandidate.setParentSuperCluster(scRef);
117  if (validConversions_) {
118  if (risolveAmbiguity_) {
119  reco::ConversionRef bestRef = solveAmbiguity(conversionHandle, scRef);
120  if (bestRef.isNonnull())
121  newCandidate.addConversion(bestRef);
122 
123  } else {
124  for (unsigned int icp = 0; icp < conversionHandle->size(); icp++) {
125  reco::ConversionRef cpRef(reco::ConversionRef(conversionHandle, icp));
126  if (cpRef->caloCluster().empty())
127  continue;
128  if (!(scRef.id() == cpRef->caloCluster()[0].id() && scRef.key() == cpRef->caloCluster()[0].key()))
129  continue;
130  if (!cpRef->isConverted())
131  continue;
132  newCandidate.addConversion(cpRef);
133  }
134 
135  } // solve or not the ambiguity of many conversion candidates
136  }
137 
138  if (validPixelSeeds_) {
139  for (unsigned int icp = 0; icp < pixelSeedHandle->size(); icp++) {
140  reco::ElectronSeedRef cpRef(reco::ElectronSeedRef(pixelSeedHandle, icp));
141  if (!cpRef->isEcalDriven())
142  continue;
143  if (!(scRef.id() == cpRef->caloCluster().id() && scRef.key() == cpRef->caloCluster().key()))
144  continue;
145  newCandidate.addElectronPixelSeed(cpRef);
146  }
147  }
148 
149  outputPhotonCoreCollection.push_back(newCandidate);
150  }
151 }
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 39 of file PhotonCoreProducer.cc.

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

39  {
40  using namespace edm;
41  // nEvt_++;
42 
43  reco::PhotonCoreCollection outputPhotonCoreCollection;
44  auto outputPhotonCoreCollection_p = std::make_unique<reco::PhotonCoreCollection>();
45 
46  // Get the Barrel Super Cluster collection
47  bool validBarrelSCHandle = true;
49  theEvent.getByToken(scHybridBarrelProducer_, scBarrelHandle);
50  if (!scBarrelHandle.isValid()) {
51  edm::LogError("PhotonCoreProducer") << "Error! Can't get the scHybridBarrelProducer";
52  validBarrelSCHandle = false;
53  }
54 
55  // Get the Endcap Super Cluster collection
56  bool validEndcapSCHandle = true;
58  theEvent.getByToken(scIslandEndcapProducer_, scEndcapHandle);
59  if (!scEndcapHandle.isValid()) {
60  edm::LogError("PhotonCoreProducer") << "Error! Can't get the scIslandEndcapProducer";
61  validEndcapSCHandle = false;
62  }
63 
65  validConversions_ = true;
67  theEvent.getByToken(conversionProducer_, conversionHandle);
68  if (!conversionHandle.isValid()) {
69  //edm::LogError("PhotonCoreProducer") << "Error! Can't get the product "<< conversionProducer_.label() << "\n" ;
70  validConversions_ = false;
71  }
72 
73  // Get ElectronPixelSeeds
74  validPixelSeeds_ = true;
77  theEvent.getByToken(pixelSeedProducer_, pixelSeedHandle);
78  if (!pixelSeedHandle.isValid()) {
79  validPixelSeeds_ = false;
80  }
81  // if ( validPixelSeeds_) pixelSeeds = *(pixelSeedHandle.product());
82 
83  int iSC = 0; // index in photon collection
84  // Loop over barrel and endcap SC collections and fill the photon collection
85  if (validBarrelSCHandle)
87  theEvent, theEventSetup, scBarrelHandle, conversionHandle, pixelSeedHandle, outputPhotonCoreCollection, iSC);
88  if (validEndcapSCHandle)
90  theEvent, theEventSetup, scEndcapHandle, conversionHandle, pixelSeedHandle, outputPhotonCoreCollection, iSC);
91 
92  // put the product in the event
93  edm::LogInfo("PhotonCoreProducer") << " Put in the event " << iSC << " Photon Candidates \n";
94  outputPhotonCoreCollection_p->assign(outputPhotonCoreCollection.begin(), outputPhotonCoreCollection.end());
95  theEvent.put(std::move(outputPhotonCoreCollection_p), PhotonCoreCollection_);
96 }
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)
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< reco::SuperClusterCollection > scHybridBarrelProducer_
std::vector< PhotonCore > PhotonCoreCollection
collectin of PhotonCore objects
Definition: PhotonCoreFwd.h:9
HLT enums.
edm::EDGetTokenT< reco::SuperClusterCollection > scIslandEndcapProducer_
std::string PhotonCoreCollection_
def move(src, dest)
Definition: eostools.py:511
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 153 of file PhotonCoreProducer.cc.

References SiStripBadComponentsDQMServiceTemplate_cfg::ep, edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::key(), AlCaHLTBitMon_ParallelJobs::p, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, mathSSE::sqrt(), and PDWG_EXOHSCP_cff::tracks.

Referenced by fillPhotonCollection().

154  {
155  std::multimap<reco::ConversionRef, double> convMap;
156  for (unsigned int icp = 0; icp < conversionHandle->size(); icp++) {
157  reco::ConversionRef cpRef(reco::ConversionRef(conversionHandle, icp));
158 
159  if (!(scRef.id() == cpRef->caloCluster()[0].id() && scRef.key() == cpRef->caloCluster()[0].key()))
160  continue;
161  if (!cpRef->isConverted())
162  continue;
163  double like = cpRef->MVAout();
164  convMap.insert(std::make_pair(cpRef, like));
165  }
166 
167  std::multimap<reco::ConversionRef, double>::iterator iMap;
168  double max_lh = -1.;
169  reco::ConversionRef bestRef;
170  // std::cout << " Pick up the best conv " << std::endl;
171  for (iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
172  double like = iMap->second;
173  if (like > max_lh) {
174  max_lh = like;
175  bestRef = iMap->first;
176  }
177  }
178 
179  //std::cout << " Best conv like " << max_lh << std::endl;
180 
181  float ep = 0;
182  if (max_lh < 0) {
183  // std::cout << " Candidates with only one track " << std::endl;
185  float epMin = 999;
186 
187  for (iMap = convMap.begin(); iMap != convMap.end(); iMap++) {
188  reco::ConversionRef convRef = iMap->first;
189  // std::vector<reco::TrackRef> tracks = convRef->tracks();
190  const std::vector<edm::RefToBase<reco::Track> > tracks = convRef->tracks();
191  float px = tracks[0]->innerMomentum().x();
192  float py = tracks[0]->innerMomentum().y();
193  float pz = tracks[0]->innerMomentum().z();
194  float p = sqrt(px * px + py * py + pz * pz);
195  ep = fabs(1. - convRef->caloCluster()[0]->energy() / p);
196  // std::cout << " 1-E/P = " << ep << std::endl;
197  if (ep < epMin) {
198  epMin = ep;
199  bestRef = iMap->first;
200  }
201  }
202  // std::cout << " Best conv 1-E/P " << ep << std::endl;
203  }
204 
205  return bestRef;
206 }
T sqrt(T t)
Definition: SSEVec.h:19

Member Data Documentation

edm::ParameterSet PhotonCoreProducer::conf_
private

Definition at line 57 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer().

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

Definition at line 52 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

double PhotonCoreProducer::minSCEt_
private

Definition at line 55 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and PhotonCoreProducer().

std::string PhotonCoreProducer::PhotonCoreCollection_
private

Definition at line 49 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

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

Definition at line 53 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

bool PhotonCoreProducer::risolveAmbiguity_
private

Definition at line 59 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and PhotonCoreProducer().

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

Definition at line 50 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

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

Definition at line 51 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

bool PhotonCoreProducer::validConversions_
private

Definition at line 56 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and produce().

bool PhotonCoreProducer::validPixelSeeds_
private

Definition at line 58 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and produce().