FairRoot/PandaRoot
PndMvdRadDamList.cxx
Go to the documentation of this file.
1 /*
2  * PndMvdRadDamList.cpp
3  *
4  * Created on: Dec 16, 2008
5  * Author: stockman
6  */
7 
8 #include "PndMvdRadDamList.h"
9 
10 #include "TFile.h"
11 #include "TTree.h"
12 
13 #include <iostream>
14 
16 {
17  Float_t E, W;
18  TFile f(fileName);
19  TTree* t = (TTree*)f.Get("data");
20  t->SetBranchAddress("E_GeV", &E);
21  t->SetBranchAddress("Weight", &W);
22 
23  for (int i = 0; i < t->GetEntriesFast(); i++){
24  t->GetEntry(i);
25  fList.push_back(std::pair<Double_t, Double_t>(E, W));
26  }
27 
28 }
29 
31 {
32  // TODO Auto-generated destructor stub
33 }
34 
36 {
37  Int_t index = FindClosestEnergyIndex(energy);
38  return Interpolate(energy, index);
39 }
40 
42 {
43 
44  for (unsigned int i = 0; i < fList.size(); i++){
45  if (fList[i].first > energy)
46  return i-1;
47  }
48  return -2; //energy is bigger than the latest entry in the list
49 }
50 
52 {
53  std::pair<Double_t, Double_t> ew1, ew2;
54  if (index == -1){ //energy is lower than the smallest energy entry in the list
55  ew1 = fList[0];
56  ew2 = fList[1];
57  std::cout << "-W- PndMvdRadDamList::Interpolate: Energy is lower than list values" << std::endl;
58  }
59  else if (index < -1){
60  ew1 = fList[fList.size()-2];
61  ew2 = fList[fList.size()-1];
62  std::cout << "-W- PndMvdRadDamList::Interpolate: Energy is bigger than list values" << std::endl;
63  }
64  else{
65  ew1 = fList[index];
66  ew2 = fList[index+1];
67  }
68  return ew1.second + (ew2.second - ew1.second)/(ew2.first - ew1.first) * (energy - ew1.first);
69 }
70 
PndMvdRadDamList(TString fileName)
std::vector< std::pair< Double_t, Double_t > > fList
Double_t GetWeight(Double_t energy)
Int_t i
Definition: run_full.C:25
ClassImp(PndMvdRadDamList)
#define W
Definition: createSTT.C:76
Double_t
virtual ~PndMvdRadDamList()
Double_t Interpolate(Double_t energy, Int_t index)
TFile * f
Definition: bump_analys.C:12
Int_t FindClosestEnergyIndex(Double_t energy)
TTree * t
Definition: bump_analys.C:13
Double_t energy
Definition: plot_dirc.C:15