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

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