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::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run &r, edm::EventSetup const &es)
 
virtual void endRun (edm::Run &, edm::EventSetup const &)
 
 PhotonCoreProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &evt, const edm::EventSetup &es)
 
 ~PhotonCoreProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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::InputTag conversionProducer_
 
double minSCEt_
 
std::string PhotonCoreCollection_
 
std::string pixelSeedProducer_
 
bool risolveAmbiguity_
 
edm::InputTag scHybridBarrelCollection_
 
edm::InputTag scHybridBarrelProducer_
 
edm::InputTag scIslandEndcapCollection_
 
edm::InputTag scIslandEndcapProducer_
 
bool validConversions_
 
bool validPixelSeeds_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Id:
PhotonCoreProducer.h,v 1.3 2010/02/22 19:30:49 nancy Exp
Date:
2010/02/22 19:30:49
Revision:
1.3
Author
Nancy Marinelli, U. of Notre Dame, US

Definition at line 34 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_, and scIslandEndcapProducer_.

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

Definition at line 39 of file PhotonCoreProducer.cc.

39 {}

Member Function Documentation

void PhotonCoreProducer::beginRun ( edm::Run r,
edm::EventSetup const &  es 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 43 of file PhotonCoreProducer.cc.

43  {
44 
45 }
void PhotonCoreProducer::endRun ( edm::Run r,
edm::EventSetup const &  theEventSetup 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 47 of file PhotonCoreProducer.cc.

47  {
48 
49 }
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 131 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().

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

Definition at line 54 of file PhotonCoreProducer.cc.

References printConversionInfo::conversionHandle, conversionProducer_, fillPhotonCollection(), edm::Event::getByLabel(), edm::InputTag::label(), PhotonCoreCollection_, pixelSeedProducer_, edm::Event::put(), scHybridBarrelProducer_, scIslandEndcapProducer_, validConversions_, and validPixelSeeds_.

54  {
55 
56 
57  using namespace edm;
58  // nEvt_++;
59 
60  reco::PhotonCoreCollection outputPhotonCoreCollection;
61  std::auto_ptr< reco::PhotonCoreCollection > outputPhotonCoreCollection_p(new reco::PhotonCoreCollection);
62 
63  // Get the Barrel Super Cluster collection
64  bool validBarrelSCHandle=true;
66  theEvent.getByLabel(scHybridBarrelProducer_,scBarrelHandle);
67  if (!scBarrelHandle.isValid()) {
68  edm::LogError("PhotonCoreProducer") << "Error! Can't get the product "<<scHybridBarrelProducer_.label();
69  validBarrelSCHandle=false;
70  }
71 
72 
73  // Get the Endcap Super Cluster collection
74  bool validEndcapSCHandle=true;
76  theEvent.getByLabel(scIslandEndcapProducer_,scEndcapHandle);
77  if (!scEndcapHandle.isValid()) {
78  edm::LogError("PhotonCoreProducer") << "Error! Can't get the product "<<scIslandEndcapProducer_.label();
79  validEndcapSCHandle=false;
80  }
81 
82 
84  validConversions_=true;
86  theEvent.getByLabel(conversionProducer_, conversionHandle);
87  if (!conversionHandle.isValid()) {
88  //edm::LogError("PhotonCoreProducer") << "Error! Can't get the product "<< conversionProducer_.label() << "\n" ;
89  validConversions_=false;
90  }
91 
92 
93 
94 
95  // Get ElectronPixelSeeds
96  validPixelSeeds_=true;
99  theEvent.getByLabel(pixelSeedProducer_, pixelSeedHandle);
100  if (!pixelSeedHandle.isValid()) {
101  validPixelSeeds_=false;
102  }
103  // if ( validPixelSeeds_) pixelSeeds = *(pixelSeedHandle.product());
104 
105 
106 
107  int iSC=0; // index in photon collection
108  // Loop over barrel and endcap SC collections and fill the photon collection
109  if ( validBarrelSCHandle) fillPhotonCollection(theEvent,
110  theEventSetup,
111  scBarrelHandle,
113  pixelSeedHandle,
114  outputPhotonCoreCollection,
115  iSC);
116  if ( validEndcapSCHandle) fillPhotonCollection(theEvent,
117  theEventSetup,
118  scEndcapHandle,
120  pixelSeedHandle,
121  outputPhotonCoreCollection,
122  iSC);
123 
124  // put the product in the event
125  edm::LogInfo("PhotonCoreProducer") << " Put in the event " << iSC << " Photon Candidates \n";
126  outputPhotonCoreCollection_p->assign(outputPhotonCoreCollection.begin(),outputPhotonCoreCollection.end());
127  theEvent.put( outputPhotonCoreCollection_p, PhotonCoreCollection_);
128 
129 }
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)
edm::InputTag scHybridBarrelProducer_
edm::InputTag conversionProducer_
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
std::string pixelSeedProducer_
edm::InputTag scIslandEndcapProducer_
std::string const & label() const
Definition: InputTag.h:25
std::vector< PhotonCore > PhotonCoreCollection
collectin of PhotonCore objects
Definition: PhotonCoreFwd.h:9
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 193 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().

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

Member Data Documentation

edm::ParameterSet PhotonCoreProducer::conf_
private

Definition at line 70 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer().

edm::InputTag PhotonCoreProducer::conversionProducer_
private

Definition at line 65 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

double PhotonCoreProducer::minSCEt_
private

Definition at line 67 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and PhotonCoreProducer().

std::string PhotonCoreProducer::PhotonCoreCollection_
private

Definition at line 59 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

std::string PhotonCoreProducer::pixelSeedProducer_
private

Definition at line 69 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

bool PhotonCoreProducer::risolveAmbiguity_
private

Definition at line 72 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and PhotonCoreProducer().

edm::InputTag PhotonCoreProducer::scHybridBarrelCollection_
private

Definition at line 62 of file PhotonCoreProducer.h.

edm::InputTag PhotonCoreProducer::scHybridBarrelProducer_
private

Definition at line 60 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

edm::InputTag PhotonCoreProducer::scIslandEndcapCollection_
private

Definition at line 63 of file PhotonCoreProducer.h.

edm::InputTag PhotonCoreProducer::scIslandEndcapProducer_
private

Definition at line 61 of file PhotonCoreProducer.h.

Referenced by PhotonCoreProducer(), and produce().

bool PhotonCoreProducer::validConversions_
private

Definition at line 68 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and produce().

bool PhotonCoreProducer::validPixelSeeds_
private

Definition at line 71 of file PhotonCoreProducer.h.

Referenced by fillPhotonCollection(), and produce().