00001
00002
00003 #ifndef GAUDIALG_GAUDIHISTOS_ICPP
00004 #define GAUDIALG_GAUDIHISTOS_ICPP 1
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <algorithm>
00018 #include <string>
00019 #include <vector>
00020 #include <set>
00021
00022
00023
00024 #include "GaudiKernel/MsgStream.h"
00025 #include "GaudiKernel/IHistogramSvc.h"
00026
00027
00028
00029 #include "GaudiUtils/HistoTableFormat.h"
00030
00031
00032
00033 #include "GaudiAlg/GaudiHistos.h"
00034 #include "GaudiAlg/CheckForNaN.h"
00035 #include "GaudiAlg/Print.h"
00036 #include "GaudiAlg/Fill.h"
00037
00038
00039
00040 namespace AIDA
00041 {
00042 class IBaseHistogram ;
00043 class IHistogram ;
00044 class IHistogram1D ;
00045 class IHistogram2D ;
00046 class IHistogram3D ;
00047 class IProfile ;
00048 class IProfile1D ;
00049 class IProfile2D ;
00050 }
00051
00052
00053
00054 template <class PBASE>
00055 GaudiHistos<PBASE>::~GaudiHistos() {}
00056
00057
00058
00059 template <class PBASE>
00060 void GaudiHistos<PBASE>::initGaudiHistosConstructor()
00061 {
00062
00063 this->declareProperty
00064 ( "HistoProduce" ,
00065 m_produceHistos = true ,
00066 "Swith on/off the production of histograms " ) ;
00067
00068 this->declareProperty
00069 ( "HistoPrint" ,
00070 m_histosPrint = false ,
00071 "Switch on/off the printout of histograms at finalization" )
00072 -> declareUpdateHandler ( &GaudiHistos<PBASE>::printHistoHandler, this ) ;
00073
00074 this->declareProperty
00075 ( "HistoCheckForNaN" ,
00076 m_checkForNaN = true ,
00077 "Swicth on/off the checks for NaN and Infinity for histogram fill" ) ;
00078
00079 this->declareProperty
00080 ( "HistoSplitDir" ,
00081 m_splitHistoDir = false ,
00082 "Split long directory names into short pieces (suitable for HBOOK)" );
00083
00084 this->declareProperty
00085 ( "HistoOffSet" ,
00086 m_histoOffSet = 0 ,
00087 "OffSet for automatically assigned histogram numerical identifiers " ) ;
00088
00089 this->declareProperty
00090 ( "HistoTopDir" ,
00091 m_histoTopDir = "" ,
00092 "Top level histogram directory (take care that it ends with '/')" ) ;
00093
00094 this->declareProperty
00095 ( "HistoDir" ,
00096 m_histoDir = this->name() ,
00097 "Histogram Directory" ) ;
00098
00099 this->declareProperty ( "FullDetail" , m_fullDetail = false ) ;
00100
00101 this->declareProperty ( "MonitorHistograms" , m_declareMoniHists = true ) ;
00102
00103 this->declareProperty
00104 ( "FormatFor1DHistoTable" ,
00105 m_histo1DTableFormat = Gaudi::Utils::Histos::Formats::format () ,
00106 "Format string for printout of 1D histograms" ) ;
00107
00108 this->declareProperty
00109 ( "ShortFormatFor1DHistoTable" ,
00110 m_histo1DTableFormatShort = " | %1$-25.25s %2%" ,
00111 "Format string for printout of 1D histograms" ) ;
00112
00113 this->declareProperty
00114 ( "HeaderFor1DHistoTable" ,
00115 m_histo1DTableHeader = Gaudi::Utils::Histos::Formats::header () ,
00116 "The table header for printout of 1D histograms " ) ;
00117 this->declareProperty
00118 ( "UseSequencialNumericAutoIDs", m_useNumericAutoIDs = false,
00119 "Flag to allow users to switch back to the old style of creating numerical automatic IDs" );
00120 m_idReplaceInfo.clear();
00121 m_idReplaceInfo["/"] = "=SLASH=";
00122 this->declareProperty
00123 ( "AutoStringIDPurgeMap", m_idReplaceInfo,
00124 "Map of strings to search and replace when using the title as the basis of automatically generated literal IDs" );
00125 }
00126
00127
00128
00129 template <class PBASE>
00130 StatusCode GaudiHistos<PBASE>::initialize()
00131 {
00132
00133 const StatusCode sc = PBASE::initialize();
00134 if ( sc.isFailure() ) return sc;
00135
00136
00137 if ( !produceHistos() )
00138 {
00139 this->debug() << "Histogram production is switched OFF" << endmsg;
00140 return sc;
00141 }
00142
00143
00144 if ( this->histoSvc() == NULL )
00145 { return this->Error("initialize():: IHistogramSvc* is invalid"); }
00146
00147
00148 if ( useNumericAutoIDs() )
00149 {
00150 this ->
00151 Warning( "Using numerical automatic IDs. These are not guaranteed to be totally deterministic. Use with care...",
00152 StatusCode::SUCCESS );
00153 }
00154
00155
00156 Print
00157 ( "The histogram path is set to be '" + histoPath() + "'",
00158 StatusCode( StatusCode::SUCCESS, true ) , MSG::DEBUG );
00159
00160 return sc;
00161 }
00162
00163
00164
00165 template <class PBASE>
00166 StatusCode GaudiHistos<PBASE>::finalize()
00167 {
00168
00169 if ( produceHistos() )
00170 {
00171
00172
00173 if ( !noHistos() )
00174 {
00175 const unsigned int n1D = histo1DMapNumID().size()+histo1DMapLitID().size();
00176 const unsigned int n2D = histo2DMapNumID().size()+histo2DMapLitID().size();
00177 const unsigned int n3D = histo3DMapNumID().size()+histo3DMapLitID().size();
00178 const unsigned int n1DP = profile1DMapNumID().size()+profile1DMapLitID().size();
00179 const unsigned int n2DP = profile2DMapNumID().size()+profile2DMapLitID().size();
00180 const unsigned int total = n1D+n2D+n3D+n1DP+n2DP;
00181 if ( total>0 )
00182 {
00183 this->always() << "Booked " << total << " Histogram(s) : ";
00184 if ( n1D>0 ) this->always() << "1D=" << n1D << " ";
00185 if ( n2D>0 ) this->always() << "2D=" << n2D << " ";
00186 if ( n3D>0 ) this->always() << "3D=" << n3D << " ";
00187 if ( n1DP>0 ) this->always() << "1DProf=" << n1DP << " ";
00188 if ( n2DP>0 ) this->always() << "2DProf=" << n2DP << " ";
00189 this->always() << endmsg;
00190 }
00191 }
00192
00193
00194 if ( histosPrint() ) { printHistos() ; }
00195
00196 }
00197
00198
00199 m_histo1DMapTitle .clear() ;
00200 m_histo2DMapTitle .clear() ;
00201 m_histo3DMapTitle .clear() ;
00202 m_histo1DMapNumID .clear() ;
00203 m_histo1DMapLitID .clear() ;
00204 m_histo2DMapNumID .clear() ;
00205 m_histo2DMapLitID .clear() ;
00206 m_histo3DMapNumID .clear() ;
00207 m_histo3DMapLitID .clear() ;
00208 m_profile1DMapTitle .clear() ;
00209 m_profile2DMapTitle .clear() ;
00210 m_profile1DMapNumID .clear() ;
00211 m_profile1DMapLitID .clear() ;
00212 m_profile2DMapNumID .clear() ;
00213 m_profile2DMapLitID .clear() ;
00214
00215
00216 return PBASE::finalize();
00217 }
00218
00219
00220
00221 template <class PBASE>
00222 int GaudiHistos<PBASE>::printHistos ( const MSG::Level level ) const
00223 {
00224
00225 std::set<const AIDA::IBaseHistogram*> histos ;
00226 std::set<const AIDA::IBaseHistogram*> profiles ;
00227
00228 using namespace Gaudi::Utils::Histos ;
00229
00230 if ( noHistos() )
00231 { if (this->msgLevel(MSG::DEBUG)) this->msgStream(level) << "No histograms are booked" << endmsg ; }
00232 else
00233 {
00234 MsgStream & msg = this->msgStream(level);
00235
00236
00237
00238
00239 Gaudi::Utils::Histos::Table table
00240 ( m_histo1DTableFormat ,
00241 m_histo1DTableHeader ) ;
00242
00243 if ( !histo1DMapNumID().empty() || !histo1DMapLitID().empty() )
00244 {
00245 msg << "List of booked 1D histograms in directory "
00246 << "\"" << histoPath() << "\" :-" ;
00247
00248 if ( !table.header().empty() )
00249 {
00250 msg << std::endl << Gaudi::Utils::Histos::format
00251 ( "ID" , table.header() , m_histo1DTableFormatShort ) ;
00252 }
00253 {
00254 typedef std::map<Histo1DMapNumID::key_type, Histo1DMapNumID::mapped_type> ordered_map_t;
00255 ordered_map_t ordered_map(histo1DMapNumID().begin(), histo1DMapNumID().end());
00256 for ( ordered_map_t::const_iterator entry = ordered_map.begin() ;
00257 ordered_map.end() != entry ; ++entry )
00258 {
00259 AIDA::IHistogram1D* aida = entry->second ;
00260 if ( NULL == aida )
00261 { this->error() << "IHistogram1D points to NULL" << endmsg ; continue ; }
00262 if ( histos.end() != histos.find( toBase ( aida ) ) ) { continue ; }
00263 histos.insert ( toBase ( aida ) ) ;
00264
00265 msg << std::endl << table.toString
00266 ( aida ,
00267 HistoID ( entry->first ) ,
00268 m_histo1DTableFormatShort ) ;
00269 }
00270 }
00271 {
00272 typedef std::map<Histo1DMapLitID::key_type, Histo1DMapLitID::mapped_type> ordered_map_t;
00273 ordered_map_t ordered_map(histo1DMapLitID().begin(), histo1DMapLitID().end());
00274 for ( ordered_map_t::const_iterator entry = ordered_map.begin() ;
00275 ordered_map.end() != entry ; ++entry )
00276 {
00277 AIDA::IHistogram1D* aida = entry->second ;
00278 if ( NULL == aida )
00279 { this->error() << "IHistogram1D points to NULL" << endmsg ; continue ; }
00280 if ( histos.end() != histos.find( toBase ( aida ) ) ) { continue ; }
00281 histos.insert ( toBase ( aida ) ) ;
00282
00283 msg << std::endl << table.toString
00284 ( aida ,
00285 entry->first ,
00286 m_histo1DTableFormatShort ) ;
00287 }
00288 }
00289 msg << endmsg ;
00290 }
00291 if ( !histo2DMapNumID().empty() || !histo2DMapLitID().empty() )
00292 {
00293 msg << "List of booked 2D histograms in directory "
00294 << "\"" << histoPath() << "\" :-" ;
00295 {
00296 typedef std::map<Histo2DMapNumID::key_type, Histo2DMapNumID::mapped_type> ordered_map_t;
00297 ordered_map_t ordered_map(histo2DMapNumID().begin(), histo2DMapNumID().end());
00298 for ( ordered_map_t::const_iterator entry = ordered_map.begin() ;
00299 ordered_map.end() != entry ; ++entry )
00300 {
00301 AIDA::IHistogram2D* aida = entry->second ;
00302 if ( NULL == aida )
00303 { this->error() << "IHistogram2D points to NULL" << endmsg ; continue ; }
00304 if ( histos.end() != histos.find( toBase ( aida ) ) ) { continue ; }
00305 histos.insert ( toBase ( aida ) ) ;
00306 msg << std::endl
00307 << GaudiAlg::Print2D::toString ( aida , entry->first );
00308 }
00309 }
00310 {
00311 typedef std::map<Histo2DMapLitID::key_type, Histo2DMapLitID::mapped_type> ordered_map_t;
00312 ordered_map_t ordered_map(histo2DMapLitID().begin(), histo2DMapLitID().end());
00313 for ( ordered_map_t::const_iterator entry = ordered_map.begin() ;
00314 ordered_map.end() != entry ; ++entry )
00315 {
00316 AIDA::IHistogram2D* aida = entry->second ;
00317 if ( NULL == aida )
00318 { this->error() << "IHistogram2D points to NULL" << endmsg ; continue ; }
00319 if ( histos.end() != histos.find( toBase ( aida ) ) ) { continue ; }
00320 histos.insert ( toBase ( aida ) ) ;
00321 msg << std::endl
00322 << GaudiAlg::Print2D::toString ( aida , entry->first );
00323 }
00324 }
00325 msg << endmsg ;
00326 }
00327
00328 if ( !histo3DMapNumID().empty() || !histo3DMapLitID().empty() )
00329 {
00330 msg << "List of booked 3D histograms in directory "
00331 << "\"" << histoPath() << "\" :-" ;
00332 {
00333 typedef std::map<Histo3DMapNumID::key_type, Histo3DMapNumID::mapped_type> ordered_map_t;
00334 ordered_map_t ordered_map(histo3DMapNumID().begin(), histo3DMapNumID().end());
00335 for ( ordered_map_t::const_iterator entry = ordered_map.begin() ;
00336 ordered_map.end() != entry ; ++entry )
00337 {
00338 AIDA::IHistogram3D* aida = entry->second ;
00339 if ( NULL == aida )
00340 { this->error() << "IHistogram3D points to NULL" << endmsg ; continue ; }
00341 if ( histos.end() != histos.find( toBase ( aida ) ) ) { continue ; }
00342 histos.insert ( toBase ( aida ) ) ;
00343 msg << std::endl << GaudiAlg::Print3D::toString ( aida , entry->first );
00344 }
00345 }
00346 {
00347 typedef std::map<Histo3DMapLitID::key_type, Histo3DMapLitID::mapped_type> ordered_map_t;
00348 ordered_map_t ordered_map(histo3DMapLitID().begin(), histo3DMapLitID().end());
00349 for ( ordered_map_t::const_iterator entry = ordered_map.begin() ;
00350 ordered_map.end() != entry ; ++entry )
00351 {
00352 AIDA::IHistogram3D* aida = entry->second ;
00353 if ( NULL == aida )
00354 { this->error() << "IHistogram3D points to NULL" << endmsg ; continue ; }
00355 if ( histos.end() != histos.find( toBase ( aida ) ) ) { continue ; }
00356 histos.insert ( toBase ( aida ) ) ;
00357 msg << std::endl << GaudiAlg::Print3D::toString ( aida , entry->first ) ;
00358 }
00359 }
00360 msg << endmsg ;
00361 }
00362 if ( !profile1DMapNumID().empty() || !profile1DMapLitID().empty() )
00363 {
00364 msg << "List of booked 1D profile histograms in directory "
00365 << "\"" << histoPath() << "\" :-" ;
00366 {
00367 typedef std::map<Profile1DMapNumID::key_type, Profile1DMapNumID::mapped_type> ordered_map_t;
00368 ordered_map_t ordered_map(profile1DMapNumID().begin(), profile1DMapNumID().end());
00369 for ( ordered_map_t::const_iterator entry = ordered_map.begin() ;
00370 ordered_map.end() != entry ; ++entry )
00371 {
00372 AIDA::IProfile1D* aida = entry->second ;
00373 if ( NULL == aida )
00374 { this->error() << "IProfile1D points to NULL" << endmsg ; continue ; }
00375 if ( profiles.end() != profiles.find( toBase ( aida ) ) ) { continue ; }
00376 profiles.insert ( toBase ( aida ) ) ;
00377 msg << std::endl << GaudiAlg::Print1DProf::toString ( aida , entry->first );
00378 }
00379 }
00380 {
00381 typedef std::map<Profile1DMapLitID::key_type, Profile1DMapLitID::mapped_type> ordered_map_t;
00382 ordered_map_t ordered_map(profile1DMapLitID().begin(), profile1DMapLitID().end());
00383 for ( ordered_map_t::const_iterator entry = ordered_map.begin() ;
00384 ordered_map.end() != entry ; ++entry )
00385 {
00386 AIDA::IProfile1D* aida = entry->second ;
00387 if ( NULL == aida )
00388 { this->error() << "IProfile1D points to NULL" << endmsg ; continue ; }
00389 if ( profiles.end() != profiles.find( toBase ( aida ) ) ) { continue ; }
00390 profiles.insert ( toBase ( aida ) ) ;
00391 msg << std::endl << GaudiAlg::Print1DProf::toString ( aida , entry->first );
00392 }
00393 }
00394 msg << endmsg ;
00395 }
00396 if ( !profile2DMapNumID().empty() || !profile2DMapLitID().empty() )
00397 {
00398 msg << "List of booked 2D profile histograms in directory "
00399 << "\"" << histoPath() << "\" :-" ;
00400 {
00401 typedef std::map<Profile2DMapNumID::key_type, Profile2DMapNumID::mapped_type> ordered_map_t;
00402 ordered_map_t ordered_map(profile2DMapNumID().begin(), profile2DMapNumID().end());
00403 for ( ordered_map_t::const_iterator entry = ordered_map.begin() ;
00404 ordered_map.end() != entry ; ++entry )
00405 {
00406 AIDA::IProfile2D* aida = entry->second ;
00407 if ( NULL == aida )
00408 { this->error() << "IProfile2D points to NULL" << endmsg ; continue ; }
00409 if ( profiles.end() != profiles.find( toBase ( aida ) ) ) { continue ; }
00410 profiles.insert ( toBase ( aida ) ) ;
00411 msg << std::endl << GaudiAlg::Print2DProf::toString ( aida , entry->first );
00412 }
00413 }
00414 {
00415 typedef std::map<Profile2DMapLitID::key_type, Profile2DMapLitID::mapped_type> ordered_map_t;
00416 ordered_map_t ordered_map(profile2DMapLitID().begin(), profile2DMapLitID().end());
00417 for ( ordered_map_t::const_iterator entry = ordered_map.begin() ;
00418 ordered_map.end() != entry ; ++entry )
00419 {
00420 AIDA::IProfile2D* aida = entry->second ;
00421 if ( NULL == aida )
00422 { this->error() << "IProfile2D points to NULL" << endmsg ; continue ; }
00423 if ( profiles.end() != profiles.find( toBase ( aida ) ) ) { continue ; }
00424 profiles.insert ( toBase ( aida ) ) ;
00425 msg << std::endl << GaudiAlg::Print2DProf::toString ( aida , entry->first );
00426 }
00427 }
00428 msg << endmsg ;
00429 }
00430
00431 }
00432 return histos.size() + profiles.size() ;
00433 }
00434
00435
00436
00437 template <class PBASE>
00438 bool GaudiHistos<PBASE>::noHistos() const
00439 {
00440 return ( histo1DMapTitle() .empty() &&
00441 histo2DMapTitle() .empty() &&
00442 histo3DMapTitle() .empty() &&
00443 profile1DMapTitle() .empty() &&
00444 profile2DMapTitle() .empty() &&
00445 histo1DMapNumID() .empty() &&
00446 histo1DMapLitID() .empty() &&
00447 histo2DMapNumID() .empty() &&
00448 histo2DMapLitID() .empty() &&
00449 histo3DMapNumID() .empty() &&
00450 histo3DMapLitID() .empty() &&
00451 profile1DMapNumID() .empty() &&
00452 profile1DMapLitID() .empty() &&
00453 profile2DMapNumID() .empty() &&
00454 profile2DMapLitID() .empty() );
00455 }
00456
00457
00458
00459
00460
00461 template <class PBASE>
00462 void GaudiHistos<PBASE>::monitorHisto
00463 ( const AIDA::IBaseHistogram* hist,
00464 const HistoID& ID ) const
00465 {
00466 if ( hist && m_declareMoniHists )
00467 {
00468 if ( this->msgLevel(MSG::DEBUG) )
00469 {
00470 this->debug() << "Monitoring histogram '"
00471 << ID.idAsString() << "' desc = '"
00472 << Gaudi::Utils::Histos::htitle(hist) << "'" << endmsg;
00473 }
00474 this->declareInfo ( histoPath()+"/"+ID.idAsString() ,
00475 hist ,
00476 Gaudi::Utils::Histos::htitle(hist) ) ;
00477 }
00478 }
00479
00480
00481
00482
00483
00484 template <class PBASE>
00485 AIDA::IHistogram1D* GaudiHistos<PBASE>::histo1D ( const HistoID& ID ) const
00486 {
00487 AIDA::IHistogram1D * h(NULL);
00488 if ( ID.numeric() )
00489 {
00490 Histo1DMapNumID::const_iterator found =
00491 histo1DMapNumID().find( ID.numericID() ) ;
00492 h = ( histo1DMapNumID().end() == found ? NULL : found->second );
00493 }
00494 else
00495 {
00496 Histo1DMapLitID::const_iterator found =
00497 histo1DMapLitID().find( ID.literalID() ) ;
00498 h = ( histo1DMapLitID().end() == found ? NULL : found->second );
00499 }
00500 return h;
00501 }
00502
00503
00504
00505 template <class PBASE>
00506 AIDA::IHistogram2D* GaudiHistos<PBASE>::histo2D ( const HistoID& ID ) const
00507 {
00508 AIDA::IHistogram2D * h(NULL);
00509 if ( ID.numeric() )
00510 {
00511 Histo2DMapNumID::const_iterator found =
00512 histo2DMapNumID().find( ID.numericID() ) ;
00513 h = ( histo2DMapNumID().end() == found ? NULL : found->second );
00514 }
00515 else
00516 {
00517 Histo2DMapLitID::const_iterator found =
00518 histo2DMapLitID().find( ID.literalID() ) ;
00519 h = ( histo2DMapLitID().end() == found ? NULL : found->second );
00520 }
00521 return h;
00522 }
00523
00524
00525
00526 template <class PBASE>
00527 AIDA::IHistogram3D* GaudiHistos<PBASE>::histo3D ( const HistoID& ID ) const
00528 {
00529 AIDA::IHistogram3D * h(NULL);
00530 if ( ID.numeric() )
00531 {
00532 Histo3DMapNumID::const_iterator found =
00533 histo3DMapNumID().find( ID.numericID() ) ;
00534 h = ( histo3DMapNumID().end() == found ? NULL : found->second );
00535 }
00536 else
00537 {
00538 Histo3DMapLitID::const_iterator found =
00539 histo3DMapLitID().find( ID.literalID() ) ;
00540 h = ( histo3DMapLitID().end() == found ? NULL : found->second );
00541 }
00542 return h;
00543 }
00544
00545
00546
00547 template <class PBASE>
00548 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D ( const HistoID& ID ) const
00549 {
00550 AIDA::IProfile1D * h(NULL);
00551 if ( ID.numeric() )
00552 {
00553 Profile1DMapNumID::const_iterator found =
00554 profile1DMapNumID().find( ID.numericID() ) ;
00555 h = ( profile1DMapNumID().end() == found ? NULL : found->second );
00556 }
00557 else
00558 {
00559 Profile1DMapLitID::const_iterator found =
00560 profile1DMapLitID().find( ID.literalID() ) ;
00561 h = ( profile1DMapLitID().end() == found ? NULL : found->second );
00562 }
00563 return h;
00564 }
00565
00566
00567
00568 template <class PBASE>
00569 AIDA::IProfile2D* GaudiHistos<PBASE>::profile2D ( const HistoID& ID ) const
00570 {
00571 AIDA::IProfile2D * h(NULL);
00572 if ( ID.numeric() )
00573 {
00574 Profile2DMapNumID::const_iterator found =
00575 profile2DMapNumID().find( ID.numericID() ) ;
00576 h = ( profile2DMapNumID().end() == found ? NULL : found->second );
00577 }
00578 else
00579 {
00580 Profile2DMapLitID::const_iterator found =
00581 profile2DMapLitID().find( ID.literalID() ) ;
00582 h = ( profile2DMapLitID().end() == found ? NULL : found->second );
00583 }
00584 return h;
00585 }
00586
00587
00588
00589 template <class PBASE>
00590 unsigned int GaudiHistos<PBASE>::totalNumberOfHistos() const
00591 {
00592 const unsigned int n1D = histo1DMapNumID().size()+histo1DMapLitID().size();
00593 const unsigned int n2D = histo2DMapNumID().size()+histo2DMapLitID().size();
00594 const unsigned int n3D = histo3DMapNumID().size()+histo3DMapLitID().size();
00595 const unsigned int n1DP = profile1DMapNumID().size()+profile1DMapLitID().size();
00596 const unsigned int n2DP = profile2DMapNumID().size()+profile2DMapLitID().size();
00597 return n1D+n2D+n3D+n1DP+n2DP;
00598 }
00599
00600
00601
00602 template <class PBASE>
00603 void GaudiHistos<PBASE>::newHistoID( const std::string & title,
00604 HistoID& ID ) const
00605 {
00606 if ( useNumericAutoIDs() || title.empty() )
00607 {
00608 if ( !useNumericAutoIDs() )
00609 {
00610 this -> Warning( "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for histogram ID",
00611 StatusCode::SUCCESS );
00612 }
00613
00614 ID = HistoID( totalNumberOfHistos() + 1 + histoOffSet() );
00615
00616 while ( histoExists( ID ) ) { ID = HistoID( ID.numeric() + 1 ) ; }
00617 }
00618 else
00619 {
00620
00621 ID = HistoID( this->convertTitleToID(title) );
00622
00623 while ( histoExists( ID ) ) { ID = HistoID(ID.idAsString()+"_"); }
00624 }
00625 }
00626
00627
00628
00629 template <class PBASE>
00630 std::string GaudiHistos<PBASE>::convertTitleToID( const std::string & title ) const
00631 {
00632
00633 std::string tmp_id = title;
00634 for ( std::map<std::string,std::string>::const_iterator i = m_idReplaceInfo.begin();
00635 i != m_idReplaceInfo.end(); ++i )
00636 {
00637 stringSearchReplace( tmp_id, i->first, i->second );
00638 }
00639 return tmp_id;
00640 }
00641
00642
00643
00644 template <class PBASE>
00645 void GaudiHistos<PBASE>::stringSearchReplace( std::string & title,
00646 const std::string & A,
00647 const std::string & B ) const
00648 {
00649 std::string::size_type slash = title.find_first_of ( A ) ;
00650 while ( std::string::npos != slash )
00651 {
00652 title = title.substr(0,slash) + B + title.substr(slash+A.size());
00653 slash = title.find_first_of( A );
00654 }
00655 }
00656
00657
00658
00659 template < class PBASE >
00660 void GaudiHistos<PBASE>::printHistoHandler( Property& )
00661 {
00662
00663 if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
00664 if ( this -> histosPrint() ) { this -> printHistos ( MSG::ALWAYS ) ; }
00665 }
00666
00667
00668 #include "GaudiAlg/GaudiHistos_1DFixedBinning.icpp"
00669 #include "GaudiAlg/GaudiHistos_1DVariableBinning.icpp"
00670
00671 #include "GaudiAlg/GaudiHistos_2DFixedBinning.icpp"
00672 #include "GaudiAlg/GaudiHistos_2DVariableBinning.icpp"
00673
00674 #include "GaudiAlg/GaudiHistos_3DFixedBinning.icpp"
00675 #include "GaudiAlg/GaudiHistos_3DVariableBinning.icpp"
00676
00677 #include "GaudiAlg/GaudiHistos_1DProfFixedBinning.icpp"
00678 #include "GaudiAlg/GaudiHistos_1DProfVariableBinning.icpp"
00679
00680 #include "GaudiAlg/GaudiHistos_2DProfFixedBinning.icpp"
00681 #include "GaudiAlg/GaudiHistos_2DProfVariableBinning.icpp"
00682
00683
00684
00685 #endif // GAUDIALG_GAUDIHISTOS_ICPP
00686