CMS 3D CMS Logo

HiEvtPlaneFlatProducer.cc
Go to the documentation of this file.
3 
6 
8 #include "Math/Vector3D.h"
9 
14 
16 
22 
30 
32 
35 
36 #include "TList.h"
37 #include "TString.h"
38 
39 #include <vector>
40 #include <ctime>
41 #include <cstdlib>
42 #include <memory>
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 
61 
64 
67 
70 
73 
77 
80 
81  const int FlatOrder_;
83  double caloCentRef_;
86  int Noffmin_;
87  int Noffmax_;
90 };
91 
93  : centralityVariable_(iConfig.getParameter<std::string>("centralityVariable")),
94  centralityBinTag_(iConfig.getParameter<edm::InputTag>("centralityBinTag")),
95  centralityTag_(iConfig.getParameter<edm::InputTag>("centralityTag")),
96  vertexTag_(iConfig.getParameter<edm::InputTag>("vertexTag")),
97  inputPlanesTag_(iConfig.getParameter<edm::InputTag>("inputPlanesTag")),
98  trackTag_(iConfig.getParameter<edm::InputTag>("trackTag")),
99  FlatOrder_(iConfig.getParameter<int>("FlatOrder")),
100  NumFlatBins_(iConfig.getParameter<int>("NumFlatBins")),
101  caloCentRef_(iConfig.getParameter<double>("caloCentRef")),
102  caloCentRefWidth_(iConfig.getParameter<double>("caloCentRefWidth")),
103  CentBinCompression_(iConfig.getParameter<int>("CentBinCompression")),
104  Noffmin_(iConfig.getParameter<int>("Noffmin")),
105  Noffmax_(iConfig.getParameter<int>("Noffmax")),
106  useOffsetPsi_(iConfig.getParameter<bool>("useOffsetPsi")) {
107  if (iConfig.exists("nonDefaultGlauberModel")) {
108  centralityMC_ = iConfig.getParameter<std::string>("nonDefaultGlauberModel");
109  }
111 
112  centralityBinToken = consumes<int>(centralityBinTag_);
113 
114  centralityToken = consumes<reco::Centrality>(centralityTag_);
115 
116  vertexToken = consumes<std::vector<reco::Vertex>>(vertexTag_);
117 
118  trackToken = consumes<reco::TrackCollection>(trackTag_);
119 
120  inputPlanesToken = consumes<reco::EvtPlaneCollection>(inputPlanesTag_);
121 
122  //register your products
123  produces<reco::EvtPlaneCollection>();
124  //now do what ever other initialization is needed
125  for (int i = 0; i < hi::NumEPNames; i++) {
126  flat[i] = new HiEvtPlaneFlatten();
128  }
129 }
130 
132  // do anything here that needs to be done at desctruction time
133  // (e.g. close files, deallocate resources etc.)
134  for (int i = 0; i < hi::NumEPNames; i++) {
135  delete flat[i];
136  }
137 }
138 
139 // ------------ method called to produce the data ------------
141  using namespace edm;
142  using namespace std;
143  using namespace reco;
144  using namespace hi;
145 
146  //
147  //Get Flattening Parameters
148  //
149  if (hiWatcher.check(iSetup)) {
150  //
151  //Get Size of Centrality Table
152  //
154  iSetup.get<HeavyIonRcd>().get(centralityLabel_, centDB_);
155  int nCentBins = centDB_->m_table.size();
156  for (int i = 0; i < hi::NumEPNames; i++) {
157  flat[i]->setCaloCentRefBins(-1, -1);
158  if (caloCentRef_ > 0) {
159  int minbin = (caloCentRef_ - caloCentRefWidth_ / 2.) * nCentBins / 100.;
160  int maxbin = (caloCentRef_ + caloCentRefWidth_ / 2.) * nCentBins / 100.;
161  minbin /= CentBinCompression_;
162  maxbin /= CentBinCompression_;
163  if (minbin > 0 && maxbin >= minbin) {
164  if (EPDet[i] == HF || EPDet[i] == Castor)
165  flat[i]->setCaloCentRefBins(minbin, maxbin);
166  }
167  }
168  }
169  }
170 
171  if (hirpWatcher.check(iSetup)) {
172  edm::ESHandle<RPFlatParams> flatparmsDB_;
173  iSetup.get<HeavyIonRPRcd>().get(flatparmsDB_);
174  LoadEPDB db(flatparmsDB_, flat);
175  if (!db.IsSuccess())
176  return;
177  }
178  //
179  //Get Centrality
180  //
181 
183 
184  if (Noffmin_ >= 0) {
185  int nOff = iEvent.get(centralityToken).Ntracks();
186  if ((nOff < Noffmin_) or (nOff >= Noffmax_)) {
187  return;
188  }
189  }
190  //
191  //Get Vertex
192  //
193  int vs_sell; // vertex collection size
194  float vzr_sell;
195  auto const& vertices3 = iEvent.get(vertexToken);
196  vs_sell = vertices3.size();
197  if (vs_sell > 0) {
198  vzr_sell = vertices3.begin()->z();
199  } else
200  vzr_sell = -999.9;
201 
202  //
203  //Get Event Planes
204  //
205 
206  auto evtplaneOutput = std::make_unique<EvtPlaneCollection>();
208  for (int i = 0; i < hi::NumEPNames; i++) {
209  ep[i] = nullptr;
210  }
211  int indx = 0;
212  for (auto const& rp : iEvent.get(inputPlanesToken)) {
213  double psiOffset = rp.angle(0);
214  double s = rp.sumSin(0);
215  double c = rp.sumCos(0);
216  uint m = rp.mult();
217 
218  double soff = s;
219  double coff = c;
220  if (useOffsetPsi_) {
221  soff = flat[indx]->getSoffset(s, vzr_sell, bin);
222  coff = flat[indx]->getCoffset(c, vzr_sell, bin);
223  psiOffset = flat[indx]->getOffsetPsi(soff, coff);
224  }
225  double psiFlat = flat[indx]->getFlatPsi(psiOffset, vzr_sell, bin);
226  ep[indx] = new EvtPlane(indx, 2, psiFlat, soff, coff, rp.sumw(), rp.sumw2(), rp.sumPtOrEt(), rp.sumPtOrEt2(), m);
227  ep[indx]->addLevel(0, rp.angle(0), s, c);
228  ep[indx]->addLevel(3, 0., rp.sumSin(3), rp.sumCos(3));
229  if (useOffsetPsi_)
230  ep[indx]->addLevel(1, psiOffset, soff, coff);
231  ++indx;
232  }
233 
234  for (int i = 0; i < hi::NumEPNames; i++) {
235  if (ep[i] != nullptr)
236  evtplaneOutput->push_back(*ep[i]);
237  }
238  iEvent.put(std::move(evtplaneOutput));
239  for (int i = 0; i < indx; i++)
240  delete ep[i];
241 }
242 
243 //define this as a plug-in
HiEvtPlaneFlatProducer::centralityTag_
edm::InputTag centralityTag_
Definition: HiEvtPlaneFlatProducer.cc:65
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:372
HiEvtPlaneFlatProducer::~HiEvtPlaneFlatProducer
~HiEvtPlaneFlatProducer() override
Definition: HiEvtPlaneFlatProducer.cc:131
mps_fire.i
i
Definition: mps_fire.py:355
HiEvtPlaneFlatProducer::Noffmin_
int Noffmin_
Definition: HiEvtPlaneFlatProducer.cc:86
HiEvtPlaneFlatten::setCaloCentRefBins
void setCaloCentRefBins(const int caloCentRefMinBin, const int caloCentRefMaxBin)
Definition: HiEvtPlaneFlatten.h:128
hi::EPNames
const std::string EPNames[]
Definition: HiEvtPlaneList.h:73
edm::ESWatcher< HeavyIonRcd >
HiEvtPlaneFlatProducer::caloCentRefWidth_
double caloCentRefWidth_
Definition: HiEvtPlaneFlatProducer.cc:84
ESHandle.h
HiEvtPlaneFlatProducer::centralityLabel_
std::string centralityLabel_
Definition: HiEvtPlaneFlatProducer.cc:59
HiEvtPlaneFlatProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HiEvtPlaneFlatProducer.cc:140
edm::EDGetTokenT< int >
edm
HLT enums.
Definition: AlignableModifier.h:19
CentralityTable.h
HiEvtPlaneFlatten
Definition: HiEvtPlaneFlatten.h:27
LoadEPDB
Definition: LoadEPDB.h:30
HeavyIonRPRcd
Definition: HeavyIonRPRcd.h:24
hi::EPDet
const int EPDet[]
Definition: HiEvtPlaneList.h:81
EDProducer.h
HeavyIonRPRcd.h
HiEvtPlaneFlatProducer::centralityBinToken
edm::EDGetTokenT< int > centralityBinToken
Definition: HiEvtPlaneFlatProducer.cc:63
HiEvtPlaneFlatProducer::trackCollection_
edm::Handle< reco::TrackCollection > trackCollection_
Definition: HiEvtPlaneFlatProducer.cc:76
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::TrackCollection >
parallelization.uint
uint
Definition: parallelization.py:124
HiEvtPlaneFlatten::getOffsetPsi
double getOffsetPsi(double s, double c) const
Definition: HiEvtPlaneFlatten.h:191
hi::EPOrder
const int EPOrder[]
Definition: HiEvtPlaneList.h:85
HiEvtPlaneFlatProducer::trackToken
edm::EDGetTokenT< reco::TrackCollection > trackToken
Definition: HiEvtPlaneFlatProducer.cc:75
HeavyIonRcd.h
dqmiodatasetharvest.db
db
Definition: dqmiodatasetharvest.py:119
MakerMacros.h
HiEvtPlaneFlatten::getFlatPsi
double getFlatPsi(double psi, double vtx, int centbin) const
Definition: HiEvtPlaneFlatten.h:161
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HiEvtPlaneFlatProducer::NumFlatBins_
int NumFlatBins_
Definition: HiEvtPlaneFlatProducer.cc:82
PoolDBOutputService.h
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HiEvtPlaneFlatProducer::hirpWatcher
edm::ESWatcher< HeavyIonRPRcd > hirpWatcher
Definition: HiEvtPlaneFlatProducer.cc:79
Service.h
Centrality.h
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
HiEvtPlaneFlatProducer::centralityToken
edm::EDGetTokenT< reco::Centrality > centralityToken
Definition: HiEvtPlaneFlatProducer.cc:66
HiEvtPlaneFlatProducer::centralityVariable_
std::string centralityVariable_
Definition: HiEvtPlaneFlatProducer.cc:58
CentralityTable::m_table
std::vector< CBin > m_table
Definition: CentralityTable.h:39
edm::ESHandle< CentralityTable >
HiEvtPlaneFlatten::getCoffset
double getCoffset(double c, double vtx, int centbin) const
Definition: HiEvtPlaneFlatten.h:183
HiEvtPlaneFlatProducer::FlatOrder_
const int FlatOrder_
Definition: HiEvtPlaneFlatProducer.cc:81
HiEvtPlaneFlatProducer::inputPlanesToken
edm::EDGetTokenT< reco::EvtPlaneCollection > inputPlanesToken
Definition: HiEvtPlaneFlatProducer.cc:72
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
Castor
TFileService.h
HiEvtPlaneFlatProducer::centralityBinTag_
edm::InputTag centralityBinTag_
Definition: HiEvtPlaneFlatProducer.cc:62
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
HiEvtPlaneFlatProducer::hiWatcher
edm::ESWatcher< HeavyIonRcd > hiWatcher
Definition: HiEvtPlaneFlatProducer.cc:78
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
HiEvtPlaneFlatProducer::flat
HiEvtPlaneFlatten * flat[hi::NumEPNames]
Definition: HiEvtPlaneFlatProducer.cc:88
HiEvtPlaneFlatProducer::Noffmax_
int Noffmax_
Definition: HiEvtPlaneFlatProducer.cc:87
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
reco::EvtPlane
Definition: EvtPlane.h:20
HiEvtPlaneFlatten::getSoffset
double getSoffset(double s, double vtx, int centbin) const
Definition: HiEvtPlaneFlatten.h:175
LoadEPDB.h
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
HiEvtPlaneList.h
get
#define get
CaloTowerCollection.h
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
HiEvtPlaneFlatProducer::trackTag_
edm::InputTag trackTag_
Definition: HiEvtPlaneFlatProducer.cc:74
VertexFwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
hi
Definition: HiEvtPlaneList.h:38
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
ESWatcher.h
HiEvtPlaneFlatProducer::CentBinCompression_
int CentBinCompression_
Definition: HiEvtPlaneFlatProducer.cc:85
CaloTPGTranscoder_cfi.HF
HF
Definition: CaloTPGTranscoder_cfi.py:4
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
HiEvtPlaneFlatProducer::inputPlanesTag_
edm::InputTag inputPlanesTag_
Definition: HiEvtPlaneFlatProducer.cc:71
HiEvtPlaneFlatProducer::caloCentRef_
double caloCentRef_
Definition: HiEvtPlaneFlatProducer.cc:83
HiEvtPlaneFlatProducer::useOffsetPsi_
bool useOffsetPsi_
Definition: HiEvtPlaneFlatProducer.cc:89
HiEvtPlaneFlatten::init
void init(int order, int nbins, std::string tag, int vord)
Definition: HiEvtPlaneFlatten.h:35
hi::NumEPNames
static const int NumEPNames
Definition: HiEvtPlaneList.h:126
HeavyIonRcd
Definition: HeavyIonRcd.h:24
HiEvtPlaneFlatProducer::HiEvtPlaneFlatProducer
HiEvtPlaneFlatProducer(const edm::ParameterSet &)
Definition: HiEvtPlaneFlatProducer.cc:92
ParameterSet.h
edm::Event
Definition: Event.h:73
HiEvtPlaneFlatProducer::vertexToken
edm::EDGetTokenT< std::vector< reco::Vertex > > vertexToken
Definition: HiEvtPlaneFlatProducer.cc:69
RPFlatParams.h
HiEvtPlaneFlatProducer
Definition: HiEvtPlaneFlatProducer.cc:48
HiEvtPlaneFlatProducer::vertexTag_
edm::InputTag vertexTag_
Definition: HiEvtPlaneFlatProducer.cc:68
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::InputTag
Definition: InputTag.h:15
HiEvtPlaneFlatProducer::centralityMC_
std::string centralityMC_
Definition: HiEvtPlaneFlatProducer.cc:60
HiEvtPlaneFlatten.h