00001 #include "AdRecHistoCheck.h"
00002
00003 #include "GaudiKernel/MsgStream.h"
00004 #include "GaudiKernel/SmartDataPtr.h"
00005 #include "GaudiKernel/DataObject.h"
00006 #include "StatisticsSvc/IStatisticsSvc.h"
00007
00008 #include "Event/RecHeader.h"
00009 #include "Event/RecTrigger.h"
00010
00011 #include "TH1F.h"
00012
00013 using namespace DayaBay;
00014 using namespace CLHEP;
00015
00016 AdRecHistoCheck::AdRecHistoCheck(const std::string& name,
00017 ISvcLocator* pSvcLocator) :
00018 GaudiAlgorithm(name,pSvcLocator)
00019 {
00020 }
00021
00022 StatusCode AdRecHistoCheck::initialize()
00023 {
00024 if ( service("StatisticsSvc", p_svc).isFailure() ) {
00025 error()<<" No StatisticsSvc available ! "<<endreq;
00026 return StatusCode::FAILURE;
00027 }
00028
00029 TH1F* h1 = new TH1F("recX","recX", 50, -1000., 1000. );
00030 h1->GetXaxis()->SetTitle("mm");
00031 if ( p_svc->put("/File1/AdRec/recX", h1).isFailure() ) {
00032 error()<<"Could't register recX "<<endreq;
00033 }
00034
00035 TH1F* h2 = new TH1F("recY","recY", 50, -1000., 1000. );
00036 h2->GetXaxis()->SetTitle("mm");
00037 if ( p_svc->put("/File1/AdRec/recY", h2).isFailure() ) {
00038 error()<<"Could't register recY "<<endreq;
00039 }
00040
00041 TH1F* h3 = new TH1F("recZ","recZ", 50, -1000., 1000. );
00042 h3->GetXaxis()->SetTitle("mm");
00043 if ( p_svc->put("/File1/AdRec/recZ", h3).isFailure() ) {
00044 error()<<"Could't register recZ "<<endreq;
00045 }
00046
00047 info() << "Finished booking Histograms" << endreq;
00048 return StatusCode::SUCCESS;
00049 }
00050
00051 StatusCode AdRecHistoCheck::execute()
00052 {
00053
00054 TH1* h1 = p_svc->getTH1F("/File1/AdRec/recX");
00055 TH1* h2 = p_svc->getTH1F("/File1/AdRec/recX");
00056 TH1* h3 = p_svc->getTH1F("/File1/AdRec/recX");
00057 if (h1 && h2 && h3 ) {
00058
00059 DayaBay::RecHeader* recHeader
00060 = get<DayaBay::RecHeader>(DayaBay::RecHeaderLocation::Default);
00061
00062 if(!recHeader) {
00063 error()<< "Could not find recHeader" << endreq;
00064 return StatusCode::FAILURE;
00065 }else {
00066
00067 const DayaBay::RecTrigger* recTrigger = &(recHeader->recTrigger());
00068 if(!recTrigger) {
00069 info() << "No recTrigger in recHeader this cycle." << endreq;
00070 return StatusCode::SUCCESS;
00071 }
00072
00073
00074 CLHEP::HepLorentzVector pos = recTrigger->position();
00075
00076 h1->Fill(pos.x());
00077 h2->Fill(pos.y());
00078 h3->Fill(pos.z());
00079
00080 }
00081 } else {
00082 error() <<" Could not retrieve Histograms "<<endreq;
00083 return StatusCode::FAILURE;
00084 }
00085
00086 return StatusCode::SUCCESS;
00087 }
00088
00089 StatusCode AdRecHistoCheck::finalize()
00090 {
00091 debug() << "Finalizing..." << endreq;
00092
00093 return StatusCode::SUCCESS;
00094 }
00095