diff --git a/DataFormats/HeavyIonEvent/interface/EvtPlane.h b/DataFormats/HeavyIonEvent/interface/EvtPlane.h index a987042de76c0..e01520bc5f4ad 100644 --- a/DataFormats/HeavyIonEvent/interface/EvtPlane.h +++ b/DataFormats/HeavyIonEvent/interface/EvtPlane.h @@ -14,7 +14,7 @@ #include #include -#include +#include namespace reco { class EvtPlane { public: @@ -22,43 +22,33 @@ namespace reco { class EvtPlane { virtual ~EvtPlane(); void AddLevel(int level, double ang, double sumsin, double sumcos); int indx() const { return indx_ ;} - double angle(int level=2) const { return (level>=0||level<=2)? angle_[level]:angle_[2]; } - double sumSin(int level=2) const { return (level>=0||level<=2)? sumSin_[level]:sumSin_[2];} - double sumCos(int level=2) const { return (level>=0||level<=2)? sumCos_[level]:sumCos_[2];} - double sumw() const { return sumw_;} - double sumw2() const { return sumw2_;} - double sumPtOrEt() const { return sumPtOrEt_;} - double sumPtOrEt2() const { return sumPtOrEt2_;} - double mult() const { return mult_;} - double Qy(int level=2) const { return sumSin(level); } - double Qx(int level=2) const { return sumCos(level); } - double Q(int level=2) const { return ((pow(Qx(level),2)+pow(Qy(level),2))>0)? sqrt(pow(Qx(level),2)+pow(Qy(level),2)): 0.;} - double qy(int level=2) const { return (mult_>0)? ((level>=0||level<=2)? sumSin_[level]/sqrt((double)mult_):sumSin_[2]/sqrt((double) mult_)):0.;} - double qx(int level=2) const { return (mult_>0)? ((level>=0||level<=2)? sumCos_[level]/sqrt((double)mult_):sumCos_[2]/sqrt((double) mult_)):0.;} - double q(int level=2) const { return ((pow(qx(level),2)+pow(qy(level),2))>0)? sqrt(pow(qx(level),2)+pow(qy(level),2)): 0.;} - double vn(int level=2) const{ return (Q(level)>0 && fabs(sumw())>0)? Q(level)/fabs(sumw()): 0.;} + float angle(int level=2) const { return (level>=0||level<=2)? angle_[level]:angle_[2]; } + float sumSin(int level=2) const { return (level>=0||level<=2)? sumSin_[level]:sumSin_[2];} + float sumCos(int level=2) const { return (level>=0||level<=2)? sumCos_[level]:sumCos_[2];} + float sumw() const { return sumw_;} + float sumw2() const { return sumw2_;} + float sumPtOrEt() const { return sumPtOrEt_;} + float sumPtOrEt2() const { return sumPtOrEt2_;} + float mult() const { return mult_;} + float qy(int level=2) const { return sumSin(level); } + float qx(int level=2) const { return sumCos(level); } + float q(int level=2) const { return ((pow(qx(level),2)+pow(qy(level),2))>0)? sqrt(pow(qx(level),2)+pow(qy(level),2)): 0.;} + float vn(int level=2) const{ return (q(level)>0 && fabs(sumw())>0)? q(level)/fabs(sumw()): 0.;} private: - int indx_; - double angle_[4]; - double sumSin_[4]; - double sumCos_[4]; - double sumw_; - double sumw2_; - double sumPtOrEt_; - double sumPtOrEt2_; - uint mult_; - + int indx_; + float angle_[4]; + float sumSin_[4]; + float sumCos_[4]; + float sumw_; + float sumw2_; + float sumPtOrEt_; + float sumPtOrEt2_; + uint mult_; + }; - + typedef std::vector EvtPlaneCollection; - } -#endif - - - - - - +#endif diff --git a/DataFormats/HeavyIonEvent/src/EvtPlane.cc b/DataFormats/HeavyIonEvent/src/EvtPlane.cc index 2080a9adcc2eb..51b83596e3b7b 100644 --- a/DataFormats/HeavyIonEvent/src/EvtPlane.cc +++ b/DataFormats/HeavyIonEvent/src/EvtPlane.cc @@ -1,31 +1,3 @@ -// // -// // $Id: EvtPlane.cc,v 1.4 2009/09/08 12:33:12 edwenger Exp $ -// // -// -// #include "DataFormats/HeavyIonEvent/interface/EvtPlane.h" -// -// using namespace reco; -// -// EvtPlane::EvtPlane(double planeA, std::string label) -// : -// angle_(planeA), -// label_(label) -// { -// // default constructor -// } -// -// -// EvtPlane::~EvtPlane() -// { -// } -// -// - - -// -// $Id: EvtPlane.cc,v 1.4 2009/09/08 12:33:12 edwenger Exp $ -// - #include "DataFormats/HeavyIonEvent/interface/EvtPlane.h" using namespace reco; @@ -39,14 +11,12 @@ EvtPlane::EvtPlane(int epindx, int level, double planeA,double sumSin, double su sumPtOrEt2_(sumPtOrEt2), mult_(mult) { + for ( int i = 0; i < 4; ++i ) { + angle_[i] = sumSin_[i] = sumCos_[i] = -10; + } angle_[level] = planeA; sumSin_[level] = sumSin; sumCos_[level] = sumCos; - if(level<2) { - angle_[2] = planeA; - sumSin_[2] = sumSin; - sumCos_[2] = sumCos; - } // default constructor } void EvtPlane::AddLevel(int level, double ang, double sumsin, double sumcos) { diff --git a/DataFormats/HeavyIonEvent/src/classes_def.xml b/DataFormats/HeavyIonEvent/src/classes_def.xml index 01c8434f3d994..968873eb8d383 100644 --- a/DataFormats/HeavyIonEvent/src/classes_def.xml +++ b/DataFormats/HeavyIonEvent/src/classes_def.xml @@ -1,6 +1,7 @@ - - + + + diff --git a/RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneFlatten.h b/RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneFlatten.h index 77ed06a6f7b30..edd861f984faa 100644 --- a/RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneFlatten.h +++ b/RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneFlatten.h @@ -10,7 +10,6 @@ // // Original Author: Stephen Sanders // Created: Mon Jun 7 14:40:12 EDT 2010 -// $Id: HiEvtPlaneFlatten.h,v 1.4 2011/11/06 23:17:27 ssanders Exp $ // // @@ -33,11 +32,8 @@ #include "DataFormats/HeavyIonEvent/interface/EvtPlane.h" -#include "TMath.h" #include - -#define MAXCUT 10000 -#define MAXCUTOFF 1000 +#include // // class declaration @@ -48,165 +44,162 @@ class HiEvtPlaneFlatten { explicit HiEvtPlaneFlatten() { - pi = TMath::Pi(); - hbins = 1; - hOrder = 9; - vorder = 2; //sets default order of event plane - minvtx = -25; - delvtx = 5; - nvtxbins = 10; + hbins_ = 1; + hOrder_ = 9; + vorder_ = 2; //sets default order of event plane + minvtx_ = -25; + delvtx_ = 5; + nvtxbins_ = 10; + soff_ = 0.; + coff_ = 0.; } - void Init(int order, int nbins, std::string tag, int vord) + void init(int order, int nbins, std::string tag, int vord) { - hOrder = order; //order of flattening - vorder = vord; //1(v1), 2(v2), 3(v3), 4(v4) + hOrder_ = order; //order of flattening + vorder_ = vord; //1(v1), 2(v2), 3(v3), 4(v4) caloCentRefMinBin_ = -1; caloCentRefMaxBin_ = -1; - hbins = nbins*nvtxbins*hOrder; - obins = nbins*nvtxbins; - if(hbins>MAXCUT) { - hbins = 1; - hOrder = 9; + hbins_ = nbins*nvtxbins_*hOrder_; + obins_ = nbins*nvtxbins_; + if(hbins_>MAXCUT) { + hbins_ = 1; + hOrder_ = 9; + } + for(int i = 0; ihfetbins) ietbin=hfetbins-1; int ibin = centbin; - int ivtx = (vtx-minvtx)/delvtx; - if(vtx < minvtx || ivtx >= nvtxbins) return -1; - cut = hOrder*nvtxbins*ibin + hOrder*ivtx + iord; - if(cut<0 || cut>=hbins) return -1; + int ivtx = (vtx-minvtx_)/delvtx_; + if(vtx < minvtx_ || ivtx >= nvtxbins_) return -1; + cut = hOrder_*nvtxbins_*ibin + hOrder_*ivtx + iord; + if(cut<0 || cut>=hbins_) return -1; return cut; } - int GetOffsetIndx(int centbin, double vtx) + int getOffsetIndx(int centbin, double vtx) const { int cut; if(centbin < 0 ) return -1; //int ietbin = hfetbins*log10( 9.*(et/scale)+1.); //if(ietbin>hfetbins) ietbin=hfetbins-1; int ibin = centbin; - int ivtx = (vtx-minvtx)/delvtx; - if(ivtx < 0 || ivtx > nvtxbins) return -1; - cut = nvtxbins*ibin + ivtx ; - if(cut<0 || cut>hbins) return -1; + int ivtx = (vtx-minvtx_)/delvtx_; + if(ivtx < 0 || ivtx > nvtxbins_) return -1; + cut = nvtxbins_*ibin + ivtx ; + if(cut<0 || cut>hbins_) return -1; return cut; } - - void Fill(double psi, double vtx, int centbin) + + void fill(double psi, double vtx, int centbin) { if(fabs(psi)>4 ) return; - for(int k = 0; k=0) { - flatX[indx]+=fcos; - flatY[indx]+=fsin; - ++flatCnt[indx]; + flatX_[indx]+=fcos; + flatY_[indx]+=fsin; + ++flatCnt_[indx]; } } } - void FillOffset(double s, double c, uint m, double vtx, int centbin) + void fillOffset(double s, double c, uint m, double vtx, int centbin) { - int indx = GetOffsetIndx(centbin,vtx); + int indx = getOffsetIndx(centbin,vtx); if(indx>=0) { - xoff[indx]+=c; - yoff[indx]+=s; - xyoffmult[indx]+=m; - ++xyoffcnt[indx]; + xoff_[indx]+=c; + yoff_[indx]+=s; + xyoffmult_[indx]+=m; + ++xyoffcnt_[indx]; } } - void FillPt(double ptval, double vtx, int centbin) + void fillPt(double ptval, double vtx, int centbin) { - - int indx = GetOffsetIndx(centbin,vtx); + int indx = getOffsetIndx(centbin,vtx); if(indx>=0) { - pt[indx]+=ptval; - pt2[indx]+=ptval*ptval; - ++ptcnt[indx]; + pt_[indx]+=ptval; + pt2_[indx]+=ptval*ptval; + ++ptcnt_[indx]; } } - void SetCaloCentRefBins(const int caloCentRefMinBin, const int caloCentRefMaxBin) { + void setCaloCentRefBins(const int caloCentRefMinBin, const int caloCentRefMaxBin) { caloCentRefMinBin_ = caloCentRefMinBin; caloCentRefMaxBin_ = caloCentRefMaxBin; caloCentRefVal_ = 1.; } - double GetEtScale(double vtx, int centbin) { + double EtScale(double vtx, int centbin) { if(caloCentRefMinBin_<0) return 1.; - int indx = GetOffsetIndx(centbin,vtx); - int refmin = GetOffsetIndx(caloCentRefMinBin_,vtx); - int refmax = GetOffsetIndx(caloCentRefMaxBin_,vtx); + int indx = getOffsetIndx(centbin,vtx); + int refmin = getOffsetIndx(caloCentRefMinBin_,vtx); + int refmax = getOffsetIndx(caloCentRefMaxBin_,vtx); caloCentRefVal_ = 0; for(int i = refmin; i<=refmax; i++) { - caloCentRefVal_+=GetPtDB(i); - } + caloCentRefVal_+=getPtDB(i); + } caloCentRefVal_/=refmax-refmin+1.; - if(caloCentRefVal_==0 || GetPtDB(indx)==0) return 1.; - return caloCentRefVal_/GetPtDB(indx); + if(caloCentRefVal_==0 || getPtDB(indx)==0) return 1.; + return caloCentRefVal_/getPtDB(indx); } - double GetW(double pt, double vtx, int centbin) + double getW(double pt, double vtx, int centbin) { - - int indx = GetOffsetIndx(centbin,vtx); + int indx = getOffsetIndx(centbin,vtx); if(indx>=0) { - double scale = GetEtScale(vtx,centbin); - double ptval = GetPtDB(indx)*scale; - double pt2val = GetPt2DB(indx)*pow(scale,2); + double scale = EtScale(vtx,centbin); + double ptval = getPtDB(indx)*scale; + double pt2val = getPt2DB(indx)*pow(scale,2); if(ptval>0) return pt*scale-pt2val/ptval; } return 0.; } - double GetFlatPsi(double psi, double vtx, int centbin) + double getFlatPsi(double psi, double vtx, int centbin) const { double correction = 0; - for(int k = 0; k=0) correction+=(2./(double)((k+1)*vorder))*(flatXDB[indx]*sin(vorder*(k+1)*psi)-flatYDB[indx]*cos(vorder*(k+1)*psi)); + for(int k = 0; k=0) correction+=(2./(double)((k+1)*vorder_))*(flatXDB_[indx]*sin(vorder_*(k+1)*psi)-flatYDB_[indx]*cos(vorder_*(k+1)*psi)); } psi+=correction; psi=bounds(psi); psi=bounds2(psi); return psi; } - - double GetOffsetPsi(double s, double c, double w, uint m, double vtx, int centbin) + + double OffsetPsi(double s, double c, double w, uint m, double vtx, int centbin) { - int indx = GetOffsetIndx(centbin,vtx); - double snew = s-yoffDB[indx]; - double cnew = c-xoffDB[indx]; - double psi = atan2(snew,cnew)/vorder; + int indx = getOffsetIndx(centbin,vtx); + double snew = s-yoffDB_[indx]; + double cnew = c-xoffDB_[indx]; + double psi = atan2(snew,cnew)/vorder_; if((fabs(snew)<1e-4) && (fabs(cnew)<1e-4)) psi = 0.; psi=bounds(psi); psi=bounds2(psi); @@ -217,39 +210,39 @@ class HiEvtPlaneFlatten { return psi; } - + ~HiEvtPlaneFlatten(){} - int GetHBins(){return hbins;} - int GetOBins(){return obins;} - int GetNvtx(){return nvtxbins;} - double GetVtxMin(){return minvtx;} - double GetVtxMax(){return minvtx+nvtxbins*delvtx;} - int GetNcent(){return hbins;} - - double GetX(int bin){return flatX[bin];} - double GetY(int bin){return flatY[bin];} - double GetXoff(int bin){return xoff[bin];} - double GetYoff(int bin){return yoff[bin];} - double GetXoffDB(int bin){return xoffDB[bin];} - double GetYoffDB(int bin){return yoffDB[bin];} - double GetXYoffcnt(int bin){return xyoffcnt[bin];} - double GetXYoffmult(int bin){return xyoffmult[bin];} - double GetPt(int bin){return pt[bin];} - double GetPt2(int bin){return pt2[bin];} - double GetPtDB(int bin){return ptDB[bin];} - double GetPt2DB(int bin){return pt2DB[bin];} - double GetPtcnt(int bin){return ptcnt[bin];} - double GetXDB(int bin) {return flatXDB[bin];} - double GetYDB(int bin) {return flatYDB[bin];} - - - double GetCnt(int bin) {return flatCnt[bin];} - void SetXDB(int indx, double val) {flatXDB[indx]=val;} - void SetYDB(int indx, double val) {flatYDB[indx]=val;} - void SetXoffDB(int indx, double val) {xoffDB[indx]=val;} - void SetYoffDB(int indx, double val) {yoffDB[indx]=val;} - void SetPtDB(int indx, double val) {ptDB[indx]=val;} - void SetPt2DB(int indx, double val) {pt2DB[indx]=val;} + int getHBins() const {return hbins_;} + int getOBins() const {return obins_;} + int getNvtx() const {return nvtxbins_;} + double getVtxMin() const {return minvtx_;} + double getVtxMax() const {return minvtx_+nvtxbins_*delvtx_;} + int getNcent() const {return hbins_;} + + double getX(int bin) const {return flatX_[bin];} + double getY(int bin) const {return flatY_[bin];} + double getXoff(int bin) const {return xoff_[bin];} + double getYoff(int bin) const {return yoff_[bin];} + double getXoffDB(int bin) const {return xoffDB_[bin];} + double getYoffDB(int bin) const {return yoffDB_[bin];} + double getXYoffcnt(int bin) const {return xyoffcnt_[bin];} + double getXYoffmult(int bin) const {return xyoffmult_[bin];} + double getPt(int bin) const {return pt_[bin];} + double getPt2(int bin) const {return pt2_[bin];} + double getPtDB(int bin) const {return ptDB_[bin];} + double getPt2DB(int bin) const {return pt2DB_[bin];} + double getPtcnt(int bin) const {return ptcnt_[bin];} + double getXDB(int bin) const {return flatXDB_[bin];} + double getYDB(int bin) const {return flatYDB_[bin];} + + + double getCnt(int bin) const {return flatCnt_[bin];} + void setXDB(int indx, double val) {flatXDB_[indx]=val;} + void setYDB(int indx, double val) {flatYDB_[indx]=val;} + void setXoffDB(int indx, double val) {xoffDB_[indx]=val;} + void setYoffDB(int indx, double val) {yoffDB_[indx]=val;} + void setPtDB(int indx, double val) {ptDB_[indx]=val;} + void setPt2DB(int indx, double val) {pt2DB_[indx]=val;} double sumSin() const { return soff_; } double sumCos() const { return coff_; } double sumw() const { return w_; } @@ -257,104 +250,104 @@ class HiEvtPlaneFlatten { double qx() const { return (w_>0)? coff_/w_:0.;}; double qy() const { return (w_>0)? soff_/w_:0.;}; double q() const { return ((pow(qx(),2)+pow(qy(),2))>0)? sqrt(pow(qx(),2)+pow(qy(),2)): 0.;}; - Double_t bounds(Double_t ang) { - if(ang<-pi) ang+=2.*pi; - if(ang>pi) ang-=2.*pi; + double bounds(double ang) const { + if(ang<-M_PI) ang+=2.*M_PI; + if(ang>M_PI) ang-=2.*M_PI; return ang; } - Double_t bounds2(Double_t ang) { - double range = pi/(double) vorder; + double bounds2(double ang) const { + double range = M_PI/(double) vorder_; while(ang<-range) { ang+=2*range; } while(ang>range) {ang-=2*range; } return ang; } - void SetCentRes1(int bin, double res, double err){ if(bin<100 && bin>=0) {centRes1[bin]=res; centResErr1[bin]=err;}} - void SetCentRes2(int bin, double res, double err){ if(bin<50 && bin>=0) {centRes2[bin]=res; centResErr2[bin]=err;}} - void SetCentRes5(int bin, double res, double err){ if(bin<20 && bin>=0) {centRes5[bin]=res; centResErr5[bin]=err;}} - void SetCentRes10(int bin, double res, double err){ if(bin<10 && bin>=0) {centRes10[bin]=res; centResErr10[bin]=err;}} - void SetCentRes20(int bin, double res, double err){ if(bin<5 && bin>=0) {centRes20[bin]=res; centResErr20[bin]=err;}} - void SetCentRes25(int bin, double res, double err){ if(bin<4 && bin>=0) {centRes25[bin]=res; centResErr25[bin]=err;}} - void SetCentRes30(int bin, double res, double err){ if(bin<3 && bin>=0) {centRes30[bin]=res; centResErr30[bin]=err;}} - void SetCentRes40(int bin, double res, double err){ if(bin<2 && bin>=0) {centRes40[bin]=res; centResErr40[bin]=err;}} - - double GetCentRes1(int bin){ if(bin<100 && bin>=0) {return centRes1[bin];} else {return 0.;}} - double GetCentRes2(int bin){ if(bin<50 && bin>=0) {return centRes2[bin];} else {return 0.;}} - double GetCentRes5(int bin){ if(bin<20 && bin>=0) {return centRes5[bin];} else {return 0.;}} - double GetCentRes10(int bin){ if(bin<10 && bin>=0) {return centRes10[bin];} else {return 0.;}} - double GetCentRes20(int bin){ if(bin<5 && bin>=0) {return centRes20[bin];} else {return 0.;}} - double GetCentRes25(int bin){ if(bin<4 && bin>=0) {return centRes25[bin];} else {return 0.;}} - double GetCentRes30(int bin){ if(bin<3 && bin>=0) {return centRes30[bin];} else {return 0.;}} - double GetCentRes40(int bin){ if(bin<2 && bin>=0) {return centRes40[bin];} else {return 0.;}} - - double GetCentResErr1(int bin){ if(bin<100 && bin>=0) {return centResErr1[bin];} else {return 0.;}} - double GetCentResErr2(int bin){ if(bin<50 && bin>=0) {return centResErr2[bin];} else {return 0.;}} - double GetCentResErr5(int bin){ if(bin<20 && bin>=0) {return centResErr5[bin];} else {return 0.;}} - double GetCentResErr10(int bin){ if(bin<10 && bin>=0) {return centResErr10[bin];} else {return 0.;}} - double GetCentResErr20(int bin){ if(bin<5 && bin>=0) {return centResErr20[bin];} else {return 0.;}} - double GetCentResErr25(int bin){ if(bin<4 && bin>=0) {return centResErr25[bin];} else {return 0.;}} - double GetCentResErr30(int bin){ if(bin<3 && bin>=0) {return centResErr30[bin];} else {return 0.;}} - double GetCentResErr40(int bin){ if(bin<2 && bin>=0) {return centResErr40[bin];} else {return 0.;}} + void setCentRes1(int bin, double res, double err){ if(bin<100 && bin>=0) {centRes1_[bin]=res; centResErr1_[bin]=err;}} + void setCentRes2(int bin, double res, double err){ if(bin<50 && bin>=0) {centRes2_[bin]=res; centResErr2_[bin]=err;}} + void setCentRes5(int bin, double res, double err){ if(bin<20 && bin>=0) {centRes5_[bin]=res; centResErr5_[bin]=err;}} + void setCentRes10(int bin, double res, double err){ if(bin<10 && bin>=0) {centRes10_[bin]=res; centResErr10_[bin]=err;}} + void setCentRes20(int bin, double res, double err){ if(bin<5 && bin>=0) {centRes20_[bin]=res; centResErr20_[bin]=err;}} + void setCentRes25(int bin, double res, double err){ if(bin<4 && bin>=0) {centRes25_[bin]=res; centResErr25_[bin]=err;}} + void setCentRes30(int bin, double res, double err){ if(bin<3 && bin>=0) {centRes30_[bin]=res; centResErr30_[bin]=err;}} + void setCentRes40(int bin, double res, double err){ if(bin<2 && bin>=0) {centRes40_[bin]=res; centResErr40_[bin]=err;}} + + double getCentRes1(int bin) const { if(bin<100 && bin>=0) {return centRes1_[bin];} else {return 0.;}} + double getCentRes2(int bin) const { if(bin<50 && bin>=0) {return centRes2_[bin];} else {return 0.;}} + double getCentRes5(int bin) const { if(bin<20 && bin>=0) {return centRes5_[bin];} else {return 0.;}} + double getCentRes10(int bin) const { if(bin<10 && bin>=0) {return centRes10_[bin];} else {return 0.;}} + double getCentRes20(int bin) const { if(bin<5 && bin>=0) {return centRes20_[bin];} else {return 0.;}} + double getCentRes25(int bin) const { if(bin<4 && bin>=0) {return centRes25_[bin];} else {return 0.;}} + double getCentRes30(int bin) const { if(bin<3 && bin>=0) {return centRes30_[bin];} else {return 0.;}} + double getCentRes40(int bin) const { if(bin<2 && bin>=0) {return centRes40_[bin];} else {return 0.;}} + + double getCentResErr1(int bin) const { if(bin<100 && bin>=0) {return centResErr1_[bin];} else {return 0.;}} + double getCentResErr2(int bin) const { if(bin<50 && bin>=0) {return centResErr2_[bin];} else {return 0.;}} + double getCentResErr5(int bin) const { if(bin<20 && bin>=0) {return centResErr5_[bin];} else {return 0.;}} + double getCentResErr10(int bin) const { if(bin<10 && bin>=0) {return centResErr10_[bin];} else {return 0.;}} + double getCentResErr20(int bin) const { if(bin<5 && bin>=0) {return centResErr20_[bin];} else {return 0.;}} + double getCentResErr25(int bin) const { if(bin<4 && bin>=0) {return centResErr25_[bin];} else {return 0.;}} + double getCentResErr30(int bin) const { if(bin<3 && bin>=0) {return centResErr30_[bin];} else {return 0.;}} + double getCentResErr40(int bin) const { if(bin<2 && bin>=0) {return centResErr40_[bin];} else {return 0.;}} private: - double flatX[MAXCUT]; - double flatY[MAXCUT]; - double flatXDB[MAXCUT]; - double flatYDB[MAXCUT]; - double flatCnt[MAXCUT]; + static const int MAXCUT = 10000; + static const int MAXCUTOFF = 1000; + double flatX_[MAXCUT]; + double flatY_[MAXCUT]; + double flatXDB_[MAXCUT]; + double flatYDB_[MAXCUT]; + double flatCnt_[MAXCUT]; - double xoff[MAXCUTOFF]; - double yoff[MAXCUTOFF]; - double xoffDB[MAXCUTOFF]; - double yoffDB[MAXCUTOFF]; - double xyoffcnt[MAXCUTOFF]; - uint xyoffmult[MAXCUTOFF]; + double xoff_[MAXCUTOFF]; + double yoff_[MAXCUTOFF]; + double xoffDB_[MAXCUTOFF]; + double yoffDB_[MAXCUTOFF]; + double xyoffcnt_[MAXCUTOFF]; + uint xyoffmult_[MAXCUTOFF]; - double pt[MAXCUTOFF]; - double pt2[MAXCUTOFF]; - double ptDB[MAXCUTOFF]; - double pt2DB[MAXCUTOFF]; - double ptcnt[MAXCUTOFF]; + double pt_[MAXCUTOFF]; + double pt2_[MAXCUTOFF]; + double ptDB_[MAXCUTOFF]; + double pt2DB_[MAXCUTOFF]; + double ptcnt_[MAXCUTOFF]; - double centRes1[100]; - double centResErr1[100]; + double centRes1_[100]; + double centResErr1_[100]; - double centRes2[50]; - double centResErr2[50]; + double centRes2_[50]; + double centResErr2_[50]; - double centRes5[20]; - double centResErr5[20]; + double centRes5_[20]; + double centResErr5_[20]; - double centRes10[10]; - double centResErr10[10]; + double centRes10_[10]; + double centResErr10_[10]; - double centRes20[5]; - double centResErr20[5]; + double centRes20_[5]; + double centResErr20_[5]; - double centRes25[4]; - double centResErr25[4]; + double centRes25_[4]; + double centResErr25_[4]; - double centRes30[3]; - double centResErr30[3]; + double centRes30_[3]; + double centResErr30_[3]; - double centRes40[2]; - double centResErr40[2]; + double centRes40_[2]; + double centResErr40_[2]; - int hOrder; //flattening order - double scale; - int hbins; //number of bins needed for flattening - int obins; //number of (x,y) offset bins - int vorder; //order of flattened event plane + int hOrder_; //flattening order + int hbins_; //number of bins needed for flattening + int obins_; //number of (x,y) offset bins + int vorder_; //order of flattened event plane int caloCentRefMinBin_; //min ref centrality bin for calo weight scale int caloCentRefMaxBin_; //max ref centrality bin for calo weight scale double caloCentRefVal_; //reference or - double pi; - int nvtxbins; - double minvtx; - double delvtx; + int nvtxbins_; + double minvtx_; + double delvtx_; double soff_ ; double coff_ ; double w_ ; diff --git a/RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneList.h b/RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneList.h index 4ee0896a25bad..4000a0d5c68a4 100644 --- a/RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneList.h +++ b/RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneList.h @@ -34,7 +34,7 @@ Index Name Detector Order hmin1 hmax1 hmin2 hmax2 minpt maxpt nsub mcw 29 Castor1mc Castor 1 -6.55 -5.10 0.00 0.00 0.01 50.00 3sub yes HFp1mc trackp1mc */ #include -using namespace std; + namespace hi{ enum EPNamesInd { diff --git a/RecoHI/HiEvtPlaneAlgos/interface/LoadEPDB.h b/RecoHI/HiEvtPlaneAlgos/interface/LoadEPDB.h index 63af3fb363793..9eb79649f3dde 100644 --- a/RecoHI/HiEvtPlaneAlgos/interface/LoadEPDB.h +++ b/RecoHI/HiEvtPlaneAlgos/interface/LoadEPDB.h @@ -1,5 +1,5 @@ -#ifndef __LoadEPDB__ -#define __LoadEPDB__ +#ifndef RecoHI_HiEvtPlaneAlgos_LoadEPDB_h +#define RecoHI_HiEvtPlaneAlgos_LoadEPDB_h // system include files #include @@ -21,25 +21,25 @@ #include "DataFormats/HeavyIonEvent/interface/EvtPlane.h" #include "RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneFlatten.h" #include "RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneList.h" -#include "TMath.h" #include + using namespace hi; class LoadEPDB { public: - + explicit LoadEPDB(edm::ESHandle flatparmsDB_, HiEvtPlaneFlatten ** flat) { int Hbins; int Obins; int flatTableSize = flatparmsDB_->m_table.size(); genFlatPsi_ = kTRUE; - if(flatTableSizeGetHBins()+2*flat[0]->GetOBins()) { + if(flatTableSizegetHBins()+2*flat[0]->getOBins()) { genFlatPsi_ = kFALSE; } else { - Hbins = flat[0]->GetHBins(); - Obins = flat[0]->GetOBins(); - + Hbins = flat[0]->getHBins(); + Obins = flat[0]->getOBins(); + for(int i = 0; im_table[i]); for(int j = 0; j=0) { if(iSetXDB(i, thisBin->x[j]); - flat[indx]->SetYDB(i, thisBin->y[j]); + flat[indx]->setXDB(i, thisBin->x[j]); + flat[indx]->setYDB(i, thisBin->y[j]); } else if(i>=Hbins && iSetXoffDB(i - Hbins, thisBin->x[j]); - flat[indx]->SetYoffDB(i - Hbins, thisBin->y[j]); - + flat[indx]->setXoffDB(i - Hbins, thisBin->x[j]); + flat[indx]->setYoffDB(i - Hbins, thisBin->y[j]); + } else if (i>=Hbins+Obins && iSetPtDB(i - Hbins- Obins, thisBin->x[j]); - flat[indx]->SetPt2DB(i - Hbins- Obins, thisBin->y[j]); - } + flat[indx]->setPtDB(i - Hbins- Obins, thisBin->x[j]); + flat[indx]->setPt2DB(i - Hbins- Obins, thisBin->y[j]); + } } } } @@ -72,44 +72,43 @@ class LoadEPDB { for(int j = 0; j< ncentbins; j++) { const RPFlatParams::EP* thisBin = &(flatparmsDB_->m_table[Hbins+2*Obins +cbins+j+1]); if(fabs(centbinning-1.)<0.01) { - for(int i = 0; iSetCentRes1(j,thisBin->x[i],thisBin->y[i]); + for(int i = 0; isetCentRes1(j,thisBin->x[i],thisBin->y[i]); } if(fabs(centbinning-2.)<0.01) { - for(int i = 0; iSetCentRes2(j,thisBin->x[i],thisBin->y[i]); + for(int i = 0; isetCentRes2(j,thisBin->x[i],thisBin->y[i]); } if(fabs(centbinning-5.)<0.01) { - for(int i = 0; iSetCentRes5(j,thisBin->x[i],thisBin->y[i]); + for(int i = 0; isetCentRes5(j,thisBin->x[i],thisBin->y[i]); } if(fabs(centbinning-10.)<0.01) { - for(int i = 0; iSetCentRes10(j,thisBin->x[i],thisBin->y[i]); + for(int i = 0; isetCentRes10(j,thisBin->x[i],thisBin->y[i]); } if(fabs(centbinning-20.)<0.01) { - for(int i = 0; iSetCentRes20(j,thisBin->x[i],thisBin->y[i]); + for(int i = 0; isetCentRes20(j,thisBin->x[i],thisBin->y[i]); } if(fabs(centbinning-25.)<0.01) { - for(int i = 0; iSetCentRes25(j,thisBin->x[i],thisBin->y[i]); + for(int i = 0; isetCentRes25(j,thisBin->x[i],thisBin->y[i]); } if(fabs(centbinning-30.)<0.01) { - for(int i = 0; iSetCentRes30(j,thisBin->x[i],thisBin->y[i]); + for(int i = 0; isetCentRes30(j,thisBin->x[i],thisBin->y[i]); } if(fabs(centbinning-40.)<0.01) { - for(int i = 0; iSetCentRes40(j,thisBin->x[i],thisBin->y[i]); + for(int i = 0; isetCentRes40(j,thisBin->x[i],thisBin->y[i]); } } - cbins+=ncentbins+1; + cbins+=ncentbins+1; } - + } - + } - - bool genFlatPsi_; + bool IsSuccess(){return genFlatPsi_;} - ~LoadEPDB(){} - + private: + bool genFlatPsi_; }; diff --git a/RecoHI/HiEvtPlaneAlgos/python/HiEvtPlane_cfi.py b/RecoHI/HiEvtPlaneAlgos/python/HiEvtPlane_cfi.py index e5b889687e312..5cbdd824ea845 100644 --- a/RecoHI/HiEvtPlaneAlgos/python/HiEvtPlane_cfi.py +++ b/RecoHI/HiEvtPlaneAlgos/python/HiEvtPlane_cfi.py @@ -1,33 +1,25 @@ import FWCore.ParameterSet.Config as cms hiEvtPlane = cms.EDProducer("EvtPlaneProducer", - vertexTag_=cms.InputTag("hiSelectedVertex"), - centralityTag_=cms.InputTag("hiCentrality"), - caloTag_=cms.InputTag("towerMaker"), - castorTag_=cms.InputTag("CastorTowerReco"), - trackTag_=cms.InputTag("hiGeneralTracks"), - centralityBinTag_ = cms.InputTag("centralityBin","HFtowers"), + vertexTag = cms.InputTag("hiSelectedVertex"), + caloTag = cms.InputTag("towerMaker"), + castorTag = cms.InputTag("CastorTowerReco"), + trackTag = cms.InputTag("hiGeneralTracks"), + centralityBinTag = cms.InputTag("centralityBin","HFtowers"), centralityVariable = cms.string("HFtowers"), nonDefaultGlauberModel = cms.string(""), - FlatOrder_ = cms.untracked.int32(9), - NumFlatBins_ = cms.untracked.int32(40), - CentBinCompression_ = cms.untracked.int32(5), - caloCentRef_ = cms.untracked.double(80.), - caloCentRefWidth_ = cms.untracked.double(5.0), - HFEtScale_ = cms.untracked.int32(3800), - loadDB_ = cms.untracked.bool(False), - minet_ = cms.untracked.double(-1.), - maxet_ = cms.untracked.double(-1.), - minpt_ = cms.untracked.double(0.3), - maxpt_ = cms.untracked.double(3.0), - minvtx_ = cms.untracked.double(-25.), - maxvtx_ = cms.untracked.double(25.), - dzerr_ = cms.untracked.double(10.), - chi2_ = cms.untracked.double(40.) + FlatOrder = cms.int32(9), + NumFlatBins = cms.int32(40), + CentBinCompression = cms.int32(5), + caloCentRef = cms.double(80.), + caloCentRefWidth = cms.double(5.0), + loadDB = cms.bool(False), + minet = cms.double(-1.), + maxet = cms.double(-1.), + minpt = cms.double(0.3), + maxpt = cms.double(3.0), + minvtx = cms.double(-25.), + maxvtx = cms.double(25.), + dzerr = cms.double(10.), + chi2 = cms.double(40.) ) - - - - - - diff --git a/RecoHI/HiEvtPlaneAlgos/python/hiEvtPlaneFlat_cfi.py b/RecoHI/HiEvtPlaneAlgos/python/hiEvtPlaneFlat_cfi.py new file mode 100644 index 0000000000000..ff42609ecbca3 --- /dev/null +++ b/RecoHI/HiEvtPlaneAlgos/python/hiEvtPlaneFlat_cfi.py @@ -0,0 +1,19 @@ +import FWCore.ParameterSet.Config as cms + +hiEvtPlaneFlat = cms.EDProducer('HiEvtPlaneFlatProducer', + vertexTag = cms.InputTag("hiSelectedVertex"), + centralityTag = cms.InputTag("hiCentrality"), + centralityBinTag = cms.InputTag("centralityBin","HFtowers"), + centralityVariable = cms.string("HFtowers"), + nonDefaultGlauberModel = cms.string(""), + inputPlanesTag = cms.InputTag("hiEvtPlane","recoLevel"), + trackTag = cms.InputTag("hiGeneralTracks"), + FlatOrder = cms.int32(9), + NumFlatBins = cms.int32(40), + Noffmin = cms.int32 (-1), + Noffmax = cms.int32 (10000), + CentBinCompression = cms.int32(5), + caloCentRef = cms.double(80.), + caloCentRefWidth = cms.double(5.0), + useOffsetPsi = cms.bool(True) + ) diff --git a/RecoHI/HiEvtPlaneAlgos/python/hievtplaneflatproducer_cfi.py b/RecoHI/HiEvtPlaneAlgos/python/hievtplaneflatproducer_cfi.py deleted file mode 100644 index 9512fcd1fe652..0000000000000 --- a/RecoHI/HiEvtPlaneAlgos/python/hievtplaneflatproducer_cfi.py +++ /dev/null @@ -1,20 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -hiEvtPlaneFlat = cms.EDProducer('HiEvtPlaneFlatProducer', - vertexTag_=cms.InputTag("hiSelectedVertex"), - centralityTag_=cms.InputTag("hiCentrality"), - centralityBinTag_ = cms.InputTag("centralityBin","HFtowers"), - centralityVariable = cms.string("HFtowers"), - nonDefaultGlauberModel = cms.string(""), - inputPlanesTag_ = cms.InputTag("hiEvtPlane","recoLevel"), - trackTag_=cms.InputTag("hiGeneralTracks"), - FlatOrder_ = cms.untracked.int32(9), - NumFlatBins_ = cms.untracked.int32(40), - Noffmin_ = cms.untracked.int32 (-1), - Noffmax_ = cms.untracked.int32 (10000), - CentBinCompression_ = cms.untracked.int32(5), - caloCentRef_ = cms.untracked.double(80.), - caloCentRefWidth_ = cms.untracked.double(5.0), - HFEtScale_ = cms.untracked.int32(3800), - useOffsetPsi_ = cms.untracked.bool(True) - ) diff --git a/RecoHI/HiEvtPlaneAlgos/src/EvtPlaneFilter.cc b/RecoHI/HiEvtPlaneAlgos/src/EvtPlaneFilter.cc index 44c1db425f44b..24c3e4dc382bf 100644 --- a/RecoHI/HiEvtPlaneAlgos/src/EvtPlaneFilter.cc +++ b/RecoHI/HiEvtPlaneAlgos/src/EvtPlaneFilter.cc @@ -8,7 +8,7 @@ */ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -17,22 +17,17 @@ #include "RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneList.h" #include "DataFormats/HeavyIonEvent/interface/EvtPlane.h" -#include - -class EvtPlaneFilter : public edm::EDFilter { +class EvtPlaneFilter : public edm::stream::EDFilter<> { public: explicit EvtPlaneFilter(const edm::ParameterSet&); ~EvtPlaneFilter(); private: - virtual void beginJob(); - virtual bool filter(edm::Event&, const edm::EventSetup&); - virtual void endJob() ; + virtual bool filter(edm::Event&, const edm::EventSetup&) override; - double vnlow_; - double vnhigh_; - int epidx_; - int eplvl_; - edm::Handle ep_; + const double vnlow_; + const double vnhigh_; + const int epidx_; + const int eplvl_; edm::EDGetTokenT tag_; }; @@ -53,23 +48,11 @@ EvtPlaneFilter::~EvtPlaneFilter() bool EvtPlaneFilter::filter(edm::Event& evt, const edm::EventSetup& es) { + edm::Handle ep_; evt.getByToken(tag_, ep_); double qn = (*ep_)[epidx_].vn(eplvl_); if ( qn < vnlow_ || qn > vnhigh_ ) return false; return true; } - - -void EvtPlaneFilter::beginJob() -{ - return; -} - - -void EvtPlaneFilter::endJob() -{ - return; -} - DEFINE_FWK_MODULE(EvtPlaneFilter); diff --git a/RecoHI/HiEvtPlaneAlgos/src/EvtPlaneProducer.cc b/RecoHI/HiEvtPlaneAlgos/src/EvtPlaneProducer.cc index 0968f21a13b18..9b4d92d07a663 100644 --- a/RecoHI/HiEvtPlaneAlgos/src/EvtPlaneProducer.cc +++ b/RecoHI/HiEvtPlaneAlgos/src/EvtPlaneProducer.cc @@ -13,7 +13,6 @@ Description: // // Original Author: Sergey Petrushanko // Created: Fri Jul 11 10:05:00 2008 -// $Id: EvtPlaneProducer.cc,v 1.18 2011/10/07 09:41:29 yilmaz Exp $ // // @@ -21,16 +20,17 @@ Description: #include #include #include -#include "TMath.h" +#include "cmath" // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/Candidate/interface/Candidate.h" @@ -47,7 +47,6 @@ Description: #include "DataFormats/CastorReco/interface/CastorTower.h" #include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/VertexReco/interface/Vertex.h" @@ -74,15 +73,9 @@ using namespace hi; // class decleration // -class EvtPlaneProducer : public edm::EDProducer { -public: - explicit EvtPlaneProducer(const edm::ParameterSet&); - ~EvtPlaneProducer(); - -private: - //edm::Service fs; +namespace hi { class GenPlane { - public: + public: GenPlane(string name,double etaminval1,double etamaxval1,double etaminval2,double etamaxval2,int orderval){ epname=name; etamin1=etaminval1; @@ -113,7 +106,7 @@ class EvtPlaneProducer : public edm::EDProducer { ++mult; } } - + double getAngle(double &ang, double &sv, double &cv, double &svNoWgt, double &cvNoWgt, double &w, double &w2, double &PtOrEt, double &PtOrEt2, uint &epmult){ ang = -10; sv = 0; @@ -160,20 +153,19 @@ class EvtPlaneProducer : public edm::EDProducer { double sumPtOrEt2; double order; }; - +} +class EvtPlaneProducer : public edm::stream::EDProducer<> { +public: + explicit EvtPlaneProducer(const edm::ParameterSet&); + ~EvtPlaneProducer(); + +private: GenPlane *rp[NumEPNames]; - virtual void beginJob() ; - virtual void produce(edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - - // ----------member data --------------------------- - // edm::InputTag vtxCollection_; - // edm::InputTag caloCollection_; - // edm::InputTag trackCollection_; + virtual void produce(edm::Event&, const edm::EventSetup&) override; - edm::Service fs; + // ----------member data --------------------------- std::string centralityVariable_; std::string centralityLabel_; @@ -181,7 +173,6 @@ class EvtPlaneProducer : public edm::EDProducer { edm::InputTag centralityBinTag_; edm::EDGetTokenT centralityBinToken; - edm::Handle cbin_; edm::InputTag vertexTag_; @@ -200,81 +191,74 @@ class EvtPlaneProducer : public edm::EDProducer { edm::EDGetTokenT trackToken; edm::Handle trackCollection_; - bool foundCentTag; - bool useECAL_; - bool useHCAL_; - bool useTrack_; + edm::ESWatcher hiWatcher; + edm::ESWatcher hirpWatcher; + bool loadDB_; double minet_; double maxet_; - double effm_; double minpt_; double maxpt_; double minvtx_; double maxvtx_; double dzerr_; double chi2_; - bool FirstEvent; int FlatOrder_; - uint runno_; int NumFlatBins_; double nCentBins_; double caloCentRef_; double caloCentRefWidth_; - int caloCentRefMinBin_; - int caloCentRefMaxBin_; int CentBinCompression_; HiEvtPlaneFlatten * flat[NumEPNames]; }; -EvtPlaneProducer::EvtPlaneProducer(const edm::ParameterSet& iConfig) { +EvtPlaneProducer::EvtPlaneProducer(const edm::ParameterSet& iConfig): + centralityVariable_ ( iConfig.getParameter("centralityVariable") ), + centralityBinTag_ ( iConfig.getParameter("centralityBinTag") ), + vertexTag_ ( iConfig.getParameter("vertexTag") ), + caloTag_ ( iConfig.getParameter("caloTag") ), + castorTag_ ( iConfig.getParameter("castorTag") ), + trackTag_ ( iConfig.getParameter("trackTag") ), + loadDB_ ( iConfig.getParameter("loadDB") ), + minet_ ( iConfig.getParameter("minet") ), + maxet_ ( iConfig.getParameter("maxet") ), + minpt_ ( iConfig.getParameter("minpt") ), + maxpt_ ( iConfig.getParameter("maxpt") ), + minvtx_ ( iConfig.getParameter("minvtx") ), + maxvtx_ ( iConfig.getParameter("maxvtx") ), + dzerr_ ( iConfig.getParameter("dzerr") ), + chi2_ ( iConfig.getParameter("chi2") ), + FlatOrder_ ( iConfig.getParameter("FlatOrder") ), + NumFlatBins_ ( iConfig.getParameter("NumFlatBins") ), + caloCentRef_ ( iConfig.getParameter("caloCentRef") ), + caloCentRefWidth_ ( iConfig.getParameter("caloCentRefWidth") ), + CentBinCompression_ ( iConfig.getParameter("CentBinCompression") ) +{ nCentBins_ = 200.; - centralityVariable_ = iConfig.getParameter("centralityVariable"); if(iConfig.exists("nonDefaultGlauberModel")){ centralityMC_ = iConfig.getParameter("nonDefaultGlauberModel"); } centralityLabel_ = centralityVariable_+centralityMC_; - centralityBinTag_ = iConfig.getParameter("centralityBinTag_"); centralityBinToken = consumes(centralityBinTag_); - vertexTag_ = iConfig.getParameter("vertexTag_"); vertexToken = consumes>(vertexTag_); - caloTag_ = iConfig.getParameter("caloTag_"); caloToken = consumes(caloTag_); - castorTag_ = iConfig.getParameter("castorTag_"); castorToken = consumes>(castorTag_); - trackTag_ = iConfig.getParameter("trackTag_"); trackToken = consumes(trackTag_); - FlatOrder_ = iConfig.getUntrackedParameter("FlatOrder_", 9); - NumFlatBins_ = iConfig.getUntrackedParameter("NumFlatBins_",20); - CentBinCompression_ = iConfig.getUntrackedParameter("CentBinCompression_",5); - caloCentRef_ = iConfig.getUntrackedParameter("caloCentRef_",80.); - caloCentRefWidth_ = iConfig.getUntrackedParameter("caloCentRefWidth_",5.); - loadDB_ = iConfig.getUntrackedParameter("loadDB_",true); - - minet_ = iConfig.getUntrackedParameter("minet_",-1.); - maxet_ = iConfig.getUntrackedParameter("maxet_",-1.); - minpt_ = iConfig.getUntrackedParameter("minpt_",0.3); - maxpt_ = iConfig.getUntrackedParameter("maxpt_",3.0); - minvtx_ = iConfig.getUntrackedParameter("minvtx_",-25.); - maxvtx_ = iConfig.getUntrackedParameter("maxvtx_",25.); - dzerr_ = iConfig.getUntrackedParameter("dzerr_",10.); - chi2_ = iConfig.getUntrackedParameter("chi2_",40.); - FirstEvent = kTRUE; produces("recoLevel"); for(int i = 0; iInit(FlatOrder_,NumFlatBins_,EPNames[i],EPOrder[i]); + flat[i]->init(FlatOrder_,NumFlatBins_,EPNames[i],EPOrder[i]); } } @@ -282,10 +266,10 @@ EvtPlaneProducer::EvtPlaneProducer(const edm::ParameterSet& iConfig) { EvtPlaneProducer::~EvtPlaneProducer() { - + // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) - + } @@ -300,14 +284,8 @@ EvtPlaneProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) using namespace edm; using namespace std; using namespace reco; - - bool newrun = false; - if(runno_ != iEvent.id().run()) newrun = true; - runno_ = iEvent.id().run(); - - if( (FirstEvent && loadDB_)|| (newrun&&loadDB_)) { - FirstEvent = kFALSE; - newrun = false; + + if( (hiWatcher.check(iSetup) || hirpWatcher.check(iSetup)) && loadDB_ ) { // //Get Size of Centrality Table // @@ -315,40 +293,39 @@ EvtPlaneProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) iSetup.get().get(centralityLabel_,centDB_); nCentBins_ = centDB_->m_table.size(); for(int i = 0; iSetCaloCentRefBins(-1,-1); + flat[i]->setCaloCentRefBins(-1,-1); if(caloCentRef_>0) { int minbin = (caloCentRef_-caloCentRefWidth_/2.)*nCentBins_/100.; int maxbin = (caloCentRef_+caloCentRefWidth_/2.)*nCentBins_/100.; minbin/=CentBinCompression_; maxbin/=CentBinCompression_; if(minbin>0 && maxbin>=minbin) { - if(EPDet[i]==HF || EPDet[i]==Castor) flat[i]->SetCaloCentRefBins(minbin,maxbin); + if(EPDet[i]==HF || EPDet[i]==Castor) flat[i]->setCaloCentRefBins(minbin,maxbin); } } } - // //Get flattening parameter file. // edm::ESHandle flatparmsDB_; iSetup.get().get(flatparmsDB_); - LoadEPDB * db = new LoadEPDB(flatparmsDB_,flat); - if(!db->IsSuccess()) { + LoadEPDB db(flatparmsDB_,flat); + if(!db.IsSuccess()) { loadDB_ = kFALSE; } - - - } //First event - + + } //rp record change + // //Get Centrality // int bin = 0; if(loadDB_) { + edm::Handle cbin_; iEvent.getByToken(centralityBinToken, cbin_); int cbin = *cbin_; - bin = cbin/CentBinCompression_; + bin = cbin/CentBinCompression_; } // //Get Vertex @@ -365,16 +342,16 @@ EvtPlaneProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) // for(int i = 0; ireset(); if(vzr_sell>minvtx_ && vzr_sellbegin();j !=caloCollection_->end(); j++) { + for (CaloTowerCollection::const_iterator j = caloCollection_->begin();j !=caloCollection_->end(); j++) { tower_eta = j->eta(); tower_phi = j->phi(); tower_energyet_e = j->emEt(); @@ -389,30 +366,29 @@ EvtPlaneProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) if(tower_energyet>maxet) continue; if(EPDet[i]==HF) { double w = tower_energyet; - if(loadDB_) w = tower_energyet*flat[i]->GetEtScale(vzr_sell,bin); + if(loadDB_) w = tower_energyet*flat[i]->EtScale(vzr_sell,bin); if(EPOrder[i]==1 ) { if(MomConsWeight[i][0]=='y' && loadDB_ ) { - w = flat[i]->GetW(tower_energyet, vzr_sell, bin); + w = flat[i]->getW(tower_energyet, vzr_sell, bin); } if(tower_eta<0 ) w=-w; } rp[i]->addParticle(w,tower_energyet,sin(EPOrder[i]*tower_phi),cos(EPOrder[i]*tower_phi),tower_eta); } } - } + } } //Castor part - - + + iEvent.getByToken(castorToken,castorCollection_); - + if(castorCollection_.isValid()){ - for (std::vector::const_iterator j = castorCollection_->begin();j !=castorCollection_->end(); j++) { - tower_eta = j->position().eta(); - double labang = 2*TMath::ATan(TMath::Exp(-tower_eta)); - tower_phi = j->position().phi(); - tower_energyet = j->energy()*TMath::Sin(labang); + for (std::vector::const_iterator j = castorCollection_->begin();j !=castorCollection_->end(); j++) { + tower_eta = j->eta(); + tower_phi = j->phi(); + tower_energyet = j->et(); double minet = minet_; double maxet = maxet_; for(int i = 0; iGetW(tower_energyet, vzr_sell, bin); + w = flat[i]->getW(tower_energyet, vzr_sell, bin); } if(tower_eta<0 ) w=-w; } rp[i]->addParticle(w,tower_energyet,sin(EPOrder[i]*tower_phi),cos(EPOrder[i]*tower_phi),tower_eta); } } - } + } } //Tracking part - + double track_eta; double track_phi; double track_pt; - + + double vzErr2 =0.0, vxyErr=0.0; + math::XYZPoint vtxPoint(0.0,0.0,0.0); + if(vertex_->size()>0) { + vtxPoint=vertex_->begin()->position(); + vzErr2= (vertex_->begin()->zError())*(vertex_->begin()->zError()); + vxyErr=vertex_->begin()->xError() * vertex_->begin()->yError(); + } + iEvent.getByToken(trackToken, trackCollection_); if(trackCollection_.isValid()){ - for(reco::TrackCollection::const_iterator j = trackCollection_->begin(); j != trackCollection_->end(); j++){ - iEvent.getByLabel(vertexTag_, vertex_); - math::XYZPoint vtxPoint(0.0,0.0,0.0); - double vzErr =0.0, vxErr=0.0, vyErr=0.0; - if(vertex_->size()>0) { - vtxPoint=vertex_->begin()->position(); - vzErr=vertex_->begin()->zError(); - vxErr=vertex_->begin()->xError(); - vyErr=vertex_->begin()->yError(); - } + for(reco::TrackCollection::const_iterator j = trackCollection_->begin(); j != trackCollection_->end(); j++){ bool accepted = true; bool isPixel = false; // determine if the track is a pixel track if ( j->numberOfValidHits() < 7 ) isPixel = true; - + // determine the vertex significance double d0=0.0, dz=0.0, d0sigma=0.0, dzsigma=0.0; d0 = -1.*j->dxy(vtxPoint); dz = j->dz(vtxPoint); - d0sigma = sqrt(j->d0Error()*j->d0Error()+vxErr*vyErr); - dzsigma = sqrt(j->dzError()*j->dzError()+vzErr*vzErr); - + d0sigma = sqrt(j->d0Error()*j->d0Error()+vxyErr); + dzsigma = sqrt(j->dzError()*j->dzError()+vzErr2); + // cuts for pixel tracks if( isPixel ){ // dz significance cut if ( fabs(dz/dzsigma) > dzerr_ ) accepted = false; // chi2/ndof cut if ( j->normalizedChi2() > chi2_ ) accepted = false; - } + } // cuts for full tracks if ( ! isPixel) { // dz and d0 significance cuts @@ -497,20 +472,19 @@ EvtPlaneProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) if(w>2.5) w=2.0; //v2 starts decreasing above ~2.5 GeV/c if(EPOrder[i]==1) { if(MomConsWeight[i][0]=='y' && loadDB_) { - w = flat[i]->GetW(track_pt, vzr_sell, bin); + w = flat[i]->getW(track_pt, vzr_sell, bin); } if(track_eta<0) w=-w; } rp[i]->addParticle(w,track_pt,sin(EPOrder[i]*track_phi),cos(EPOrder[i]*track_phi),track_eta); } } - } + } } //end for } - + std::auto_ptr evtplaneOutput(new EvtPlaneCollection); - EvtPlane *ep[NumEPNames]; - + double ang=-10; double sv = 0; double cv = 0; @@ -525,29 +499,13 @@ EvtPlaneProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for(int i = 0; igetAngle(ang,sv,cv,svNoWgt, cvNoWgt, wv,wv2,pe,pe2,epmult); - ep[i] = new EvtPlane(i,0,ang,sv,cv,wv,wv2,pe,pe2,epmult); - ep[i]->AddLevel(3, 0., svNoWgt, cvNoWgt); + evtplaneOutput->push_back( EvtPlane(i,0,ang,sv,cv,wv,wv2,pe,pe2,epmult) ); + evtplaneOutput->back().AddLevel(3, 0., svNoWgt, cvNoWgt); } - for(int i = 0; ipush_back(*ep[i]); - } - - iEvent.put(evtplaneOutput, "recoLevel"); } } -// ------------ method called once each job just before starting event loop ------------ -void -EvtPlaneProducer::beginJob() -{ -} - -// ------------ method called once each job just after ending the event loop ------------ -void -EvtPlaneProducer::endJob() { -} - //define this as a plug-in DEFINE_FWK_MODULE(EvtPlaneProducer); diff --git a/RecoHI/HiEvtPlaneAlgos/src/HiEvtPlaneFlatProducer.cc b/RecoHI/HiEvtPlaneAlgos/src/HiEvtPlaneFlatProducer.cc index 4171bd816096c..340f672cbe294 100644 --- a/RecoHI/HiEvtPlaneAlgos/src/HiEvtPlaneFlatProducer.cc +++ b/RecoHI/HiEvtPlaneAlgos/src/HiEvtPlaneFlatProducer.cc @@ -14,15 +14,13 @@ // // Original Author: Stephen Sanders // Created: Sat Jun 26 16:04:04 EDT 2010 -// $Id: HiEvtPlaneFlatProducer.cc,v 1.12 2011/12/04 05:13:03 ssanders Exp $ -// // // system include files #include // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -32,6 +30,7 @@ #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h" #include "DataFormats/HeavyIonEvent/interface/Centrality.h" @@ -81,69 +80,56 @@ using std::vector; // class declaration // -class HiEvtPlaneFlatProducer : public edm::EDProducer { +class HiEvtPlaneFlatProducer : public edm::stream::EDProducer<> { public: explicit HiEvtPlaneFlatProducer(const edm::ParameterSet&); ~HiEvtPlaneFlatProducer(); - + private: - virtual void beginJob() ; - virtual void produce(edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - + virtual void produce(edm::Event&, const edm::EventSetup&) override; + // ----------member data --------------------------- - - + std::string centralityVariable_; std::string centralityLabel_; std::string centralityMC_; - + edm::InputTag centralityBinTag_; edm::EDGetTokenT centralityBinToken; - edm::Handle cbin_; - + edm::InputTag centralityTag_; edm::EDGetTokenT centralityToken; - edm::Handle centrality_; - + edm::InputTag vertexTag_; edm::EDGetTokenT> vertexToken; - edm::Handle> vertex_; - - + edm::InputTag inputPlanesTag_; edm::EDGetTokenT inputPlanesToken; - edm::Handle evtPlanes_; - + edm::InputTag trackTag_; edm::EDGetTokenT trackToken; edm::Handle trackCollection_; - + + edm::ESWatcher hiWatcher; + edm::ESWatcher hirpWatcher; + int FlatOrder_; + int NumFlatBins_; double caloCentRef_; double caloCentRefWidth_; - int caloCentRefMinBin_; - int caloCentRefMaxBin_; - int NumFlatBins_; int CentBinCompression_; int Noffmin_; int Noffmax_; - double ntrkval; - unsigned int runno_; - bool FirstEvent; HiEvtPlaneFlatten * flat[NumEPNames]; - RPFlatParams * rpFlat; - int nRP; bool useOffsetPsi_; int Hbins; int Obins; - bool UseEtHF; double nCentBins_; -}; +}; // // constants, enums and typedefs // - + typedef std::vector TrackingParticleCollection; typedef TrackingParticleRefVector::iterator tp_iterator; @@ -155,51 +141,50 @@ typedef TrackingParticleRefVector::iterator tp_iterator; // // constructors and destructor // -HiEvtPlaneFlatProducer::HiEvtPlaneFlatProducer(const edm::ParameterSet& iConfig):runno_(0) +HiEvtPlaneFlatProducer::HiEvtPlaneFlatProducer(const edm::ParameterSet& iConfig): + centralityVariable_ ( iConfig.getParameter("centralityVariable")), + centralityBinTag_ ( iConfig.getParameter("centralityBinTag")), + centralityTag_ ( iConfig.getParameter("centralityTag")), + vertexTag_ ( iConfig.getParameter("vertexTag")), + inputPlanesTag_ ( iConfig.getParameter("inputPlanesTag")), + trackTag_ ( iConfig.getParameter("trackTag")), + FlatOrder_ ( iConfig.getParameter("FlatOrder")), + NumFlatBins_ ( iConfig.getParameter("NumFlatBins")), + caloCentRef_ ( iConfig.getParameter("caloCentRef")), + caloCentRefWidth_ ( iConfig.getParameter("caloCentRefWidth")), + CentBinCompression_ ( iConfig.getParameter("CentBinCompression")), + Noffmin_ ( iConfig.getParameter("Noffmin")), + Noffmax_ ( iConfig.getParameter("Noffmax")), + useOffsetPsi_ ( iConfig.getParameter("useOffsetPsi")) { - UseEtHF = kFALSE; +// UseEtHF = kFALSE; nCentBins_ = 200.; - - centralityVariable_ = iConfig.getParameter("centralityVariable"); + if(iConfig.exists("nonDefaultGlauberModel")){ centralityMC_ = iConfig.getParameter("nonDefaultGlauberModel"); } centralityLabel_ = centralityVariable_+centralityMC_; - centralityBinTag_ = iConfig.getParameter("centralityBinTag_"); centralityBinToken = consumes(centralityBinTag_); - centralityTag_ = iConfig.getParameter("centralityTag_"); centralityToken = consumes(centralityTag_); - vertexTag_ = iConfig.getParameter("vertexTag_"); vertexToken = consumes>(vertexTag_); - trackTag_ = iConfig.getParameter("trackTag_"); trackToken = consumes(trackTag_); - inputPlanesTag_ = iConfig.getParameter("inputPlanesTag_"); inputPlanesToken = consumes(inputPlanesTag_); - FlatOrder_ = iConfig.getUntrackedParameter("FlatOrder_", 9); - NumFlatBins_ = iConfig.getUntrackedParameter("NumFlatBins_",40); - CentBinCompression_ = iConfig.getUntrackedParameter("CentBinCompression_",5); - caloCentRef_ = iConfig.getUntrackedParameter("caloCentRef_",80.); - caloCentRefWidth_ = iConfig.getUntrackedParameter("caloCentRefWidth_",5.); - Noffmin_ = iConfig.getUntrackedParameter("Noffmin_", 0); - Noffmax_ = iConfig.getUntrackedParameter("Noffmax_", 50000); - useOffsetPsi_ = iConfig.getUntrackedParameter("useOffsetPsi_",true); - FirstEvent = kTRUE; - //register your products + //register your products produces(); //now do what ever other initialization is needed for(int i = 0; iInit(FlatOrder_,NumFlatBins_,EPNames[i],EPOrder[i]); + flat[i]->init(FlatOrder_,NumFlatBins_,EPNames[i],EPOrder[i]); } - Hbins = flat[0]->GetHBins(); - Obins = flat[0]->GetOBins(); - + Hbins = flat[0]->getHBins(); + Obins = flat[0]->getOBins(); + } @@ -224,16 +209,10 @@ HiEvtPlaneFlatProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetu using namespace std; using namespace reco; - bool newrun = false; - if(runno_ != iEvent.id().run()) newrun = true; - runno_ = iEvent.id().run(); - // //Get Flattening Parameters // - if(FirstEvent || newrun) { - FirstEvent = false; - newrun = false; + if( hiWatcher.check(iSetup) ) { // //Get Size of Centrality Table @@ -242,36 +221,39 @@ HiEvtPlaneFlatProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetu iSetup.get().get(centralityLabel_,centDB_); nCentBins_ = centDB_->m_table.size(); for(int i = 0; iSetCaloCentRefBins(-1,-1); + flat[i]->setCaloCentRefBins(-1,-1); if(caloCentRef_>0) { int minbin = (caloCentRef_-caloCentRefWidth_/2.)*nCentBins_/100.; int maxbin = (caloCentRef_+caloCentRefWidth_/2.)*nCentBins_/100.; minbin/=CentBinCompression_; maxbin/=CentBinCompression_; if(minbin>0 && maxbin>=minbin) { - if(EPDet[i]==HF || EPDet[i]==Castor) flat[i]->SetCaloCentRefBins(minbin,maxbin); + if(EPDet[i]==HF || EPDet[i]==Castor) flat[i]->setCaloCentRefBins(minbin,maxbin); } } } + } + if( hirpWatcher.check(iSetup) ) { edm::ESHandle flatparmsDB_; iSetup.get().get(flatparmsDB_); - LoadEPDB * db = new LoadEPDB(flatparmsDB_,flat); - if(!db->IsSuccess()) return; + LoadEPDB db(flatparmsDB_,flat); + if(db.IsSuccess()) return; } // //Get Centrality // int bin = 0; + edm::Handle cbin_; iEvent.getByToken(centralityBinToken, cbin_); int cbin = *cbin_; - bin = cbin/CentBinCompression_; + bin = cbin/CentBinCompression_; if(Noffmin_>=0) { + edm::Handle centrality_; iEvent.getByToken(centralityToken, centrality_); int Noff = centrality_->Ntracks(); - ntrkval = Noff; if ( (Noff < Noffmin_) or (Noff >= Noffmax_) ) { return; } @@ -281,6 +263,7 @@ HiEvtPlaneFlatProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetu // int vs_sell; // vertex collection size float vzr_sell; + edm::Handle> vertex_; iEvent.getByToken(vertexToken,vertex_); const reco::VertexCollection * vertices3 = vertex_.product(); vs_sell = vertices3->size(); @@ -288,11 +271,12 @@ HiEvtPlaneFlatProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetu vzr_sell = vertices3->begin()->z(); } else vzr_sell = -999.9; - + // //Get Event Planes // + edm::Handle evtPlanes_; iEvent.getByToken(inputPlanesToken,evtPlanes_); if(!evtPlanes_.isValid()){ @@ -312,10 +296,11 @@ HiEvtPlaneFlatProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetu double c = rp->sumCos(); double w = rp->sumw(); uint m = rp->mult(); - + double psiOffset = angorig; - if(useOffsetPsi_) psiOffset = flat[indx]->GetOffsetPsi(s,c,w,m,vzr_sell,bin); - double psiFlat = flat[indx]->GetFlatPsi(psiOffset,vzr_sell,bin); + + if(useOffsetPsi_) psiOffset = flat[indx]->OffsetPsi(s,c,w,m,vzr_sell,bin); + double psiFlat = flat[indx]->getFlatPsi(psiOffset,vzr_sell,bin); ep[indx]= new EvtPlane(indx, 2, psiFlat, flat[indx]->sumSin(), flat[indx]->sumCos(),rp->sumw(), rp->sumw2(), rp->sumPtOrEt(), rp->sumPtOrEt2(), rp->mult()); ep[indx]->AddLevel(0,rp->angle(), rp->sumSin(), rp->sumCos()); ep[indx]->AddLevel(3,0., rp->sumSin(3), rp->sumCos(3)); @@ -332,15 +317,15 @@ HiEvtPlaneFlatProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetu } // ------------ method called once each job just before starting event loop ------------ -void -HiEvtPlaneFlatProducer::beginJob() -{ -} +//void +//HiEvtPlaneFlatProducer::beginJob() +//{ +//} // ------------ method called once each job just after ending the event loop ------------ -void -HiEvtPlaneFlatProducer::endJob() { -} +//void +//HiEvtPlaneFlatProducer::endJob() { +//} //define this as a plug-in DEFINE_FWK_MODULE(HiEvtPlaneFlatProducer); diff --git a/RecoHI/HiEvtPlaneAlgos/test/hievtplaneflat_cfg.py b/RecoHI/HiEvtPlaneAlgos/test/hievtplaneflat_cfg.py index cb2c84a90f8c6..3d81dea214808 100644 --- a/RecoHI/HiEvtPlaneAlgos/test/hievtplaneflat_cfg.py +++ b/RecoHI/HiEvtPlaneAlgos/test/hievtplaneflat_cfg.py @@ -6,7 +6,7 @@ process.load("FWCore.MessageService.MessageLogger_cfi") process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') process.load("RecoHI.HiEvtPlaneAlgos.HiEvtPlane_cfi") -process.load("RecoHI.HiEvtPlaneAlgos.hievtplaneflatproducer_cfi") +process.load("RecoHI.HiEvtPlaneAlgos.hiEvtPlaneFlat_cfi") process.load("RecoHI.HiCentralityAlgos.CentralityBin_cfi") process.load("CondCore.DBCommon.CondDBCommon_cfi") process.load('GeneratorInterface.HiGenCommon.HeavyIon_cff')