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

In This Package:

CalibHistoCheck.cc

Go to the documentation of this file.
00001 #include "CalibHistoCheck.h"
00002 
00003 #include "StatisticsSvc/IStatisticsSvc.h"
00004 
00005 #include "Event/CalibReadoutHeader.h"
00006 #include "Event/CalibReadout.h"
00007 #include "Event/CalibReadoutPmtCrate.h"
00008 #include "Event/CalibReadoutPmtChannel.h"
00009 
00010 #include "TH1F.h"
00011 #include "TH2D.h"
00012 
00013 #include <vector>
00014 
00015 using namespace std;
00016 using namespace DayaBay;
00017 
00018 CalibHistoCheck::CalibHistoCheck(const std::string& name,
00019                                  ISvcLocator* pSvcLocator) : 
00020   GaudiAlgorithm(name,pSvcLocator)
00021 {
00022 }
00023 
00024 StatusCode CalibHistoCheck::initialize()
00025 {
00026   if ( service("StatisticsSvc", p_statsSvc).isFailure() ) {
00027     error()<<" No StatisticsSvc available ! "<<endreq;
00028     return StatusCode::FAILURE;
00029   } 
00030   
00031   TH1F*  h1 = new TH1F("Tdc","Tdc", 500, -500., 0. );
00032   h1->GetXaxis()->SetTitle("ns");
00033   if ( p_statsSvc->put("/File1/Calib/CalibPmt/Tdc", h1).isFailure() ) {
00034     error()<<"Could't register Tdc "<<endreq; 
00035   }
00036   
00037   TH1F*  h2 = new TH1F("Adc","Adc", 400, 0., 40. );
00038   h2->GetXaxis()->SetTitle("p.e");
00039   if ( p_statsSvc->put("/File1/Calib/CalibPmt/Adc", h2).isFailure() ) {
00040     error()<<"Could't register Adc "<<endreq; 
00041   }
00042 
00043   info() << "Finished booking Histograms" << endreq;
00044   return StatusCode::SUCCESS;
00045 }
00046 
00047 StatusCode CalibHistoCheck::execute()
00048 {
00049   
00050   TH1* tdcH = p_statsSvc->getTH1F("/File1/Calib/CalibPmt/Tdc");
00051   TH1* adcH = p_statsSvc->getTH1F("/File1/Calib/CalibPmt/Adc");
00052   if (tdcH && adcH) {
00053     
00054     const  DayaBay::CalibReadoutHeader* calibHeader 
00055       = get<DayaBay::CalibReadoutHeader>(
00056                                  DayaBay::CalibReadoutHeaderLocation::Default);
00057     
00058     if(!calibHeader) {
00059       error()<< "Could not find calibHeader" << endreq;
00060       return StatusCode::FAILURE; 
00061     }else {
00062       if(!calibHeader->calibReadout()) {
00063         info() << "No CalibReadout in calibHeader. No tdc/adc will be filled." << endreq;
00064         return StatusCode::SUCCESS;
00065       }
00066       
00067       const DayaBay::CalibReadoutPmtCrate* calibCrate 
00068         = dynamic_cast<const DayaBay::CalibReadoutPmtCrate*>(
00069                                                   calibHeader->calibReadout());
00070       const DayaBay::CalibReadoutPmtCrate::PmtChannelReadouts calib_chVec 
00071         = calibCrate->channelReadout();
00072 
00073       DayaBay::CalibReadoutPmtCrate::PmtChannelReadouts::const_iterator cpcrIter
00074         = calib_chVec.begin();
00075 
00076       for(; cpcrIter!=calib_chVec.end(); ++cpcrIter) {
00077         
00078         // Get charge on this PMT
00079         double charge = cpcrIter->maxCharge();
00080         adcH->Fill(charge);
00081 
00082         // Get time on this PMT
00083         vector<double> time = cpcrIter->time();
00084         for(size_t len=0; len<time.size(); len++) tdcH->Fill(time[len]);
00085       }
00086         
00087     }
00088   } else {
00089     error() <<" Could not retrieve Histograms "<<endreq;
00090     return StatusCode::FAILURE;
00091   } 
00092   
00093   return StatusCode::SUCCESS;
00094 }
00095 
00096 StatusCode CalibHistoCheck::finalize()
00097 {
00098   debug() << "Finalizing..." << endreq;
00099   
00100   return StatusCode::SUCCESS;
00101 }
00102 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:43:27 2011 for CalibAlg by doxygen 1.4.7