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

In This Package:

DataAnalyses.cc

Go to the documentation of this file.
00001 #include "DataAnalyses.h"
00002 #include "Event/CalibReadoutHeader.h"
00003 #include "Event/CalibReadoutPmtCrate.h"
00004 #include "Event/ReadoutHeader.h"
00005 #include "Event/ReadoutPmtCrate.h"
00006 #include "Event/RawEventHeader.h"
00007 #include "Event/RawRom.h"
00008 #include "Event/RawRomLtb.h"
00009 #include "Event/RawPmtChannel.h"
00010 #include "Event/GenHeader.h"
00011 #include "HepMC/GenEvent.h"
00012 #include "HepMC/GenVertex.h"
00013 #include "Event/RecHeader.h"
00014 #include "DetHelpers/IPmtGeomInfoSvc.h"
00015 #include "DataSvc/ICableSvc.h"
00016 #include "DatabaseInterface/DbiResultPtr.h"
00017 #include <map>
00018 
00019 using namespace std;
00020 using namespace DayaBay;
00021 
00022 uint32_t uTriggerSum= 0;
00023 int last_trig_timeSec = 0;
00024 int last_trig_timeNanoSec = 0;
00025 int Max_MultiTDC = 4;
00026 
00027   DataAnalyses::DataAnalyses(const string& name, ISvcLocator* svcloc)
00028 : GaudiAlgorithm(name, svcloc), m_log(msgSvc(), name)
00029 , m_cableSvc(0)
00030 //, m_pmtGeomSvc(0)
00031 {
00032   declareProperty("PrintFreq", m_printFreq = 100, "print frequency for event information");
00033   declareProperty("CheckGen", m_checkGen = false, "check GenEvent");
00034   declareProperty("CheckReadout", m_checkReadout = false, "check ReadoutEvent");
00035   declareProperty("CheckLtb", m_checkLtb = false, "check Ltb information");
00036   declareProperty("CheckCalibReadout", m_checkCalibReadout = false, "check CalibReadoutEvent");
00037   declareProperty("CheckRec", m_checkRec = false, "check RecEvent");
00038   declareProperty("CableSvcName", m_cableSvcName = "StaticCableSvc",
00039     "Name of service to map between detector, hardware, and electronic IDs");
00040   declareProperty("PmtGeomSvcName", m_pmtGeomSvcName = "PmtGeomInfoSvc",
00041     "Name of Pmt Geometry Information Service");
00042   m_execNum = 0;
00043   m_ntuple0 = 0;
00044   m_ntuple1 = 0;
00045   m_ntuple2 = 0;
00046   m_ntuple3 = 0;
00047 }
00048 
00049 DataAnalyses::~DataAnalyses()
00050 {
00051 }
00052 
00053 StatusCode DataAnalyses::initialize()
00054 {
00055   m_log << MSG::DEBUG << "initialize()" << endreq;
00056   // Get Cable Service
00057   m_cableSvc = svc<ICableSvc>(m_cableSvcName, true);
00058 
00059   // Get PmtGeomInfo Service
00060   m_pmtGeomSvc = svc<IPmtGeomInfoSvc>(m_pmtGeomSvcName, true);
00061 
00062   //  Book NTuple 0
00063   if(m_checkGen) {
00064     NTuplePtr nt0(ntupleSvc(), "FILE1/Gen");
00065     if ( nt0 ) m_ntuple0 = nt0;
00066     else {
00067       m_ntuple0 = ntupleSvc()->book("FILE1/Gen", CLID_ColumnWiseTuple, "Gen");
00068       if ( m_ntuple0 )    {
00069         m_ntuple0->addItem ("EventType",      m_eventType);
00070         m_ntuple0->addItem ("VertexSize",     m_nVertex, 0, 30);
00071         m_ntuple0->addItem ("ver_x0",  m_nVertex, m_verX0);
00072         m_ntuple0->addItem ("ver_y0",  m_nVertex, m_verY0);
00073         m_ntuple0->addItem ("ver_z0",  m_nVertex, m_verZ0);
00074         m_ntuple0->addItem ("ParticleSize",   m_nParticle, 0, 30);
00075         m_ntuple0->addItem ("ver_px",  m_nParticle, m_verPx);
00076         m_ntuple0->addItem ("ver_py",  m_nParticle, m_verPy);
00077         m_ntuple0->addItem ("ver_pz",  m_nParticle, m_verPz);
00078       }
00079       else { // Did not manage to book the NTuple....
00080         error() << "Can not book NTuple:" << long(m_ntuple0) << endmsg;
00081         return StatusCode::FAILURE;
00082       }
00083     }
00084   }
00085 
00086   //  Book NTuple 1
00087   if(m_checkReadout) {
00088     NTuplePtr nt1(ntupleSvc(), "FILE1/Readout");
00089     if ( nt1 ) m_ntuple1 = nt1;
00090     else {
00091       m_ntuple1 = ntupleSvc()->book("FILE1/Readout", CLID_ColumnWiseTuple, "Readout");
00092       if ( m_ntuple1 )    {
00093         info() << "Start m_ntuple1 addItem successful!" << endmsg;
00094         // Trigger number serial
00095         m_ntuple1->addItem ("TriggerNumber",m_triggerNumber);
00096 
00097         // Trigger Type
00098         m_ntuple1->addItem ("TriggerType",  m_triggerType);
00099 
00100         // Trigger Time from LTB is recorded in two stage:
00101         // TimeSec: absolute time at 'Second' level, unit: sec
00102         // TimeNanoSec: relative time at sub-second level, unit: nanosec
00103         // Final Trigger Time calculation: (TimeSec + TimeNanoSec*1.0e-9), unit: sec
00104         // Above irect calculation may have precision problem
00105         // for 'double'-'integer' conversion.
00106         m_ntuple1->addItem ("TriggerTime",  m_triggerTime);
00107         m_ntuple1->addItem ("TriggerTimeSec",  m_triggerTimeSec);
00108         m_ntuple1->addItem ("TriggerTimeNanoSec",  m_triggerTimeNanoSec);
00109         m_ntuple1->addItem ("TrigTimeInterval",  m_trigTimeInterval);
00110         
00111         // Adc sum for all channels
00112         m_ntuple1->addItem ("QSum",         m_QSum);
00113 
00114         // Number of channels that have Tdc, Adc record
00115         m_ntuple1->addItem ("ChannelSize",  m_nChannel, 0, 250);
00116         
00117         // Tdc multiplicity for each channel
00118         m_ntuple1->addItem ("MultiTDC",     m_nChannel, m_MultiTDC);
00119 
00120         // Adc value for each channel
00121         m_ntuple1->addItem ("ADC",          m_nChannel, m_adc);
00122 
00123         // Adc Gain for each channel
00124         m_ntuple1->addItem ("ADCGain",      m_nChannel, m_adcGain);
00125 
00126         // Adc Range for each channel
00127         m_ntuple1->addItem ("ADCRange",     m_nChannel, m_adcRange);
00128 
00129         // The clock cycle during ADC peaking-finding
00130         m_ntuple1->addItem ("ADCPeakingCycle", m_nChannel, m_adcPeakingCycle);
00131 
00132         // Pedestal for each channel
00133         m_ntuple1->addItem ("Pedestal",          m_nChannel, m_pedestal);
00134 
00135         // The first TDC for each channel.
00136         // TDC is recorded as the PMT hit time relative to trigger time,
00137         // then the earlier PMT hit time, the larger TDC value
00138         m_ntuple1->addItem ("FirstTDC",    m_nChannel, m_firstTdc);
00139 
00140         // The second to fourth TDC for each channel if multiple TDC hits exist
00141         m_ntuple1->addItem ("SecondTDC",    m_nChannel, m_secondTdc);
00142         m_ntuple1->addItem ("ThirdTDC",    m_nChannel, m_thirdTdc);
00143         m_ntuple1->addItem ("FourthTDC",    m_nChannel, m_fourthTdc);
00144         //m_ntuple1->addItem ("TDC",        m_nChannel*Max_MultiTDC, m_firstTdc);
00145 
00146         // Fee Channel ID
00147         m_ntuple1->addItem ("ChannelID",    m_nChannel, m_channelId);
00148 
00149         // The slot number that this Fee board loactes
00150         m_ntuple1->addItem ("Slot",         m_nChannel, m_slot);
00151 
00152         // The corresponding channel number on this Fee board
00153         m_ntuple1->addItem ("Connector",    m_nChannel, m_connector);
00154 
00155         // PMT Sensor ID
00156         m_ntuple1->addItem ("SensorID",    m_nChannel, m_sensorId);
00157 
00158         // The corresponding ring number on this Fee board
00159         m_ntuple1->addItem ("Ring",    m_nChannel, m_ring);
00160 
00161         // The corresponding column number on this Fee board
00162         m_ntuple1->addItem ("Column",    m_nChannel, m_column);
00163 
00164         // The Tdc value and channel number for the earliest hit in this event
00165         m_ntuple1->addItem ("EarliestHitChn",  m_earliestHitChn);
00166         m_ntuple1->addItem ("EarliestHitTdc",  m_earliestHitTdc);
00167 
00168         // The Tdc value and channel number for the latest hit in this event
00169         m_ntuple1->addItem ("LatestHitChn",  m_latestHitChn);
00170         m_ntuple1->addItem ("LatestHitTdc",  m_latestHitTdc);
00171       }
00172       else { // Did not manage to book the NTuple....
00173         error() << "Can not book NTuple:" << long(m_ntuple1) << endmsg;
00174         return StatusCode::FAILURE;
00175       }
00176     }
00177   }
00178 
00179   //  Book NTuple 2
00180   if(m_checkCalibReadout) {
00181     NTuplePtr nt2(ntupleSvc(), "FILE1/CalibReadout");
00182     if ( nt2 ) m_ntuple2 = nt2;
00183     else {
00184       m_ntuple2 = ntupleSvc()->book("FILE1/CalibReadout", CLID_ColumnWiseTuple, "CalibReadout");
00185       if ( m_ntuple2 )    {
00186         m_ntuple2->addItem ("TriggerNumber",m_calibTriggerNumber);
00187         m_ntuple2->addItem ("EvtNumber",    m_calibEvtNumber);
00188         m_ntuple2->addItem ("TriggerTimeSec",  m_calibTriggerTimeSec);
00189         m_ntuple2->addItem ("TriggerTimeNanoSec",  m_calibTriggerTimeNanoSec);
00190         //m_ntuple2->addItem ("EarliesTime",  m_calibEarliestTime);
00191         m_ntuple2->addItem ("QSum",         m_calibQSum);
00192         m_ntuple2->addItem ("ChannelSize",  m_nCalibChannel, 0, 250);
00193         m_ntuple2->addItem ("Charge",       m_nCalibChannel, m_calibAdc);
00194         m_ntuple2->addItem ("Time",         m_nCalibChannel, m_calibTdc);
00195         m_ntuple2->addItem ("Ring",         m_nCalibChannel, m_calibRing);
00196         m_ntuple2->addItem ("Column",       m_nCalibChannel, m_calibColumn);
00197       }
00198       else { // Did not manage to book the NTuple....
00199         error() << "Can not book NTuple:" << long(m_ntuple2) << endmsg;
00200         return StatusCode::FAILURE;
00201       }
00202     }
00203   }
00204 
00205   //  Book NTuple 3
00206   if(m_checkRec) {
00207     NTuplePtr nt3(ntupleSvc(), "FILE1/Rec");
00208     if ( nt3 ) m_ntuple3 = nt3;
00209     else {
00210       m_ntuple3 = ntupleSvc()->book("FILE1/Rec", CLID_ColumnWiseTuple, "Rec");
00211       if ( m_ntuple3 )    {
00212         m_ntuple3->addItem ("RecSize",  m_nRec, 0,  30);
00213         m_ntuple3->addItem ("Energy",   m_nRec, m_energy);
00214         m_ntuple3->addItem ("RecX",     m_nRec, m_recX);
00215         m_ntuple3->addItem ("RecY",     m_nRec, m_recY);
00216         m_ntuple3->addItem ("RecZ",     m_nRec, m_recZ);
00217         m_ntuple3->addItem ("RecPx",    m_nRec, m_recPx);
00218         m_ntuple3->addItem ("RecPy",    m_nRec, m_recPy);
00219         m_ntuple3->addItem ("RecPz",    m_nRec, m_recPz);
00220       }
00221       else { // Did not manage to book the NTuple....
00222         error() << "Can not book NTuple:" << long(m_ntuple3) << endmsg;
00223         return StatusCode::FAILURE;
00224       }
00225     }
00226   }
00227 
00228   //  Book NTuple 4
00229   if(m_checkLtb) {
00230     NTuplePtr nt4(ntupleSvc(), "FILE1/Ltb");
00231     if ( nt4 ) m_ntuple4 = nt4;
00232     else {
00233       m_ntuple4 = ntupleSvc()->book("FILE1/Ltb", CLID_ColumnWiseTuple, "Ltb");
00234       if ( m_ntuple4 )    {
00235         info() << "Start m_ntuple4 addItem successful!" << endmsg;
00236         m_ntuple4->addItem("LtbFrameNum",           m_ltbFrameNum, 0, 20);
00237         m_ntuple4->addItem("LtbTimestampType",      m_ltbFrameNum, m_ltbTimestampType);
00238         m_ntuple4->addItem("LtbTrigTimeSec",        m_ltbFrameNum, m_ltbTrigTimeSec);
00239         m_ntuple4->addItem("LtbTrigTimeNanoSec",    m_ltbFrameNum, m_ltbTrigTimeNanoSec);
00240         m_ntuple4->addItem("LtbTrigType",           m_ltbFrameNum, m_ltbTrigType);
00241         m_ntuple4->addItem("LtbHSum",               m_ltbFrameNum, m_ltbHSum);
00242         m_ntuple4->addItem("LtbESumComp",           m_ltbFrameNum, m_ltbESumComp);
00243         m_ntuple4->addItem("LtbESumADC",            m_ltbFrameNum, m_ltbESumADC);
00244         m_ntuple4->addItem("LtbBlockedValidTrigger",m_ltbFrameNum, m_ltbBlockedValidTrigger);
00245       }
00246       else { // Did not manage to book the NTuple....
00247         error() << "Can not book NTuple:" << long(m_ntuple4) << endmsg;
00248         return StatusCode::FAILURE;
00249       }
00250     }
00251   }
00252 
00253   return StatusCode::SUCCESS;
00254 }
00255 
00256 StatusCode DataAnalyses::execute()
00257 {
00258   m_log << MSG::DEBUG << "execute() ______________________________ start" << endreq;
00259 
00260   if(m_printFreq>0 && m_execNum%m_printFreq==0) cout << "---------- " << m_execNum << endl;
00261 
00262   map<int,int> m_sensorIdMap;
00263 
00264   //----------------------------------------------------------------------------------------
00265   //GenHeader
00266 
00267   if(m_checkGen) {
00268 
00269     GenHeader* gh = get<GenHeader>("/Event/Gen/GenHeader");
00270 
00271     if (gh == 0) {
00272       m_log << MSG::ERROR << " =======> Requested Object can not be accessable." << endreq;
00273       return StatusCode::FAILURE;
00274     }
00275 
00276     if (m_printFreq > 0 && m_execNum % m_printFreq == 0) {
00277       //m_log << MSG::INFO << "Gen Header: " << *gh << endreq;
00278       m_log << MSG::INFO << "execNumber: " << gh->execNumber() << endreq;
00279       //gh->event()->print();
00280       m_log << MSG::INFO << "signal_process_id= " << gh->event()->signal_process_id() << endreq;
00281       m_log << MSG::INFO << "vertices_size= " << gh->event()->vertices_size() << endreq;
00282     }
00283 
00284     m_eventType = gh->event()->signal_process_id();
00285     m_nVertex = gh->event()->vertices_size();
00286     m_nParticle = gh->event()->particles_size();
00287 
00288     unsigned int iVertex = 0;
00289     for(HepMC::GenEvent::vertex_const_iterator it = gh->event()->vertices_begin();
00290         it != gh->event()->vertices_end();
00291         it++ ) {
00292       if(m_printFreq > 0 && m_execNum % m_printFreq == 0) {
00293         m_log << MSG::INFO << "vertex= " << (*it)->position().x() 
00294               <<","<< (*it)->position().y()<<","<<(*it)->position().z()
00295               << endreq;
00296       }
00297       m_verX0[iVertex] = (*it)->position().x();
00298       m_verY0[iVertex] = (*it)->position().y();
00299       m_verZ0[iVertex] = (*it)->position().z();
00300       iVertex++;
00301     }
00302 
00303     unsigned int iParticle = 0;
00304     for(HepMC::GenEvent::particle_const_iterator it = gh->event()->particles_begin();
00305         it != gh->event()->particles_end();
00306         it++ ) {
00307       if(m_printFreq > 0 && m_execNum % m_printFreq == 0) {
00308         m_log << MSG::INFO << "particle momentum= " 
00309               << (*it)->momentum().x() <<","
00310               << (*it)->momentum().y() <<","
00311               << (*it)->momentum().z() 
00312               << endreq;
00313       }
00314       m_verPx[iParticle] = (*it)->momentum().x();
00315       m_verPy[iParticle] = (*it)->momentum().y();
00316       m_verPz[iParticle] = (*it)->momentum().z();
00317       iParticle++;
00318     }
00319 
00320     m_ntuple0->write();
00321 
00322   }//GenHeader
00323 
00324   //----------------------------------------------------------------------------------------
00325   //ReadoutHeader
00326 
00327   if(m_checkReadout) {
00328 
00329     ReadoutHeader* roh = get<ReadoutHeader>("/Event/Readout/ReadoutHeader");
00330     if (roh == 0) {
00331       m_log << MSG::ERROR << " =======> Requested Object can not be accessable." << endreq;
00332       return StatusCode::FAILURE;
00333     }
00334 
00335 
00336     Readout* readout = const_cast<Readout*>(roh->readout());
00337     if(!readout) return StatusCode::SUCCESS;
00338     ReadoutPmtCrate* crate = dynamic_cast<ReadoutPmtCrate*>(readout);
00339     ReadoutPmtCrate::PmtChannelReadouts channels = crate->channelReadout();
00340 
00341     if(m_printFreq > 0 && m_execNum % m_printFreq == 0) {
00342       m_log << MSG::INFO << "Readout Header: " << *roh << endreq;
00343       m_log << MSG::INFO << "channels=" << crate->channelReadout().size()  << endreq;
00344     }
00345 
00346     //  Context, ServiceMode for this data
00347     int task = 0;
00348     ServiceMode svcMode(roh->context(), task);
00349 
00350     if(m_execNum==0) m_firstTime = readout->triggerTime();
00351 
00352     m_triggerNumber = crate->triggerNumber();
00353     m_triggerTime = (readout->triggerTime()-m_firstTime).GetSeconds();
00354     m_triggerTimeSec = readout->triggerTime().GetSec();
00355     m_triggerTimeNanoSec = readout->triggerTime().GetNanoSec();
00356     if(m_execNum==0) {
00357       m_trigTimeInterval = 0.0;
00358     }
00359     else {
00360       m_trigTimeInterval = (m_triggerTimeSec - last_trig_timeSec)
00361         + 1.0e-9*( m_triggerTimeNanoSec - last_trig_timeNanoSec);
00362     }
00363 
00364     last_trig_timeSec=readout->triggerTime().GetSec();
00365     last_trig_timeNanoSec=readout->triggerTime().GetNanoSec();
00366 
00367     /* Another method to get trigger time
00368        currentTriggerTime = readout->triggerTime();
00369 
00370        if(m_execNum==0) {
00371        lastTriggerTime = readout->triggerTime();
00372        }
00373        trigTimeInterval = currentTriggerTime - lastTriggerTime;
00374        m_triggerTimeSec = currentTriggerTime.GetSec();
00375        m_triggerTimeNanoSec = currentTriggerTime.GetNanoSec();
00376        m_trigTimeInterval = trigTimeInterval.GetSeconds();
00377 
00378        lastTriggerTime = readout->triggerTime();
00379        */
00380 
00381     m_triggerType = crate->triggerType();
00382 
00383     m_QSum = 0.0;
00384     m_nChannel = crate->channelReadout().size();
00385     unsigned int ichannel = 0;
00386     map<long, long> firstHitTdcMap;
00387     vector<long> firstHitTdcVec;
00388     ReadoutPmtCrate::PmtChannelReadouts::iterator it;
00389     for (it=channels.begin(); it != channels.end(); it++) {
00390 
00391       const vector<int>& adc = it->second.adc();
00392       const vector<int>& tdc = it->second.tdc();
00393       const vector<int>& adcPeakingCycle = it->second.adcCycle();
00394       const vector<int>& adcRange = it->second.adcRange();
00395       int firstTdc = it->second.earliestTdc();
00396       DayaBay::FeeChannelId channelId = it->first;
00397       unsigned int size = adc.size();
00398       int slot = channelId.board();
00399       int connector = channelId.connector() - 1;
00400       int localChannelId = slot*16 + connector;
00401 
00402       DayaBay::AdPmtSensor adPmtId = m_cableSvc->adPmtSensor(channelId, svcMode);
00403       m_sensorIdMap[adPmtId.sensorId()] = ichannel;
00404 
00405       int ring = adPmtId.ring();
00406       int column = adPmtId.column();
00407       int sensorId;
00408       if(ring==0) { //2 inch PMT
00409         sensorId = 192 + column;
00410       } else {
00411         sensorId = (column-1)*8+ring;
00412       }
00413       //if(size != tdc.size()) {
00414       //  m_log << MSG::ERROR << "ADC and TDC vector have different size!" << endreq;
00415       //  return StatusCode::FAILURE;
00416       //}
00417       if(size>0) {
00418         m_adc[ichannel] = it->second.earliestAdc();
00419         m_QSum += it->second.earliestAdc();
00420         m_adcPeakingCycle[ichannel] = it->second.adcCycle(it->second.earliestTdcIndex());
00421         m_adcRange[ichannel] = it->second.adcRange(it->second.earliestTdcIndex());
00422         m_pedestal[ichannel] = it->second.pedestal(it->second.earliestTdcIndex());
00423 
00424         m_MultiTDC[ichannel] = tdc.size();
00425         m_channelId[ichannel] = localChannelId;
00426         m_slot[ichannel] = slot;
00427         m_connector[ichannel] = connector;
00428         m_sensorId[ichannel] = sensorId;
00429         m_ring[ichannel] = ring;
00430         m_column[ichannel] = column;
00431 
00432         m_firstTdc[ichannel] = firstTdc;
00433         firstHitTdcVec.push_back(firstTdc);
00434         firstHitTdcMap[firstTdc] = localChannelId;
00435 
00436 
00437         if(size==1) {
00438           m_secondTdc[ichannel]  = -9999;
00439           m_thirdTdc[ichannel]  = -9999;
00440           m_fourthTdc[ichannel]  = -9999;
00441         }
00442         if(size==2) {
00443           m_secondTdc[ichannel]  = tdc[1];
00444           m_thirdTdc[ichannel]  = -9999;
00445           m_fourthTdc[ichannel]  = -9999;
00446         }
00447         if(size==3) {
00448           m_secondTdc[ichannel]  = tdc[1];
00449           m_thirdTdc[ichannel]  = tdc[2];
00450           m_fourthTdc[ichannel]  = -9999;
00451         }
00452         if(size>=4) {
00453           m_secondTdc[ichannel]  = tdc[1];
00454           m_thirdTdc[ichannel]  = tdc[2];
00455           m_fourthTdc[ichannel]  = tdc[3];
00456         }
00457 
00458         ichannel++;
00459       }
00460 
00461       if(m_printFreq > 0 && m_execNum % m_printFreq == 0) {
00462         m_log << MSG::INFO << it->second << endreq;
00463       }
00464     }
00465 
00466     if(channels.size()>0) {
00467       sort(firstHitTdcVec.begin(), firstHitTdcVec.end());
00468       m_earliestHitTdc = firstHitTdcVec[ichannel-1];
00469       m_latestHitTdc = firstHitTdcVec[0];
00470       m_earliestHitChn = (firstHitTdcMap.find(m_earliestHitTdc))->second;
00471       m_latestHitChn = (firstHitTdcMap.find(m_latestHitTdc))->second;
00472     }
00473 
00474     m_ntuple1->write();
00475 
00476   }//ReadoutHeader
00477 
00478 
00479   //----------------------------------------------------------------------------------------
00480   //CalibReadoutHeader
00481 
00482   if(m_checkCalibReadout) {
00483 
00484     CalibReadoutHeader* croh = get<CalibReadoutHeader>("/Event/CalibReadout/CalibReadoutHeader");
00485     if (croh == 0) {
00486       m_log << MSG::ERROR << " =======> Requested Object can not be accessable." << endreq;
00487       return StatusCode::FAILURE;
00488     }
00489     m_calibEvtNumber = croh->execNumber();
00490 
00491     CalibReadout* calibReadout = const_cast<CalibReadout*>(croh->calibReadout());
00492     CalibReadoutPmtCrate* calibCrate = dynamic_cast<CalibReadoutPmtCrate*>(calibReadout);
00493     CalibReadoutPmtCrate::PmtChannelReadouts calibChannels = calibCrate->channelReadout();
00494 
00495     if(m_printFreq > 0 && m_execNum % m_printFreq == 0) {
00496       m_log << MSG::INFO << "CalibReadout Header: " << *croh << endreq;
00497       m_log << MSG::INFO << "calibChannels=" << calibChannels.size()  << endreq;
00498     }
00499 
00500     m_calibTriggerNumber = calibCrate->triggerNumber();
00501     m_calibTriggerTimeSec = calibCrate->triggerTime().GetSec();
00502     m_calibTriggerTimeNanoSec = calibCrate->triggerTime().GetNanoSec();
00503 
00504     m_nCalibChannel = calibCrate->channelReadout().size();
00505     unsigned int ichannel = 0;
00506     double qsum = 0;
00507     CalibReadoutPmtCrate::PmtChannelReadouts::iterator it;
00508     for (it=calibChannels.begin(); it != calibChannels.end(); it++) {
00509 
00510       if(m_checkReadout) {  //associate readout and calib readout
00511         ichannel = m_sensorIdMap[it->pmtSensorId().sensorId()];
00512       }
00513       //cout << "ichannel= " << ichannel << endl;
00514 
00515       if(it->size()>0) {
00516         // get ring and column
00517         DayaBay::AdPmtSensor adPmtSensor(it->pmtSensorId().sensorId());
00518         m_calibRing[ichannel] = adPmtSensor.ring();
00519         m_calibColumn[ichannel] = adPmtSensor.column();
00520 
00521         //get earliest charge and time of this PMT
00522         double earliestCharge = it->earliestCharge();
00523         double earliestTime= it->earliestTime();
00524 
00525         m_calibAdc[ichannel] = earliestCharge;
00526         m_calibTdc[ichannel] = earliestTime;
00527 
00528         qsum += earliestCharge;
00529 
00530         if(!m_checkReadout) ichannel++;
00531       }
00532       m_calibQSum = qsum;
00533 
00534       if(m_printFreq > 0 && m_execNum % m_printFreq == 0) {
00535         m_log << MSG::INFO << (*it)  << endreq;
00536       }
00537     }
00538 
00539     m_ntuple2->write();
00540 
00541   }//CalibReadoutHeader
00542 
00543 
00544   //----------------------------------------------------------------------------------------
00545   //RecHeader
00546 
00547   if(m_checkRec) {
00548 
00549     RecHeader* rh = get<RecHeader>("/Event/Rec/RecHeader");
00550     if (rh == 0) {
00551       m_log << MSG::ERROR << " =======> Requested Object can not be accessable." << endreq;
00552       return StatusCode::FAILURE;
00553     }
00554 
00555     RecTrigger& recTrigger = rh->recTrigger();
00556     m_nRec = 1;
00557     m_energy[0] = recTrigger.energy();
00558     m_recX[0] = recTrigger.position().x();
00559     m_recY[0] = recTrigger.position().y();
00560     m_recZ[0] = recTrigger.position().z();
00561     m_recPx[0] = recTrigger.direction().x();
00562     m_recPy[0] = recTrigger.direction().y();
00563     m_recPz[0] = recTrigger.direction().z();
00564 
00565     m_ntuple3->write();
00566 
00567   }
00568 
00569   //----------------------------------------------------------------------------------------
00570   // Ltb information
00571   if(m_checkLtb) {
00572     debug() << "Check Ltb information" << endreq;
00573     RawEventHeader* reh = get<RawEventHeader>(RawEventHeaderLocation::Default);
00574     if(reh == 0) {
00575       m_log << MSG::ERROR << "=======> Request Object can not be accessable." << endreq;
00576       return StatusCode::FAILURE;
00577     }
00578 
00579     const vector<DayaBay::RawRom*>& modules = reh->modules();
00580     for(unsigned int i=0; i<modules.size(); i++) {
00581       if(modules[i]->type()==3) { // RomLtb
00582         DayaBay::RawRomLtb* rawRomLtb;
00583         rawRomLtb = dynamic_cast<DayaBay::RawRomLtb*>(modules[i]);
00584         const std::vector<DayaBay::RawLtbFrame*> & ltbFrame = rawRomLtb->frames();
00585         m_ltbFrameNum = ltbFrame.size();
00586         for(size_t j=0; j<ltbFrame.size(); j++) {
00587           m_ltbTimestampType[j] = ltbFrame[j]->timestampType() ? 1 : 0;
00588           m_ltbTrigTimeSec[j] = ltbFrame[j]->timestamp().GetSec();
00589           m_ltbTrigTimeNanoSec[j] = ltbFrame[j]->timestamp().GetNanoSec();
00590           m_ltbTrigType[j] = ltbFrame[j]->triggerSrc();
00591           m_ltbHSum[j] = ltbFrame[j]->hsum();
00592           m_ltbESumComp[j] = ltbFrame[j]->esumComp();
00593           m_ltbESumADC[j] = ltbFrame[j]->esumADC();
00594           m_ltbBlockedValidTrigger[j] = ltbFrame[j]->blockedValidTrigger();
00595         }
00596         break;
00597       }
00598     }
00599 
00600     m_ntuple4->write();
00601   }
00602 
00603   m_execNum++;
00604   m_log << MSG::DEBUG << "execute() ______________________________ end" << endreq;
00605   return StatusCode::SUCCESS;
00606 }
00607 
00608 StatusCode DataAnalyses::finalize()
00609 {
00610   m_log << MSG::DEBUG << "finalize()" << endreq;
00611   return StatusCode::SUCCESS;
00612 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:34:06 2011 for AnalysesEx by doxygen 1.4.7