CMS 3D CMS Logo

HiEvtPlaneFlatProducer.cc
Go to the documentation of this file.
1 #include <memory>
4 
7 
9 #include "Math/Vector3D.h"
10 
14 
16 
22 
30 
32 #include <ctime>
33 #include <cstdlib>
34 
37 
38 using namespace std;
39 using namespace hi;
40 
41 #include <vector>
42 using std::vector;
43 
44 //
45 // class declaration
46 //
47 
49 public:
51  ~HiEvtPlaneFlatProducer() override;
52 
53 private:
54  void produce(edm::Event&, const edm::EventSetup&) override;
55 
56  // ----------member data ---------------------------
57 
60 
63 
66 
69 
72 
76 
81 
82  const int FlatOrder_;
85  double flatminvtx_;
86  double flatdelvtx_;
87  double caloCentRef_;
92  double nCentBins_;
93 };
94 //
95 // constructors and destructor
96 //
98  : centralityVariable_(iConfig.getParameter<std::string>("centralityVariable")),
99  centralityBinTag_(iConfig.getParameter<edm::InputTag>("centralityBinTag")),
100  centralityTag_(iConfig.getParameter<edm::InputTag>("centralityTag")),
101  vertexTag_(iConfig.getParameter<edm::InputTag>("vertexTag")),
102  inputPlanesTag_(iConfig.getParameter<edm::InputTag>("inputPlanesTag")),
103  trackTag_(iConfig.getParameter<edm::InputTag>("trackTag")),
104  FlatOrder_(iConfig.getParameter<int>("FlatOrder")),
105  NumFlatBins_(iConfig.getParameter<int>("NumFlatBins")),
106  flatnvtxbins_(iConfig.getParameter<int>("flatnvtxbins")),
107  flatminvtx_(iConfig.getParameter<double>("flatminvtx")),
108  flatdelvtx_(iConfig.getParameter<double>("flatdelvtx")),
109  caloCentRef_(iConfig.getParameter<double>("caloCentRef")),
110  caloCentRefWidth_(iConfig.getParameter<double>("caloCentRefWidth")),
111  CentBinCompression_(iConfig.getParameter<int>("CentBinCompression")),
112  useOffsetPsi_(iConfig.getParameter<bool>("useOffsetPsi")) {
113  nCentBins_ = 200.;
114 
115  if (iConfig.exists("nonDefaultGlauberModel")) {
116  centralityMC_ = iConfig.getParameter<std::string>("nonDefaultGlauberModel");
117  }
120 
121  centralityBinToken_ = consumes<int>(centralityBinTag_);
122 
123  centralityToken_ = consumes<reco::Centrality>(centralityTag_);
124 
125  vertexToken_ = consumes<std::vector<reco::Vertex>>(vertexTag_);
126 
127  trackToken_ = consumes<reco::TrackCollection>(trackTag_);
128 
129  inputPlanesToken_ = consumes<reco::EvtPlaneCollection>(inputPlanesTag_);
130 
131  //register your products
132  produces<reco::EvtPlaneCollection>();
133  //now do what ever other initialization is needed
134  for (int i = 0; i < NumEPNames; i++) {
135  flat[i] = new HiEvtPlaneFlatten();
137  }
138 }
139 
141  // do anything here that needs to be done at desctruction time
142  // (e.g. close files, deallocate resources etc.)
143  for (int i = 0; i < NumEPNames; i++) {
144  delete flat[i];
145  }
146 }
147 
148 //
149 // member functions
150 //
151 
152 // ------------ method called to produce the data ------------
154  using namespace edm;
155  using namespace std;
156  using namespace reco;
157 
158  if (hiWatcher.check(iSetup)) {
159  //
160  //Get Size of Centrality Table
161  //
162  auto const& centDB = iSetup.getData(centralityESToken_);
163  nCentBins_ = centDB.m_table.size();
164  for (int i = 0; i < NumEPNames; i++) {
165  if (caloCentRef_ > 0) {
166  int minbin = (caloCentRef_ - caloCentRefWidth_ / 2.) * nCentBins_ / 100.;
167  int maxbin = (caloCentRef_ + caloCentRefWidth_ / 2.) * nCentBins_ / 100.;
168  minbin /= CentBinCompression_;
169  maxbin /= CentBinCompression_;
170  if (minbin > 0 && maxbin >= minbin) {
171  if (EPDet[i] == HF || EPDet[i] == Castor)
172  flat[i]->setCaloCentRefBins(minbin, maxbin);
173  }
174  }
175  }
176  }
177  //
178  //Get flattening parameter file.
179  //
180  if (hirpWatcher.check(iSetup)) {
182  } //rp record change
183 
184  //
185  //Get Centrality
186  //
187  int bin = 0;
188  int cbin = 0;
189  cbin = iEvent.get(centralityBinToken_);
190  bin = cbin / CentBinCompression_;
191  //
192  //Get Vertex
193  //
194 
195  //best vertex
196  double bestvz = -999.9;
197  const reco::Vertex& vtx = iEvent.get(vertexToken_)[0];
198  bestvz = vtx.z();
199 
200  //
201  //Get Event Planes
202  //
203 
204  auto const& evtPlanes = iEvent.get(inputPlanesToken_);
205 
206  auto evtplaneOutput = std::make_unique<EvtPlaneCollection>();
208  for (int i = 0; i < NumEPNames; i++) {
209  ep[i] = nullptr;
210  }
211  int indx = 0;
212  for (auto&& rp : (evtPlanes)) {
213  double s = rp.sumSin(0);
214  double c = rp.sumCos(0);
215  uint m = rp.mult();
216  double soff = s;
217  double coff = c;
218  double psiOffset = -10;
219  double psiFlat = -10;
220  if (rp.angle(0) > -5) {
221  if (useOffsetPsi_) {
222  soff = flat[indx]->soffset(s, bestvz, bin);
223  coff = flat[indx]->coffset(c, bestvz, bin);
224  psiOffset = flat[indx]->offsetPsi(soff, coff);
225  }
226  psiFlat = flat[indx]->getFlatPsi(psiOffset, bestvz, bin);
227  }
228  ep[indx] = new EvtPlane(indx, 2, psiFlat, soff, coff, rp.sumw(), rp.sumw2(), rp.sumPtOrEt(), rp.sumPtOrEt2(), m);
229  ep[indx]->addLevel(0, rp.angle(0), s, c);
230  ep[indx]->addLevel(3, 0., rp.sumSin(3), rp.sumCos(3));
231  if (useOffsetPsi_)
232  ep[indx]->addLevel(1, psiOffset, soff, coff);
233  ++indx;
234  }
235 
236  for (int i = 0; i < NumEPNames; i++) {
237  if (ep[i] != nullptr)
238  evtplaneOutput->push_back(*ep[i]);
239  }
240  iEvent.put(std::move(evtplaneOutput));
241  for (int i = 0; i < indx; i++)
242  delete ep[i];
243 }
244 
245 //define this as a plug-in
double offsetPsi(double s, double c) const
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< int > centralityBinToken_
edm::ESGetToken< RPFlatParams, HeavyIonRPRcd > flatparmsToken_
edm::EDGetTokenT< reco::Centrality > centralityToken_
edm::ESWatcher< HeavyIonRcd > hiWatcher
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< reco::TrackCollection > trackToken_
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::ESGetToken< CentralityTable, HeavyIonRcd > centralityESToken_
void setCaloCentRefBins(const int caloCentRefMinBin, const int caloCentRefMaxBin)
HiEvtPlaneFlatten * flat[NumEPNames]
int iEvent
Definition: GenABIO.cc:224
Definition: EPCuts.h:4
void produce(edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< std::vector< reco::Vertex > > vertexToken_
double getFlatPsi(double psi, double vtx, int centbin) const
const std::array< int, NumEPNames > EPDet
bool getData(T &iHolder) const
Definition: EventSetup.h:122
double coffset(double c, double vtx, int centbin) const
void init(int order, int nbins, int nvtxbins=10, double minvtx=-25, double delvtx=5, std::string tag="", int vord=2)
HiEvtPlaneFlatProducer(const edm::ParameterSet &)
double soffset(double s, double vtx, int centbin) const
edm::EDGetTokenT< reco::EvtPlaneCollection > inputPlanesToken_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
fixed size matrix
edm::Handle< reco::TrackCollection > trackCollection_
HLT enums.
edm::ESWatcher< HeavyIonRPRcd > hirpWatcher
const std::array< int, NumEPNames > EPOrder
const std::array< std::string, NumEPNames > EPNames
static const int NumEPNames
def move(src, dest)
Definition: eostools.py:511