DAS  3.0
Das Analysis System
RoccoR

#include <RoccoR.h>

+ Collaboration diagram for RoccoR:

Classes

struct  CorParams
 
struct  RocOne
 

Public Types

enum  TYPE { MC, DT }
 

Public Member Functions

 RoccoR ()
 
 RoccoR (std::string filename)
 
void init (std::string filename)
 
void reset ()
 
bool empty () const
 
const RocResgetRes (int s=0, int m=0) const
 
double getM (int T, int H, int F, int s=0, int m=0) const
 
double getA (int T, int H, int F, int s=0, int m=0) const
 
double getK (int T, int H, int s=0, int m=0) const
 
double kGenSmear (double pt, double eta, double v, double u, RocRes::TYPE TT=RocRes::Data, int s=0, int m=0) const
 
double kScaleMC (int Q, double pt, double eta, double phi, int s=0, int m=0) const
 
double kScaleDT (int Q, double pt, double eta, double phi, int s=0, int m=0) const
 
double kSpreadMC (int Q, double pt, double eta, double phi, double gt, int s=0, int m=0) const
 
double kSmearMC (int Q, double pt, double eta, double phi, int n, double u, int s=0, int m=0) const
 
double kScaleDTerror (int Q, double pt, double eta, double phi) const
 
double kSpreadMCerror (int Q, double pt, double eta, double phi, double gt) const
 
double kSmearMCerror (int Q, double pt, double eta, double phi, int n, double u) const
 
double kScaleFromGenMC (int Q, double pt, double eta, double phi, int n, double gt, double w, int s=0, int m=0) const
 
double kScaleAndSmearMC (int Q, double pt, double eta, double phi, int n, double u, double w, int s=0, int m=0) const
 
double kScaleFromGenMCerror (int Q, double pt, double eta, double phi, int n, double gt, double w) const
 
double kScaleAndSmearMCerror (int Q, double pt, double eta, double phi, int n, double u, double w) const
 

Protected Member Functions

int etaBin (double eta) const
 
int phiBin (double phi) const
 

Private Types

enum  TVAR { Default, Replica, Symhes }
 

Private Member Functions

template<typename T >
double error (T f) const
 

Private Attributes

int NETA
 
int NPHI
 
double DPHI
 
std::vector< double > etabin
 
int nset
 
std::vector< int > nmem
 
std::vector< int > tvar
 
std::vector< std::vector< RocOne > > RC
 

Static Private Attributes

static const double MPHI =-CrystalBall::pi
 

Member Enumeration Documentation

◆ TVAR

enum TVAR
private
Enumerator
Default 
Replica 
Symhes 

◆ TYPE

enum TYPE
Enumerator
MC 
DT 
152 {MC, DT};

Constructor & Destructor Documentation

◆ RoccoR() [1/2]

RoccoR ( )
112 {}

◆ RoccoR() [2/2]

RoccoR ( std::string  filename)
114  {
115  init(filename);
116 }

Member Function Documentation

◆ empty()

bool empty ( ) const
inline
159 {return RC.empty();}

◆ error()

double error ( f) const
private
313  {
314  double sum=0;
315  for(int s=0; s<nset; ++s){
316  for(int i=0; i<nmem[s]; ++i) {
317  double d = f(s,i) - f(0,0);
318  sum += d*d/nmem[s];
319  }
320  }
321  return sqrt(sum);
322 }

◆ etaBin()

int etaBin ( double  eta) const
protected
250  {
251  for(int i=0; i<NETA-1; ++i) if(x<etabin[i+1]) return i;
252  return NETA-1;
253 }

◆ getA()

double getA ( int  T,
int  H,
int  F,
int  s = 0,
int  m = 0 
) const
inline
162 {return RC[s][m].CP[T][H][F].A;}

◆ getK()

double getK ( int  T,
int  H,
int  s = 0,
int  m = 0 
) const
inline
163 {return RC[s][m].RR.resol[H].kRes[T];}

◆ getM()

double getM ( int  T,
int  H,
int  F,
int  s = 0,
int  m = 0 
) const
inline
161 {return RC[s][m].CP[T][H][F].M;}

◆ getRes()

const RocRes& getRes ( int  s = 0,
int  m = 0 
) const
inline
160 {return RC[s][m].RR;}

◆ init()

void init ( std::string  filename)
129  {
130  std::ifstream in(filename.c_str());
131  if(in.fail()) throw std::invalid_argument("RoccoR::init could not open file " + filename);
132 
133  int RMIN(0), RTRK(0), RETA(0);
134  std::vector<double> BETA;
135 
136  std::string tag;
137  int type, sys, mem, var, bin;
138  std::string s;
139  while(std::getline(in, s)){
140  std::stringstream ss(s);
141  if(s.substr(0,7)=="VERSION") {
142  ss >> s >> s;
143  std::cout << Form("%-8s %s", "RoccoR:", s.c_str()) << std::endl;
144  continue;
145  }
146  std::string first4=s.substr(0,4);
147  if(first4=="NSET"){
148  ss >> tag >> nset;
149  nmem.resize(nset);
150  tvar.resize(nset);
151  RC.resize(nset);
152  }
153  else if(first4=="NMEM") {
154  ss >> tag;
155  for(int i=0; i<nset; ++i) {
156  ss >> nmem[i];
157  RC[i].resize(nmem[i]);
158  }
159  }
160  else if(first4=="TVAR") {
161  ss >> tag;
162  for(int i=0; i<nset; ++i) ss >> tvar[i];
163  }
164  else if(first4=="RMIN") ss >> tag >> RMIN;
165  else if(first4=="RTRK") ss >> tag >> RTRK;
166  else if(first4=="RETA") {
167  ss >> tag >> RETA;
168  BETA.resize(RETA+1);
169  for(auto &h: BETA) ss >> h;
170 
171  }
172  else if(first4=="CPHI") {
173  ss >> tag >> NPHI;
175  }
176  else if(first4=="CETA") {
177  ss >> tag >> NETA;
178  etabin.resize(NETA+1);
179  for(auto& h: etabin) ss >> h;
180  }
181  else{
182  ss >> sys >> mem >> tag;
183  auto &rc = RC[sys][mem];
184  rc.RR.NETA=RETA;
185  rc.RR.NTRK=RTRK;
186  rc.RR.NMIN=RMIN;
187  auto &resol = rc.RR.resol;
188  if(resol.empty()){
189  resol.resize(RETA);
190  for(size_t ir=0; ir<resol.size(); ++ir){
191  auto &r = resol[ir];
192  r.eta = BETA[ir];
193  r.cb.resize(RTRK);
194  for(auto i:{0,1})r.nTrk[i].resize(RTRK+1);
195  for(auto i:{0,1,2})r.rsPar[i].resize(RTRK);
196  }
197  }
198  auto &cp = rc.CP;
199  for(TYPE T:{MC,DT}){
200  if(cp[T].empty()){
201  cp[T].resize(NETA);
202  for(auto &i: cp[T]) i.resize(NPHI);
203  }
204  }
205 
206  if(tag=="R"){
207  ss >> var >> bin;
208  for(int i=0; i<RTRK; ++i) {
209  switch(var){
210  case 0: ss >> resol[bin].rsPar[var][i]; break;
211  case 1: ss >> resol[bin].rsPar[var][i]; break;
212  case 2: ss >> resol[bin].rsPar[var][i]; resol[bin].rsPar[var][i]/=100; break;
213  case 3: ss >> resol[bin].cb[i].s; break;
214  case 4: ss >> resol[bin].cb[i].a; break;
215  case 5: ss >> resol[bin].cb[i].n; break;
216  default: break;
217  }
218  }
219  }
220  else if(tag=="T") {
221  ss >> type >> bin;
222  for(int i=0; i<RTRK+1; ++i) ss >> resol[bin].nTrk[type][i];
223  }
224  else if(tag=="F") {
225  ss >> type;
226  for(int i=0; i<RETA; ++i) ss >> resol[i].kRes[type];
227 
228  }
229  else if(tag=="C") {
230  ss >> type >> var >> bin;
231  for(int i=0; i<NPHI; ++i){
232  auto &x = cp[type][bin][i];
233  if(var==0) { ss >> x.M; x.M = 1.0+x.M/100;}
234  else if(var==1){ ss >> x.A; x.A/=100; }
235  }
236  }
237  }
238  }
239 
240  for(auto &rcs: RC)
241  for(auto &rcm: rcs)
242  for(auto &r: rcm.RR.resol)
243  for(auto &i: r.cb) i.init();
244 
245  in.close();
246 }

◆ kGenSmear()

double kGenSmear ( double  pt,
double  eta,
double  v,
double  u,
RocRes::TYPE  TT = RocRes::Data,
int  s = 0,
int  m = 0 
) const
307  {
308  if(empty()) return 1.0;
309  return RC[s][m].RR.kSmear(pt, eta, TT, v, u);
310 }

◆ kScaleAndSmearMC()

double kScaleAndSmearMC ( int  Q,
double  pt,
double  eta,
double  phi,
int  n,
double  u,
double  w,
int  s = 0,
int  m = 0 
) const
299  {
300  const auto& rc=RC[s][m];
301  int H = etaBin(eta);
302  int F = phiBin(phi);
303  double k=1.0/(rc.CP[MC][H][F].M + Q*rc.CP[MC][H][F].A*pt);
304  return k*rc.RR.kExtra(k*pt, eta, n, u, w);
305 }

◆ kScaleAndSmearMCerror()

double kScaleAndSmearMCerror ( int  Q,
double  pt,
double  eta,
double  phi,
int  n,
double  u,
double  w 
) const
340  {
341  return error([this, Q, pt, eta, phi, n, u, w](int s, int m) {return kScaleAndSmearMC(Q, pt, eta, phi, n, u, w, s, m);});
342 }

◆ kScaleDT()

double kScaleDT ( int  Q,
double  pt,
double  eta,
double  phi,
int  s = 0,
int  m = 0 
) const
262  {
263  int H = etaBin(eta);
264  int F = phiBin(phi);
265  return 1.0/(RC[s][m].CP[DT][H][F].M + Q*RC[s][m].CP[DT][H][F].A*pt);
266 }

◆ kScaleDTerror()

double kScaleDTerror ( int  Q,
double  pt,
double  eta,
double  phi 
) const
324  {
325  return error([this, Q, pt, eta, phi](int s, int m) {return kScaleDT(Q, pt, eta, phi, s, m);});
326 }

◆ kScaleFromGenMC()

double kScaleFromGenMC ( int  Q,
double  pt,
double  eta,
double  phi,
int  n,
double  gt,
double  w,
int  s = 0,
int  m = 0 
) const
291  {
292  const auto& rc=RC[s][m];
293  int H = etaBin(eta);
294  int F = phiBin(phi);
295  double k=1.0/(rc.CP[MC][H][F].M + Q*rc.CP[MC][H][F].A*pt);
296  return k*rc.RR.kSpread(gt, k*pt, eta, n, w);
297 }

◆ kScaleFromGenMCerror()

double kScaleFromGenMCerror ( int  Q,
double  pt,
double  eta,
double  phi,
int  n,
double  gt,
double  w 
) const
336  {
337  return error([this, Q, pt, eta, phi, n, gt, w](int s, int m) {return kScaleFromGenMC(Q, pt, eta, phi, n, gt, w, s, m);});
338 }

◆ kScaleMC()

double kScaleMC ( int  Q,
double  pt,
double  eta,
double  phi,
int  s = 0,
int  m = 0 
) const
268  {
269  int H = etaBin(eta);
270  int F = phiBin(phi);
271  return 1.0/(RC[s][m].CP[MC][H][F].M + Q*RC[s][m].CP[MC][H][F].A*pt);
272 }

◆ kSmearMC()

double kSmearMC ( int  Q,
double  pt,
double  eta,
double  phi,
int  n,
double  u,
int  s = 0,
int  m = 0 
) const
282  {
283  const auto& rc=RC[s][m];
284  int H = etaBin(eta);
285  int F = phiBin(phi);
286  double k=1.0/(rc.CP[MC][H][F].M + Q*rc.CP[MC][H][F].A*pt);
287  return k*rc.RR.kExtra(k*pt, eta, n, u);
288 }

◆ kSmearMCerror()

double kSmearMCerror ( int  Q,
double  pt,
double  eta,
double  phi,
int  n,
double  u 
) const
332  {
333  return error([this, Q, pt, eta, phi, n, u](int s, int m){return kSmearMC(Q, pt, eta, phi, n, u, s, m);});
334 }

◆ kSpreadMC()

double kSpreadMC ( int  Q,
double  pt,
double  eta,
double  phi,
double  gt,
int  s = 0,
int  m = 0 
) const
274  {
275  const auto& rc=RC[s][m];
276  int H = etaBin(eta);
277  int F = phiBin(phi);
278  double k=1.0/(rc.CP[MC][H][F].M + Q*rc.CP[MC][H][F].A*pt);
279  return k*rc.RR.kSpread(gt, k*pt, eta);
280 }

◆ kSpreadMCerror()

double kSpreadMCerror ( int  Q,
double  pt,
double  eta,
double  phi,
double  gt 
) const
328  {
329  return error([this, Q, pt, eta, phi, gt](int s, int m){return kSpreadMC(Q, pt, eta, phi, gt, s, m);});
330 }

◆ phiBin()

int phiBin ( double  phi) const
protected
255  {
256  int ibin=(x-MPHI)/DPHI;
257  if(ibin<0) return 0;
258  if(ibin>=NPHI) return NPHI-1;
259  return ibin;
260 }

◆ reset()

void reset ( )
118  {
119  NETA=0;
120  NPHI=0;
121  std::vector<double>().swap(etabin);
122  nset=0;
123  std::vector<int>().swap(nmem);
124  std::vector<std::vector<RocOne>>().swap(RC);
125 
126 }

Member Data Documentation

◆ DPHI

double DPHI
private

◆ etabin

std::vector<double> etabin
private

◆ MPHI

const double MPHI =-CrystalBall::pi
staticprivate

◆ NETA

int NETA
private

◆ nmem

std::vector<int> nmem
private

◆ NPHI

int NPHI
private

◆ nset

int nset
private

◆ RC

std::vector<std::vector<RocOne> > RC
private

◆ tvar

std::vector<int> tvar
private

The documentation for this class was generated from the following files:
RoccoR::nset
int nset
Definition: RoccoR.h:141
RoccoR::kScaleAndSmearMC
double kScaleAndSmearMC(int Q, double pt, double eta, double phi, int n, double u, double w, int s=0, int m=0) const
Definition: RoccoR.cc:299
RoccoR::kSmearMC
double kSmearMC(int Q, double pt, double eta, double phi, int n, double u, int s=0, int m=0) const
Definition: RoccoR.cc:282
RoccoR::RC
std::vector< std::vector< RocOne > > RC
Definition: RoccoR.h:144
jmarExample.pt
pt
Definition: jmarExample.py:19
RoccoR::error
double error(T f) const
Definition: RoccoR.cc:313
RoccoR::tvar
std::vector< int > tvar
Definition: RoccoR.h:143
RoccoR::NPHI
int NPHI
Definition: RoccoR.h:130
Ntupliser_cfg.f
f
Definition: Ntupliser_cfg.py:256
RoccoR::Symhes
@ Symhes
Definition: RoccoR.h:125
DAS::JetEnergy::w
static const float w
Definition: common.h:51
RoccoR::nmem
std::vector< int > nmem
Definition: RoccoR.h:142
RoccoR::phiBin
int phiBin(double phi) const
Definition: RoccoR.cc:255
RoccoR::init
void init(std::string filename)
Definition: RoccoR.cc:129
RoccoR::TYPE
TYPE
Definition: RoccoR.h:152
CrystalBall::pi
static const double pi
Definition: RoccoR.h:7
RoccoR::DPHI
double DPHI
Definition: RoccoR.h:131
RoccoR::empty
bool empty() const
Definition: RoccoR.h:159
RoccoR::MPHI
static const double MPHI
Definition: RoccoR.h:127
RoccoR::etaBin
int etaBin(double eta) const
Definition: RoccoR.cc:250
RoccoR::kScaleFromGenMC
double kScaleFromGenMC(int Q, double pt, double eta, double phi, int n, double gt, double w, int s=0, int m=0) const
Definition: RoccoR.cc:291
Darwin::Tools
Classes and functions related to the framework.
Definition: Dict_rdict.cxx:990
RoccoR::NETA
int NETA
Definition: RoccoR.h:129
RoccoR::DT
@ DT
Definition: RoccoR.h:152
RoccoR::kScaleDT
double kScaleDT(int Q, double pt, double eta, double phi, int s=0, int m=0) const
Definition: RoccoR.cc:262
RoccoR::Default
@ Default
Definition: RoccoR.h:125
RoccoR::etabin
std::vector< double > etabin
Definition: RoccoR.h:132
jmarExample.eta
eta
DeepAK8/ParticleNet tagging.
Definition: jmarExample.py:19
RoccoR::kSpreadMC
double kSpreadMC(int Q, double pt, double eta, double phi, double gt, int s=0, int m=0) const
Definition: RoccoR.cc:274
RoccoR::Replica
@ Replica
Definition: RoccoR.h:125
RoccoR::MC
@ MC
Definition: RoccoR.h:152