CMS 3D CMS Logo

HiEvtPlaneFlatProducer.cc
Go to the documentation of this file.
1 #include <memory>
4 
7 
9 #include "Math/Vector3D.h"
10 
15 
17 
23 
31 
33 #include <ctime>
34 #include <cstdlib>
35 
38 
39 using namespace std;
40 using namespace hi;
41 
42 #include <vector>
43 using std::vector;
44 
45 //
46 // class declaration
47 //
48 
50 public:
52  ~HiEvtPlaneFlatProducer() override;
53 
54 private:
55  void produce(edm::Event&, const edm::EventSetup&) override;
56 
57  // ----------member data ---------------------------
58 
62 
65 
68 
71 
74 
78 
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  }
119 
120  centralityBinToken_ = consumes<int>(centralityBinTag_);
121 
122  centralityToken_ = consumes<reco::Centrality>(centralityTag_);
123 
124  vertexToken_ = consumes<std::vector<reco::Vertex>>(vertexTag_);
125 
126  trackToken_ = consumes<reco::TrackCollection>(trackTag_);
127 
128  inputPlanesToken_ = consumes<reco::EvtPlaneCollection>(inputPlanesTag_);
129 
130  //register your products
131  produces<reco::EvtPlaneCollection>();
132  //now do what ever other initialization is needed
133  for (int i = 0; i < NumEPNames; i++) {
134  flat[i] = new HiEvtPlaneFlatten();
136  }
137 }
138 
140  // do anything here that needs to be done at desctruction time
141  // (e.g. close files, deallocate resources etc.)
142  for (int i = 0; i < NumEPNames; i++) {
143  delete flat[i];
144  }
145 }
146 
147 //
148 // member functions
149 //
150 
151 // ------------ method called to produce the data ------------
153  using namespace edm;
154  using namespace std;
155  using namespace reco;
156 
157  if (hiWatcher.check(iSetup)) {
158  //
159  //Get Size of Centrality Table
160  //
162  iSetup.get<HeavyIonRcd>().get(centralityLabel_, centDB_);
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)) {
181  edm::ESHandle<RPFlatParams> flatparmsDB_;
182  iSetup.get<HeavyIonRPRcd>().get(flatparmsDB_);
183  LoadEPDB db(flatparmsDB_, flat);
184  } //rp record change
185 
186  //
187  //Get Centrality
188  //
189  int bin = 0;
190  int cbin = 0;
191  cbin = iEvent.get(centralityBinToken_);
192  bin = cbin / CentBinCompression_;
193  //
194  //Get Vertex
195  //
196 
197  //best vertex
198  double bestvz = -999.9;
199  const reco::Vertex& vtx = iEvent.get(vertexToken_)[0];
200  bestvz = vtx.z();
201 
202  //
203  //Get Event Planes
204  //
205 
206  auto const& evtPlanes = iEvent.get(inputPlanesToken_);
207 
208  auto evtplaneOutput = std::make_unique<EvtPlaneCollection>();
210  for (int i = 0; i < NumEPNames; i++) {
211  ep[i] = nullptr;
212  }
213  int indx = 0;
214  for (auto&& rp : (evtPlanes)) {
215  double s = rp.sumSin(0);
216  double c = rp.sumCos(0);
217  uint m = rp.mult();
218  double soff = s;
219  double coff = c;
220  double psiOffset = -10;
221  double psiFlat = -10;
222  if (rp.angle(0) > -5) {
223  if (useOffsetPsi_) {
224  soff = flat[indx]->soffset(s, bestvz, bin);
225  coff = flat[indx]->coffset(c, bestvz, bin);
226  psiOffset = flat[indx]->offsetPsi(soff, coff);
227  }
228  psiFlat = flat[indx]->getFlatPsi(psiOffset, bestvz, bin);
229  }
230  ep[indx] = new EvtPlane(indx, 2, psiFlat, soff, coff, rp.sumw(), rp.sumw2(), rp.sumPtOrEt(), rp.sumPtOrEt2(), m);
231  ep[indx]->addLevel(0, rp.angle(0), s, c);
232  ep[indx]->addLevel(3, 0., rp.sumSin(3), rp.sumCos(3));
233  if (useOffsetPsi_)
234  ep[indx]->addLevel(1, psiOffset, soff, coff);
235  ++indx;
236  }
237 
238  for (int i = 0; i < NumEPNames; i++) {
239  if (ep[i] != nullptr)
240  evtplaneOutput->push_back(*ep[i]);
241  }
242  iEvent.put(std::move(evtplaneOutput));
243  for (int i = 0; i < indx; i++)
244  delete ep[i];
245 }
246 
247 //define this as a plug-in
HiEvtPlaneFlatProducer::centralityTag_
edm::InputTag centralityTag_
Definition: HiEvtPlaneFlatProducer.cc:66
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
EvtPlane.h
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
HiEvtPlaneFlatProducer::~HiEvtPlaneFlatProducer
~HiEvtPlaneFlatProducer() override
Definition: HiEvtPlaneFlatProducer.cc:139
mps_fire.i
i
Definition: mps_fire.py:428
HiEvtPlaneFlatten::setCaloCentRefBins
void setCaloCentRefBins(const int caloCentRefMinBin, const int caloCentRefMaxBin)
Definition: HiEvtPlaneFlatten.h:139
edm::ESWatcher< HeavyIonRcd >
HiEvtPlaneFlatProducer::caloCentRefWidth_
double caloCentRefWidth_
Definition: HiEvtPlaneFlatProducer.cc:88
ESHandle.h
HiEvtPlaneFlatProducer::centralityLabel_
std::string centralityLabel_
Definition: HiEvtPlaneFlatProducer.cc:60
HiEvtPlaneFlatProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HiEvtPlaneFlatProducer.cc:152
edm::EDGetTokenT< int >
edm
HLT enums.
Definition: AlignableModifier.h:19
CentralityTable.h
HiEvtPlaneFlatten
Definition: HiEvtPlaneFlatten.h:27
LoadEPDB
Definition: LoadEPDB.h:28
HeavyIonRPRcd
Definition: HeavyIonRPRcd.h:24
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
HiEvtPlaneFlatProducer::inputPlanesToken_
edm::EDGetTokenT< reco::EvtPlaneCollection > inputPlanesToken_
Definition: HiEvtPlaneFlatProducer.cc:73
hi::EPNames
const std::array< std::string, NumEPNames > EPNames
Definition: HiEvtPlaneList.h:30
EDProducer.h
HeavyIonRPRcd.h
HiEvtPlaneFlatProducer::trackCollection_
edm::Handle< reco::TrackCollection > trackCollection_
Definition: HiEvtPlaneFlatProducer.cc:77
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
hi::EPOrder
const std::array< int, NumEPNames > EPOrder
Definition: HiEvtPlaneList.h:44
edm::Handle< reco::TrackCollection >
parallelization.uint
uint
Definition: parallelization.py:124
HiEvtPlaneFlatProducer::flatdelvtx_
double flatdelvtx_
Definition: HiEvtPlaneFlatProducer.cc:86
HeavyIonRcd.h
dqmiodatasetharvest.db
db
Definition: dqmiodatasetharvest.py:119
HiEvtPlaneFlatProducer::flatnvtxbins_
int flatnvtxbins_
Definition: HiEvtPlaneFlatProducer.cc:84
MakerMacros.h
HiEvtPlaneFlatten::getFlatPsi
double getFlatPsi(double psi, double vtx, int centbin) const
Definition: HiEvtPlaneFlatten.h:173
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HiEvtPlaneFlatProducer::NumFlatBins_
int NumFlatBins_
Definition: HiEvtPlaneFlatProducer.cc:83
PoolDBOutputService.h
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HiEvtPlaneFlatProducer::hirpWatcher
edm::ESWatcher< HeavyIonRPRcd > hirpWatcher
Definition: HiEvtPlaneFlatProducer.cc:80
Service.h
Centrality.h
HiEvtPlaneFlatten::coffset
double coffset(double c, double vtx, int centbin) const
Definition: HiEvtPlaneFlatten.h:196
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
HiEvtPlaneFlatProducer::centralityVariable_
std::string centralityVariable_
Definition: HiEvtPlaneFlatProducer.cc:59
CentralityTable::m_table
std::vector< CBin > m_table
Definition: CentralityTable.h:39
edm::ESHandle< CentralityTable >
HiEvtPlaneFlatProducer::centralityToken_
edm::EDGetTokenT< reco::Centrality > centralityToken_
Definition: HiEvtPlaneFlatProducer.cc:67
HiEvtPlaneFlatten::soffset
double soffset(double s, double vtx, int centbin) const
Definition: HiEvtPlaneFlatten.h:187
HiEvtPlaneFlatProducer::nCentBins_
double nCentBins_
Definition: HiEvtPlaneFlatProducer.cc:92
HiEvtPlaneFlatProducer::FlatOrder_
const int FlatOrder_
Definition: HiEvtPlaneFlatProducer.cc:82
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
Castor
TFileService.h
HiEvtPlaneFlatProducer::centralityBinTag_
edm::InputTag centralityBinTag_
Definition: HiEvtPlaneFlatProducer.cc:63
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
HiEvtPlaneFlatProducer::hiWatcher
edm::ESWatcher< HeavyIonRcd > hiWatcher
Definition: HiEvtPlaneFlatProducer.cc:79
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
reco::EvtPlane
Definition: EvtPlane.h:20
LoadEPDB.h
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
HiEvtPlaneList.h
get
#define get
hi::EPDet
const std::array< int, NumEPNames > EPDet
Definition: HiEvtPlaneList.h:38
CaloTowerCollection.h
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
HiEvtPlaneFlatProducer::trackTag_
edm::InputTag trackTag_
Definition: HiEvtPlaneFlatProducer.cc:75
VertexFwd.h
hi
Definition: EPCuts.h:4
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HiEvtPlaneFlatProducer::flatminvtx_
double flatminvtx_
Definition: HiEvtPlaneFlatProducer.cc:85
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
Frameworkfwd.h
ESWatcher.h
HiEvtPlaneFlatProducer::CentBinCompression_
int CentBinCompression_
Definition: HiEvtPlaneFlatProducer.cc:89
HiEvtPlaneFlatProducer::trackToken_
edm::EDGetTokenT< reco::TrackCollection > trackToken_
Definition: HiEvtPlaneFlatProducer.cc:76
HiEvtPlaneFlatProducer::centralityBinToken_
edm::EDGetTokenT< int > centralityBinToken_
Definition: HiEvtPlaneFlatProducer.cc:64
HiEvtPlaneFlatProducer::inputPlanesTag_
edm::InputTag inputPlanesTag_
Definition: HiEvtPlaneFlatProducer.cc:72
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HiEvtPlaneFlatProducer::caloCentRef_
double caloCentRef_
Definition: HiEvtPlaneFlatProducer.cc:87
HiEvtPlaneFlatProducer::useOffsetPsi_
bool useOffsetPsi_
Definition: HiEvtPlaneFlatProducer.cc:91
hi::NumEPNames
static const int NumEPNames
Definition: HiEvtPlaneList.h:28
HiEvtPlaneFlatten::init
void init(int order, int nbins, int nvtxbins=10, double minvtx=-25, double delvtx=5, std::string tag="", int vord=2)
Definition: HiEvtPlaneFlatten.h:35
HiEvtPlaneFlatten::offsetPsi
double offsetPsi(double s, double c) const
Definition: HiEvtPlaneFlatten.h:204
HeavyIonRcd
Definition: HeavyIonRcd.h:24
HiEvtPlaneFlatProducer::HiEvtPlaneFlatProducer
HiEvtPlaneFlatProducer(const edm::ParameterSet &)
Definition: HiEvtPlaneFlatProducer.cc:97
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
edm::Event
Definition: Event.h:73
RPFlatParams.h
DigiToRawDM_cff.HF
HF
Definition: DigiToRawDM_cff.py:22
HiEvtPlaneFlatProducer
Definition: HiEvtPlaneFlatProducer.cc:49
HiEvtPlaneFlatProducer::vertexTag_
edm::InputTag vertexTag_
Definition: HiEvtPlaneFlatProducer.cc:69
HiEvtPlaneFlatProducer::flat
HiEvtPlaneFlatten * flat[NumEPNames]
Definition: HiEvtPlaneFlatProducer.cc:90
HiEvtPlaneFlatProducer::vertexToken_
edm::EDGetTokenT< std::vector< reco::Vertex > > vertexToken_
Definition: HiEvtPlaneFlatProducer.cc:70
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::InputTag
Definition: InputTag.h:15
HiEvtPlaneFlatProducer::centralityMC_
std::string centralityMC_
Definition: HiEvtPlaneFlatProducer.cc:61
reco::Vertex
Definition: Vertex.h:35
HiEvtPlaneFlatten.h