31{
32
35 TFile* theLCClassificationFile =
new TFile(
file.c_str());
36 if ( !theLCClassificationFile ) {
37 return StatusCode::FAILURE;
38 }
39
40 CaloLocalHadCoeff::LocalHadArea theArea("Classification",0,3);
41
42 TList * theKeyList = theLCClassificationFile->GetListOfKeys();
43 while ( theKeyList->GetEntries() ) {
44 TProfile2D * prof = (TProfile2D *)theLCClassificationFile->Get(theKeyList->First()->GetTitle());
45
46 std::string sTitle(prof->GetTitle());
47 bool allValid(true);
48
49 std::vector<std::string>
keys;
50 keys.emplace_back(
"_iside_");
51 keys.emplace_back(
"_ieta_");
52 keys.emplace_back(
"_iphi_");
53 keys.emplace_back(
"_ilogE_");
54
55 std::vector<std::string>
names;
56 names.emplace_back(
"side");
57 names.emplace_back(
"|eta|");
58 names.emplace_back(
"phi");
59 names.emplace_back(
"log10(E_clus (MeV))");
60 names.emplace_back(prof->GetXaxis()->GetTitle());
61 names.emplace_back(prof->GetYaxis()->GetTitle());
62
63 std::vector<int>
types;
70
71 std::vector<int> ibin(
names.size(),-1);
72 std::vector<double> rmin(
names.size(),-1);
73 std::vector<double> rmax(
names.size(),-1);
74 std::vector<int> nbin(
names.size(),-1);
75 unsigned int idim;
76
77 for (idim=0;idim<
keys.size();idim++) {
78 size_t found = sTitle.find(keys[idim]);
79 if ( found == std::string::npos ) {
80 ATH_MSG_ERROR (
"Could not find key " << keys[idim] <<
" in current histogram.");
81 allValid = false;
82 }
83 else {
85 std::istringstream tstr(sTitle.substr(found+keys[idim].length()));
86 tstr >> ibin[idim] >>
c >>
c >> rmin[idim] >>
c >> rmax[idim] >>
c >> nbin[idim];
87 if ( ibin[idim] < 0 || ibin[idim] >= nbin[idim] ) {
88 ATH_MSG_ERROR (
"Found invalid bin number " << ibin[idim] <<
" not in valid range [0," << nbin[idim] <<
" in current histogram.");
89 allValid = false;
90 }
91 }
92 }
93 if ( allValid ) {
94
95 nbin[
names.size()-2] = prof->GetNbinsX();
96 rmin[
names.size()-2] = prof->GetXaxis()->GetXmin();
97 rmax[
names.size()-2] = prof->GetXaxis()->GetXmax();
98 nbin[
names.size()-1] = prof->GetNbinsY();
99 rmin[
names.size()-1] = prof->GetYaxis()->GetXmin();
100 rmax[
names.size()-1] = prof->GetYaxis()->GetXmax();
101
102 if ( theArea.getNdim() == 0 ) {
103 for (idim = 0;idim<
names.size();idim++) {
104 CaloLocalHadCoeff::LocalHadDimension theDim(names[idim].c_str(),
types[idim],nbin[idim],rmin[idim],rmax[idim]);
105 theArea.addDimension(theDim);
106 }
107 ATH_MSG_INFO (
"adding Area with nDim = " << theArea.getNdim());
108 data.addArea(theArea);
109 }
110
111 TAxis * xax = prof->GetXaxis();
112 TAxis * yax = prof->GetYaxis();
113 for (ibin[
names.size()-2]=0;ibin[
names.size()-2]<prof->GetNbinsX();ibin[
names.size()-2]++) {
114 for (ibin[
names.size()-1]=0;ibin[
names.size()-1]<prof->GetNbinsY();ibin[
names.size()-1]++) {
115 float logEDens = xax->GetBinCenter(ibin[
names.size()-2]+1);
116 float loglambda = yax->GetBinCenter(ibin[
names.size()-1]+1);
117 int iBin = prof->FindBin(logEDens,loglambda);
118
123
124 msg() << MSG::INFO <<
"Now set data for bins: ";
125 for(unsigned int ii=0;ii<ibin.size();ii++)
126 msg() << ibin[ii] <<
" ";
128 int dbin =
data.getBin(0,ibin);
129 if (dbin >= 0)
130 data.setCoeff(dbin,theData);
131 }
132 }
133 }
134 theKeyList->RemoveFirst();
135 }
136
137 return StatusCode::SUCCESS;
138}
char data[hepevt_bytes_allocation_ATLAS]
static const std::vector< std::string > types
std::vector< float > LocalHadCoeff
Correction parameters for one general bin.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)