CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VoronoiBackgroundProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <iostream>
4 
5 // user include files
8 
11 
13 
18 
20 
21 using namespace std;
22 //
23 // class declaration
24 //
25 
27  public:
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33  private:
34  virtual void produce(edm::Event&, const edm::EventSetup&);
35 
36  // ----------member data ---------------------------
37 
43  double equalizeR_;
44  bool isCalo_;
45  int etaBins_;
47  std::vector<reco::VoronoiBackground> vvm;
48 
49 };
50 
51 //
52 // constants, enums and typedefs
53 //
54 
55 
56 //
57 // static data member definitions
58 //
59 
60 //
61 // constructors and destructor
62 //
64  voronoi_(0),
65  doEqualize_(iConfig.getParameter<bool>("doEqualize")),
66  equalizeThreshold0_(iConfig.getParameter<double>("equalizeThreshold0")),
67  equalizeThreshold1_(iConfig.getParameter<double>("equalizeThreshold1")),
68  equalizeR_(iConfig.getParameter<double>("equalizeR")),
69  isCalo_(iConfig.getParameter<bool>("isCalo")),
70  etaBins_(iConfig.getParameter<int>("etaBins")),
71  fourierOrder_(iConfig.getParameter<int>("fourierOrder"))
72 {
73 
74  src_ = iConfig.getParameter<edm::InputTag>("src");
75  //register your products
76 
77  produces<reco::VoronoiMap>();
78  produces<std::vector<float> >();
79 }
80 
81 
83 {
84 }
85 
86 
87 //
88 // member functions
89 //
90 
91 // ------------ method called to produce the data ------------
92 void
94 {
95  using namespace edm;
96  if(voronoi_ == 0){
97  bool data = iEvent.isRealData();
99  }
100 
101  voronoi_->clear();
102  vvm.clear();
103 
105  iEvent.getByLabel(src_,inputsHandle);
106 
107  for(unsigned int i = 0; i < inputsHandle->size(); ++i){
108  reco::CandidateViewRef ref(inputsHandle,i);
109  voronoi_->push_back_particle(ref->pt(),ref->eta(),ref->phi(),0);
110  }
111 
112  std::vector<double> subtracted_momenta = voronoi_->subtracted_unequalized_perp();
113  std::vector<double> equalized_momenta = voronoi_->subtracted_equalized_perp();
114  std::vector<double> particle_area = voronoi_->particle_area();
115  std::vector<double> voronoi_vn = voronoi_->perp_fourier();
116  std::auto_ptr<std::vector<float> > vnout(new std::vector<float>(voronoi_vn.begin(), voronoi_vn.end()));
117  std::auto_ptr<reco::VoronoiMap> mapout(new reco::VoronoiMap());
118  reco::VoronoiMap::Filler filler(*mapout);
119 
120  for(unsigned int i = 0; i < inputsHandle->size(); ++i){
121  reco::CandidateViewRef ref(inputsHandle,i);
122  const double pre_eq_pt = subtracted_momenta[i];
123  const double post_eq_pt = equalized_momenta[i];
124  const double area = particle_area[i];
125  const double mass_square = ref->massSqr();
126  const double pre_eq_mt = sqrt(mass_square + pre_eq_pt * pre_eq_pt);
127  const double post_eq_mt = sqrt(mass_square + post_eq_pt * post_eq_pt);
128 
129  reco::VoronoiBackground bkg(pre_eq_pt,post_eq_pt,pre_eq_mt,post_eq_mt,area);
130  LogDebug("VoronoiBackgroundProducer")<<"Subtraction --- oldpt : "<<ref->pt()<<" --- newpt : "<<post_eq_pt<<endl;
131  vvm.push_back(bkg);
132  }
133 
134  filler.insert(inputsHandle,vvm.begin(),vvm.end());
135  filler.fill();
136  iEvent.put(vnout);
137  iEvent.put(mapout);
138 
139 }
140 
141 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
142 void
145  desc.setUnknown();
146  descriptions.addDefault(desc);
147 }
148 
149 //define this as a plug-in
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< double > perp_fourier(void)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
virtual void produce(edm::Event &, const edm::EventSetup &)
bool isRealData() const
Definition: EventBase.h:60
std::vector< double > particle_area(void)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:243
void push_back_particle(const double perp, const double pseudorapidity, const double azimuth, const unsigned int reduced_particle_flow_id)
void addDefault(ParameterSetDescription const &psetDescription)
VoronoiBackgroundProducer(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
T sqrt(T t)
Definition: SSEVec.h:46
std::vector< reco::VoronoiBackground > vvm
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< double > subtracted_unequalized_perp(void)
std::vector< double > subtracted_equalized_perp(void)