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

In This Package:

RawDataReader.cc

Go to the documentation of this file.
00001 #include "RawDataReader.h"
00002 #include "Event/ReadoutHeader.h"
00003 #include "Event/ReadoutPmtCrate.h"
00004 #include "Event/RawEventHeader.h"
00005 #include "Event/RawRom.h"
00006 #include "Event/RawRomFee.h"
00007 #include "Event/RawPmtChannel.h"
00008 #include "Event/RawRomLtb.h"
00009 #include "Event/RawLtbFrame.h"
00010 
00011 using namespace std;
00012 using namespace DayaBay;
00013 
00014 RawDataReader::RawDataReader(const string& name, ISvcLocator* svcloc)
00015       : GaudiAlgorithm(name, svcloc)
00016       , m_log(msgSvc(), name)
00017 {
00018    declareProperty("PrintFreq", m_printFreq = 100, "print frequency for event information");
00019    declareProperty("CheckRawEvent", m_checkRawEvent = false, "Whether check raw event");
00020 }
00021 
00022 RawDataReader::~RawDataReader()
00023 {
00024 }
00025 
00026 StatusCode RawDataReader::initialize()
00027 {
00028    m_log << MSG::DEBUG << "initialize()" << endreq;
00029    return StatusCode::SUCCESS;
00030 }
00031 
00032 StatusCode RawDataReader::execute()
00033 {
00034    m_log << MSG::DEBUG << "execute() ______________________________ start" << endreq;
00035 
00036    ReadoutHeader* roh = get<ReadoutHeader>("/Event/Readout/ReadoutHeader");
00037    if (roh == 0) {
00038       m_log << MSG::ERROR << " =======> Requested Object can not be accessable." << endreq;
00039       return StatusCode::FAILURE;
00040    }
00041 
00042 
00043    Readout* readout = const_cast<Readout*>(roh->readout());
00044    ReadoutPmtCrate* crate = dynamic_cast<ReadoutPmtCrate*>(readout);
00045    ReadoutPmtCrate::PmtChannelReadouts channels = crate->channelReadout();
00046 
00047    if (m_printFreq > 0 && crate->triggerNumber() % m_printFreq == 0) {
00048       m_log << MSG::INFO << "detector: " << crate->detector().detName() 
00049         << " site="<<crate->detector().site() << " detectorId="<<crate->detector().detectorId()  << endreq;
00050       m_log << MSG::INFO << "Readout: " << (Readout)(*(roh->readout()))  << endreq;
00051       m_log << MSG::INFO << "Readout: " << *readout  << endreq;
00052       m_log << MSG::INFO << "ReadoutPmtCrate: " << *crate  << endreq;
00053 
00054       m_log << MSG::INFO << "FADC size=" << crate->fadcReadout().size()  << endreq;
00055       ReadoutPmtCrate::FadcReadouts &fadcReadouts = crate->fadcReadout();
00056       ReadoutPmtCrate::FadcReadouts::iterator itfadc;
00057       for(itfadc=fadcReadouts.begin(); itfadc!=fadcReadouts.end(); itfadc++) {
00058         m_log << MSG::INFO << itfadc->first << " => " << itfadc->second  << endreq;
00059       }
00060       
00061       m_log << MSG::INFO << "#channels=" << crate->channelReadout().size()  << endreq;
00062       ReadoutPmtCrate::PmtChannelReadouts::iterator it;
00063       for (it=channels.begin(); it != channels.end(); it++) {
00064          m_log << MSG::INFO << it->first << " => " << it->second  << endreq;
00065 
00066          for(unsigned int i=0; i<it->second.size(); i++) {
00067            m_log << MSG::DEBUG << "ADC= (" << it->second.adc(i) 
00068              << "," << it->second.adcRange(i) << "," << it->second.adcCycle(i)
00069              << "), TDC= (" << it->second.tdc(i) << "," << it->second.tdcHitCount(i) << ")" << endreq;
00070          }
00071 
00072          m_log << MSG::DEBUG << "size = " << it->second.size() 
00073            << ", maxAdcIndex= " << it->second.maxAdcIndex()
00074            << ", maxAdc= " << it->second.maxAdc()
00075            << ", sumAdc= " << it->second.sumAdc()
00076            << ", earliestTdcIndex= " << it->second.earliestTdcIndex()
00077            << ", earliestTdc= " << it->second.earliestTdc()
00078            << ", earliestAdc= " << it->second.earliestAdc()
00079            << endreq;
00080       }
00081       
00082    }
00083 
00084    if(m_checkRawEvent) {
00085 
00086      RawEventHeader* reh = get<RawEventHeader>(RawEventHeaderLocation::Default);
00087      if (reh == 0) {
00088        m_log << MSG::ERROR << " =======> Requested Object can not be accessable." << endreq;
00089        return StatusCode::FAILURE;
00090      }
00091 
00092      if (m_printFreq > 0 && reh->evtNum() % m_printFreq == 0) {
00093        //m_log << MSG::INFO << *reh << endreq;
00094        const vector<RawRom*>& modules = reh->modules();
00095        for(unsigned int i=0; i<modules.size(); i++) {
00096          m_log << MSG::INFO << "Rom type: " << modules[i]->type() << endreq;
00097          switch(modules[i]->type()) {
00098            case 1:  //RomFee 
00099              {
00100                RawRomFee* rawRomFee = dynamic_cast<RawRomFee*>(modules[i]);
00101                m_log << MSG::INFO << "RawRomFee: " << *rawRomFee << endreq;
00102                const vector<DayaBay::RawPmtChannel*>& channels = rawRomFee->channels();
00103                for(unsigned int j=0; j<channels.size(); j++) {
00104                  m_log << MSG::INFO << "RawPmtChannel: " << *(channels[j]) << endreq;
00105                }
00106              }
00107              break;
00108            case 3:  //RomLtb
00109              {
00110                RawRomLtb* rawRomLtb = dynamic_cast<RawRomLtb*>(modules[i]);
00111                m_log << MSG::INFO << "RawRomLtb: " << *rawRomLtb << endreq;
00112                const vector<DayaBay::RawLtbFrame*>& frames = rawRomLtb->frames();
00113                for(unsigned int j=0; j<frames.size(); j++) {
00114                  m_log << MSG::INFO << "RawLtbFrame: " << *(frames[j]) << endreq;
00115                }
00116              }
00117              break;
00118            default:
00119              break;
00120          }
00121        }
00122      }
00123 
00124    }
00125 
00126    m_log << MSG::DEBUG << "execute() ______________________________ end" << endreq;
00127    return StatusCode::SUCCESS;
00128 }
00129 
00130 StatusCode RawDataReader::finalize()
00131 {
00132   m_log << MSG::DEBUG << "finalize()" << endreq;
00133   return StatusCode::SUCCESS;
00134 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:27:41 2011 for RawDataTest by doxygen 1.4.7