1616
1717#include " FFitWeights.h"
1818
19+ #include < string>
20+ #include < cstdio>
21+ #include < vector>
22+
1923#include < TSpline.h>
2024
2125ClassImp (FFitWeights)
@@ -43,30 +47,30 @@ FFitWeights::~FFitWeights()
4347 delete qAxis;
4448};
4549
46- void FFitWeights::Init ()
50+ void FFitWeights::init ()
4751{
4852 fW_data = new TObjArray ();
4953 fW_data ->SetName (" FFitWeights_Data" );
5054 fW_data ->SetOwner (kTRUE );
5155
5256 if (!qAxis)
53- this ->SetBinAxis (500 , 0 , 25 );
57+ this ->setBinAxis (500 , 0 , 25 );
5458 for (const auto & qn : qnTYPE) {
55- fW_data ->Add (new TH2D (this ->GetQName (qn.first , qn.second .c_str ()), this ->GetAxisName (qn.first , qn.second .c_str ()), CentBin, 0 , CentBin, qAxis->GetNbins (), qAxis->GetXmin (), qAxis->GetXmax ()));
59+ fW_data ->Add (new TH2D (this ->getQName (qn.first , qn.second .c_str ()), this ->getAxisName (qn.first , qn.second .c_str ()), CentBin, 0 , CentBin, qAxis->GetNbins (), qAxis->GetXmin (), qAxis->GetXmax ()));
5660 }
5761};
5862
59- void FFitWeights::Fill (float centrality, float qn, int nh, const char * pf)
63+ void FFitWeights::fillWeights (float centrality, float qn, int nh, const char * pf)
6064{
6165 TObjArray* tar{nullptr };
6266
6367 tar = fW_data ;
6468 if (!tar)
6569 return ;
6670
67- TH2D* th2 = reinterpret_cast <TH2D*>(tar->FindObject (this ->GetQName (nh, pf)));
71+ TH2D* th2 = reinterpret_cast <TH2D*>(tar->FindObject (this ->getQName (nh, pf)));
6872 if (!th2) {
69- tar->Add (new TH2D (this ->GetQName (nh, pf), this ->GetAxisName (nh, pf), CentBin, 0 , CentBin, qAxis->GetNbins (), qAxis->GetXmin (), qAxis->GetXmax ()));
73+ tar->Add (new TH2D (this ->getQName (nh, pf), this ->getAxisName (nh, pf), CentBin, 0 , CentBin, qAxis->GetNbins (), qAxis->GetXmin (), qAxis->GetXmax ()));
7074 th2 = reinterpret_cast <TH2D*>(tar->At (tar->GetEntries () - 1 ));
7175 }
7276 th2->Fill (centrality, qn);
@@ -83,12 +87,12 @@ Long64_t FFitWeights::Merge(TCollection* collist)
8387 FFitWeights* l_w = 0 ;
8488 TIter all_w (collist);
8589 while ((l_w = (reinterpret_cast <FFitWeights*>(all_w ())))) {
86- AddArray (fW_data , l_w->GetDataArray ());
90+ addArray (fW_data , l_w->getDataArray ());
8791 nmerged++;
8892 }
8993 return nmerged;
9094};
91- void FFitWeights::AddArray (TObjArray* targ, TObjArray* sour)
95+ void FFitWeights::addArray (TObjArray* targ, TObjArray* sour)
9296{
9397 if (!sour) {
9498 printf (" Source array does not exist!\n " );
@@ -107,7 +111,7 @@ void FFitWeights::AddArray(TObjArray* targ, TObjArray* sour)
107111 }
108112};
109113
110- void FFitWeights::qSelectionSpline (std::vector<int > nhv, std::vector<std::string> stv) /* only execute OFFLINE */
114+ void FFitWeights::qSelection (std::vector<int > nhv, std::vector<std::string> stv) /* only execute OFFLINE */
111115{
112116 TObjArray* tar{nullptr };
113117
@@ -117,15 +121,15 @@ void FFitWeights::qSelectionSpline(std::vector<int> nhv, std::vector<std::string
117121
118122 for (const auto & pf : stv) {
119123 for (const auto & nh : nhv) {
120- TH2D* th2 = reinterpret_cast <TH2D*>(tar->FindObject (this ->GetQName (nh, pf.c_str ())));
124+ TH2D* th2{ reinterpret_cast <TH2D*>(tar->FindObject (this ->getQName (nh, pf.c_str ())))} ;
121125 if (!th2) {
122126 printf (" qh not found!\n " );
123127 return ;
124128 }
125129
126- TH1D* tmp = nullptr ;
127- TGraph* tmpgr = nullptr ;
128- TSpline3* spline = nullptr ;
130+ TH1D* tmp{ nullptr } ;
131+ TGraph* tmpgr{ nullptr } ;
132+ // TSpline3* spline = nullptr;
129133 for (int iSP{0 }; iSP < 90 ; iSP++) {
130134 tmp = th2->ProjectionY (Form (" q%i_%i_%i" , nh, iSP, iSP + 1 ), iSP + 1 , iSP + 1 );
131135 std::vector<double > xq (nResolution);
@@ -134,35 +138,36 @@ void FFitWeights::qSelectionSpline(std::vector<int> nhv, std::vector<std::string
134138 xq[i] = static_cast <double >(i + 1 ) / static_cast <double >(nResolution);
135139 tmp->GetQuantiles (nResolution, yq.data (), xq.data ());
136140 tmpgr = new TGraph (nResolution, yq.data (), xq.data ());
137- spline = new TSpline3 (Form (" sp_q%i%s_%i" , nh, pf.c_str (), iSP), tmpgr);
138- spline->SetName (Form (" sp_q%i%s_%i" , nh, pf.c_str (), iSP));
139- fW_data ->Add (spline);
141+ tmpgr->SetName (Form (" sp_q%i%s_%i" , nh, pf.c_str (), iSP));
142+ // spline = new TSpline3(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP), tmpgr);
143+ // spline->SetName(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP));
144+ fW_data ->Add (tmpgr);
140145 }
141146 }
142147 }
143148};
144149
145- float FFitWeights::EvalSplines (float centr, const float & dqn, const int nh, const char * pf)
150+ float FFitWeights::eval (float centr, const float & dqn, const int nh, const char * pf)
146151{
147152 TObjArray* tar{nullptr };
148153
149154 tar = fW_data ;
150155 if (!tar)
151156 return -1 ;
152157
153- int isp = static_cast <int >(centr);
158+ int isp{ static_cast <int >(centr)} ;
154159 if (isp < 0 || isp > 90 ) {
155160 return -1 ;
156161 }
157162
158- TSpline3 * spline = nullptr ;
159- spline = reinterpret_cast <TSpline3 *>(tar->FindObject (Form (" sp_q%i%s_%i" , nh, pf, isp)));
163+ TGraph * spline{ nullptr } ;
164+ spline = reinterpret_cast <TGraph *>(tar->FindObject (Form (" sp_q%i%s_%i" , nh, pf, isp)));
160165 if (!spline) {
161166 return -1 ;
162167 }
163168
164- float qn_val = 100 . * spline->Eval (dqn);
165- if (qn_val < 0 ) {
169+ float qn_val{ static_cast < float >( 100 . * spline->Eval (dqn))} ;
170+ if (qn_val < 0 || qn_val > 100.05 ) {
166171 return -1 ;
167172 }
168173
0 commit comments