| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

AdReconFigs Class Reference

#include <AdReconFigs.h>

Inheritance diagram for AdReconFigs:

[legend]
Collaboration diagram for AdReconFigs:
[legend]
List of all members.

Public Member Functions

 AdReconFigs (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~AdReconFigs ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
virtual StatusCode sysExecute ()
void put (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const
void put (DataObject *object, const std::string &address, const bool useRootInTES=true) const
Gaudi::Utils::GetData< TYPE
>::return_type 
get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Gaudi::Utils::GetData< TYPE
>::return_type 
get (const std::string &location, const bool useRootInTES=true) const
TYPE * getDet (IDataProviderSvc *svc, const std::string &location) const
TYPE * getDet (const std::string &location) const
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
bool exist (const std::string &location, const bool useRootInTES=true) const
bool existDet (IDataProviderSvc *svc, const std::string &location) const
bool existDet (const std::string &location) const
TYPE * getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
TYPE * getOrCreate (const std::string &location, const bool useRootInTES=true) const
bool registerContext () const
INTupleSvcevtColSvc () const
IAlgContextSvccontextSvc () const
TOOL * tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
TOOL * tool (const std::string &type, const IInterface *parent=0, bool create=true) const
SERVICE * svc (const std::string &name, const bool create=true) const
IUpdateManagerSvcupdMgrSvc () const
IDataProviderSvcfastContainersSvc () const
StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
StatusCode Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
StatusCode Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
StatusCode Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
MsgStreammsgStream (const MSG::Level level) const
MsgStreamalways () const
MsgStreamfatal () const
MsgStreamerr () const
MsgStreamerror () const
MsgStreamwarning () const
MsgStreaminfo () const
MsgStreamdebug () const
MsgStreamverbose () const
MsgStreammsg () const
const Statisticscounters () const
StatEntitycounter (const std::string &tag) const
MSG::Level msgLevel () const
bool msgLevel (const MSG::Level level) const
void resetMsgStream () const
bool typePrint () const
bool propsPrint () const
bool statPrint () const
bool errorsPrint () const
long printStat (const MSG::Level level=MSG::ALWAYS) const
long printErrors (const MSG::Level level=MSG::ALWAYS) const
long printProps (const MSG::Level level=MSG::ALWAYS) const
void registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL)
void registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL)
StatusCode runUpdate ()
TransientFastContainer< T > * getFastContainer (const std::string &location, typename TransientFastContainer< T >::size_type initial=0)
StatusCode release (const IInterface *interface) const
unsigned long release ()
const std::string & context () const
const std::string & rootInTES () const
double globalTimeOffset () const
virtual StatusCode sysStart ()
virtual StatusCode sysInitialize ()
virtual StatusCode sysReinitialize ()
virtual StatusCode sysRestart ()
virtual StatusCode sysStop ()
virtual StatusCode sysFinalize ()
virtual StatusCode sysBeginRun ()
virtual StatusCode sysEndRun ()
virtual const std::string & name () const
virtual const std::string & version () const
virtual StatusCode configure ()
virtual StatusCode terminate ()
virtual StatusCode start ()
virtual StatusCode stop ()
virtual StatusCode reinitialize ()
virtual StatusCode restart ()
virtual bool isExecuted () const
virtual void setExecuted (bool state)
virtual void resetExecuted ()
virtual StatusCode beginRun ()
virtual StatusCode endRun ()
virtual Gaudi::StateMachine::State FSMState () const
virtual Gaudi::StateMachine::State targetFSMState () const
virtual bool isEnabled () const
virtual bool filterPassed () const
virtual void setFilterPassed (bool state)
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
void setOutputLevel (int level)
IAuditorSvcauditorSvc () const
IChronoStatSvcchronoSvc () const
IChronoStatSvcchronoStatService () const
IDataProviderSvcdetSvc () const
IDataProviderSvcdetDataService () const
IConversionSvcdetCnvSvc () const
IConversionSvcdetDataCnvService () const
IDataProviderSvceventSvc () const
IDataProviderSvcevtSvc () const
IDataProviderSvceventDataService () const
IConversionSvceventCnvSvc () const
IConversionSvceventDataCnvService () const
IHistogramSvchistoSvc () const
IHistogramSvchistogramDataService () const
IMessageSvcmsgSvc () const
IMessageSvcmessageService () const
INTupleSvcntupleSvc () const
INTupleSvcntupleService () const
IRndmGenSvcrandSvc () const
IToolSvctoolSvc () const
IExceptionSvcexceptionSvc () const
ISvcLocatorserviceLocator () const
ISvcLocatorsvcLoc () const
StatusCode createSubAlgorithm (const std::string &type, const std::string &name, Algorithm *&pSubAlg)
std::vector< Algorithm * > * subAlgorithms () const
virtual StatusCode setProperty (const Property &p)
virtual StatusCode setProperty (const std::string &s)
virtual StatusCode setProperty (const std::string &n, const std::string &v)
StatusCode setProperty (const std::string &name, const TYPE &value)
virtual StatusCode getProperty (Property *p) const
virtual const PropertygetProperty (const std::string &name) const
virtual StatusCode getProperty (const std::string &n, std::string &v) const
virtual const std::vector<
Property * > & 
getProperties () const
StatusCode setProperties ()
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
IMonitorSvcmonitorSvc () const
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
unsigned long addRef ()
StatusCode queryInterface (const InterfaceID &riid, void **)

Static Public Member Functions

static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()

Public Attributes

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR

Protected Types

typedef std::map< std::string,
StatEntity
Statistics
typedef std::map< std::string,
unsigned int > 
Counter
typedef std::vector< IAlgTool * > AlgTools
typedef std::pair< IInterface *,
std::string > 
ServiceEntry
typedef std::vector< ServiceEntryServices

Protected Member Functions

StatusCode releaseTool (const IAlgTool *tool) const
StatusCode releaseSvc (const IInterface *svc) const
bool isInitialized () const
bool isFinalized () const
int outputLevel () const
IntegerPropertyoutputLevelProperty ()
void initOutputLevel (Property &prop)

Static Protected Attributes

static const bool IgnoreRootInTES
static const bool UseRootInTES

Private Member Functions

TH1 * getOrMakeHist (int run, const DayaBay::Detector &detector, int histogram)
std::string getPath (int run, const char *detectorName, const char *histName)
void extendRange (TH1 *hist, int xBinsAdd, int yBinsAdd=0)

Private Attributes

std::string m_reconLocation
IStatisticsSvcm_statsSvc
TimeStampm_firstTriggerTime
std::map< DayaBay::Detector,
TimeStamp
m_lastTriggerTime
std::map< int, TH1 ** > m_shortCuts
std::vector< TH1 * > m_normalize

Detailed Description

Definition at line 35 of file AdReconFigs.h.


Constructor & Destructor Documentation

AdReconFigs::AdReconFigs ( const std::string &  name,
ISvcLocator pSvcLocator 
)

Definition at line 15 of file AdReconFigs.cc.

00017   : GaudiAlgorithm(name,pSvcLocator),
00018     m_statsSvc(0),
00019     m_firstTriggerTime(0)
00020 {
00021   declareProperty("ReconLocation", m_reconLocation="/Event/Rec/AdSimple",
00022                   "Generate histograms for this reconstruction TES path");
00023 }

AdReconFigs::~AdReconFigs (  )  [virtual]

Definition at line 25 of file AdReconFigs.cc.

00026 {
00027 }


Member Function Documentation

StatusCode AdReconFigs::initialize (  )  [virtual]

Reimplemented from GaudiAlgorithm.

Definition at line 29 of file AdReconFigs.cc.

00030 {
00031   // Initialize the necessary services
00032   StatusCode sc = this->service("StatisticsSvc",m_statsSvc,true);
00033   if(sc.isFailure()){
00034     error() << "Failed to get StatisticsSvc" << endreq;
00035     return sc;
00036   }
00037   return sc;
00038 }

StatusCode AdReconFigs::execute (  )  [virtual]

Reimplemented from GaudiAlgorithm.

Definition at line 40 of file AdReconFigs.cc.

00041 {
00042   // Add the current event into histograms
00043   DayaBay::RecHeader* recHeader = 
00044     get<DayaBay::RecHeader>(m_reconLocation);
00045   if(!recHeader){
00046     error() << "Failed to get reconstructed header: " << m_reconLocation
00047             << endreq;
00048     return StatusCode::FAILURE;
00049   }
00050 
00051   const DayaBay::RecTrigger* recTrigger = &(recHeader->recTrigger());
00052   if(!recTrigger){
00053     error() << "Failed to get reconstructed trigger: " << m_reconLocation
00054             << endreq;
00055     return StatusCode::FAILURE;
00056   }
00057   
00058   if(!recTrigger->detector().isAD()){
00059     // Not an AD, continue
00060     return StatusCode::SUCCESS;
00061   }
00062 
00063   // Wow... Look at the trouble we have to go through to get the run number
00064   int runNumber = 0;
00065   {
00066     // Add the current event into histograms
00067     DayaBay::ReadoutHeader* readoutHeader = 
00068       get<DayaBay::ReadoutHeader>("/Event/Readout/ReadoutHeader");
00069     if(!readoutHeader){
00070       error() << "Failed to get readout header." << endreq;
00071       return StatusCode::FAILURE;
00072     }
00073     
00074     const DayaBay::DaqCrate* ro = readoutHeader->daqCrate();
00075     if(!ro){
00076       error() << "Failed to get readout from header" << endreq;
00077       return StatusCode::FAILURE;
00078     }
00079     
00080     runNumber = ro->runNumber();
00081   }
00082 
00083   if(!m_firstTriggerTime){
00084     m_firstTriggerTime = new TimeStamp(recTrigger->triggerTime());
00085   }
00086 
00087   // Find histograms
00088   const DayaBay::Detector& detector = recTrigger->detector();
00089   TH1F* adEnergy = dynamic_cast<TH1F*>(this->getOrMakeHist(runNumber,
00090                                                            detector,
00091                                                            ADENERGY));
00092   TH2F* adZVsRho = dynamic_cast<TH2F*>(this->getOrMakeHist(runNumber,
00093                                                            detector,
00094                                                            ADZVSRHO));
00095   TH2F* adYVsX = dynamic_cast<TH2F*>(this->getOrMakeHist(runNumber,
00096                                                          detector,
00097                                                          ADYVSX));
00098   TH2F* adZVsXcal = dynamic_cast<TH2F*>(this->getOrMakeHist(runNumber,
00099                                                             detector,
00100                                                             ADZVSXCAL));
00101 
00102   if(recTrigger->energyStatus()==ReconStatus::kGood){
00103     adEnergy->Fill(recTrigger->energy());
00104   }
00105   if(recTrigger->positionStatus()==ReconStatus::kGood){
00106     // FIXME: Use CLHEP units
00107     double x = recTrigger->position().x() / 1000.;
00108     double y = recTrigger->position().y() / 1000.;
00109     double z = recTrigger->position().z() / 1000.;
00110     double rhoSq = x*x+y*y;
00111     double xCal = x*TMath::Cos(DayaBay::Calibration::AD_AxisB_phi)
00112       + y*TMath::Sin(DayaBay::Calibration::AD_AxisB_phi);
00113     adZVsRho->Fill( rhoSq/4., z );
00114     adYVsX->Fill(x, y);
00115     adZVsXcal->Fill(xCal, z);
00116   }
00117 
00118   m_lastTriggerTime[recTrigger->detector()] = recTrigger->triggerTime();
00119 
00120   return StatusCode::SUCCESS;
00121 }

StatusCode AdReconFigs::finalize (  )  [virtual]

Reimplemented from GaudiAlgorithm.

Definition at line 123 of file AdReconFigs.cc.

00124 {
00125   // Handle Normalized histograms
00126   for(unsigned int normIdx=0; normIdx<m_normalize.size(); normIdx++){
00127     TH1* hist = m_normalize[normIdx];
00128     hist->Sumw2();
00129     if(hist->GetNormFactor()>0){
00130       double scale = 1./hist->GetNormFactor();
00131       hist->SetNormFactor(1);
00132       hist->Scale( scale );
00133     }
00134     hist->SetBit(TH1::kIsAverage);
00135   }
00136   m_normalize.clear();
00137   // Clean-up histogram shortcuts
00138   std::map<int,TH1**>::iterator histIter, histEnd = m_shortCuts.end();
00139   for(histIter = m_shortCuts.begin(); histIter!=histEnd; histIter++){
00140     delete [] (histIter->second);
00141     histIter->second = 0;
00142   }
00143   if( m_statsSvc ) m_statsSvc->release();
00144   if(m_firstTriggerTime){
00145     delete m_firstTriggerTime;
00146     m_firstTriggerTime = 0;
00147   }
00148   return StatusCode::SUCCESS;
00149 }

TH1 * AdReconFigs::getOrMakeHist ( int  run,
const DayaBay::Detector detector,
int  histogram 
) [private]

Definition at line 153 of file AdReconFigs.cc.

00155 {
00156   int siteInt = 0;
00157   switch(detector.site()){
00158   case Site::kUnknown:
00159     siteInt = 0; break;
00160   case Site::kDayaBay:
00161     siteInt = 1; break;
00162   case Site::kLingAo:
00163     siteInt = 2; break;
00164   case Site::kFar:
00165     siteInt = 3; break;
00166   case Site::kSAB:
00167     siteInt = 4; break;
00168   default:
00169     error() << "Unknown site: " << detector.detName() << endreq;
00170     return 0;
00171   }
00172   int detectorInt = int(detector.detectorId());
00173   std::map<int,TH1**>::iterator histIter = m_shortCuts.find(run);
00174   TH1** histograms = 0;
00175   if( histIter == m_shortCuts.end() ){
00176     // Initialize histogram shortcuts
00177     histograms = new TH1*[MAXRECHISTS];
00178     for(int i=0; i<MAXRECHISTS; i++) histograms[i] = 0;
00179     m_shortCuts[run] = histograms;
00180   }else{
00181     // Found run
00182     histograms = histIter->second;
00183   }
00184   
00185   TH1* hist = 
00186     histograms[siteInt * NDETECTORS * NRECHISTOGRAMS
00187                + detectorInt * NRECHISTOGRAMS
00188                + histogram];
00189   if(!hist){
00190     // Make this histogram
00191     std::string histName;
00192     std::string histTitle;
00193     if(detector.detectorId()){
00194       // Make detector histogram
00195       std::string reconStyle = "Unknown"; 
00196       for(int strIdx=m_reconLocation.size()-1; strIdx>=0; strIdx--){
00197         if(m_reconLocation[strIdx]=='/'){
00198           reconStyle=std::string(m_reconLocation,strIdx+1);
00199           break;
00200         }
00201       }
00202       switch(histogram){
00203       case ADENERGY:
00204         // AD Energy 
00205         histName = std::string("adEnergy_") + reconStyle;
00206         histTitle = std::string("AD Energy (") + reconStyle
00207           + std::string(")");
00208         hist = new TH1F(histName.c_str(),histTitle.c_str(),
00209                         1100,-1,10);
00210         hist->GetXaxis()->SetTitle("Energy [MeV]");
00211         hist->GetYaxis()->SetTitle("Events / keV");
00212         break;
00213       case ADZVSRHO:
00214         // AD Z vs Rho 
00215         histName = std::string("adZVsRho_") + reconStyle;
00216         histTitle = std::string("AD Reconstructed Position (") + reconStyle
00217           + std::string(")");
00218         hist = new TH2F(histName.c_str(),histTitle.c_str(),
00219                         400,0,1.6,400,-2,2);
00220         hist->GetXaxis()->SetTitle("( #rho / 2 m )^{2}");
00221         hist->GetYaxis()->SetTitle("z [m]");
00222         break;
00223       case ADYVSX:
00224         // AD Y vs X 
00225         histName = std::string("adYVsX_") + reconStyle;
00226         histTitle = std::string("AD Reconstructed Position (") + reconStyle
00227           + std::string(")");
00228         hist = new TH2F(histName.c_str(),histTitle.c_str(),
00229                         400,-3,3,400,-3,3);
00230         hist->GetXaxis()->SetTitle("x [m]");
00231         hist->GetYaxis()->SetTitle("y [m]");
00232         break;
00233       case ADZVSXCAL:
00234         // AD Z vs X_calibration  
00235         histName = std::string("adZVsXcal_") + reconStyle;
00236         histTitle = std::string("AD Reconstructed Position (") + reconStyle
00237           + std::string(")");
00238         hist = new TH2F(histName.c_str(),histTitle.c_str(),
00239                         400,-3,3,400,-2,2);
00240         hist->GetXaxis()->SetTitle("x_{calib} [m]");
00241         hist->GetYaxis()->SetTitle("z [m]");
00242         break;
00243       default:
00244         error() << "Unknown Histogram: " << histogram << endreq;
00245         return 0;
00246       }
00247     }
00248     debug() << "Making histogram: " << histName << endreq;
00249     m_statsSvc->put( this->getPath(run, detector.detName().c_str(), 
00250                                    histName.c_str()), 
00251                      hist );
00252     histograms[siteInt * NDETECTORS * NRECHISTOGRAMS
00253                + detectorInt * NRECHISTOGRAMS
00254                + histogram] = hist;
00255   }
00256 
00257   return hist;
00258 }

std::string AdReconFigs::getPath ( int  run,
const char *  detectorName,
const char *  histName 
) [private]

Definition at line 260 of file AdReconFigs.cc.

00262 {
00263   // Construct histogram path in statistics service
00264   std::stringstream path;
00265   path << "/file1/diagnostics/run_" << std::setfill('0') << std::setw(7) 
00266        << run;
00267   if(detectorName){
00268     path << "/detector_" << detectorName;
00269   }
00270   path << "/" << histName;
00271   return path.str();
00272 }

void AdReconFigs::extendRange ( TH1 *  hist,
int  xBinsAdd,
int  yBinsAdd = 0 
) [private]

Definition at line 274 of file AdReconFigs.cc.

00275 {
00276   // Automatically extend the histogram range, and replace
00277   //  Currently works for TH1F and TH2F
00278   info() << "Extending histogram range: " << hist->GetName() << endreq;
00279   TH1* extension = 0;
00280   if(hist->IsA() == TH2F::Class()){
00281     extension = new TH2F("","",
00282                          xBinsAdd + hist->GetNbinsX(),
00283                          hist->GetXaxis()->GetXmin(),
00284                          hist->GetXaxis()->GetXmax() 
00285                          + xBinsAdd*hist->GetXaxis()->GetBinWidth(0),
00286                          yBinsAdd + hist->GetNbinsY(),
00287                          hist->GetYaxis()->GetXmin(),
00288                          hist->GetYaxis()->GetXmax() 
00289                          + yBinsAdd*hist->GetYaxis()->GetBinWidth(0));
00290   }else if(hist->IsA() == TH1F::Class()){
00291     extension = new TH1F("","",
00292                          xBinsAdd + hist->GetNbinsX(),
00293                          hist->GetXaxis()->GetXmin(),
00294                          hist->GetXaxis()->GetXmax() 
00295                          + xBinsAdd*hist->GetXaxis()->GetBinWidth(0));
00296   }else{
00297     error() << "Cannot extend range of type: " << hist->ClassName() << endreq;
00298     return;
00299   }
00300   TList list;
00301   list.Add(extension);
00302   hist->Merge(&list);
00303   delete extension;
00304   return;
00305 }


Member Data Documentation

std::string AdReconFigs::m_reconLocation [private]

Definition at line 55 of file AdReconFigs.h.

IStatisticsSvc* AdReconFigs::m_statsSvc [private]

Definition at line 58 of file AdReconFigs.h.

TimeStamp* AdReconFigs::m_firstTriggerTime [private]

Definition at line 60 of file AdReconFigs.h.

std::map<DayaBay::Detector,TimeStamp> AdReconFigs::m_lastTriggerTime [private]

Definition at line 61 of file AdReconFigs.h.

std::map<int,TH1**> AdReconFigs::m_shortCuts [private]

Definition at line 62 of file AdReconFigs.h.

std::vector<TH1*> AdReconFigs::m_normalize [private]

Definition at line 63 of file AdReconFigs.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:25:15 2011 for AdBasicFigs by doxygen 1.4.7