CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HiEvtPlaneFlatProducer.cc
Go to the documentation of this file.
1 //
2 // Original Author: Stephen Sanders
3 // Created: Sat Jun 26 16:04:04 EDT 2010
4 //
5 //
6 
7 
8 // system include files
9 #include <memory>
10 
11 // user include files
14 
17 
19 #include "Math/Vector3D.h"
20 
24 
27 
44 
51 
53 #include "TList.h"
54 #include "TString.h"
55 #include <time.h>
56 #include <cstdlib>
57 
59 
60 using namespace std;
61 using namespace hi;
62 
63 #include <vector>
64 using std::vector;
65 
66 
67 //
68 // class declaration
69 //
70 
72  public:
75 
76  private:
77  virtual void beginJob() override ;
78  virtual void produce(edm::Event&, const edm::EventSetup&) override;
79  virtual void endJob() override ;
80 
81  // ----------member data ---------------------------
82 
86 
87  int vs_sell; // vertex collection size
88  float vzr_sell;
89  float vzErr_sell;
90 
91  Double_t epang[NumEPNames];
94  int nRP;
96 
97 };
98 
99 //
100 // constants, enums and typedefs
101 //
102 typedef std::vector<TrackingParticle> TrackingParticleCollection;
104 
105 
106 //
107 // static data member definitions
108 //
109 
110 //
111 // constructors and destructor
112 //
114 {
115 
116  vtxCollection_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vtxCollection_"));
117  inputPlanes_ = consumes<reco::EvtPlaneCollection>(iConfig.getParameter<edm::InputTag>("inputPlanes_"));
118  centrality_ = consumes<int>(iConfig.getParameter<edm::InputTag>("centrality_"));
119  storeNames_ = 1;
120  //register your products
121  produces<reco::EvtPlaneCollection>();
122  //now do what ever other initialization is needed
123  Int_t FlatOrder = 21;
124  for(int i = 0; i<NumEPNames; i++) {
125  flat[i] = new HiEvtPlaneFlatten();
126  flat[i]->Init(FlatOrder,11,4,EPNames[i],EPOrder[i]);
127  }
128 
129 }
130 
131 
133 {
134 
135  // do anything here that needs to be done at desctruction time
136  // (e.g. close files, deallocate resources etc.)
137 
138 }
139 
140 
141 //
142 // member functions
143 //
144 
145 // ------------ method called to produce the data ------------
146 void
148 {
149  using namespace edm;
150  using namespace std;
151  using namespace reco;
152 
153  //
154  //Get Centrality
155  //
156 
157  edm::Handle<int> ch;
158  iEvent.getByToken(centrality_,ch);
159  int bin = *(ch.product());
160 
161  // double centval = 2.5*bin+1.25;
162  //
163  //Get Vertex
164  //
165  edm::Handle<reco::VertexCollection> vertexCollection3;
166  iEvent.getByToken(vtxCollection_,vertexCollection3);
167  const reco::VertexCollection * vertices3 = vertexCollection3.product();
168  vs_sell = vertices3->size();
169  if(vs_sell>0) {
170  vzr_sell = vertices3->begin()->z();
171  vzErr_sell = vertices3->begin()->zError();
172  } else
173  vzr_sell = -999.9;
174  //
175  //Get Flattening Parameters
176  //
177  edm::ESHandle<RPFlatParams> flatparmsDB_;
178  iSetup.get<HeavyIonRPRcd>().get(flatparmsDB_);
179  int flatTableSize = flatparmsDB_->m_table.size();
180  for(int i = 0; i<flatTableSize; i++) {
181  const RPFlatParams::EP* thisBin = &(flatparmsDB_->m_table[i]);
182  for(int j = 0; j<NumEPNames; j++) {
183  int indx = thisBin->RPNameIndx[j];
184  if(indx>=0) {
185  flat[indx]->SetXDB(i, thisBin->x[j]);
186  flat[indx]->SetYDB(i, thisBin->y[j]);
187  }
188  }
189  }
190 
191  //
192  //Get Event Planes
193  //
194 
196  iEvent.getByToken(inputPlanes_,evtPlanes);
197 
198  if(!evtPlanes.isValid()){
199  // cout << "Error! Can't get hiEvtPlane product!" << endl;
200  return ;
201  }
202 
203  std::auto_ptr<EvtPlaneCollection> evtplaneOutput(new EvtPlaneCollection);
204  EvtPlane * ep[NumEPNames];
205  for(int i = 0; i<NumEPNames; i++) {
206  ep[i]=0;
207  }
208  for (EvtPlaneCollection::const_iterator rp = evtPlanes->begin();rp !=evtPlanes->end(); rp++) {
209  if(rp->angle() > -5) {
210  string baseName = rp->label();
211  for(int i = 0; i< NumEPNames; i++) {
212  if(EPNames[i].compare(baseName)==0) {
213  double psiFlat = flat[i]->GetFlatPsi(rp->angle(),vzr_sell,bin);
214  epang[i]=psiFlat;
215  if(EPNames[i].compare(rp->label())==0) {
216  if(storeNames_) ep[i]= new EvtPlane(psiFlat, rp->sumSin(), rp->sumCos(),rp->label().data());
217  else ep[i]= new EvtPlane(psiFlat, rp->sumSin(), rp->sumCos(),"");
218  }
219  }
220  }
221  }
222  }
223 
224  for(int i = 0; i< NumEPNames; i++) {
225  if(ep[i]!=0) evtplaneOutput->push_back(*ep[i]);
226  }
227  iEvent.put(evtplaneOutput);
228  storeNames_ = 0;
229 }
230 
231 // ------------ method called once each job just before starting event loop ------------
232 void
234 {
235 }
236 
237 // ------------ method called once each job just after ending the event loop ------------
238 void
240 }
241 
242 //define this as a plug-in
T getParameter(std::string const &) const
const int EPOrder[]
int i
Definition: DBlmapReader.cc:9
std::vector< TrackingParticle > TrackingParticleCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< reco::EvtPlaneCollection > inputPlanes_
edm::EDGetTokenT< int > centrality_
TrackingParticleRefVector::iterator tp_iterator
std::string label() const
Definition: EvtPlane.h:19
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const std::string EPNames[]
void beginJob()
Definition: Breakpoints.cc:15
return((rh^lh)&mask)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
virtual void produce(edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< reco::VertexCollection > vtxCollection_
std::vector< EvtPlane > EvtPlaneCollection
Definition: EvtPlane.h:33
int j
Definition: DBlmapReader.cc:9
HiEvtPlaneFlatProducer(const edm::ParameterSet &)
const T & get() const
Definition: EventSetup.h:55
virtual void endJob() override
int RPNameIndx[50]
Definition: RPFlatParams.h:16
static const int NumEPNames
virtual void beginJob() override