CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual void produce (edm::Event &evt, const edm::EventSetup &es)
 
 ~PhotonCoreProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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_
 
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<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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_
edm::EDGetTokenT< reco::SuperClusterCollection > scHybridBarrelProducer_
edm::EDGetTokenT< reco::SuperClusterCollection > scIslandEndcapProducer_
std::string PhotonCoreCollection_
PhotonCoreProducer::~PhotonCoreProducer ( )

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_, 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  if ( validConversions_) {
149 
150  if ( risolveAmbiguity_ ) {
151  reco::ConversionRef bestRef=solveAmbiguity( conversionHandle , scRef);
152  if (bestRef.isNonnull() ) newCandidate.addConversion(bestRef);
153 
154  } else {
155 
156 
157  for( unsigned int icp = 0; icp < conversionHandle->size(); icp++) {
158  reco::ConversionRef cpRef(reco::ConversionRef(conversionHandle,icp));
159  if ( !cpRef->caloCluster().size()) continue;
160  if (!( scRef.id() == cpRef->caloCluster()[0].id() && scRef.key() == cpRef->caloCluster()[0].key() )) continue;
161  if ( !cpRef->isConverted() ) continue;
162  newCandidate.addConversion(cpRef);
163 
164  }
165 
166  } // solve or not the ambiguity of many conversion candidates
167 
168  }
169 
170  if ( validPixelSeeds_) {
171  for( unsigned int icp = 0; icp < pixelSeedHandle->size(); icp++) {
172  reco::ElectronSeedRef cpRef(reco::ElectronSeedRef(pixelSeedHandle,icp));
173  if ( ! cpRef->isEcalDriven() ) continue;
174  if (!( scRef.id() == cpRef->caloCluster().id() && scRef.key() == cpRef->caloCluster().key() )) continue;
175  newCandidate.addElectronPixelSeed(cpRef);
176  }
177  }
178 
179  outputPhotonCoreCollection.push_back(newCandidate);
180 
181  }
182 
183 
184 }
reco::ConversionRef solveAmbiguity(const edm::Handle< reco::ConversionCollection > &conversionHandle, reco::SuperClusterRef &sc)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void PhotonCoreProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::stream::EDProducerBase.

Definition at line 48 of file PhotonCoreProducer.cc.

References printConversionInfo::conversionHandle, conversionProducer_, fillPhotonCollection(), edm::Event::getByToken(), 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  std::auto_ptr< reco::PhotonCoreCollection > outputPhotonCoreCollection_p(new 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,
109  pixelSeedHandle,
110  outputPhotonCoreCollection,
111  iSC);
112  if ( validEndcapSCHandle) fillPhotonCollection(theEvent,
113  theEventSetup,
114  scEndcapHandle,
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( 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
edm::EDGetTokenT< reco::SuperClusterCollection > scHybridBarrelProducer_
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 189 of file PhotonCoreProducer.cc.

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

Referenced by fillPhotonCollection().

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

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