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

In This Package:

AdQuality.cc

Go to the documentation of this file.
00001 
00002 #include "AdQuality.h"
00003 
00004 #include "Context/Context.h"
00005 #include "Conventions/Detectors.h"
00006 #include "DataSvc/ICableSvc.h"
00007 #include "Event/ReadoutHeader.h"
00008 #include "Event/Readout.h"
00009 #include "Event/ReadoutPmtCrate.h"
00010 #include "Event/ReadoutPmtChannel.h"
00011 
00012 #include "GaudiKernel/ITHistSvc.h"
00013 
00014 #include "TH2F.h"
00015 #include "TH1F.h"
00016 
00017 using namespace std;
00018 using namespace DayaBay;
00019 
00020 class AdQualityPlots {
00021     DayaBay::Detector detector;
00022     MsgStream& log;
00023 public:
00024 
00025     // direct access
00026     TH2F* hitMap2d;
00027     TH1F* hitMap1d;
00028 
00029     AdQualityPlots(DayaBay::Detector det, MsgStream& msg) : detector(det), log(msg) { }
00030 
00031     StatusCode book(ITHistSvc* hsvc, string filepath) {
00032 
00033         {
00034             string name = detector.detName() + "_HitMap2D";
00035             string title = "Hit map for " + detector.detName();
00036             hitMap2d = new TH2F(name.c_str(),title.c_str(),
00037                                 24,0,24, 8,0,8);
00038             
00039             name = filepath+"/"+detector.detName()+"/hitMap2D";
00040             if (hsvc->regHist(name,hitMap2d).isFailure()) {
00041                 log << MSG::ERROR << "Could not register " << name << endreq;
00042                 delete hitMap2d; hitMap2d = 0;
00043                 return StatusCode::FAILURE;
00044             }
00045         }
00046 
00047         {
00048             string name = detector.detName() + "_HitMap1D";
00049             string title = "Hit map for " + detector.detName();
00050             hitMap1d = new TH1F(name.c_str(), title.c_str(),
00051                                 8*24,0,8*24);
00052             hitMap1d->Sumw2();
00053             name = filepath+"/"+detector.detName()+"/hitMap1D";
00054             if (hsvc->regHist(name,hitMap1d).isFailure()) {
00055                 log << MSG::ERROR << "Could not register " << name << endreq;
00056                 delete hitMap1d; hitMap1d = 0;
00057                 return StatusCode::FAILURE;
00058             }
00059         }
00060 
00061         return StatusCode::SUCCESS;
00062     }
00063 
00064     StatusCode fill(ICableSvc* cable, const ServiceMode &sm, 
00065                     const ReadoutPmtCrate* ro) 
00066     {
00067 
00068         // std::map<DayaBay::FeeChannelId,DayaBay::ReadoutPmtChannel> 
00069         const ReadoutPmtCrate::PmtChannelReadouts& 
00070             channelMap = ro->channelReadout();
00071         ReadoutPmtCrate::PmtChannelReadouts::const_iterator
00072             it, done = channelMap.end();
00073         for (it=channelMap.begin(); it != done; ++it) {
00074 
00075             float charge = it->second.sumAdc();
00076 
00077             DayaBay::AdPmtSensor pmt = cable->adPmtSensor(it->first,sm);
00078 
00079             hitMap1d->Fill(pmt.column()-1.0 + 24*(pmt.ring()-1) + 0.5, charge);
00080             hitMap2d->Fill(pmt.column()-0.5, pmt.ring()-0.5,charge);
00081         }
00082         return StatusCode::SUCCESS;
00083     }
00084 
00085 };
00086 
00087 
00088 AdQuality::AdQuality(const std::string& name, ISvcLocator* pSvcLocator)
00089     : GaudiAlgorithm(name,pSvcLocator)
00090     , m_hsvc(0)
00091 {
00092     declareProperty("Location",m_location=DayaBay::ReadoutHeaderLocation::Default,
00093                     "Location in the TES to ReadoutHeaders");
00094     declareProperty("FilePath",m_filepath="/file1/adqual/",
00095                     "File path with with to register histograms.");
00096 }
00097 
00098 AdQuality::~AdQuality()
00099 {
00100 }
00101 
00102 StatusCode AdQuality::initialize()
00103 {
00104     this->GaudiAlgorithm::initialize();
00105 
00106     // Get the histogram service
00107     if ( service("THistSvc", m_hsvc).isFailure()) {
00108         error() << " No THistSvc available." << endreq;
00109         return StatusCode::FAILURE;
00110     } 
00111     // Get the cable service
00112     if ( service("StaticCableSvc", m_cable).isFailure()) {
00113         error() << " No CableService available." << endreq;
00114         return StatusCode::FAILURE;
00115     } 
00116 
00117     return StatusCode::SUCCESS;
00118 }
00119 
00120 StatusCode AdQuality::execute()
00121 {
00122     DayaBay::ReadoutHeader* roh = get<DayaBay::ReadoutHeader>(m_location);
00123 
00124     const DayaBay::ReadoutPmtCrate* ro = 
00125         dynamic_cast<const DayaBay::ReadoutPmtCrate*>(roh->readout());
00126     if (!ro) {
00127         debug() << "Got a non-PmtCrate readout, skipping..." << endreq;
00128         return StatusCode::SUCCESS;
00129     }
00130 
00131     const Context &ctx = roh->context();
00132     DayaBay::Detector det(ctx.GetSite(),ctx.GetDetId());
00133     AdQualityPlots* plots = m_plots[det];
00134     if (!plots) {
00135         plots = new AdQualityPlots(det,info());
00136         m_plots[det] = plots;
00137         plots->book(m_hsvc,m_filepath);
00138     }
00139 
00140     return plots->fill(m_cable,ServiceMode(ctx,0),ro);
00141 }
00142 
00143 StatusCode AdQuality::finalize()
00144 {
00145     return this->GaudiAlgorithm::finalize();
00146 }
00147 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:33:30 2011 for DataQuality by doxygen 1.4.7