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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 20 of file PhotonCoreProducer.cc.

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

20  :
21  conf_(config)
22 
23 {
24 
25  // use onfiguration file to setup input/output collection names
27  consumes<reco::SuperClusterCollection>(conf_.getParameter<edm::InputTag>("scHybridBarrelProducer"));
29  consumes<reco::SuperClusterCollection>(conf_.getParameter<edm::InputTag>("scIslandEndcapProducer"));
31  consumes<reco::ConversionCollection>(conf_.getParameter<edm::InputTag>("conversionProducer"));
32  PhotonCoreCollection_ = conf_.getParameter<std::string>("photonCoreCollection");
34  consumes<reco::ElectronSeedCollection>(conf_.getParameter<edm::InputTag>("pixelSeedProducer"));
35  minSCEt_ = conf_.getParameter<double>("minSCEt");
36  risolveAmbiguity_ = conf_.getParameter<bool>("risolveConversionAmbiguity");
37 
38  // Register the product
39  produces< reco::PhotonCoreCollection >(PhotonCoreCollection_);
40 
41 }
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 43 of file PhotonCoreProducer.cc.

43 {}

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

132  {
133 
134 
135 
136  reco::ElectronSeedCollection::const_iterator pixelSeedItr;
137  for(unsigned int lSC=0; lSC < scHandle->size(); lSC++) {
138 
139  // get SuperClusterRef
140  reco::SuperClusterRef scRef(reco::SuperClusterRef(scHandle, lSC));
141  iSC++;
142  //const reco::SuperCluster* pClus=&(*scRef);
143 
144  // SC energy preselection
145  if (scRef->energy()/cosh(scRef->eta()) <= minSCEt_) continue;
146 
147  reco::PhotonCore newCandidate(scRef);
148  newCandidate.setParentSuperCluster(scRef);
149  if ( validConversions_) {
150 
151  if ( risolveAmbiguity_ ) {
152  reco::ConversionRef bestRef=solveAmbiguity( conversionHandle , scRef);
153  if (bestRef.isNonnull() ) newCandidate.addConversion(bestRef);
154 
155  } else {
156 
157 
158  for( unsigned int icp = 0; icp < conversionHandle->size(); icp++) {
159  reco::ConversionRef cpRef(reco::ConversionRef(conversionHandle,icp));
160  if ( cpRef->caloCluster().empty()) continue;
161  if (!( scRef.id() == cpRef->caloCluster()[0].id() && scRef.key() == cpRef->caloCluster()[0].key() )) continue;
162  if ( !cpRef->isConverted() ) continue;
163  newCandidate.addConversion(cpRef);
164 
165  }
166 
167  } // solve or not the ambiguity of many conversion candidates
168 
169  }
170 
171  if ( validPixelSeeds_) {
172  for( unsigned int icp = 0; icp < pixelSeedHandle->size(); icp++) {
173  reco::ElectronSeedRef cpRef(reco::ElectronSeedRef(pixelSeedHandle,icp));
174  if ( ! cpRef->isEcalDriven() ) continue;
175  if (!( scRef.id() == cpRef->caloCluster().id() && scRef.key() == cpRef->caloCluster().key() )) continue;
176  newCandidate.addElectronPixelSeed(cpRef);
177  }
178  }
179 
180  outputPhotonCoreCollection.push_back(newCandidate);
181 
182  }
183 
184 
185 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
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 48 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_.

48  {
49 
50 
51  using namespace edm;
52  // nEvt_++;
53 
54  reco::PhotonCoreCollection outputPhotonCoreCollection;
55  auto outputPhotonCoreCollection_p = std::make_unique<reco::PhotonCoreCollection>();
56 
57  // Get the Barrel Super Cluster collection
58  bool validBarrelSCHandle=true;
60  theEvent.getByToken(scHybridBarrelProducer_,scBarrelHandle);
61  if (!scBarrelHandle.isValid()) {
62  edm::LogError("PhotonCoreProducer")
63  << "Error! Can't get the scHybridBarrelProducer";
64  validBarrelSCHandle=false;
65  }
66 
67 
68  // Get the Endcap Super Cluster collection
69  bool validEndcapSCHandle=true;
71  theEvent.getByToken(scIslandEndcapProducer_,scEndcapHandle);
72  if (!scEndcapHandle.isValid()) {
73  edm::LogError("PhotonCoreProducer")
74  << "Error! Can't get the scIslandEndcapProducer";
75  validEndcapSCHandle=false;
76  }
77 
78 
80  validConversions_=true;
82  theEvent.getByToken(conversionProducer_, conversionHandle);
83  if (!conversionHandle.isValid()) {
84  //edm::LogError("PhotonCoreProducer") << "Error! Can't get the product "<< conversionProducer_.label() << "\n" ;
85  validConversions_=false;
86  }
87 
88 
89 
90 
91  // Get ElectronPixelSeeds
92  validPixelSeeds_=true;
95  theEvent.getByToken(pixelSeedProducer_, pixelSeedHandle);
96  if (!pixelSeedHandle.isValid()) {
97  validPixelSeeds_=false;
98  }
99  // if ( validPixelSeeds_) pixelSeeds = *(pixelSeedHandle.product());
100 
101 
102 
103  int iSC=0; // index in photon collection
104  // Loop over barrel and endcap SC collections and fill the photon collection
105  if ( validBarrelSCHandle) fillPhotonCollection(theEvent,
106  theEventSetup,
107  scBarrelHandle,
108  conversionHandle,
109  pixelSeedHandle,
110  outputPhotonCoreCollection,
111  iSC);
112  if ( validEndcapSCHandle) fillPhotonCollection(theEvent,
113  theEventSetup,
114  scEndcapHandle,
115  conversionHandle,
116  pixelSeedHandle,
117  outputPhotonCoreCollection,
118  iSC);
119 
120  // put the product in the event
121  edm::LogInfo("PhotonCoreProducer") << " Put in the event " << iSC << " Photon Candidates \n";
122  outputPhotonCoreCollection_p->assign(outputPhotonCoreCollection.begin(),outputPhotonCoreCollection.end());
123  theEvent.put(std::move(outputPhotonCoreCollection_p), PhotonCoreCollection_);
124 
125 }
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:74
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:510
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 190 of file PhotonCoreProducer.cc.

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

Referenced by fillPhotonCollection().

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

Member Data Documentation

edm::ParameterSet PhotonCoreProducer::conf_
private

Definition at line 61 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer().

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

Definition at line 56 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

double PhotonCoreProducer::minSCEt_
private

Definition at line 59 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and PhotonCoreProducer().

std::string PhotonCoreProducer::PhotonCoreCollection_
private

Definition at line 53 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

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

Definition at line 57 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

bool PhotonCoreProducer::risolveAmbiguity_
private

Definition at line 63 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and PhotonCoreProducer().

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

Definition at line 54 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

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

Definition at line 55 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

bool PhotonCoreProducer::validConversions_
private

Definition at line 60 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and produce().

bool PhotonCoreProducer::validPixelSeeds_
private

Definition at line 62 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and produce().