14 # pragma warning( disable : 2259 )
20 # pragma warning( disable : 4996 )
43 string histoAddr(
const string&
name ) {
44 if (
name.starts_with(
"/stat/" ) ) {
return string(
name, 6 ); }
48 string histoAddr(
const DataObject* obj,
const string& rel ) {
49 if ( !obj ) {
return rel; }
51 if ( !reg ) {
return rel; }
54 if ( rel.empty() ) {
return histoAddr(
name ); }
55 if (
'/' ==
name[
name.size() - 1] ||
'/' == rel[0] ) {
return histoAddr(
name + rel ); }
56 return histoAddr(
name +
"/" + rel );
60 auto it =
std::find_if(
m.begin(),
m.end(), [&lead](
const auto& i ) { return 0 == i.first.find( lead ); } );
61 if ( it ==
m.end() )
return 0;
62 string addr = string( it->first, lead.size() );
66 return 1 + removeLeading(
m, lead );
81 if ( !hObj->annotation().addItem(
"id", obj.substr( 1 ) ) ) hObj->annotation().setValue(
"id", obj.substr( 1 ) );
84 if ( !hObj->annotation().addItem(
"id", obj ) ) hObj->annotation().setValue(
"id", obj );
92 TH3D* h3d = Gaudi::getRepresentation<IHistogram3D, TH3D>(
h );
94 TH2D* h2d =
dynamic_cast<TH2D*
>( h3d->Project3D( dir.c_str() ) );
108 if ( b )
return b->
print(
s );
109 error() <<
"Unknown histogram type: Cannot cast to Gaudi::HistogramBase." <<
endmsg;
116 if ( b )
return b->
write(
s );
117 error() <<
"Unknown histogram type: Cannot cast to Gaudi::HistogramBase." <<
endmsg;
124 if ( b )
return b->
write( file_name );
125 error() <<
"Unknown histogram type: Cannot cast to Gaudi::HistogramBase." <<
endmsg;
137 if ( tmp.rfind(
SEPARATOR ) == tmp.length() - 1 ) { tmp.erase( tmp.length() - 1, 1 ); }
139 return { tmp.substr( 0, sep ), tmp.substr( sep + 1 ) };
144 string tmpPath = newPath;
146 tmpPath.insert( tmpPath.begin(),
SEPARATOR );
150 if ( tmpPath.rfind(
SEPARATOR ) == tmpPath.length() - 1 ) { tmpPath.erase( tmpPath.rfind(
SEPARATOR ), 1 ); }
153 if ( sc.
isSuccess() ) {
return pObject; }
155 string rest( tmpPath, sep + 1, tmpPath.length() - sep );
156 string subPath( tmpPath, 0, sep );
160 error() <<
"Unable to create the histogram path" <<
endmsg;
169 auto directory = std::make_unique<DataObject>();
174 error() <<
"Unable to create the histogram directory: " << parentDir <<
"/" << subDir <<
endmsg;
179 error() <<
"Unable to create the histogram directory: " << parentDir <<
"/" << subDir <<
endmsg;
183 return directory.release();
198 string::size_type loc =
ident.find(
" " );
199 string filename, auth, svc =
"", typ =
"";
200 string logname =
ident.substr( 0, loc );
201 for (
auto attrib : Parser(
ident.substr( loc + 1 ) ) ) {
202 switch ( ::
toupper( attrib.tag[0] ) ) {
214 if ( typ.length() > 0 ) {
218 entryname += logname;
220 switch ( ::
toupper( typ[0] ) ) {
231 info() <<
"Added stream file:" <<
filename <<
" as " << logname <<
endmsg;
238 error() <<
"Cannot add " <<
ident <<
" invalid filename!" <<
endmsg;
247 auto rootObj = std::make_unique<DataObject>();
248 status =
setRoot(
"/stat", rootObj.get() );
250 error() <<
"Unable to set hstogram data store root." <<
endmsg;
254 auto svc = service<IConversionSvc>(
"HistogramPersistencySvc",
true );
256 error() <<
"Could not find HistogramPersistencySvc." <<
endmsg;
263 if ( !status.
isSuccess() )
return status;
267 info() <<
" Predefined 1D-Histograms: " <<
endmsg;
269 info() <<
" Path='" << ih.first <<
"'"
270 <<
" Description " << ih.second <<
endmsg;
287 throw GaudiException(
"Cannot cast 2D histogram to H2D to create sliceX `" +
name +
"'!",
"HistogramSvc",
323 return i_book( pPar, rel, title,
326 string hn = histoAddr( pPar, rel );
329 return i_book( pPar, rel, title,
333 debug() <<
" Redefine the parameters for the histogram '" + hn +
"' to be " << ifound->second <<
endmsg;
336 return i_book( pPar, rel, ifound->second.title(),
338 ifound->second.bins(), ifound->second.lowEdge(), ifound->second.lowEdge() ) );
352 removeLeading(
m_defs1D.value(),
"/stat/" );
358 return path.substr(
root.size() ) +
'/' + rel;
370 if (
m_defs1D.end() != im ) { debug() <<
" " << im->second; }
378 AIDA::IHistogram1D*
HistogramSvc::book(
const string&
par,
const string& rel,
const string& title,
int nx,
double lowx,
384 AIDA::IHistogram1D*
HistogramSvc::book(
const string&
par,
int hID,
const string& title,
int nx,
double lowx,
398 return book( loc.first, loc.second, title, nx, lowx, upx );
402 AIDA::IHistogram1D*
HistogramSvc::book(
const string& full,
const string& title,
int nx,
double lowx,
double upx ) {
408 double lowx,
double upx,
const string& opt ) {
414 double upx,
const string& opt ) {
420 double upx,
const string& opt ) {
426 double lowx,
double upx,
const string& opt ) {
427 return bookProf( loc.first, loc.second, title, nx, lowx, upx, opt );
431 AIDA::IProfile1D*
HistogramSvc::bookProf(
const string& full,
const string& title,
int nx,
double lowx,
double upx,
432 const string& opt ) {
438 double upx,
const string& opt ) {
446 double lowx,
double upx,
double upper,
double lower,
const string& opt ) {
452 double upx,
double upper,
double lower,
const string& opt ) {
458 double upx,
double upper,
double lower,
const string& opt ) {
464 double lowx,
double upx,
double upper,
double lower,
const string& opt ) {
465 return bookProf( loc.first, loc.second, title, nx, lowx, upx, upper, lower, opt );
469 AIDA::IProfile1D*
HistogramSvc::bookProf(
const string& full,
const string& title,
int nx,
double lowx,
double upx,
470 double upper,
double lower,
const string& opt ) {
476 double upx,
double upper,
double lower,
const string& opt ) {
501 return book( loc.first, loc.second, title, e );
538 return bookProf( loc.first, loc.second, title, e );
544 return i_book( pPar, rel, title,
556 Edges e,
double upper,
double lower ) {
562 double upper,
double lower ) {
574 Edges e,
double upper,
double lower ) {
575 return bookProf( loc.first, loc.second, title, e, upper, lower );
580 double upper,
double lower ) {
581 return i_book( pPar, rel, title,
587 double upx,
int ny,
double lowy,
double upy ) {
588 return book(
i_splitPath( full ), title, nx, lowx, upx, ny, lowy, upy );
593 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy ) {
599 double upx,
int ny,
double lowy,
double upy ) {
605 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy ) {
606 return book( loc.first, loc.second, title, nx, lowx, upx, ny, lowy, upy );
611 double upx,
int ny,
double lowy,
double upy ) {
617 double lowx,
double upx,
int ny,
double lowy,
double upy ) {
625 double upx,
int ny,
double lowy,
double upy,
double upper,
double lower ) {
631 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy,
632 double upper,
double lower ) {
633 return bookProf(
createPath(
par ), rel, title, nx, lowx, upx, ny, lowy, upy, upper, lower );
638 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy,
639 double upper,
double lower ) {
640 return bookProf( loc.first, loc.second, title, nx, lowx, upx, ny, lowy, upy, upper, lower );
645 double lowx,
double upx,
int ny,
double lowy,
double upy,
double upper,
647 return bookProf(
par,
std::to_string( hID ), title, nx, lowx, upx, ny, lowy, upy, upper, lower );
652 double upx,
int ny,
double lowy,
double upy,
double upper,
double lower ) {
653 return bookProf( pPar,
std::to_string( hID ), title, nx, lowx, upx, ny, lowy, upy, upper, lower );
658 double lowx,
double upx,
int ny,
double lowy,
double upy,
double upper,
660 return i_book( pPar, rel, title,
662 upy, upper, lower ) );
667 double upx,
int ny,
double lowy,
double upy ) {
673 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy ) {
679 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy ) {
680 return bookProf( loc.first, loc.second, title, nx, lowx, upx, ny, lowy, upy );
685 double lowx,
double upx,
int ny,
double lowy,
double upy ) {
691 double upx,
int ny,
double lowy,
double upy ) {
697 double lowx,
double upx,
int ny,
double lowy,
double upy ) {
700 Gaudi::createProf2D(
serviceLocator(),
buildHistoPath( pPar, rel ), title, nx, lowx, upx, ny, lowy, upy, 0, 0 ) );
722 return book( loc.first, loc.second, title, x, y );
761 return bookProf( loc.first, loc.second, title, x, y );
767 return i_book( pPar, rel, title,
773 double upper,
double lower ) {
779 Edges x,
Edges y,
double upper,
double lower ) {
785 double upper,
double lower ) {
791 double upper,
double lower ) {
797 Edges x,
Edges y,
double upper,
double lower ) {
798 return bookProf( loc.first, loc.second, title, x, y, upper, lower );
803 Edges y,
double upper,
double lower ) {
804 return i_book( pPar, rel, title,
810 double upx,
int ny,
double lowy,
double upy,
int nz,
double lowz,
double upz ) {
811 return book(
i_splitPath( full ), title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
816 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy,
int nz,
817 double lowz,
double upz ) {
818 return book(
createPath(
par ), rel, title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
823 double upx,
int ny,
double lowy,
double upy,
int nz,
double lowz,
double upz ) {
824 return book(
par,
std::to_string( hID ), title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
829 double upx,
int ny,
double lowy,
double upy,
int nz,
double lowz,
double upz ) {
830 return book( pPar,
std::to_string( hID ), title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
835 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy,
int nz,
836 double lowz,
double upz ) {
837 return book( loc.first, loc.second, title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
842 double lowx,
double upx,
int ny,
double lowy,
double upy,
int nz,
double lowz,
844 return i_book( pPar, rel, title,
845 Gaudi::createH3D(
serviceLocator(),
buildHistoPath( pPar, rel ), title, nx, lowx, upx, ny, lowy, upy,
875 return book( loc.first, loc.second, title, x, y, z );
909 return Helper(
this ).retrieve( pReg,
path, obj );
914 return Helper(
this ).retrieve( pReg,
path, obj );
919 return Helper(
this ).retrieve( pReg,
path, obj );
924 return Helper(
this ).retrieve( pReg,
path, obj );
929 return Helper(
this ).retrieve( pReg,
path, obj );
934 return Helper(
this ).retrieve( full, obj );
939 return Helper(
this ).retrieve( full, obj );
944 return Helper(
this ).retrieve( full, obj );
949 return Helper(
this ).retrieve( full, obj );
954 return Helper(
this ).retrieve( full, obj );
960 AIDA::IProfile1D*& obj ) {
961 return Helper(
this ).retrieve( parent, rel, obj );
966 return Helper(
this ).retrieve( parent, rel, obj );
971 return Helper(
this ).retrieve( parent, rel, obj );
976 return Helper(
this ).retrieve( parent, rel, obj );
981 return Helper(
this ).retrieve( parent, rel, obj );
986 return Helper(
this ).retrieve( parent, item, obj );
991 return Helper(
this ).retrieve( parent, item, obj );
996 return Helper(
this ).retrieve( parent, item, obj );
1001 return Helper(
this ).retrieve( parent, item, obj );
1006 return Helper(
this ).retrieve( parent, item, obj );
1010 return Helper(
this ).retrieve(
par, item, obj );
1015 return Helper(
this ).retrieve(
par, item, obj );
1020 return Helper(
this ).retrieve(
par, item, obj );
1025 return Helper(
this ).retrieve(
par, item, obj );
1030 return Helper(
this ).retrieve(
par, item, obj );
1035 return Helper(
this ).retrieve(
par, item, obj );
1040 return Helper(
this ).retrieve(
par, item, obj );
1045 return Helper(
this ).retrieve(
par, item, obj );
1050 return Helper(
this ).retrieve(
par, item, obj );
1055 return Helper(
this ).retrieve(
par, item, obj );
1060 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1065 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1070 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1075 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1080 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1085 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1090 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1095 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1100 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1105 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1110 return Helper(
this ).find( pReg,
path, obj );
1114 return Helper(
this ).find( pReg,
path, obj );
1118 return Helper(
this ).find( pReg,
path, obj );
1122 return Helper(
this ).find( pReg,
path, obj );
1126 return Helper(
this ).find( pReg,
path, obj );
1130 return Helper(
this ).find( full, obj );
1134 return Helper(
this ).find( full, obj );
1139 return Helper(
this ).find( full, obj );
1144 return Helper(
this ).find( full, obj );
1149 return Helper(
this ).find( full, obj );
1154 return Helper(
this ).find(
par, rel, obj );
1159 return Helper(
this ).find(
par, rel, obj );
1164 return Helper(
this ).find(
par, rel, obj );
1169 return Helper(
this ).find(
par, rel, obj );
1174 return Helper(
this ).find(
par, rel, obj );
1179 return Helper(
this ).find(
par, item, obj );
1184 return Helper(
this ).find(
par, item, obj );
1189 return Helper(
this ).find(
par, item, obj );
1194 return Helper(
this ).find(
par, item, obj );
1199 return Helper(
this ).find(
par, item, obj );
1204 return Helper(
this ).find(
par, item, obj );
1209 return Helper(
this ).find(
par, item, obj );
1214 return Helper(
this ).find(
par, item, obj );
1219 return Helper(
this ).find(
par, item, obj );
1224 return Helper(
this ).find(
par, item, obj );
1229 return Helper(
this ).find(
par, item, obj );
1234 return Helper(
this ).find(
par, item, obj );
1239 return Helper(
this ).find(
par, item, obj );
1244 return Helper(
this ).find(
par, item, obj );
1249 return Helper(
this ).find(
par, item, obj );
1254 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1259 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1264 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1269 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1274 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1279 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1284 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1289 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1294 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1299 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1304 return sliceX(
name,
h, IAxis::UNDERFLOW_BIN, IAxis::OVERFLOW_BIN );
1309 return sliceY(
name,
h, IAxis::UNDERFLOW_BIN, IAxis::OVERFLOW_BIN );
1324 const AIDA::IHistogram1D& b ) {
1330 const AIDA::IHistogram1D& b ) {
1336 const AIDA::IHistogram1D& b ) {
1342 const AIDA::IHistogram1D& b ) {
1348 const AIDA::IHistogram2D& b ) {
1354 const AIDA::IHistogram2D& b ) {
1360 const AIDA::IHistogram2D& b ) {
1366 const AIDA::IHistogram2D& b ) {
1372 const AIDA::IHistogram3D& b ) {
1378 const AIDA::IHistogram3D& b ) {
1384 const AIDA::IHistogram3D& b ) {
1390 const AIDA::IHistogram3D& b ) {
1411 double lowx,
double upx ) {
1412 return book(
name, title, nx, lowx, upx );
1418 return book(
name, title, nx, lowx, upx );
1430 return book( nameAndTitle, nameAndTitle, nx, lowx, upx );
1440 const AIDA::IHistogram1D&
h ) {
1446 const AIDA::IHistogram1D&
h ) {
1457 double lowx,
double upx,
int ny,
double lowy,
double upy ) {
1458 return book(
name, title, nx, lowx, upx, ny, lowy, upy );
1463 double lowx,
double upx,
int ny,
double lowy,
double upy,
1465 return book(
name, title, nx, lowx, upx, ny, lowy, upy );
1476 int ny,
double lowy,
double upy ) {
1477 return book( nameAndTitle, nameAndTitle, nx, lowx, upx, ny, lowy, upy );
1487 const AIDA::IHistogram2D&
h ) {
1493 const AIDA::IHistogram2D&
h ) {
1504 double lowx,
double upx,
int ny,
double lowy,
double upy,
int nz,
1505 double lowz,
double upz ) {
1506 return book(
name, title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
1511 double lowx,
double upx,
int ny,
double lowy,
double upy,
int nz,
1513 return book(
name, title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
1519 return book(
name, title, x, y, z );
1524 int ny,
double lowy,
double upy,
int nz,
double lowz,
1526 return book( nameAndTitle, nameAndTitle, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
1536 const AIDA::IHistogram3D&
h ) {
1542 const AIDA::IHistogram3D&
h ) {
1559 double upx,
double upper,
double lower,
const std::string& opt ) {
1560 return bookProf(
name, title, nx, lowx, upx, upper, lower, opt );
1571 double upper,
double lower,
const std::string& ) {
1577 return bookProf( nametit, nametit, nx, lowx, upx,
"s" );
1582 double upper,
double lower ) {
1583 return bookProf( nametit, nametit, nx, lowx, upx, upper, lower,
"s" );
1593 const AIDA::IProfile1D&
h ) {
1599 const AIDA::IProfile1D&
h ) {
1610 double upx,
int ny,
double lowy,
double upy ) {
1611 return bookProf(
name, title, nx, lowx, upx, ny, lowy, upy );
1616 double upx,
int ny,
double lowy,
double upy,
1618 return bookProf(
name, title, nx, lowx, upx, ny, lowy, upy );
1629 int ny,
double lowy,
double upy ) {
1630 return bookProf( nameAndTitle, nameAndTitle, nx, lowx, upx, ny, lowy, upy );
1635 double upx,
int ny,
double lowy,
double upy,
double upper,
1637 return bookProf(
name, title, nx, lowx, upx, ny, lowy, upy, upper, lower );
1642 double upx,
int ny,
double lowy,
double upy,
double upper,
1644 return bookProf(
name, title, nx, lowx, upx, ny, lowy, upy, upper, lower );
1649 const Edges& y,
double upper,
double lower,
1656 int ny,
double lowy,
double upy,
double upper,
double lower ) {
1657 return bookProf( nameAndTitle, nameAndTitle, nx, lowx, upx, ny, lowy, upy, upper, lower );
1667 const AIDA::IProfile2D&
h ) {
1673 const AIDA::IProfile2D&
h ) {