FairRoot/PandaRoot
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
PndEmcClusterHistCalibrator Class Reference

#include <PndEmcClusterCalibrator.h>

Inheritance diagram for PndEmcClusterHistCalibrator:
PndEmcAbsClusterCalibrator

Public Member Functions

 PndEmcClusterHistCalibrator (Int_t version=1)
 
virtual ~PndEmcClusterHistCalibrator ()
 
virtual Double_t Energy (PndEmcCluster *clust, Int_t pid=22)
 
virtual TVector3 Where (PndEmcCluster *clust, Int_t pid=22)
 

Protected Attributes

Int_t fVersion
 
TString fPath
 

Private Member Functions

Int_t FindTheBin (TH2 *lookup_table, Float_t value_x, Float_t value_y, Int_t &bin_x, Int_t &bin_y)
 
Double_t GetValueInZ (TH2 *lookup_table, Float_t value_x, Float_t value_y, Bool_t use_interpolation=kFALSE)
 
 PndEmcClusterHistCalibrator (const PndEmcClusterHistCalibrator &L)
 
PndEmcClusterHistCalibratoroperator= (const PndEmcClusterHistCalibrator &)
 

Private Attributes

TFile * fPhoton
 
TFile * fElectron
 
TFile * fPion
 
TH2F * fHEnergyRatioBarrelPhoton
 
TH2F * fHEnergyRatioFwdPhoton
 
TH2F * fHEnergyRatioBwdPhoton
 
TH2F * fHEnergyRatioShashlykPhoton
 
TH2F * fHThetaDiffBarrelPhoton
 
TH2F * fHThetaDiffFwdPhoton
 
TH2F * fHThetaDiffBwdPhoton
 
TH2F * fHThetaDiffShashlykPhoton
 

Detailed Description

Definition at line 74 of file PndEmcClusterCalibrator.h.

Constructor & Destructor Documentation

PndEmcClusterHistCalibrator::PndEmcClusterHistCalibrator ( Int_t  version = 1)

Definition at line 92 of file PndEmcClusterCalibrator.cxx.

References fHEnergyRatioBarrelPhoton, fHEnergyRatioBwdPhoton, fHEnergyRatioFwdPhoton, fHEnergyRatioShashlykPhoton, fHThetaDiffBarrelPhoton, fHThetaDiffBwdPhoton, fHThetaDiffFwdPhoton, fHThetaDiffShashlykPhoton, PndEmcAbsClusterCalibrator::fPath, fPhoton, and TString.

92  :
93 fPhoton(new TFile()), fElectron(new TFile()), fPion(new TFile()),
95 {
96 
97  fPath = getenv("VMCWORKDIR");
98  fPath += "/macro/params/";
99 
100  TString fileNamePhoton;
101  fileNamePhoton.Form("emc_correction_hist_gamma_%i.root",version);
102  fileNamePhoton=fPath+fileNamePhoton;
103 
104  fPhoton = new TFile(fileNamePhoton,"READ");
105  if (fPhoton->IsZombie())
106  {
107  std::cout<<"EMC cluster correction file "<<fileNamePhoton<<" for photons does not exist for given version"<<std::endl;
108  } else
109  {
110  // Photon
111  fHEnergyRatioBarrelPhoton = (TH2F*) fPhoton->Get("hisEnergyRatioBarrel");
112  fHThetaDiffBarrelPhoton = (TH2F*) fPhoton->Get("hisThetaDiffBarrel");
113  fHEnergyRatioFwdPhoton = (TH2F*) fPhoton->Get("hisEnergyRatioFwd");
114  fHThetaDiffFwdPhoton = (TH2F*) fPhoton->Get("hisThetaDiffFwd");
115  fHEnergyRatioBwdPhoton = (TH2F*) fPhoton->Get("hisEnergyRatioBwd");
116  fHThetaDiffBwdPhoton = (TH2F*) fPhoton->Get("hisThetaDiffBwd");
117  fHEnergyRatioShashlykPhoton = (TH2F*) fPhoton->Get("hisEnergyRatioShashlyk");
118  fHThetaDiffShashlykPhoton = (TH2F*) fPhoton->Get("hisThetaDiffShashlyk");
119  }
120 
121 // TString fileNameElectron;
122 // TString fileNamePion;
123 // fileNameElectron.Form("emc_correction_hist_electron_%i.root",version);
124 // fileNamePion.Form("emc_correction_hist_pion_%i.root",version);
125 // fileNameElectron=fPath+fileNameElectron;
126 // fileNamePion=fPath+fileNamePion;
127 // fHEnergyRatioBarrelElectron=0; fHEnergyRatioFwdElectron=0; fHEnergyRatioBwdElectron=0; fHEnergyRatioShashlykElectron=0;
128 // fHThetaDiffBarrelElectron=0; fHThetaDiffFwdElectron=0; fHThetaDiffBwdElectron=0; fHThetaDiffShashlykElectron=0;
129 // fHEnergyRatioBarrelPion=0; fHEnergyRatioFwdPion=0; fHEnergyRatioBwdPion=0; fHEnergyRatioShashlykPion=0;
130 // fHThetaDiffBarrelPion=0; fHThetaDiffFwdPion=0; fHThetaDiffBwdPion=0; fHThetaDiffShashlykPion=0;
131 //
132 //
133 // fElectron = new TFile(fileNameElectron,"READ");
134 // if (fElectron->IsZombie())
135 // {
136 // std::cout<<"EMC cluster correction file "<<fileNameElectron<<" for electrons does not exist for given version"<<std::endl;
137 // } else
138 // {
139 // // Electron
140 // fHEnergyRatioBarrelElectron = (TH2F*) fElectron->Get("hisEnergyRatioBarrel");
141 // fHThetaDiffBarrelElectron = (TH2F*) fElectron->Get("hisThetaDiffBarrel");
142 // fHEnergyRatioFwdElectron = (TH2F*) fElectron->Get("hisEnergyRatioFwd");
143 // fHThetaDiffFwdElectron = (TH2F*) fElectron->Get("hisThetaDiffFwd");
144 // fHEnergyRatioBwdElectron = (TH2F*) fElectron->Get("hisEnergyRatioBwd");
145 // fHThetaDiffBwdElectron = (TH2F*) fElectron->Get("hisThetaDiffBwd");
146 // fHEnergyRatioShashlykElectron = (TH2F*) fElectron->Get("hisEnergyRatioShashlyk");
147 // fHThetaDiffShashlykElectron = (TH2F*) fElectron->Get("hisThetaDiffShashlyk");
148 // }
149 //
150 // fPion = new TFile(fileNamePion,"READ");
151 // if (fPion->IsZombie())
152 // {
153 // std::cout<<"EMC cluster correction file "<<fileNamePion<<" for pions does not exist for given version"<<std::endl;
154 // } else
155 // {
156 // // Pion
157 // fHEnergyRatioBarrelPion = (TH2F*) fPion->Get("hisEnergyRatioBarrel");
158 // fHThetaDiffBarrelPion = (TH2F*) fPion->Get("hisThetaDiffBarrel");
159 // fHEnergyRatioFwdPion = (TH2F*) fPion->Get("hisEnergyRatioFwd");
160 // fHThetaDiffFwdPion = (TH2F*) fPion->Get("hisThetaDiffFwd");
161 // fHEnergyRatioBwdPion = (TH2F*) fPion->Get("hisEnergyRatioBwd");
162 // fHThetaDiffBwdPion = (TH2F*) fPion->Get("hisThetaDiffBwd");
163 // fHEnergyRatioShashlykPion = (TH2F*) fPion->Get("hisEnergyRatioShashlyk");
164 // fHThetaDiffShashlykPion = (TH2F*) fPion->Get("hisThetaDiffShashlyk");
165 // }
166 
167 }
PndEmcClusterHistCalibrator::~PndEmcClusterHistCalibrator ( )
virtual

Definition at line 169 of file PndEmcClusterCalibrator.cxx.

References fPhoton.

170 {
171  fPhoton->Close();
172  delete fPhoton;
173 // fElectron->Close();
174 // fPion->Close();
175 // delete fElectron;
176 // delete fPion;
177 }
PndEmcClusterHistCalibrator::PndEmcClusterHistCalibrator ( const PndEmcClusterHistCalibrator L)
private

Member Function Documentation

Double_t PndEmcClusterHistCalibrator::Energy ( PndEmcCluster clust,
Int_t  pid = 22 
)
virtual

Implements PndEmcAbsClusterCalibrator.

Definition at line 179 of file PndEmcClusterCalibrator.cxx.

References Bool_t, Double_t, energy, PndEmcCluster::energy(), fHEnergyRatioBarrelPhoton, fHEnergyRatioBwdPhoton, fHEnergyRatioFwdPhoton, fHEnergyRatioShashlykPhoton, PndEmcCluster::GetModule(), GetValueInZ(), Pi, theta, and PndEmcCluster::where().

180 {
181  Double_t valzEn;
182  Bool_t use_interpolation=kTRUE;
183 
184  Double_t energy=theCluster->energy();
185  TVector3 position=theCluster->where();
186  Double_t theta=position.Theta();
187  Double_t thetaRad=theta*(180./TMath::Pi());
188 
189  Int_t module=theCluster->GetModule();
190 
191  //TH2F *fHEnergyRatioBarrel, *fHThetaDiffBarrel, *fHEnergyRatioFwd, *fHThetaDiffFwd,
192  //*fHEnergyRatioBwd, *fHThetaDiffBwd, *fHEnergyRatioShashlyk, *fHThetaDiffShashlyk; //[R.K. 01/2017] unused variable?
193 
194  switch (pid)
195  {
196  case 22: // photon
197  switch (module)
198  {
199  case 1:
200  case 2:
201  valzEn = GetValueInZ( fHEnergyRatioBarrelPhoton, energy, thetaRad, use_interpolation);
202  break;
203  case 3:
204  valzEn = GetValueInZ( fHEnergyRatioFwdPhoton, energy, thetaRad, use_interpolation);
205  break;
206  case 4:
207  valzEn = GetValueInZ( fHEnergyRatioBwdPhoton, energy, thetaRad, use_interpolation);
208  break;
209  case 5:
210  valzEn = GetValueInZ( fHEnergyRatioShashlykPhoton, energy, thetaRad, use_interpolation);
211  break;
212  default:
213  std::cout<<"Wrong EMC module in PndEmcClusterHistCalibrator"<<std::endl;
214  }
215  break;
216 // case 11: // electron
217 // case -11: // positron
218 // switch (module)
219 // {
220 // case 1:
221 // case 2:
222 // valzEn = GetValueInZ( fHEnergyRatioBarrelElectron, energy, thetaRad, use_interpolation);
223 // break;
224 // case 3:
225 // valzEn = GetValueInZ( fHEnergyRatioFwdElectron, energy, thetaRad, use_interpolation);
226 // break;
227 // case 4:
228 // valzEn = GetValueInZ( fHEnergyRatioBwdElectron, energy, thetaRad, use_interpolation);
229 // break;
230 // case 5:
231 // valzEn = GetValueInZ( fHEnergyRatioShashlykElectron, energy, thetaRad, use_interpolation);
232 // break;
233 // default:
234 // std::cout<<"Wrong EMC module in PndEmcClusterHistCalibrator"<<std::endl;
235 // }
236 // break;
237 // case 211:
238 // case -211:
239 // switch (module)
240 // {
241 // case 1:
242 // case 2:
243 // valzEn = GetValueInZ( fHEnergyRatioBarrelPion, energy, thetaRad, use_interpolation);
244 // break;
245 // case 3:
246 // valzEn = GetValueInZ( fHEnergyRatioFwdPion, energy, thetaRad, use_interpolation);
247 // break;
248 // case 4:
249 // valzEn = GetValueInZ( fHEnergyRatioBwdPion, energy, thetaRad, use_interpolation);
250 // break;
251 // case 5:
252 // valzEn = GetValueInZ( fHEnergyRatioShashlykPion, energy, thetaRad, use_interpolation);
253 // break;
254 // default:
255 // std::cout<<"Wrong EMC module in PndEmcClusterHistCalibrator"<<std::endl;
256 // }
257 // break;
258  default:
259  std::cout<<"Emc cluster correction for pid= "<<pid<<" is not defined. Photon values is used."<<std::endl;
260  switch (module)
261  {
262  case 1:
263  case 2:
264  valzEn = GetValueInZ( fHEnergyRatioBarrelPhoton, energy, thetaRad, use_interpolation);
265  break;
266  case 3:
267  valzEn = GetValueInZ( fHEnergyRatioFwdPhoton, energy, thetaRad, use_interpolation);
268  break;
269  case 4:
270  valzEn = GetValueInZ( fHEnergyRatioBwdPhoton, energy, thetaRad, use_interpolation);
271  break;
272  case 5:
273  valzEn = GetValueInZ( fHEnergyRatioShashlykPhoton, energy, thetaRad, use_interpolation);
274  break;
275  default:
276  std::cout<<"Wrong EMC module in PndEmcClusterHistCalibrator"<<std::endl;
277  }
278  }
279 
280  Double_t energyCorrected = energy/valzEn;
281 
282  return energyCorrected;
283 }
int pid()
Double_t
Double_t Pi
Double_t GetValueInZ(TH2 *lookup_table, Float_t value_x, Float_t value_y, Bool_t use_interpolation=kFALSE)
Double_t energy
Definition: plot_dirc.C:15
Int_t PndEmcClusterHistCalibrator::FindTheBin ( TH2 *  lookup_table,
Float_t  value_x,
Float_t  value_y,
Int_t &  bin_x,
Int_t &  bin_y 
)
private

Definition at line 397 of file PndEmcClusterCalibrator.cxx.

Referenced by GetValueInZ().

398 {
399  bin_x = lookup_table->GetXaxis()->FindBin(value_x);
400  bin_y = lookup_table->GetYaxis()->FindBin(value_y);
401 
402  if ((bin_x < 1) || (bin_x > lookup_table->GetXaxis()->GetNbins()))
403  {
404  bin_x = -1; bin_y = -1;
405  return -1;
406  }
407 
408  if ((bin_y < 1) || (bin_y > lookup_table->GetYaxis()->GetNbins()))
409  {
410  bin_x = -1; bin_y = -1;
411  return -2;
412  }
413 
414  return 0; // Success
415 }
Double_t PndEmcClusterHistCalibrator::GetValueInZ ( TH2 *  lookup_table,
Float_t  value_x,
Float_t  value_y,
Bool_t  use_interpolation = kFALSE 
)
private

Definition at line 418 of file PndEmcClusterCalibrator.cxx.

References FindTheBin().

Referenced by Energy(), and Where().

419 {
420  // We own the EmcLocMaxInfo objects. Delete from last time.
421  // Clean-up res, We need an empty set to store the results.
422 
423  if (use_interpolation)
424  {
425  //cout<<"use_interpolation = kTRUE "<<endl;
426  //
427  // Use the interpolarion routine of ROOT:
428  // Interpolate approximates the value via bilinear
429  // interpolation based on the four nearest bin centers
430  // see Wikipedia, Bilinear Interpolation
431  // Andy Mastbaum 10/8/2008
432  // vaguely based on R.Raja 6-Sep-2008
433  //
434  //cout<<"value_x = "<< value_x <<", value_y = "<<value_y <<endl;
435 
436  // If values are outside histogram range return 1
437  Int_t binx, biny, retval;
438  retval = FindTheBin(lookup_table, value_x, value_y, binx, biny);
439  if (retval)
440  {
441  //std::cout<<"Energy = "<<value_x<<" theta="<<value_y<<std::endl;
442  return 1.;
443  }
444  return (lookup_table->Interpolate(value_x,value_y));
445  }
446  else
447  {
448  //cout<<"use_interpolation = kFALSE "<<endl;
449  Int_t binx, biny, retval;
450  retval = FindTheBin(lookup_table, value_x, value_y, binx, biny);
451  if (retval)
452  {
453  cout << "<E> Error in FindTheBin, check your table and input values!!!!: " << retval << endl;
454  return 0;
455  }
456 
457  return (lookup_table->GetBinContent(binx,biny));
458  }
459  return 0;
460 }
Int_t FindTheBin(TH2 *lookup_table, Float_t value_x, Float_t value_y, Int_t &bin_x, Int_t &bin_y)
PndEmcClusterHistCalibrator& PndEmcClusterHistCalibrator::operator= ( const PndEmcClusterHistCalibrator )
inlineprivate

Definition at line 98 of file PndEmcClusterCalibrator.h.

98 {return *this;};
TVector3 PndEmcClusterHistCalibrator::Where ( PndEmcCluster clust,
Int_t  pid = 22 
)
virtual

Implements PndEmcAbsClusterCalibrator.

Definition at line 285 of file PndEmcClusterCalibrator.cxx.

References Bool_t, Double_t, energy, PndEmcCluster::energy(), fHThetaDiffBarrelPhoton, fHThetaDiffBwdPhoton, fHThetaDiffFwdPhoton, fHThetaDiffShashlykPhoton, PndEmcCluster::GetModule(), GetValueInZ(), Pi, and PndEmcCluster::where().

286 {
287  Double_t valzTh;
288  Bool_t use_interpolation=kTRUE;
289 
290  Double_t energy=theCluster->energy();
291  TVector3 position=theCluster->where();
292  Double_t thetaRad=position.Theta()*(180./TMath::Pi());
293  Double_t phiRad=position.Phi();
294  Double_t mag=position.Mag();
295 
296  Int_t module=theCluster->GetModule();
297 
298  switch (pid)
299  {
300  case 22: // photon
301  switch (module)
302  {
303  case 1:
304  case 2:
305  valzTh = GetValueInZ( fHThetaDiffBarrelPhoton, energy, thetaRad, use_interpolation);
306  break;
307  case 3:
308  valzTh = GetValueInZ( fHThetaDiffFwdPhoton, energy, thetaRad, use_interpolation);
309  break;
310  case 4:
311  valzTh = GetValueInZ( fHThetaDiffBwdPhoton, energy, thetaRad, use_interpolation);
312  break;
313  case 5:
314  valzTh = GetValueInZ( fHThetaDiffShashlykPhoton, energy, thetaRad, use_interpolation);
315  break;
316  default:
317  std::cout<<"Wrong EMC module in PndEmcClusterHistCalibrator"<<std::endl;
318  }
319  break;
320 // case 11: // electron
321 // case -11: // positron
322 // switch (module)
323 // {
324 // case 1:
325 // case 2:
326 // valzTh = GetValueInZ( fHThetaDiffBarrelElectron, energy, thetaRad, use_interpolation);
327 // break;
328 // case 3:
329 // valzTh = GetValueInZ( fHThetaDiffFwdElectron, energy, thetaRad, use_interpolation);
330 // break;
331 // case 4:
332 // valzTh = GetValueInZ( fHThetaDiffBwdElectron, energy, thetaRad, use_interpolation);
333 // break;
334 // case 5:
335 // valzTh = GetValueInZ( fHThetaDiffShashlykElectron, energy, thetaRad, use_interpolation);
336 // break;
337 // default:
338 // std::cout<<"Wrong EMC module in PndEmcClusterHistCalibrator"<<std::endl;
339 // }
340 // break;
341 // case 211:
342 // case -211:
343 // switch (module)
344 // {
345 // case 1:
346 // case 2:
347 // valzTh = GetValueInZ( fHThetaDiffBarrelPion, energy, thetaRad, use_interpolation);
348 // break;
349 // case 3:
350 // valzTh = GetValueInZ( fHThetaDiffFwdPion, energy, thetaRad, use_interpolation);
351 // break;
352 // case 4:
353 // valzTh = GetValueInZ( fHThetaDiffBwdPion, energy, thetaRad, use_interpolation);
354 // break;
355 // case 5:
356 // valzTh = GetValueInZ( fHThetaDiffShashlykPion, energy, thetaRad, use_interpolation);
357 // break;
358 // default:
359 // std::cout<<"Wrong EMC module in PndEmcClusterHistCalibrator"<<std::endl;
360 // }
361 // break;
362  default:
363  std::cout<<"Emc cluster correction for pid= "<<pid<<" is not defined. Photon values is used."<<std::endl;
364  switch (module)
365  {
366  case 1:
367  case 2:
368  valzTh = GetValueInZ( fHThetaDiffBarrelPhoton, energy, thetaRad, use_interpolation);
369  break;
370  case 3:
371  valzTh = GetValueInZ( fHThetaDiffFwdPhoton, energy, thetaRad, use_interpolation);
372  break;
373  case 4:
374  valzTh = GetValueInZ( fHThetaDiffBwdPhoton, energy, thetaRad, use_interpolation);
375  break;
376  case 5:
377  valzTh = GetValueInZ( fHThetaDiffShashlykPhoton, energy, thetaRad, use_interpolation);
378  break;
379  default:
380  std::cout<<"Wrong EMC module in PndEmcClusterHistCalibrator"<<std::endl;
381  }
382  }
383 
384  Double_t thetaCorrected = valzTh+thetaRad;
385  Double_t thetaCorrectedRad = thetaCorrected*(TMath::Pi()/180.);
386 
387  TVector3 correctedPos;
388  correctedPos.SetMagThetaPhi(mag,thetaCorrectedRad,phiRad);
389 
390  return correctedPos;
391 }
int pid()
Double_t
Double_t Pi
Double_t GetValueInZ(TH2 *lookup_table, Float_t value_x, Float_t value_y, Bool_t use_interpolation=kFALSE)
Double_t energy
Definition: plot_dirc.C:15

Member Data Documentation

TFile * PndEmcClusterHistCalibrator::fElectron
private

Definition at line 89 of file PndEmcClusterCalibrator.h.

TH2F* PndEmcClusterHistCalibrator::fHEnergyRatioBarrelPhoton
private

Definition at line 90 of file PndEmcClusterCalibrator.h.

Referenced by Energy(), and PndEmcClusterHistCalibrator().

TH2F * PndEmcClusterHistCalibrator::fHEnergyRatioBwdPhoton
private

Definition at line 90 of file PndEmcClusterCalibrator.h.

Referenced by Energy(), and PndEmcClusterHistCalibrator().

TH2F * PndEmcClusterHistCalibrator::fHEnergyRatioFwdPhoton
private

Definition at line 90 of file PndEmcClusterCalibrator.h.

Referenced by Energy(), and PndEmcClusterHistCalibrator().

TH2F * PndEmcClusterHistCalibrator::fHEnergyRatioShashlykPhoton
private

Definition at line 90 of file PndEmcClusterCalibrator.h.

Referenced by Energy(), and PndEmcClusterHistCalibrator().

TH2F* PndEmcClusterHistCalibrator::fHThetaDiffBarrelPhoton
private

Definition at line 91 of file PndEmcClusterCalibrator.h.

Referenced by PndEmcClusterHistCalibrator(), and Where().

TH2F * PndEmcClusterHistCalibrator::fHThetaDiffBwdPhoton
private

Definition at line 91 of file PndEmcClusterCalibrator.h.

Referenced by PndEmcClusterHistCalibrator(), and Where().

TH2F * PndEmcClusterHistCalibrator::fHThetaDiffFwdPhoton
private

Definition at line 91 of file PndEmcClusterCalibrator.h.

Referenced by PndEmcClusterHistCalibrator(), and Where().

TH2F * PndEmcClusterHistCalibrator::fHThetaDiffShashlykPhoton
private

Definition at line 91 of file PndEmcClusterCalibrator.h.

Referenced by PndEmcClusterHistCalibrator(), and Where().

TString PndEmcAbsClusterCalibrator::fPath
protectedinherited
TFile* PndEmcClusterHistCalibrator::fPhoton
private
TFile * PndEmcClusterHistCalibrator::fPion
private

Definition at line 89 of file PndEmcClusterCalibrator.h.

Int_t PndEmcAbsClusterCalibrator::fVersion
protectedinherited

Definition at line 49 of file PndEmcClusterCalibrator.h.


The documentation for this class was generated from the following files: