14 # pragma warning( disable : 2259 )
20 # pragma warning( disable : 4996 )
43 string histoAddr(
const string&
name ) {
44 if ( 0 ==
name.find(
"/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 ) };
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 string hn = histoAddr( pPar, rel );
327 debug() <<
" Redefine the parameters for the histogram '" + hn +
"' to be " << ifound->second <<
endmsg;
330 return i_book( pPar, rel, ifound->second.title(),
331 Gaudi::createH1D( ifound->second.title(), ifound->second.bins(), ifound->second.lowEdge(),
332 ifound->second.lowEdge() ) );
346 removeLeading(
m_defs1D.value(),
"/stat/" );
358 if (
m_defs1D.end() != im ) { debug() <<
" " << im->second; }
366 AIDA::IHistogram1D*
HistogramSvc::book(
const string&
par,
const string& rel,
const string& title,
int nx,
double lowx,
372 AIDA::IHistogram1D*
HistogramSvc::book(
const string&
par,
int hID,
const string& title,
int nx,
double lowx,
386 return book( loc.first, loc.second, title, nx, lowx, upx );
390 AIDA::IHistogram1D*
HistogramSvc::book(
const string& full,
const string& title,
int nx,
double lowx,
double upx ) {
396 double lowx,
double upx,
const string& opt ) {
402 double upx,
const string& opt ) {
408 double upx,
const string& opt ) {
414 double lowx,
double upx,
const string& opt ) {
415 return bookProf( loc.first, loc.second, title, nx, lowx, upx, opt );
419 AIDA::IProfile1D*
HistogramSvc::bookProf(
const string& full,
const string& title,
int nx,
double lowx,
double upx,
420 const string& opt ) {
426 double upx,
const string& opt ) {
432 double lowx,
double upx,
double upper,
double lower,
const string& opt ) {
438 double upx,
double upper,
double lower,
const string& opt ) {
444 double upx,
double upper,
double lower,
const string& opt ) {
450 double lowx,
double upx,
double upper,
double lower,
const string& opt ) {
451 return bookProf( loc.first, loc.second, title, nx, lowx, upx, upper, lower, opt );
455 AIDA::IProfile1D*
HistogramSvc::bookProf(
const string& full,
const string& title,
int nx,
double lowx,
double upx,
456 double upper,
double lower,
const string& opt ) {
462 double upx,
double upper,
double lower,
const string& opt ) {
485 return book( loc.first, loc.second, title, e );
522 return bookProf( loc.first, loc.second, title, e );
539 Edges e,
double upper,
double lower ) {
545 double upper,
double lower ) {
557 Edges e,
double upper,
double lower ) {
558 return bookProf( loc.first, loc.second, title, e, upper, lower );
563 double upper,
double lower ) {
569 double upx,
int ny,
double lowy,
double upy ) {
570 return book(
i_splitPath( full ), title, nx, lowx, upx, ny, lowy, upy );
575 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy ) {
581 double upx,
int ny,
double lowy,
double upy ) {
587 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy ) {
588 return book( loc.first, loc.second, title, nx, lowx, upx, ny, lowy, upy );
593 double upx,
int ny,
double lowy,
double upy ) {
599 double lowx,
double upx,
int ny,
double lowy,
double upy ) {
605 double upx,
int ny,
double lowy,
double upy,
double upper,
double lower ) {
611 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy,
612 double upper,
double lower ) {
613 return bookProf(
createPath(
par ), rel, title, nx, lowx, upx, ny, lowy, upy, upper, lower );
618 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy,
619 double upper,
double lower ) {
620 return bookProf( loc.first, loc.second, title, nx, lowx, upx, ny, lowy, upy, upper, lower );
625 double lowx,
double upx,
int ny,
double lowy,
double upy,
double upper,
627 return bookProf(
par,
std::to_string( hID ), title, nx, lowx, upx, ny, lowy, upy, upper, lower );
632 double upx,
int ny,
double lowy,
double upy,
double upper,
double lower ) {
633 return bookProf( pPar,
std::to_string( hID ), title, nx, lowx, upx, ny, lowy, upy, upper, lower );
638 double lowx,
double upx,
int ny,
double lowy,
double upy,
double upper,
640 return i_book( pPar, rel, title,
Gaudi::createProf2D( title, nx, lowx, upx, ny, lowy, upy, upper, lower ) );
645 double upx,
int ny,
double lowy,
double upy ) {
651 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy ) {
657 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy ) {
658 return bookProf( loc.first, loc.second, title, nx, lowx, upx, ny, lowy, upy );
663 double lowx,
double upx,
int ny,
double lowy,
double upy ) {
669 double upx,
int ny,
double lowy,
double upy ) {
675 double lowx,
double upx,
int ny,
double lowy,
double upy ) {
676 return i_book( pPar, rel, title,
Gaudi::createProf2D( title, nx, lowx, upx, ny, lowy, upy, 0, 0 ) );
698 return book( loc.first, loc.second, title, x, y );
737 return bookProf( loc.first, loc.second, title, x, y );
748 double upper,
double lower ) {
754 Edges x,
Edges y,
double upper,
double lower ) {
760 double upper,
double lower ) {
766 double upper,
double lower ) {
772 Edges x,
Edges y,
double upper,
double lower ) {
773 return bookProf( loc.first, loc.second, title, x, y, upper, lower );
778 Edges y,
double upper,
double lower ) {
784 double upx,
int ny,
double lowy,
double upy,
int nz,
double lowz,
double upz ) {
785 return book(
i_splitPath( full ), title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
790 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy,
int nz,
791 double lowz,
double upz ) {
792 return book(
createPath(
par ), rel, title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
797 double upx,
int ny,
double lowy,
double upy,
int nz,
double lowz,
double upz ) {
798 return book(
par,
std::to_string( hID ), title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
803 double upx,
int ny,
double lowy,
double upy,
int nz,
double lowz,
double upz ) {
804 return book( pPar,
std::to_string( hID ), title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
809 int nx,
double lowx,
double upx,
int ny,
double lowy,
double upy,
int nz,
810 double lowz,
double upz ) {
811 return book( loc.first, loc.second, title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
816 double lowx,
double upx,
int ny,
double lowy,
double upy,
int nz,
double lowz,
818 return i_book( pPar, rel, title,
Gaudi::createH3D( title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz ) );
847 return book( loc.first, loc.second, title, x, y, z );
881 return Helper(
this ).retrieve( pReg,
path, obj );
886 return Helper(
this ).retrieve( pReg,
path, obj );
891 return Helper(
this ).retrieve( pReg,
path, obj );
896 return Helper(
this ).retrieve( pReg,
path, obj );
901 return Helper(
this ).retrieve( pReg,
path, obj );
906 return Helper(
this ).retrieve( full, obj );
911 return Helper(
this ).retrieve( full, obj );
916 return Helper(
this ).retrieve( full, obj );
921 return Helper(
this ).retrieve( full, obj );
926 return Helper(
this ).retrieve( full, obj );
932 AIDA::IProfile1D*& obj ) {
933 return Helper(
this ).retrieve( parent, rel, obj );
938 return Helper(
this ).retrieve( parent, rel, obj );
943 return Helper(
this ).retrieve( parent, rel, obj );
948 return Helper(
this ).retrieve( parent, rel, obj );
953 return Helper(
this ).retrieve( parent, rel, obj );
958 return Helper(
this ).retrieve( parent, item, obj );
963 return Helper(
this ).retrieve( parent, item, obj );
968 return Helper(
this ).retrieve( parent, item, obj );
973 return Helper(
this ).retrieve( parent, item, obj );
978 return Helper(
this ).retrieve( parent, item, obj );
982 return Helper(
this ).retrieve(
par, item, obj );
987 return Helper(
this ).retrieve(
par, item, obj );
992 return Helper(
this ).retrieve(
par, item, obj );
997 return Helper(
this ).retrieve(
par, item, obj );
1002 return Helper(
this ).retrieve(
par, item, obj );
1007 return Helper(
this ).retrieve(
par, item, obj );
1012 return Helper(
this ).retrieve(
par, item, obj );
1017 return Helper(
this ).retrieve(
par, item, obj );
1022 return Helper(
this ).retrieve(
par, item, obj );
1027 return Helper(
this ).retrieve(
par, item, obj );
1032 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1037 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1042 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1047 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1052 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1057 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1062 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1067 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1072 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1077 return Helper(
this ).retrieve( ::detail::cast(
par ), item, obj );
1082 return Helper(
this ).find( pReg,
path, obj );
1086 return Helper(
this ).find( pReg,
path, obj );
1090 return Helper(
this ).find( pReg,
path, obj );
1094 return Helper(
this ).find( pReg,
path, obj );
1098 return Helper(
this ).find( pReg,
path, obj );
1102 return Helper(
this ).find( full, obj );
1106 return Helper(
this ).find( full, obj );
1111 return Helper(
this ).find( full, obj );
1116 return Helper(
this ).find( full, obj );
1121 return Helper(
this ).find( full, obj );
1126 return Helper(
this ).find(
par, rel, obj );
1131 return Helper(
this ).find(
par, rel, obj );
1136 return Helper(
this ).find(
par, rel, obj );
1141 return Helper(
this ).find(
par, rel, obj );
1146 return Helper(
this ).find(
par, rel, obj );
1151 return Helper(
this ).find(
par, item, obj );
1156 return Helper(
this ).find(
par, item, obj );
1161 return Helper(
this ).find(
par, item, obj );
1166 return Helper(
this ).find(
par, item, obj );
1171 return Helper(
this ).find(
par, item, obj );
1176 return Helper(
this ).find(
par, item, obj );
1181 return Helper(
this ).find(
par, item, obj );
1186 return Helper(
this ).find(
par, item, obj );
1191 return Helper(
this ).find(
par, item, obj );
1196 return Helper(
this ).find(
par, item, obj );
1201 return Helper(
this ).find(
par, item, obj );
1206 return Helper(
this ).find(
par, item, obj );
1211 return Helper(
this ).find(
par, item, obj );
1216 return Helper(
this ).find(
par, item, obj );
1221 return Helper(
this ).find(
par, item, obj );
1226 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1231 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1236 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1241 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1246 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1251 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1256 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1261 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1266 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1271 return Helper(
this ).find( ::detail::cast(
par ), item, obj );
1276 return sliceX(
name,
h, IAxis::UNDERFLOW_BIN, IAxis::OVERFLOW_BIN );
1281 return sliceY(
name,
h, IAxis::UNDERFLOW_BIN, IAxis::OVERFLOW_BIN );
1296 const AIDA::IHistogram1D& b ) {
1302 const AIDA::IHistogram1D& b ) {
1308 const AIDA::IHistogram1D& b ) {
1314 const AIDA::IHistogram1D& b ) {
1320 const AIDA::IHistogram2D& b ) {
1326 const AIDA::IHistogram2D& b ) {
1332 const AIDA::IHistogram2D& b ) {
1338 const AIDA::IHistogram2D& b ) {
1344 const AIDA::IHistogram3D& b ) {
1350 const AIDA::IHistogram3D& b ) {
1356 const AIDA::IHistogram3D& b ) {
1362 const AIDA::IHistogram3D& b ) {
1383 double lowx,
double upx ) {
1384 return book(
name, title, nx, lowx, upx );
1390 return book(
name, title, nx, lowx, upx );
1402 return book( nameAndTitle, nameAndTitle, nx, lowx, upx );
1412 const AIDA::IHistogram1D&
h ) {
1418 const AIDA::IHistogram1D&
h ) {
1429 double lowx,
double upx,
int ny,
double lowy,
double upy ) {
1430 return book(
name, title, nx, lowx, upx, ny, lowy, upy );
1435 double lowx,
double upx,
int ny,
double lowy,
double upy,
1437 return book(
name, title, nx, lowx, upx, ny, lowy, upy );
1448 int ny,
double lowy,
double upy ) {
1449 return book( nameAndTitle, nameAndTitle, nx, lowx, upx, ny, lowy, upy );
1459 const AIDA::IHistogram2D&
h ) {
1465 const AIDA::IHistogram2D&
h ) {
1476 double lowx,
double upx,
int ny,
double lowy,
double upy,
int nz,
1477 double lowz,
double upz ) {
1478 return book(
name, title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
1483 double lowx,
double upx,
int ny,
double lowy,
double upy,
int nz,
1485 return book(
name, title, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
1491 return book(
name, title, x, y, z );
1496 int ny,
double lowy,
double upy,
int nz,
double lowz,
1498 return book( nameAndTitle, nameAndTitle, nx, lowx, upx, ny, lowy, upy, nz, lowz, upz );
1508 const AIDA::IHistogram3D&
h ) {
1514 const AIDA::IHistogram3D&
h ) {
1531 double upx,
double upper,
double lower,
const std::string& opt ) {
1532 return bookProf(
name, title, nx, lowx, upx, upper, lower, opt );
1543 double upper,
double lower,
const std::string& ) {
1549 return bookProf( nametit, nametit, nx, lowx, upx,
"s" );
1554 double upper,
double lower ) {
1555 return bookProf( nametit, nametit, nx, lowx, upx, upper, lower,
"s" );
1565 const AIDA::IProfile1D&
h ) {
1571 const AIDA::IProfile1D&
h ) {
1582 double upx,
int ny,
double lowy,
double upy ) {
1583 return bookProf(
name, title, nx, lowx, upx, ny, lowy, upy );
1588 double upx,
int ny,
double lowy,
double upy,
1590 return bookProf(
name, title, nx, lowx, upx, ny, lowy, upy );
1601 int ny,
double lowy,
double upy ) {
1602 return bookProf( nameAndTitle, nameAndTitle, nx, lowx, upx, ny, lowy, upy );
1607 double upx,
int ny,
double lowy,
double upy,
double upper,
1609 return bookProf(
name, title, nx, lowx, upx, ny, lowy, upy, upper, lower );
1614 double upx,
int ny,
double lowy,
double upy,
double upper,
1616 return bookProf(
name, title, nx, lowx, upx, ny, lowy, upy, upper, lower );
1621 const Edges& y,
double upper,
double lower,
1628 int ny,
double lowy,
double upy,
double upper,
double lower ) {
1629 return bookProf( nameAndTitle, nameAndTitle, nx, lowx, upx, ny, lowy, upy, upper, lower );
1639 const AIDA::IProfile2D&
h ) {
1645 const AIDA::IProfile2D&
h ) {