CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ConversionGSCrysFixer.cc
Go to the documentation of this file.
1 #include <memory>
10 
15 
17 
19 {
20  getToken(inputConvsToken_, config, "conversions");
21  getToken(ebSCsToken_, config, "superClusters", "particleFlowSuperClusterECALBarrel");
22  getToken(ebSCMapToken_, config, "scMaps", "parentSCsEB");
23  getToken(eeSCsToken_, config, "superClusters", "particleFlowSuperClusterECALEndcapWithPreshower");
24  getToken(eeSCMapToken_, config, "scMaps", "parentSCsEE");
25 
26  produces<reco::ConversionCollection>();
27 }
28 
30 {
31 }
32 
33 void
35 {
36  std::auto_ptr<reco::ConversionCollection> pOutput(new reco::ConversionCollection);
37 
38  auto& inputConvs(*getHandle(_event, inputConvsToken_, "conversions"));
39  auto ebSCs(getHandle(_event, ebSCsToken_, "ebSCs"));
40  auto& ebSCMap(*getHandle(_event, ebSCMapToken_, "ebSCMap"));
41  auto eeSCs(getHandle(_event, eeSCsToken_, "eeSCs"));
42  auto& eeSCMap(*getHandle(_event, eeSCMapToken_, "eeSCMap"));
43 
44  for (auto& inConv : inputConvs) {
45  pOutput->emplace_back(inConv);
46  auto& newConv(pOutput->back());
47 
49  for (auto ptr : inConv.caloCluster()) {
50  auto* sc(static_cast<reco::SuperCluster const*>(ptr.get()));
52  if (sc->seed()->seed().subdetId() == EcalBarrel)
53  newSC = GainSwitchTools::findNewRef(ptr, ebSCs, ebSCMap);
54  else
55  newSC = GainSwitchTools::findNewRef(ptr, eeSCs, eeSCMap);
56 
57  if (newSC.isNonnull())
58  clusters.push_back(edm::refToPtr(newSC));
59  }
60 
61  newConv.setMatchingSuperCluster(clusters);
62  }
63 
64  _event.put(pOutput);
65 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
edm::Handle< T > getHandle(edm::Event const &_event, edm::EDGetTokenT< T > const &token, std::string const &name)
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
edm::EDGetTokenT< SCRefMap > eeSCMapToken_
edm::EDGetTokenT< reco::ConversionCollection > inputConvsToken_
void produce(edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< reco::SuperClusterCollection > ebSCsToken_
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
edm::EDGetTokenT< SCRefMap > ebSCMapToken_
ConversionGSCrysFixer(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
edm::EDGetTokenT< reco::SuperClusterCollection > eeSCsToken_
void getToken(edm::EDGetTokenT< T > &token, edm::ParameterSet const &pset, std::string const &label, std::string const &instance="")
static edm::Ref< typename H::element_type > findNewRef(R const &, H const &, M const &)