CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTRemoveDuplicatedSC.cc
Go to the documentation of this file.
5 
11 
12 #include <string>
13 
15 {
16 
17 
18  // the input producers
19  sCInputProducer_ = consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("L1NonIsoUskimmedSC"));
20  alreadyExistingSC_= consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("L1IsoSC"));
21 
22  // set the producer parameters
23  outputCollection_ = ps.getParameter<std::string>("L1NonIsoSkimmedCollection");
24  produces<reco::SuperClusterCollection>(outputCollection_);
25 
26 }
27 
29 {}
30 
32 
34  desc.add<edm::InputTag>(("L1NonIsoUskimmedSC"), edm::InputTag("hltCorrectedMulti5x5EndcapSuperClustersWithPreshowerL1NonIsolatedTemp"));
35  desc.add<edm::InputTag>(("L1IsoSC"), edm::InputTag("hltCorrectedMulti5x5EndcapSuperClustersWithPreshowerL1Isolated"));
36  desc.add<std::string>(("L1NonIsoSkimmedCollection"), "");
37  descriptions.add(("hltEgammaHLTRemoveDuplicatedSC"), desc);
38 }
39 
40 
41 void
43 
44  using namespace edm;
45 
46  // Get raw SuperClusters from the event
47  Handle<reco::SuperClusterCollection> UnskimmedSuperCluster;
48  evt.getByToken(sCInputProducer_, UnskimmedSuperCluster);
49  Handle<reco::SuperClusterCollection> L1IsoSuperCluster;
50  evt.getByToken(alreadyExistingSC_, L1IsoSuperCluster);
51 
52  // Create a pointer to the existing SuperClusters
53  const reco::SuperClusterCollection *UnskimmedL1NonIsoSC = UnskimmedSuperCluster.product();
54  const reco::SuperClusterCollection *L1IsoSC = L1IsoSuperCluster.product();
55 
56 
57  // Define a collection of corrected SuperClusters to put back into the event
58  std::auto_ptr<reco::SuperClusterCollection> corrClusters(new reco::SuperClusterCollection);
59 
60  // Loop over raw clusters and make corrected ones
61  reco::SuperClusterCollection::const_iterator aClus;
62  reco::SuperClusterCollection::const_iterator cit;
63  for(aClus = UnskimmedL1NonIsoSC->begin(); aClus != UnskimmedL1NonIsoSC->end(); aClus++)
64  {
65  bool AlreadyThere = false;
66  //reco::SuperCluster newClus;
67  for(cit = L1IsoSC->begin(); cit != L1IsoSC->end(); cit++){
68  if( fabs(aClus->energy()- cit->energy()) < 0.5 && fabs(aClus->eta()- cit->eta()) < 0.0175 ){
69  float deltaphi=fabs( aClus->phi() - cit->phi() );
70  if(deltaphi>6.283185308) deltaphi -= 6.283185308;
71  if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi;
72 
73  if( deltaphi < 0.035 ){AlreadyThere = true; break;}
74  }
75  }
76  // if(AlreadyThere){std::cout<<"AAAA: SC removed: "<<aClus->energy()<<" "<<aClus->eta()<<" "<<aClus->phi()<<std::endl;}
77  if(!AlreadyThere){corrClusters->push_back(*aClus);}
78  }
79 
80  // Put collection of corrected SuperClusters into the event
81  evt.put(corrClusters, outputCollection_);
82 
83 }
84 
85 
86 
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
EgammaHLTRemoveDuplicatedSC(const edm::ParameterSet &)
edm::EDGetTokenT< reco::SuperClusterCollection > sCInputProducer_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< reco::SuperClusterCollection > alreadyExistingSC_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void produce(edm::Event &, const edm::EventSetup &) override