13 #include "TProfile2D.h"
18 ISvcLocator * pSvcLocator) :
35 unsigned int nAreas(0);
36 std::vector<CaloLocalHadCoeff::LocalHadArea> theAreas;
39 theAreas.push_back(theArea);
42 for (
int iread=0;iread<2;iread++) {
44 TFile* theLCWeightFile =
new TFile(
file.c_str());
45 if ( !theLCWeightFile ) {
46 return StatusCode::FAILURE;
48 TList * theKeyList = theLCWeightFile->GetListOfKeys();
49 while ( theKeyList->GetEntries() ) {
50 TProfile2D * prof = (TProfile2D *)theLCWeightFile->Get(theKeyList->First()->GetTitle());
52 std::string sTitle(prof->GetTitle());
54 std::string
key(
"_isamp_");
56 if (
found == std::string::npos ) {
60 std::istringstream tstr(sTitle.substr(
found+
key.length()));
64 ATH_MSG_ERROR(
"Found invalid sampling " << isamp <<
" in current histogram." );
70 std::vector<std::string>
keys;
71 keys.emplace_back(
"_iside_");
72 keys.emplace_back(
"_ieta_");
73 keys.emplace_back(
"_iphi_");
75 std::vector<std::string>
names;
76 names.emplace_back(
"side");
77 names.emplace_back(
"|eta|");
78 names.emplace_back(
"phi");
79 names.emplace_back(prof->GetXaxis()->GetTitle());
80 names.emplace_back(prof->GetYaxis()->GetTitle());
82 std::vector<int> types;
89 std::vector<int> ibin(
names.size(),-1);
90 std::vector<double> rmin(
names.size(),-1);
91 std::vector<double> rmax(
names.size(),-1);
92 std::vector<int> nbin(
names.size(),-1);
95 for (idim=0;idim<
keys.size();idim++) {
97 if (
found == std::string::npos ) {
103 std::istringstream tstr(sTitle.substr(
found+
keys[idim].length()));
104 tstr >> ibin[idim] >>
c >>
c >> rmin[idim] >>
c >> rmax[idim] >>
c >> nbin[idim];
105 if ( ibin[idim] < 0 || ibin[idim] >= nbin[idim] ) {
106 ATH_MSG_ERROR(
"Found invalid bin number " << ibin[idim] <<
" not in valid range [0," << nbin[idim] <<
" in current histogram." );
113 nbin[
names.size()-2] = prof->GetNbinsX();
114 rmin[
names.size()-2] = prof->GetXaxis()->GetXmin();
115 rmax[
names.size()-2] = prof->GetXaxis()->GetXmax();
116 nbin[
names.size()-1] = prof->GetNbinsY();
117 rmin[
names.size()-1] = prof->GetYaxis()->GetXmin();
118 rmax[
names.size()-1] = prof->GetYaxis()->GetXmax();
120 if ( isampmap[isamp] < 0 ) {
121 isampmap[isamp] = nAreas;
123 for (idim = 0;idim<
names.size();idim++) {
125 theAreas[isamp].addDimension(theDim);
128 else if ( iread == 1 ) {
130 TAxis * xax = prof->GetXaxis();
131 TAxis * yax = prof->GetYaxis();
132 for (ibin[
names.size()-2]=0;ibin[
names.size()-2]<prof->GetNbinsX();ibin[
names.size()-2]++) {
133 for (ibin[
names.size()-1]=0;ibin[
names.size()-1]<prof->GetNbinsY();ibin[
names.size()-1]++) {
134 float logEClus = xax->GetBinCenter(ibin[
names.size()-2]+1);
135 float logEDensCell = yax->GetBinCenter(ibin[
names.size()-1]+1);
136 int iBin = prof->FindBin(logEClus,logEDensCell);
143 msg() << MSG::INFO <<
"Now set data for isamp=" << isamp
145 for(
unsigned int ii=0;ii<ibin.size();ii++)
146 msg() << ibin[ii] <<
" ";
148 data.setCoeff(
data.getBin(isampmap[isamp],ibin),theData);
155 theKeyList->RemoveFirst();
159 for(
unsigned int jsamp=0;jsamp<theAreas.size();jsamp++) {
160 if ( theAreas[jsamp].getNdim() > 0 ) {
161 ATH_MSG_INFO(
"adding Area for jsamp=" << jsamp <<
" with nDim = " << theAreas[jsamp].getNdim() );
162 data.addArea(theAreas[jsamp]);
166 theLCWeightFile->Close();
167 delete theLCWeightFile;
169 return StatusCode::SUCCESS;
174 auto data = std::make_unique<CaloLocalHadCoeff>();
177 return StatusCode::SUCCESS;
183 return StatusCode::SUCCESS;
188 return StatusCode::SUCCESS;