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

In This Package:

ReconDataHistogram Class Reference

#include <ReconDataHistogram.h>

Inheritance diagram for ReconDataHistogram:

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

Public Member Functions

 ReconDataHistogram (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~ReconDataHistogram ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode execute ()
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 Types

 kEnergyVsR
 kEnergyVsZ
 kRateVsR
 kRateVsZ
enum  Fig_t { kEnergyVsR, kEnergyVsZ, kRateVsR, kRateVsZ }

Private Member Functions

TH1 * getOrMakeHist (int run, const DayaBay::Detector &detector, int histIndex)
std::string getPath (int run, const DayaBay::Detector &detector, const char *histName)

Private Attributes

IStatisticsSvc * m_statsSvc
TimeStampm_firstTriggerTime
TimeStamp m_lastTriggerTime
std::map< int, TH1 ** > m_hist
std::vector< TH1 * > m_scale
unsigned long m_eventCount

Detailed Description

Definition at line 24 of file ReconDataHistogram.h.


Member Enumeration Documentation

enum ReconDataHistogram::Fig_t [private]

Enumerator:
kEnergyVsR 
kEnergyVsZ 
kRateVsR 
kRateVsZ 

Definition at line 51 of file ReconDataHistogram.h.

00051                {
00052       kEnergyVsR,
00053       kEnergyVsZ,
00054       kRateVsR,
00055       kRateVsZ
00056     };


Constructor & Destructor Documentation

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

Definition at line 31 of file ReconDataHistogram.cc.

00033   : GaudiAlgorithm(name,pSvcLocator),
00034     m_statsSvc(0),
00035     m_eventCount(0),
00036     m_firstTriggerTime(0)
00037 {
00038 }

ReconDataHistogram::~ReconDataHistogram (  )  [virtual]

Definition at line 40 of file ReconDataHistogram.cc.

00041 {
00042 }


Member Function Documentation

StatusCode ReconDataHistogram::initialize (  )  [virtual]

Reimplemented from GaudiAlgorithm.

Definition at line 44 of file ReconDataHistogram.cc.

00045 {
00046   // Initialize the necessary services
00047   StatusCode sc = service("StatisticsSvc",m_statsSvc,true);
00048   if(sc.isFailure()){
00049     error() << "Failed to get StatisticsSvc" << endreq;
00050     return sc;
00051   }
00052   return sc;
00053 }

StatusCode ReconDataHistogram::finalize (  )  [virtual]

Reimplemented from GaudiAlgorithm.

Definition at line 114 of file ReconDataHistogram.cc.

00115 {
00116   info() << "Finalizing " << endreq;
00117 
00118   for(unsigned int Idx=0; Idx<m_scale.size(); Idx++){
00119     TH1* hist = m_scale[Idx];
00120     hist->Sumw2();
00121     double duration = m_lastTriggerTime.GetSeconds() - m_firstTriggerTime->GetSeconds();
00122     hist->Scale(1/duration);
00123   }
00124   m_scale.clear();
00125 
00126   if( m_statsSvc ) {
00127     m_statsSvc->release();
00128   }
00129 
00130   if(m_firstTriggerTime){
00131     delete m_firstTriggerTime;
00132     m_firstTriggerTime = 0;
00133   }
00134 
00135   return StatusCode::SUCCESS;
00136 }

StatusCode ReconDataHistogram::execute (  )  [virtual]

Reimplemented from GaudiAlgorithm.

Definition at line 55 of file ReconDataHistogram.cc.

00056 {
00057   verbose() << "executing: " << m_eventCount << endreq;
00058   // Add the current event into histograms
00059   DayaBay::RecHeader* recHeader = 
00060     get<DayaBay::RecHeader>("/Event/Rec/AdSimple");
00061   if(!recHeader){
00062     error() << "Failed to get reconstructed header:" << "/Event/Rec/AdSimple"
00063             << endreq;
00064     return StatusCode::FAILURE;
00065   }
00066 
00067   const DayaBay::RecTrigger* recTrigger = &(recHeader->recTrigger());
00068   if(!recTrigger){
00069     error() << "Failed to get reconstructed trigger: " << "Event/Rec/AdSimple"
00070             << endreq;
00071     return StatusCode::FAILURE;
00072   }
00073   
00074   if(!recTrigger->detector().isAD()){
00075     // Not an AD, continue
00076     return StatusCode::SUCCESS;
00077   }
00078  
00079   const DayaBay::Detector& detector = recTrigger->detector();
00080   info() << "Detector = " << detector << endreq;
00081 
00082   if(!m_firstTriggerTime){
00083     m_firstTriggerTime = new TimeStamp(recTrigger->triggerTime());
00084   }
00085   
00086   TH2F* h_energyVsR = dynamic_cast<TH2F*>(getOrMakeHist(1, detector, kEnergyVsR));
00087   TH2F* h_energyVsZ = dynamic_cast<TH2F*>(getOrMakeHist(1, detector, kEnergyVsZ));
00088   TH1F* h_rateVsR = dynamic_cast<TH1F*>(getOrMakeHist(1, detector, kRateVsR));
00089   TH1F* h_rateVsZ = dynamic_cast<TH1F*>(getOrMakeHist(1, detector, kRateVsZ));
00090   
00091   if(recTrigger->positionStatus()==ReconStatus::kGood){
00092     double x = recTrigger->position().x() / 1000;
00093     double y = recTrigger->position().y() / 1000;
00094     double z = recTrigger->position().z() / 1000;
00095     double r = TMath::Sqrt(x*x+y*y);
00096     h_rateVsR->Fill(r);
00097     h_rateVsZ->Fill(z);
00098     if(recTrigger->energyStatus()==ReconStatus::kGood){
00099       h_energyVsR->Fill(r, recTrigger->energy());
00100       h_energyVsZ->Fill(z,recTrigger->energy());
00101     }
00102   }
00103 
00104   m_lastTriggerTime = recTrigger->triggerTime();
00105   
00106   ++m_eventCount;
00107   if (0 == (m_eventCount % 1000)) {
00108     info() << " Processed " << m_eventCount << " events" << endreq;
00109   }
00110 
00111   return StatusCode::SUCCESS;
00112 }

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

Definition at line 138 of file ReconDataHistogram.cc.

00140 {
00141   debug() << "Detector=" << detector << "," << detector.fullPackedData() << endreq;
00142 
00143   int siteInt = 0;
00144   switch(detector.site()){
00145   case Site::kUnknown:
00146     siteInt = 0; break;
00147   case Site::kDayaBay:
00148     siteInt = 1; break;
00149   case Site::kLingAo:
00150     siteInt = 2; break;
00151   case Site::kFar:
00152     siteInt = 3; break;
00153   case Site::kSAB:
00154     siteInt = 4; break;
00155   default:
00156     error() << "Unknown site: " << detector.detName() << endreq;
00157     return 0;
00158   }
00159 
00160 //  int detectorInt = detector.fullPackedData();
00161   int detectorInt = int(detector.detectorId());
00162   std::map<int,TH1**>::iterator histIter = m_hist.find(detectorInt);
00163   TH1** histograms = 0;
00164   if( histIter == m_hist.end() ){
00165     info() << "Create " << MAXRECHISTS << " histograms for " << detector << endreq;
00166     // Initialize histogram 
00167     histograms = new TH1*[MAXRECHISTS];
00168     for(int i=0; i<MAXRECHISTS; i++) histograms[i] = 0;
00169     m_hist[detectorInt] = histograms;
00170   }else{
00171     // Found detector
00172     histograms = histIter->second;
00173   }
00174 
00175   int iHist = siteInt * NDETECTORS * NRECHISTOGRAMS + detectorInt * NRECHISTOGRAMS + histIndex;
00176   //cout<<"siteInt:  "<<siteInt<<"  detectorInt:  "<<detectorInt<<"  iHist:  "<<iHist<<endreq;
00177   info() << "Histogram index = " << iHist << endreq;
00178   TH1* hist = histograms[siteInt * NDETECTORS * NRECHISTOGRAMS + detectorInt * NRECHISTOGRAMS + histIndex];
00179   if(!hist){
00180     // Make this histogram
00181     std::string histName;
00182     if(detector.detectorId()){
00183        
00184       // Make detector histIndex
00185       switch(histIndex){
00186         case kEnergyVsR:
00187           hist = new TH2F("h_sum_energyVsR","h_sum_energyVsR",250, 0, 2.5, 110, -1, 10);
00188           hist->GetXaxis()->SetTitle("R_{recon}/m");
00189           hist->GetYaxis()->SetTitle("E_{recon}/MeV");
00190           break;
00191         case kEnergyVsZ:
00192           hist = new TH2F("h_sum_energyVsZ","h_sum_energyVsZ",500, -2.5, 2.5, 110, -1, 10);
00193           hist->GetXaxis()->SetTitle("Z_{recon}/m");
00194           hist->GetYaxis()->SetTitle("E_{recon}/MeV");
00195           break;
00196         case kRateVsR:
00197           hist = new TH1F("h_sum_rateVsR","h_sum_rateVsR", 250, 0, 2.5);
00198           hist->GetXaxis()->SetTitle("R_{recon}/m");
00199           hist->GetYaxis()->SetTitle("EventRate/bin(1cm)");
00200           m_scale.push_back(hist);
00201           break;
00202         case kRateVsZ:
00203           hist = new TH1F("h_sum_rateVsZ","h_sum_rateVsZ",500, -2.5, 2.5);
00204           hist->GetXaxis()->SetTitle("Z_{recon}/m");
00205           hist->GetYaxis()->SetTitle("EventRate/bin(1cm)");
00206           m_scale.push_back(hist);
00207           break;
00208         default:
00209           error() << "Unknown histogram for event: " << histIndex << endreq;
00210           return 0;
00211       }
00212       
00213     }
00214     info() << "Making histogram: " << hist->GetName() << endreq;
00215     m_statsSvc->put( getPath(run, detector, hist->GetName()), hist );
00216     histograms[ siteInt * NDETECTORS * NRECHISTOGRAMS + detectorInt * NRECHISTOGRAMS + histIndex] = hist;
00217   }
00218 
00219   return hist;
00220 }

std::string ReconDataHistogram::getPath ( int  run,
const DayaBay::Detector detector,
const char *  histName 
) [private]

Definition at line 222 of file ReconDataHistogram.cc.

00224 {
00225   // Construct histogram path in statistics service
00226   std::stringstream path;
00227   path << "/file1/";
00228   path << Site::AsString(detector.site()) << "/" << DetectorId::AsString(detector.detectorId());
00229   path << "/Recon";
00230   path << "/" << histName;
00231   debug() << "Histogram path = " << path << endreq;
00232   return path.str();
00233 }


Member Data Documentation

IStatisticsSvc* ReconDataHistogram::m_statsSvc [private]

Definition at line 36 of file ReconDataHistogram.h.

TimeStamp* ReconDataHistogram::m_firstTriggerTime [private]

Definition at line 37 of file ReconDataHistogram.h.

TimeStamp ReconDataHistogram::m_lastTriggerTime [private]

Definition at line 38 of file ReconDataHistogram.h.

std::map<int,TH1**> ReconDataHistogram::m_hist [private]

Definition at line 44 of file ReconDataHistogram.h.

std::vector<TH1*> ReconDataHistogram::m_scale [private]

Definition at line 45 of file ReconDataHistogram.h.

unsigned long ReconDataHistogram::m_eventCount [private]

Definition at line 49 of file ReconDataHistogram.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:26:21 2011 for DQMRawData by doxygen 1.4.7