/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Private Types | Private Member Functions | Private Attributes
RpcDataHistogram Class Reference

#include <RpcDataHistogram.h>

List of all members.

Public Member Functions

 RpcDataHistogram (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~RpcDataHistogram ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode execute ()

Private Types

enum  RpcFig_t {
  kSysTrigRate, kDeltaTrigTime, k4FoldRate, kDelta4FoldTime,
  kDelta4FoldTimeLog, kLayerMult, kFecErr, kRtmErr,
  kModuleMult, kHit_Id, kHitMapL1, kHitMapL2,
  kHitMapL3, kHitMapL4, k4FoldMapPatch, k4FoldRateMap,
  k4FoldMultMap, kEfficiencyStats, kEfficiencyMapL1, kEfficiencyMapL2,
  kEfficiencyMapL3, kEfficiencyMapL4, kNoiseRateStats, kNoiseRateMapL1,
  kNoiseRateMapL2, kNoiseRateMapL3, kNoiseRateMapL4
}

Private Member Functions

int daqTrigType (int offTrigType)
TH1 * makeHist (int run, int site, int detector, int row, int column, int histIndex)
std::string getPath (int run, int site, int detector, int row, int column, const char *histName)
const char * SiteAsString (int site)
void handleFecReadout (const DybDaq::FecReadout &fecReadout, int site, ServiceMode svcMode)
void handleFecData (const DybDaq::FecData *fecData, int site, ServiceMode svcMode)
bool checkParity (unsigned nanoSec, unsigned fecHitData, bool transErr1)
void handleRtmReadout (const DybDaq::RtmReadout &rtmReadout, int site)
void handleRtmData (const DybDaq::RtmData *rtmData, int site)
void extendRange (TH1 *hist, int xBinsAdd, int yBinsAdd=0)
double calInterval (unsigned int firstSec, unsigned int firstNanoSec, unsigned int secondSec, unsigned int secondNanoSec)

Private Attributes

IStatisticsSvc * m_statsSvc
ICableSvc * m_cableSvc
std::map< int, TH1 ** > m_rpcHist
std::map< int, std::string > m_rpcHistPath
bool m_rpcOrNot
bool m_teleTrigger
int NROW
int m_printFreq
int m_clockType
int m_GPSUsed
int m_triggerCount
int m_ModuleTriggerCount
int m_trigger [99][4]
int m_triggerEff [99][4]
int m_noiseCount [99][4]
int m_4foldCount [99]
int m_4foldCountCut [99]
int m_4foldCountEff [99]
int m_4foldMultCount [99]
double m_noiseTime [99][4]
double m_effRes
double m_runTime
double m_readoutWindow
int m_lastCFId
unsigned int m_firstRtmTrigSec
unsigned int m_firstRtmTrigNanoSec
unsigned int m_firstFecTrigSec
unsigned int m_firstFecTrigNanoSec
unsigned int m_lastRtmTrigSec
unsigned int m_lastRtmTrigNanoSec
unsigned int m_last4FoldSec
unsigned int m_last4FoldNanoSec
unsigned long m_eventCount
char * m_fecErrType [6]
char * m_rtmErrType [6]

Detailed Description

Definition at line 34 of file RpcDataHistogram.h.


Member Enumeration Documentation

Enumerator:
kSysTrigRate 
kDeltaTrigTime 
k4FoldRate 
kDelta4FoldTime 
kDelta4FoldTimeLog 
kLayerMult 
kFecErr 
kRtmErr 
kModuleMult 
kHit_Id 
kHitMapL1 
kHitMapL2 
kHitMapL3 
kHitMapL4 
k4FoldMapPatch 
k4FoldRateMap 
k4FoldMultMap 
kEfficiencyStats 
kEfficiencyMapL1 
kEfficiencyMapL2 
kEfficiencyMapL3 
kEfficiencyMapL4 
kNoiseRateStats 
kNoiseRateMapL1 
kNoiseRateMapL2 
kNoiseRateMapL3 
kNoiseRateMapL4 

Definition at line 103 of file RpcDataHistogram.h.


Constructor & Destructor Documentation

RpcDataHistogram::RpcDataHistogram ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 45 of file RpcDataHistogram.cc.

                              :
  GaudiAlgorithm(name, pSvcLocator),
  m_statsSvc(0),
  NROW(6),
  m_rpcOrNot(0),
  m_clockType(-1), // 0: internal clock,1: external clock 
  m_GPSUsed(-1), 
  m_triggerCount(0),
  m_ModuleTriggerCount(0),
  m_teleTrigger(0),
  m_effRes(0.01),  // resolution of efficiency distribution (1.01/m_effRes should be an integer)
  m_runTime(0),
  m_readoutWindow((16.0+3.5+2.5)*25.0*0.000000001),  // ( signal readout window + signal widening + natural signal width ) * clock cycle
  m_lastCFId(-1),
  m_firstRtmTrigSec(0), 
  m_firstRtmTrigNanoSec(0), 
  m_firstFecTrigSec(0), 
  m_firstFecTrigNanoSec(0), 
  m_lastRtmTrigSec(0), 
  m_lastRtmTrigNanoSec(0), 
  m_last4FoldSec(0),
  m_last4FoldNanoSec(0),
  m_eventCount(0)
{
  for( int m = 0; m < (9+2)*NCOLUMN; m++ ){
        m_4foldCount[m] = 0;
        m_4foldCountCut[m] = 0;
        m_4foldCountEff[m] = 0;
        m_4foldMultCount[m] = 0;
    for( int l = 0; l < 4; l++ ){
      m_trigger[m][l] = 0;
      m_triggerEff[m][l] = 0;
      m_noiseCount[m][l] = 0;
      m_noiseTime[m][l] = 0.0;
          //for( int n = 0; n < 4; n++)  m_2foldNumbers[m][l][n] = 0;
    }
  }
  m_fecErrType[0] = "clockErr"; 
  m_fecErrType[1] = "GPSErr"; 
  m_fecErrType[2] = "fullFlag"; 
  m_fecErrType[3] = "parity"; 
  m_fecErrType[4] = "transErr"; 
  m_fecErrType[5] = "bitsCheck";
  m_rtmErrType[0] = "clockErr"; 
  m_rtmErrType[1] = "GPSErr"; 
  m_rtmErrType[2] = "fullFlag"; 
  m_rtmErrType[3] = "transErr"; 
  m_rtmErrType[4] = "romAlmostFull"; 
  m_rtmErrType[5] = "rtmAlmostFull"; 
  declareProperty("PrintFreq", m_printFreq=100000);
}
RpcDataHistogram::~RpcDataHistogram ( ) [virtual]

Definition at line 99 of file RpcDataHistogram.cc.

{
}

Member Function Documentation

StatusCode RpcDataHistogram::initialize ( ) [virtual]

Definition at line 112 of file CalibDataHistogram.cc.

{
  StatusCode sc = this->service("PmtGeomInfoSvc",m_pmtGeomSvc,true);
  if(sc.isFailure()){
    error() << "Failed to get PmtGeomInfoSvc" << endreq;
    return sc;
  }

  sc = this->service("StatisticsSvc",m_statsSvc,true);
  if(sc.isFailure()){
    error() << "Failed to get StatisticsSvc" << endreq;
    return sc;
  }

  return sc;
}
StatusCode RpcDataHistogram::finalize ( ) [virtual]

fFee_hitRate[iFee][iChn] = (((float)uFee_hitSum[iFee][iChn])/((float)uTriggerSum)) ;

h_sum_hitRate->SetBinContent(iChn+1+iFee*MAXCHNNUM,(fFee_hitRate[iFee][iChn]*100));

h_sum_ADCMean->SetBinContent(iChn+1+iFee*MAXCHNNUM ,h_Charge[iFee][iChn]->GetMean()); h_sum_ADCRMS->SetBinContent(iChn+1+iFee*MAXCHNNUM ,h_Charge[iFee][iChn]->GetRMS());

Definition at line 129 of file CalibDataHistogram.cc.

{
  // for POOL
  for(int i=0;i!=POOLIO;i++)
    {
      if(h_sum_pool_MaxCharge_Patton[i])
        {
          h_sum_pool_MaxCharge_Patton[i]->Sumw2();
          if(h_sum_pool_MaxCharge_Patton[i]->GetNormFactor()>0)
            {
              double scale = 1./(h_sum_pool_MaxCharge_Patton[i]->GetNormFactor());
              h_sum_pool_MaxCharge_Patton[i]->SetNormFactor(1);
              h_sum_pool_MaxCharge_Patton[i]->Scale( scale );
            }
          h_sum_pool_MaxCharge_Patton[i]->SetBit(TH1::kIsAverage);
        }
    }
  
  // for AD   
  for(int i=0;i!=DETNUMPLUS;i++)
    {
      if(h_sum_MaxCharge_Patton[i])
        {
          h_sum_MaxCharge_Patton[i]->Sumw2();

          if(h_sum_MaxCharge_Patton[i]->GetNormFactor()>0)
            {
              double scale = 1./(h_sum_MaxCharge_Patton[i]->GetNormFactor());
              h_sum_MaxCharge_Patton[i]->SetNormFactor(1);
              h_sum_MaxCharge_Patton[i]->Scale( scale );
            }

          h_sum_MaxCharge_Patton[i]->SetBit(TH1::kIsAverage);
        }
    }

  debug() << MSG::DEBUG << "finalize()" << endreq;
  return StatusCode::SUCCESS;
}
StatusCode RpcDataHistogram::execute ( ) [virtual]

Definition at line 169 of file CalibDataHistogram.cc.

{
  debug() << "execute() ______________________________ begin" << endreq;
  
  CalibReadoutHeader* croh = get<CalibReadoutHeader>("/Event/CalibReadout/CalibReadoutHeader");
  if(!croh) 
    {
      error() << " =======> Requested Object can not be accessable." << endreq;
      return StatusCode::FAILURE;
    }

  CalibReadout* calibReadout = const_cast<CalibReadout*>(croh->calibReadout());
  if(!calibReadout)
    {
      error() << " =======> Failed to get calibrated readout from header" << endreq;
      return StatusCode::FAILURE;
    }

  const DayaBay::Detector detector = calibReadout->detector();
  string SiteName = Site::AsString(detector.site());
  string DetName  = DetectorId::AsString(detector.detectorId());

  if(!(DetName=="IWS"||DetName=="OWS"||DetName=="AD1"||DetName=="AD2"||DetName=="AD3"||DetName=="AD4"))
    {
      return StatusCode::SUCCESS;
    }

  CalibReadoutPmtCrate* calibCrate = dynamic_cast<CalibReadoutPmtCrate*>(calibReadout);
  if(!calibCrate)
    {
      error() << " =======> Failed to get PMT readout" << endreq;
      return StatusCode::FAILURE;
    }

  CalibReadoutPmtCrate::PmtChannelReadouts calibChannels = calibCrate->channelReadout();
  CalibReadoutPmtCrate::PmtChannelReadouts::iterator it;

  stringstream path;
  path<<"/file1/";
  ostringstream ossSiteDetId;
  ossSiteDetId<<Site::AsString(detector.site())<<"/"<<DetectorId::AsString(detector.detectorId())<<"/";
  
  string pathDir = path.str()+ossSiteDetId.str();
  string pathSumDir = pathDir+"Calib/";  
  
  if(DetName=="IWS"||DetName=="OWS")
    {
      int fPOOLIO       = 0;
      int fPOOLPMTIO    = 0;
      int fPOOLWALLPLUS = 0;
      int fPOOLWALLPMT  = 0;

      double pmtid     = 0;
      double qmax      = 0;
      double qsum      = 0;
      double sumCharge = 0;
      
      if(DetName=="OWS"){
        fPOOLIO = 1;
      }else{
        fPOOLIO = 0;
      }
            
      if(!h_sum_pool_MaxCharge_Patton[fPOOLIO])
        {
          h_sum_pool_FEEQSUM[fPOOLIO] = new TH1F("h_sum_pool_FEEQSUM", "h_sum_pool_FEEQSUM", 5000 , 0, m_maxTotalCharge);
          m_statsSvc->put((pathSumDir+"h_sum_pool_FEEQSUM").c_str(), h_sum_pool_FEEQSUM[fPOOLIO]);
          
          
          h_sum_pool_Charge_PMT[fPOOLIO] = new TH2F("h_sum_pool_ChargePMT", "h_sum_pool_ChargePMT", 
                                                    MAXPOOLPMT, 0.5, MAXPOOLPMT+0.5, 3000, 0, m_maxCharge);
          m_statsSvc->put((pathSumDir+"h_sum_pool_ChargePMT").c_str(), h_sum_pool_Charge_PMT[fPOOLIO]);
          
          
          h_sum_pool_RMS_Charge_PMT[fPOOLIO]  = new TH1F("h_sum_pool_RMSChargePMT", "h_sum_pool_RMSChargePMT",
                                                         MAXPOOLPMT, 0.5, MAXPOOLPMT+0.5);
          m_statsSvc->put((pathSumDir+"h_sum_pool_RMSChargePMT").c_str(), h_sum_pool_RMS_Charge_PMT[fPOOLIO]);
          
          
          h_sum_pool_Time_PMT[fPOOLIO] = new TH2F("h_sum_pool_TimePMT", "h_sum_pool_TimePMT", 
                                                  MAXPOOLPMT, 0.5, MAXPOOLPMT+0.5, 3000, m_minTime, m_maxTime);
          m_statsSvc->put((pathSumDir+"h_sum_pool_TimePMT").c_str(), h_sum_pool_Time_PMT[fPOOLIO]);
          
          
          h_sum_pool_RMS_Time_PMT[fPOOLIO]  = new TH1F("h_sum_pool_RMSTimePMT", "h_sum_pool_RMSTimePMT",
                                                       MAXPOOLPMT, 0.5, MAXPOOLPMT+0.5);
          m_statsSvc->put((pathSumDir+"h_sum_pool_RMSTimePMT").c_str(), h_sum_pool_RMS_Time_PMT[fPOOLIO]);
          
          
          h_sum_pool_Charge_Ratio[fPOOLIO]    = new TH2F("h_sum_pool_ChargeRatio", "h_sum_pool_ChargeRatio",
                                                         5000 , 0, m_maxTotalCharge, 1000, 0, 1);
          m_statsSvc->put((pathSumDir+"h_sum_pool_ChargeRatio").c_str(), h_sum_pool_Charge_Ratio[fPOOLIO]);
          
          
          h_sum_pool_MaxCharge_Patton[fPOOLIO] = new TH2F("h_sum_pool_MaxChargePatton","h_sum_pool_MaxChargePatton",101,-20,20,100,-20,20);
          h_sum_pool_MaxCharge_Patton[fPOOLIO]->SetNormFactor(0);
          m_statsSvc->put((pathSumDir+"h_sum_pool_MaxChargePatton").c_str(), h_sum_pool_MaxCharge_Patton[fPOOLIO]);
        }
      
      for(it=calibChannels.begin(); it!=calibChannels.end(); it++)
        {
          PoolPmtSensor sensorId(it->pmtSensorId().fullPackedData());

          if(sensorId.inwardFacing()) 
            fPOOLPMTIO=0;
          else
            fPOOLPMTIO=1;

          fPOOLWALLPLUS = sensorId.wallNumber();
          fPOOLWALLPMT  = sensorId.wallSpot();
          
          switch(fPOOLWALLPLUS)
            {
            case 0:
              pmtid = 0;
              break;
            case 1:
              pmtid = (1-fPOOLIO)*fPOOLWALLPMT       + fPOOLIO*(fPOOLWALLPMT + fPOOLPMTIO*8) -0.5;
              break;
            case 2:
              pmtid = (1-fPOOLIO)*(10+fPOOLWALLPMT)  + fPOOLIO*(12+fPOOLWALLPMT+fPOOLPMTIO*8) -0.5;
              break;
            case 3:
              pmtid = (1-fPOOLIO)*(18+fPOOLWALLPMT)  + fPOOLIO*(28+fPOOLWALLPMT+fPOOLPMTIO*16) -0.5;
              break;
            case 4:
              pmtid = (1-fPOOLIO)*(42+fPOOLWALLPMT)  + fPOOLIO*(56+fPOOLWALLPMT+fPOOLPMTIO*8) -0.5;
              break;
            case 5:
              pmtid = (1-fPOOLIO)*(50+fPOOLWALLPMT)  + fPOOLIO*(72+fPOOLWALLPMT+fPOOLPMTIO*8) -0.5;
              break;
            case 6:
              pmtid = (1-fPOOLIO)*(60+fPOOLWALLPMT)  + fPOOLIO*(84+fPOOLWALLPMT+fPOOLPMTIO*8) -0.5;
              break;
            case 7:
              pmtid = (1-fPOOLIO)*(68+fPOOLWALLPMT)  + fPOOLIO*(100+fPOOLWALLPMT+fPOOLPMTIO*16) -0.5;
              break;
            case 8:
              pmtid = (1-fPOOLIO)*(92+fPOOLWALLPMT)  + fPOOLIO*(128+fPOOLWALLPMT+fPOOLPMTIO*8) -0.5;
              break;
            case 9:
              pmtid = (1-fPOOLIO)*(100+fPOOLWALLPMT) + fPOOLIO*(144+fPOOLWALLPMT) -0.5;
              break;
            default:
              break;
            }

          ostringstream ossPIoo,ossWALL,ossPMTIDD,ossPMTIoo;
          ossPIoo<<fPOOLIO;
          ossWALL<<setw(2)<<setfill('0')<<fPOOLWALLPLUS;
          ossPMTIDD<<setw(2)<<setfill('0')<<fPOOLWALLPMT;
          ossPMTIoo<<fPOOLPMTIO;
          
          string pathPmt = "P"+ossPIoo.str()+"_"+"Wall"+ossWALL.str()+"_"+"Pmt"+ossPMTIDD.str()+"_"+"F"+ossPMTIoo.str()+"/";
          string pathALL = pathDir+pathPmt;
          
          if(h_pool_charge[fPOOLIO][fPOOLPMTIO][fPOOLWALLPLUS][fPOOLWALLPMT]==NULL)
            {
              h_pool_charge[fPOOLIO][fPOOLPMTIO][fPOOLWALLPLUS][fPOOLWALLPMT] = new TH1F("Charge",
                                                                                         "Charge",1000, 0, m_maxCharge);
              m_statsSvc->put((pathALL+"Charge").c_str(), h_pool_charge[fPOOLIO][fPOOLPMTIO][fPOOLWALLPLUS][fPOOLWALLPMT]);
              
              
              h_pool_time[fPOOLIO][fPOOLPMTIO][fPOOLWALLPLUS][fPOOLWALLPMT] = new TH1F("Time",
                                                                                       "Time",1000, m_minTime, m_maxTime);
              m_statsSvc->put((pathALL+"Time").c_str(), h_pool_time[fPOOLIO][fPOOLPMTIO][fPOOLWALLPLUS][fPOOLWALLPMT]);
            }

          for(unsigned int i=0; i<it->size(); i++) 
            {
              h_pool_charge[fPOOLIO][fPOOLPMTIO][fPOOLWALLPLUS][fPOOLWALLPMT]->Fill(it->charge(i));
              h_pool_time[fPOOLIO][fPOOLPMTIO][fPOOLWALLPLUS][fPOOLWALLPMT]->Fill(it->time(i));
              
              h_sum_pool_Charge_PMT[fPOOLIO]->Fill(pmtid,it->charge(i));
              h_sum_pool_Time_PMT[fPOOLIO]->Fill(pmtid,it->time(i));
            }
          
          sumCharge = it->sumCharge();
          if(sumCharge > qmax) qmax = sumCharge;
          qsum += sumCharge;      

          XYPos pmtHistXY = this->getPmtHistXY(sensorId);         
          h_sum_pool_MaxCharge_Patton[fPOOLIO]->Fill(pmtHistXY.x,pmtHistXY.y,it->sumCharge());
        }
      
      h_sum_pool_FEEQSUM[fPOOLIO]->Fill(qsum);
      if(qsum>0) h_sum_pool_Charge_Ratio[fPOOLIO]->Fill(qsum,qmax/qsum);     
      h_sum_pool_MaxCharge_Patton[fPOOLIO]->SetNormFactor( h_sum_pool_MaxCharge_Patton[fPOOLIO]->GetNormFactor()+1 );
    }
  
  else if(DetName=="AD1"||DetName=="AD2"||DetName=="AD3"||DetName=="AD4")
    {
      int ring         = 0;
      int column       = 0;      
      double pmtid     = 0;
      double qsum      = 0;
      double qmax      = 0;
      double sumCharge = 0;
      int DetId        = detector.detectorId();

      if(!h_sum_MaxCharge_Patton[DetId])
        {
          h_sum_FEEQSUM[DetId]         = new TH1F("h_sum_FEEQSUM", "h_FEEQSUM", 5000 , 0, m_maxTotalCharge);
          m_statsSvc->put((pathSumDir+"h_sum_FEEQSUM").c_str(), h_sum_FEEQSUM[DetId]);
          
          
          h_sum_Charge_PMT[DetId]      = new TH2F("h_sum_ChargePMT", "h_sum_ChargePMT", 
                                                  MAXRING*MAXCOLUMN, 0.5, MAXRING*MAXCOLUMN+0.5, 3000, 0, m_maxCharge);
          m_statsSvc->put((pathSumDir+"h_sum_ChargePMT").c_str(), h_sum_Charge_PMT[DetId]);

          
          h_sum_RMS_Charge_PMT[DetId]  = new TH1F("h_sum_RMSChargePMT", "h_sum_RMSChargePMT",
                                                  MAXRING*MAXCOLUMN, 0.5, MAXRING*MAXCOLUMN+0.5);
          m_statsSvc->put((pathSumDir+"h_sum_RMSChargePMT").c_str(), h_sum_RMS_Charge_PMT[DetId]);
          
          
          h_sum_Time_PMT[DetId]        = new TH2F("h_sum_TimePMT", "h_sum_TimePMT", 
                                                  MAXRING*MAXCOLUMN, 0.5, MAXRING*MAXCOLUMN+0.5, 1000, m_minTime, m_maxTime);
          m_statsSvc->put((pathSumDir+"h_sum_TimePMT").c_str(), h_sum_Time_PMT[DetId]);
          
          
          h_sum_RMS_Time_PMT[DetId]    = new TH1F("h_sum_RMSTimePMT", "h_sum_RMSTimePMT",
                                                  MAXRING*MAXCOLUMN, 0.5, MAXRING*MAXCOLUMN+0.5);
          m_statsSvc->put((pathSumDir+"h_sum_RMSTimePMT").c_str(), h_sum_RMS_Time_PMT[DetId]);
              
          
          h_sum_Charge_Ratio[DetId]    = new TH2F("h_sum_ChargeRatio", "h_sum_ChargeRatio",
                                                  5000 , 0, m_maxTotalCharge, 1000, 0, 1);
          m_statsSvc->put((pathSumDir+"h_sum_ChargeRatio").c_str(), h_sum_Charge_Ratio[DetId]);
          
          h_sum_MaxCharge_Patton[DetId]   = new TH2F("h_sum_MaxChargePatton","h_sum_MaxChargePatton",49,0.25,24.75,19,-0.75,8.75);
          m_statsSvc->put((pathSumDir+"h_sum_MaxChargePatton").c_str(), h_sum_MaxCharge_Patton[DetId]);       
        }

      for (it=calibChannels.begin(); it != calibChannels.end(); it++) 
        {
          AdPmtSensor sensorId(it->pmtSensorId().fullPackedData());
          ring = sensorId.ring();
          column = sensorId.column();
          
          ostringstream ossPmtRing,ossPmtColumn;
          ossPmtRing<<setw(2)<<setfill('0')<<ring;
          ossPmtColumn<<setw(2)<<setfill('0')<<column;

          string pathPmtRingColumn = "Ring"+ossPmtRing.str()+"_"+"Column"+ossPmtColumn.str()+"/";
          string pathALL           = pathDir+pathPmtRingColumn;

          if(h_charge[DetId][ring][column]==NULL)
            {
              h_charge[DetId][ring][column] = new TH1F("Charge","Charge",1000, 0, m_maxCharge);
              m_statsSvc->put((pathALL+"Charge").c_str(), h_charge[DetId][ring][column]);
              
              h_time[DetId][ring][column] = new TH1F("Time","Time",1000, m_minTime, m_maxTime);
              m_statsSvc->put((pathALL+"Time").c_str(), h_time[DetId][ring][column]);
            }

          if(ring==0) 
            {
              pmtid = 192+column -0.5;
            } 
          else 
            {
              pmtid = (ring-1)*24+column -0.5;
            }
          
          for(unsigned int i=0; i<it->size(); i++) 
            {
              
              h_charge[DetId][ring][column]->Fill(it->charge(i));
              h_time[DetId][ring][column]->Fill(it->time(i));
              
              h_sum_Charge_PMT[DetId]->Fill(pmtid,it->charge(i));
              h_sum_Time_PMT[DetId]->Fill(pmtid,it->time(i));
            }
          
          sumCharge = it->sumCharge();
          if(sumCharge > qmax) qmax = sumCharge;
          qsum += sumCharge;
          
          h_sum_MaxCharge_Patton[DetId]->Fill(column,ring,it->maxCharge());
        }
      
      h_sum_FEEQSUM[DetId]->Fill(qsum);
      if(qsum>0) h_sum_Charge_Ratio[DetId]->Fill(qsum,qmax/qsum);
      h_sum_MaxCharge_Patton[DetId]->SetNormFactor( h_sum_MaxCharge_Patton[DetId]->GetNormFactor()+1 );
    }

  debug() << "execute() ______________________________ end" << endreq;
  return StatusCode::SUCCESS;
}
int RawDataHistogram::daqTrigType ( int  offTrigType) [private]

Definition at line 446 of file RawDataHistogram.cc.

{
  int trigType = 0;
  if(offTrigType & DayaBay::Trigger::kMult) {  
    trigType = trigType | (1<<8);
  } else if(offTrigType & DayaBay::Trigger::kCross) {  //CROSS_TRIGGER_IN
    trigType = trigType | (1<<1);
  } else if(offTrigType & DayaBay::Trigger::kManual) {  //MANUAL_TRIGGER
    trigType = trigType | (1<<0);
  } else if(offTrigType & DayaBay::Trigger::kPeriodic) {  //PERIODIC_TRIGGER
    trigType = trigType | (1<<2);
  } else if(offTrigType & DayaBay::Trigger::kESumAll) {
    trigType = trigType | (1<<12);
  } else if(offTrigType & DayaBay::Trigger::kESumHigh) {
    trigType = trigType | (1<<10);
  } else if(offTrigType & DayaBay::Trigger::kESumLow) {
    trigType = trigType | (1<<11);
  } else if(offTrigType & DayaBay::Trigger::kESumADC) {
    trigType = trigType | (1<<9);
  }
  return trigType;
}
TH1 * RpcDataHistogram::makeHist ( int  run,
int  site,
int  detector,
int  row,
int  column,
int  histIndex 
) [private]

Definition at line 740 of file RpcDataHistogram.cc.

{
  debug() << "Detector=" << detector << endreq;

  TH1* hist = 0;
  if( m_rpcHistPath.find(histIndex) == m_rpcHistPath.end() ){
    std::string histName;
    if(row){
      switch(histIndex){
        default:
          error() << "Unknown histogram for single channel: " << histIndex << endreq;
          return 0;
      }
    } else {
      // initialize histogram variables
      int nBins=2100;
      float lowLim = -0.01, upLim = 0.21;
      switch(histIndex){
        case kSysTrigRate:
          hist = new TH1F("h_sum_SysTrigRate", "System trigger rate", 60, m_firstRtmTrigSec, m_firstRtmTrigSec + 60);
          hist->GetXaxis()->SetTitle("Run time (Beijing)");
                  hist->GetXaxis()->SetLabelSize(0.03);
          hist->GetYaxis()->SetTitle("Rate [Hz]");
          hist->GetXaxis()->SetTimeDisplay(1);
          hist->GetXaxis()->SetTimeFormat(TimeFormat);
          hist->GetXaxis()->SetTimeOffset(0,"gmt");
          hist->GetXaxis()->SetNdivisions(505);
          break;
        case kDeltaTrigTime:
          if(site==1) {
            nBins = 2100;
            lowLim = -0.002;
            upLim = 0.082;
          } else if(site==2) {
            nBins = 1400;
            lowLim = -0.003;
            upLim = 0.123;
          } else if(site==3) {
            nBins = 840;
            lowLim = -0.02;
            upLim = 0.40;
          }
          hist = new TH1F("h_sum_DeltaTrigTime", "Time between system triggers", nBins, lowLim, upLim);
          hist->GetXaxis()->SetTitle("#Deltat(s)");
          hist->GetYaxis()->SetTitle("Entries");
          break;
        case k4FoldRate:
          hist = new TH1F("h_sum_Rate4Fold", "4-fold rate", 60, m_firstFecTrigSec, m_firstFecTrigSec + 60);
          hist->GetXaxis()->SetTitle("Run time (Beijing)");
                  hist->GetXaxis()->SetLabelSize(0.03);
          hist->GetYaxis()->SetTitle("Rate [Hz/m^{2}]");
          hist->GetXaxis()->SetTimeDisplay(1);
          hist->GetXaxis()->SetTimeFormat(TimeFormat);
          hist->GetXaxis()->SetTimeOffset(0,"gmt");
          hist->GetXaxis()->SetNdivisions(505);
          break;
        case kDelta4FoldTime:
          if(site==1) {
            nBins = 1846;
            lowLim = -0.005;
            upLim = 0.115;
          } else if(site==2) {
            nBins = 1230;
            lowLim = -0.008;
            upLim = 0.238;
          } else if(site==3) {
            nBins = 1000;
            lowLim = -0.04;
            upLim = 1.26;
          }
          hist = new TH1F("h_sum_Delta4FoldTime", "Time between 4-fold triggers", nBins, lowLim, upLim);
          hist->GetXaxis()->SetTitle("#Deltat(s)");
          hist->GetYaxis()->SetTitle("Entries");
          break;
        case kDelta4FoldTimeLog:
          hist = new TH1F("h_sum_Delta4FoldLogTime", "Time between 4-fold triggers (log)", 900, -8.0, 1.0);
          hist->GetXaxis()->SetTitle("log_{10}#Deltat(s)");
          hist->GetYaxis()->SetTitle("Entries");
          break;
        case kLayerMult:
          hist = new TH1F("h_sum_LayerMult", "No. of triggered layers per readout module", 5, -0.5, 4.5); //55,-0.5,54.5
          hist->GetXaxis()->SetTitle("Number of layers");
          hist->GetYaxis()->SetTitle("Entries");
          break;
            case kFecErr: 
          hist = new TH2F("h_sum_ErrFec", "FEC errors", 60, m_firstFecTrigSec, m_firstFecTrigSec + 60, 6, 0, 6); 
          hist->GetXaxis()->SetTitle("Run time (Beijing)"); 
          hist->GetXaxis()->SetLabelSize(0.03); 
          hist->GetXaxis()->SetTimeDisplay(1); 
          hist->GetXaxis()->SetTimeFormat(TimeFormat); 
          hist->GetXaxis()->SetTimeOffset(0,"gmt"); 
          hist->GetXaxis()->SetNdivisions(505); 
          for(int i = 0; i <= 5; i++){ 
            hist->GetYaxis()->SetBinLabel(i + 1, m_fecErrType[i]); 
          } 
          break; 
      case kRtmErr: 
        hist = new TH2F("h_sum_ErrRtm", "RTM errors", 60, m_firstRtmTrigSec, m_firstRtmTrigSec + 60, 6, 0, 6); 
        hist->GetXaxis()->SetTitle("Run time (Beijing)"); 
        hist->GetXaxis()->SetLabelSize(0.03); 
        hist->GetXaxis()->SetTimeDisplay(1); 
        hist->GetXaxis()->SetTimeFormat(TimeFormat); 
        hist->GetXaxis()->SetTimeOffset(0,"gmt"); 
        hist->GetXaxis()->SetNdivisions(505); 
        for(int i = 0; i <= 5; i++){ 
          hist->GetYaxis()->SetBinLabel(i + 1, m_rtmErrType[i]); 
        } 
        break;
        case kModuleMult:
          hist = new TH1F("h_sum_ModuleMult", "No. of triggered modules per system trigger (100 ns readout)", NROW*NCOLUMN+1, -0.5, NROW*NCOLUMN+0.5);
          hist->GetXaxis()->SetTitle("Number of modules");
          hist->GetYaxis()->SetTitle("Entries");
          break;
        case kHit_Id:
          hist = new TH1F("h_sum_Hit_Id", "Hit vs Strip ID", (NROW*NCOLUMN+10)*4*8, -0.5-5*4*8, (NROW*NCOLUMN+5)*4*8-0.5);
                  hist->SetAxisRange(-0.5-5*4*8, (NROW*NCOLUMN+10)*4*8-0.5, "X");
          hist->GetXaxis()->SetTitle("[(Row*9+Col)*4+Layer]*8+Strip");
          hist->GetYaxis()->SetTitle("Entries");
          break;
        case kHitMapL1:                 // hits per layer: 9, 0.5, 9.5, NROW+2, -0.5, NROW+2-0.5);    hits per strip: 8*9, -0.5, 71.5, NROW+2, -0.5, (NROW+2)-0.5);
          hist = new TH2F("h_sum_HitMapL1", "Hit vs Strip Layer1", 8*9, -0.5, 71.5, NROW+2, -0.5, (NROW+2)-0.5);
          hist->GetYaxis()->SetTitle("Row");  //"Row"
          hist->GetXaxis()->SetTitle("Column*8+Strip");  //"Column"
          break;
        case kHitMapL2:                 // hits per layer: , 9, 0.5, 9.5, NROW+2, -0.5, NROW+2-0.5);    hits per strip: 9, -0.5, 8.5, (NROW+2)*8, -0.5, (NROW+2)*8-0.5);
          hist = new TH2F("h_sum_HitMapL2", "Hit vs Strip Layer2", 9, -0.5, 8.5, (NROW+2)*8, -0.5, (NROW+2)*8-0.5);
          hist->GetYaxis()->SetTitle("Row*8+Strip");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case kHitMapL3:                 // hits per layer: , 9, 0.5, 9.5, NROW+2, -0.5, NROW+2-0.5);    hits per strip: 9, -0.5, 8.5, (NROW+2)*8, -0.5, (NROW+2)*8-0.5);
          hist = new TH2F("h_sum_HitMapL3", "Hit vs Strip Layer3", 9, -0.5, 8.5, (NROW+2)*8, -0.5, (NROW+2)*8-0.5);
          hist->GetYaxis()->SetTitle("Row*8+Strip");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case kHitMapL4:                 // hits per layer: 9, 0.5, 9.5, NROW+2, -0.5, NROW+2-0.5);    hits per strip: 8*9, -0.5, 71.5, NROW+2, -0.5, (NROW+2)-0.5);
          hist = new TH2F("h_sum_HitMapL4", "Hit vs Strip Layer4", 8*9, -0.5, 71.5, NROW+2, -0.5, (NROW+2)-0.5);
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column*8+Strip");
          break;
        case k4FoldMapPatch:
          hist = new TH2F("h_sum_4FoldMapPatch", "4-fold map Patch", 8*9, -0.5, 71.5, 8*(NROW+2), -0.5, 8*(NROW+2)-0.5);
          hist->GetYaxis()->SetTitle("Row*8 + StripY");
          hist->GetXaxis()->SetTitle("Column*8 + StripX");
          break;
        case k4FoldRateMap:
          hist = new TH2F("h_sum_4FoldMapRate", "4-fold rate map [Hz/m^{2}]", 9+2*9, 0.5, 9.5+2*9, NROW+2, -0.5, NROW+2-0.5);
                  hist->SetAxisRange(0.5, 9.5-1, "X");  
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case k4FoldMultMap:
          hist = new TH2F("h_sum_4FoldMultMap", "Map of fraction of 4-folds with >8 strips", 9+2*9, 0.5, 9.5+2*9, NROW+2, -0.5, NROW+2-0.5);
                  hist->SetAxisRange(0.5, 9.5-1, "X");
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case kEfficiencyStats:
          hist = new TH1F("h_sum_EfficiencyStats", "Efficiency distribution", (int)(1.01/m_effRes)+2*396, -m_effRes/2, 1.00+m_effRes/2+2*396*m_effRes);
                  hist->SetAxisRange(0.00, 1.00, "X");
          hist->GetXaxis()->SetTitle("Efficiency (each layer of each module)");
          hist->GetYaxis()->SetTitle("Entries");
          break;
        case kEfficiencyMapL1:
          hist = new TH2F("h_sum_EfficiencyMapL1", "Efficiency map Layer1", 9+2*9, 0.5, 9.5+2*9, NROW+2, -0.5, NROW+2-0.5);
                  hist->SetAxisRange(-0.5, 9.5-1, "X");
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case kEfficiencyMapL2:
          hist = new TH2F("h_sum_EfficiencyMapL2", "Efficiency map Layer2", 9+2*9, 0.5, 9.5+2*9, NROW+2, -0.5, NROW+2-0.5);
                  hist->SetAxisRange(-0.5, 9.5-1, "X");
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case kEfficiencyMapL3:
          hist = new TH2F("h_sum_EfficiencyMapL3", "Efficiency map Layer3", 9+2*9, 0.5, 9.5+2*9, NROW+2, -0.5, NROW+2-0.5);
                  hist->SetAxisRange(-0.5, 8.5, "X");
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case kEfficiencyMapL4:
          hist = new TH2F("h_sum_EfficiencyMapL4", "Efficiency map Layer4", 9+2*9, 0.5, 9.5+2*9, NROW+2, -0.5, NROW+2-0.5);
                  hist->SetAxisRange(-0.5, 8.5, "X");
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case kNoiseRateStats:
          hist = new TH1F("h_sum_NoiseRateStats", "Singles rate distribution", 51+2*396, -0.06, 6.06+2*396*0.12);
                  hist->SetAxisRange(-0.06, 6.00, "X");
          hist->GetXaxis()->SetTitle("Singles Rate (each layer of each module) [kHz/m^{2}]");
          hist->GetYaxis()->SetTitle("Entries");
          break;
        case kNoiseRateMapL1:
          hist = new TH2F("h_sum_NoiseRateMapL1", "Singles rate map Layer1 [kHz/m^{2}]", 9+2*9, 0.5, 9.5+2*9, NROW+2, -0.5, NROW+2-0.5);
                  hist->SetAxisRange(-0.5, 9.5-1, "X");
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case kNoiseRateMapL2:
          hist = new TH2F("h_sum_NoiseRateMapL2", "Singles rate map Layer2 [kHz/m^{2}]", 9+2*9, 0.5, 9.5+2*9, NROW+2, -0.5, NROW+2-0.5);
                  hist->SetAxisRange(-0.5, 9.5-1, "X");
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case kNoiseRateMapL3:
          hist = new TH2F("h_sum_NoiseRateMapL3", "Singles rate map Layer3 [kHz/m^{2}]", 9+2*9, 0.5, 9.5+2*9, NROW+2, -0.5, NROW+2-0.5);
                  hist->SetAxisRange(-0.5, 9.5-1, "X");
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column");
          break;
        case kNoiseRateMapL4:
          hist = new TH2F("h_sum_NoiseRateMapL4", "Singles rate map Layer4 [kHz/m^{2}]", 9+2*9, 0.5, 9.5+2*9, NROW+2, -0.5, NROW+2-0.5);
                  hist->SetAxisRange(-0.5, 8.5, "X");
          hist->GetYaxis()->SetTitle("Row");
          hist->GetXaxis()->SetTitle("Column");
          break;
        default:
          error() << "Unknown histogram for single channel: " << histIndex << endreq;
          return 0;
      }
    }
    
    debug() << "Making histogram: " << hist->GetName() << endreq;
    std::string rpcHistPath = getPath(run, site, detector, row, column, hist->GetName());
    m_rpcHistPath[histIndex] = rpcHistPath;
    m_statsSvc->put( rpcHistPath, hist );
  }

  return hist;
}
std::string RpcDataHistogram::getPath ( int  run,
int  site,
int  detector,
int  row,
int  column,
const char *  histName 
) [private]

Definition at line 667 of file DaqDataHistogram.cc.

{
  // Construct histogram path in statistics service
  std::stringstream path;
  //path << "/file1/diagnostics/run_" << std::setfill('0') << std::setw(7)
  //    << run << "/";
  path << "/file1/";
  path << Site::AsString(detector.site()) << "/" << DetectorId::AsString(detector.detectorId());
  if(board){
    path << "/board" << std::setfill('0') << std::setw(2) 
      << board << "_connector" << std::setfill('0') << std::setw(2)
      << connector;
  } else {
    path << "/Raw";
  }
  path << "/" << histName;
  debug() << "Histogram path = " << path << endreq;
  return path.str();
}
const char * RpcDataHistogram::SiteAsString ( int  site) [private]

Definition at line 1032 of file RpcDataHistogram.cc.

{
  switch(site) {
    case 0:      return "Unknown"; break;
    case 1:      return "DayaBay"; break;
    case 2:       return "LingAo"; break;
    case 3:          return "Far"; break;
    case 4:          return "Mid"; break;
    case 5:     return "Aberdeen"; break;
    case 6:          return "SAB";
    case 7: return "PMTBenchTest"; break;
    case 127: return "All"; break;
    default: return "?Unknown?"; break;
  }
}
void RpcDataHistogram::handleFecReadout ( const DybDaq::FecReadout fecReadout,
int  site,
ServiceMode  svcMode 
) [private]

Definition at line 382 of file RpcDataHistogram.cc.

                                                                                                 {
  const FecReadout::FecDataPtrList& fecList = fecReadout.fecDataList();
  FecReadout::FecDataPtrList::const_iterator it = fecList.begin();
  while ( it != fecList.end() ) {
    handleFecData( *it, site,svcMode);
    ++it;
  }
}
void RpcDataHistogram::handleFecData ( const DybDaq::FecData fecData,
int  site,
ServiceMode  svcMode 
) [private]

Definition at line 392 of file RpcDataHistogram.cc.

{
  if( m_firstFecTrigSec == 0 ){
        m_firstFecTrigSec = fecData->second(); 
        m_firstFecTrigNanoSec = fecData->nanoSecond(); 
        // After the initialization of m_firstFecTrigSec, then initialize h_sum_ErrFec and h_sum_Rate4Fold. 
        makeHist(1, site, 7, 0, 0, kFecErr); 
    makeHist(1, site, 7, 0, 0, k4FoldRate);
  }
  bool parity = checkParity(fecData->nanoSecond(),fecData->hitMap(),fecData->parity());  // the parity flag indicates transfer errors from CF to IF. If the number of '1's in the 64 bit sum of nanoSecond and hitMap is odd, the parity flag is '1'; otherwise, the parity flag is '0'.  
  bool transErr = fecData->transErr(); // Trans_error flags the parity check for the serial transfer from FEC to CF.  When it is '1', it means the parity check is wrong. There must be an error during serial transmission.
  bool validCLK = fecData->validCLK(); 
  bool validGPS = fecData->validGPS(); 
  bool fullFlag = fecData->fullFlag(); // FULL means buffer full, when it is “1”, it means has lost some Trigger data in the past time.
  bool bitsCheck = fecData->bitsCheck();
  if(m_clockType == -1) m_clockType = validCLK; 
  if(m_GPSUsed == -1) m_GPSUsed = validGPS; 
        
  TH2F* h_fecErr = m_statsSvc->getTH2F(m_rpcHistPath[kFecErr].c_str()); 
  if(parity) h_fecErr->Fill(fecData->second(), 0); 
  if(transErr) h_fecErr->Fill(fecData->second(), 1); 
  if(validCLK != m_clockType && m_clockType != -1) h_fecErr->Fill(fecData->second(), 2); 
  if(validGPS != m_GPSUsed && m_GPSUsed != -1) h_fecErr->Fill(fecData->second(), 3); 
  if(fullFlag) h_fecErr->Fill(fecData->second(), 4); 
  if(!bitsCheck) h_fecErr->Fill(fecData->second(), 5); 
  
  TH2F* h_hitMap[4];
  h_hitMap[0] = m_statsSvc->getTH2F(m_rpcHistPath[kHitMapL1].c_str());
  h_hitMap[1] = m_statsSvc->getTH2F(m_rpcHistPath[kHitMapL2].c_str());
  h_hitMap[2] = m_statsSvc->getTH2F(m_rpcHistPath[kHitMapL3].c_str());
  h_hitMap[3] = m_statsSvc->getTH2F(m_rpcHistPath[kHitMapL4].c_str());

  TH1F* h_hit_Id = m_statsSvc->getTH1F(m_rpcHistPath[kHit_Id].c_str());

  TH2F* h_4FoldMapPatch = m_statsSvc->getTH2F(m_rpcHistPath[k4FoldMapPatch].c_str());
  
  unsigned int cfId = fecData->rpcCFId();
  unsigned int fecId = fecData->rpcFecId();
  unsigned int dataMap = fecData->hitMap();
  
  bool tele = false;
  if((cfId==1||cfId==3)&&fecId==14)
          tele = true;
  int row = 0;
  int col = 0;
  int module = 0;
 
  int layer, ch;
  int data[4] = {0,0,0,0};    // save which layers hit
  int nFold = 0;        // save layer fold-number of event (0 to 4)
  int nHit = 0;        // save strip hit-number of event (0 to 32)
  int hit[32] = {0};    // save which strips hit
  int hitNum[4] = {0};  // save how many hits in each layer
  
  // count and map hits in layers and strips
  for( int i = 0; i < 32; i++ )
  {
          DayaBay::FecChannelId* fecChId;
          if(site==3)
                  fecChId = new DayaBay::FecChannelId(cfId,fecId,i,Site::Site_t(4),DetectorId::DetectorId_t(7));
          else
                  fecChId = new DayaBay::FecChannelId(cfId,fecId,i,Site::Site_t(site),DetectorId::DetectorId_t(7));
          DayaBay::RpcSensor sensor = m_cableSvc->rpcSensor(*fecChId, svcMode);
          row = sensor.panelRow();
          col = sensor.panelColumn()-1;//starts from 0
          layer = sensor.layer()-1; //starts from 0
          ch = sensor.strip() -1; //starts from 0
          module = row * NCOLUMN + col;
    if( (dataMap >> i)&1 == 1 )
    {
      data[layer] = 1;     
      hitNum[layer]++;
      hit[layer*8+ch] = 1;

      h_hit_Id->Fill( ((module-NCOLUMN)*4 + layer) * 8 + ch );
      //h_hitMap[layer]->Fill( 1+col, row );
          if(layer==0 || layer==3)
        if(site>=3)
          h_hitMap[layer]->Fill(col*8+(7-ch),row);
        else
          h_hitMap[layer]->Fill(col*8+ch,row);
          else
        if(site>=3)
          h_hitMap[layer]->Fill(col,row*8+(7-ch));
        else
          h_hitMap[layer]->Fill(col,row*8+ch);
    }
  }
  nFold = data[0] + data[1] + data[2] + data[3];
  nHit = hitNum[0] + hitNum[1] + hitNum[2] + hitNum[3];
  
  // count number of triggered layers in each triggered module
  if(nFold>=0) {
    TH1F* h_layerMult = m_statsSvc->getTH1F(m_rpcHistPath[kLayerMult].c_str());
    h_layerMult->Fill(nFold);
  }
  
  // record layers and times associated with nFold zeros, singles, 2-folds, 3-folds, and 4-folds within the module
  
 if(fecData->forceTrigger())
 {
   if( nFold <= 2 )  // require <=2 layer having hits to avoid muon contamination 
   {
     for( int l = 0; l < 4; l++ )
     {    
       m_noiseTime[module][l] += m_readoutWindow;
       if(data[l] == 1) 
             m_noiseCount[module][l] += 1;  // use 1 to avoid influence of cross-talk (~1%).  do not use hitNum[l] since multiple singles are unlikely (~0.1%).  
     }
   } 
 }
 
 if(fecData->trigType()==3) // 3 out of 4 triggers
 {
  // count 3-folds each layer is not associated with (for layer efficiency calculations)
  if(nFold==3) 
  {         
    for( int l = 0; l < 4; l++ ) 
    {
        if( data[l] == 0 ) {
           layer = l;
           m_trigger[module][layer]++;
            break;
         }
     }
     // count 3-folds with at least one pair of overlapping strips for efficiency calculation
     if (nHit==3) 
     {
       for( int i = 0; i < 8; i++ )
       {
         if ( (hit[i]==1 && hit[i+24]==1) || (hit[i+8]==1 && hit[i+16]==1) )
         {
           m_triggerEff[module][layer]++;
           break;
         }
       }
     }
  }
  if( nFold == 4 ) 
  {
    m_4foldCount[module]++;
    for( int l = 0; l < 4; l++ ) 
    m_trigger[module][l]++;
    
    if(nHit>8) 
      m_4foldMultCount[module]++;

    // 4FoldMap Patch
    for( int i = 0; i < 8; i++ )
    { // top and bottom strips, which are parallel
      if( hit[i]==1 && hit[i+24]==1)
      {
        for( int j=8; j < 16; j++ )
        {       // middle two strips, which are parallel
          if( hit[j]==1 && hit[j+8]==1 ) 
          {  // can be satisfied more than once
            if(site>=3)  // The orientation (face away from electronics room) of EH3 RPC modules is different from the other 2 halls.
            {
              h_4FoldMapPatch->Fill(col*8.0+(7-i), row*8.0+(15-j));
            }
            else
            {
              h_4FoldMapPatch->Fill(col*8.0+i, row*8.0+j-8);
            }
          }
        }
      }
    }
        
    // count 4-folds with at least one pair of overlapping strips for efficiency calculation
    if (nHit==4) 
    {
      m_4foldCountCut[module]++;
      for( int i = 0; i < 8; i++ ) 
      {
        if ( (hit[i]==1 && hit[i+24]==1) || (hit[i+8]==1 && hit[i+16]==1) )
        {
          m_4foldCountEff[module]++;
          for( int l = 0; l < 4; l++ ) 
            m_triggerEff[module][l]++;
            break;
        }
      }
    }

          if (!tele) {  // if not a telescope RPC
            // 4FoldRate vs time
            TH1F* h_4FoldRate = m_statsSvc->getTH1F(m_rpcHistPath[k4FoldRate].c_str());
            int secondsPast = fecData->second() - (int)(h_4FoldRate->GetXaxis()->GetXmax());
            if( secondsPast >= 0 )  this->extendRange( h_4FoldRate, secondsPast + 2 );
            h_4FoldRate->Fill(fecData->second());

            if(m_last4FoldSec != 0) {
              double dt = calInterval(m_last4FoldSec, m_last4FoldNanoSec, fecData->second(), fecData->nanoSecond());
              TH1F* h_delta4FoldTime = m_statsSvc->getTH1F(m_rpcHistPath[kDelta4FoldTime].c_str());
              h_delta4FoldTime->Fill(dt);
              if(dt>0) 
              {
                TH1F* h_delta4FoldTimeLog = m_statsSvc->getTH1F(m_rpcHistPath[kDelta4FoldTimeLog].c_str());
                h_delta4FoldTimeLog->Fill(log10(dt));
              }
              else if (dt<0 && m_triggerCount<10000) 
                std::cout << m_eventCount << "  " << m_triggerCount << ":  time (FEC) between 4-fold triggers = " << dt << std::endl;
            }

            m_last4FoldSec = fecData->second();
            m_last4FoldNanoSec = fecData->nanoSecond();
          }
                  
   }
 }

}  // end of function: RpcDataHistogram::handleFecData(const FecData* fecData, int site, ServiceMode svcMode)
bool RpcDataHistogram::checkParity ( unsigned  nanoSec,
unsigned  fecHitData,
bool  transErr1 
) [private]

Definition at line 607 of file RpcDataHistogram.cc.

{ 
  int num = 0; 
  for(int i=0;i<32;i++) 
  { 
    if(nanoSec>>i&1==1) num++; 
    if(fecHitData>>i&1==1) num++; 
  } 
  
  num = num%2; 
  // std::cout<<std::hex << "NanoSec:0x"<<nanoSec<<",FecData:0x"<<fecHitData<<std::dec<<",parity="<<parity<<std::endl; 
  if(num==parity) return false; // ok 
  else return true; // error 
} 
void RpcDataHistogram::handleRtmReadout ( const DybDaq::RtmReadout rtmReadout,
int  site 
) [private]

Definition at line 623 of file RpcDataHistogram.cc.

{
  const RtmReadout::RtmDataPtrList& rtmList = rtmReadout.rtmDataList();
  RtmReadout::RtmDataPtrList::const_iterator it = rtmList.begin();
  while ( it != rtmList.end() ) {
    handleRtmData( *it , site);
    ++it;
  }
}
void RpcDataHistogram::handleRtmData ( const DybDaq::RtmData rtmData,
int  site 
) [private]

Definition at line 634 of file RpcDataHistogram.cc.

{

  int currentCFId = rtmData->rpcCFId();
  int rtmSecond = rtmData->second();
  
  info() << " ** RtmData: " << '\n'
    << currentCFId << '\t' << rtmData->transErr() << '\t' << rtmData->validCLK() << '\n'
    << rtmSecond << "s    " << rtmData->nanoSecond() << "ns    " << rtmData->accumulation() << '\n'
    << std::hex << "0x" << rtmData->triggerRot() << "    0x" << rtmData->triggerMap() << std::dec << endreq;

  bool tele=0;
  bool transErr = rtmData->transErr(); 
  bool validCLK = rtmData->validCLK(); 
  bool validGPS = rtmData->validGPS(); 
  bool romAlmostFull = rtmData->romAlmostFull(); 
  bool rtmAlmostFull = rtmData->rtmAlmostFull(); 
  bool fullFlag = rtmData->fullFlag(); 
 
  if(m_clockType == -1) m_clockType = validCLK; 
  if(m_GPSUsed == -1) m_GPSUsed = validGPS;
  
  if( m_firstRtmTrigSec == 0 ) {
    m_firstRtmTrigSec = rtmSecond;
    m_firstRtmTrigNanoSec = rtmData->nanoSecond();
    // After the initialization of m_firstRtmTrigSec, initialize h_sum_SysTrigRate and h_sum_ErrRtm.
    makeHist(1, site, 7, 0, 0, kSysTrigRate);
    makeHist(1, site, 7, 0, 0, kRtmErr); 
  }
  TH2F* h_rtmErr = m_statsSvc->getTH2F(m_rpcHistPath[kRtmErr].c_str()); 
  
  if(validCLK != m_clockType && m_clockType != -1) h_rtmErr->Fill(rtmSecond, 0);
  //if(!validCLK) h_rtmErr->Fill(rtmSecond, 0); 
  if(validGPS != m_GPSUsed && m_GPSUsed != -1) h_rtmErr->Fill(rtmSecond, 1); 
  //if(!validGPS) h_rtmErr->Fill(rtmSecond, 1);
  if(fullFlag) h_rtmErr->Fill(rtmSecond, 2); 
  if(transErr) h_rtmErr->Fill(rtmSecond, 3); 
  if(romAlmostFull) h_rtmErr->Fill(rtmSecond, 4); 
  if(rtmAlmostFull) h_rtmErr->Fill(rtmSecond, 5);
  
  // prevent forced triggers from contributing to RTM histograms
  if( rtmData->forceTrigger() )  return;
  
  // NOTE:  the condition on currentCFId is due to the fact that the RTM has 2 CFs (3 in EH3).  So, there are 2 readouts in each system (RTM) readout.  
  // the following assumes that all CFId readouts are sequentially ordered in a group and all CFId groups are time ordered.  
  
  if ( currentCFId == 0 || m_lastCFId==currentCFId ) {  // trigger times should not equal
    m_triggerCount++;
        
    // time between system triggers
    if (m_triggerCount > 1) {
      double dt = calInterval(m_lastRtmTrigSec, m_lastRtmTrigNanoSec, rtmSecond, rtmData->nanoSecond()); 
      TH1F* h_deltaTrigTime = m_statsSvc->getTH1F(m_rpcHistPath[kDeltaTrigTime].c_str());
      h_deltaTrigTime->Fill(dt);
    }
    m_lastRtmTrigSec = rtmSecond;
    m_lastRtmTrigNanoSec = rtmData->nanoSecond();
        
        // trigger rate
    TH1F* h_sysTrigRate = m_statsSvc->getTH1F(m_rpcHistPath[kSysTrigRate].c_str());
        int secondsPast = rtmSecond - (int)(h_sysTrigRate->GetXaxis()->GetXmax());
    if( secondsPast >= 0 ) {
      debug() << "difference: " << secondsPast << endreq;
      this->extendRange( h_sysTrigRate, secondsPast + 2 );
    }
        h_sysTrigRate->Fill(rtmSecond);
  }
    
  // count number of modules triggered in each system trigger (count previous trigger set ==> will not fill last trigger)
  
  unsigned int trigMap = rtmData->triggerRot();  // triggerRot() (for triggered modules)  triggerMap() (for nearest neighbor readout modules)
  if ( (trigMap >> 30)&1==1)  tele=1;  // bit used for telescope RPC trigger
  
  if (m_lastCFId==currentCFId) {  // if current CFId is same as previous, do not fill current or previous CF readout
    if (m_triggerCount<5000) {
      //std::cout << m_eventCount << "  " << m_triggerCount << ":  redundant CFIds " << currentCFId << " at time " << (rtmData->nanoSecond()*1.0)/(NANOSECRANGE*1.0) << std::endl;
      if (tele)
        std::cout << m_eventCount << "  " << m_triggerCount << ":  telescope RPC(s) in redundant CFId=" << currentCFId << " at time " << (rtmData->nanoSecond()*1.0)/(NANOSECRANGE*1.0) << std::endl;
    }
    if (currentCFId>0 && (!m_teleTrigger || m_ModuleTriggerCount>0) ) {  // count readout from previous CF
      TH1F* h_moduleMult = m_statsSvc->getTH1F(m_rpcHistPath[kModuleMult].c_str());
      h_moduleMult->Fill(m_ModuleTriggerCount);  // fill the previous set of CFs
    }
    m_ModuleTriggerCount=0;  // re-initialize the count at CF=0
  }
  
  if ( currentCFId==0 && (!m_teleTrigger || m_ModuleTriggerCount>0) && m_lastCFId>0 && m_triggerCount > 1 ) {
    TH1F* h_moduleMult = m_statsSvc->getTH1F(m_rpcHistPath[kModuleMult].c_str());
    h_moduleMult->Fill(m_ModuleTriggerCount);  // fill the previous set of CFs
        m_ModuleTriggerCount=0;  // initialize the count at CF=0
  }
  
  // check current CFId trigger data
  for( int b = 0; b<=27; b++ ){  // there are 27 FECs (2 ROTs) to one CF
    if ( b == 15 )  continue;   // ignore the bit of the 3/4 flag
    if ( (trigMap >> b)&1==1)  m_ModuleTriggerCount++;
  }
  
  if (tele)  m_teleTrigger=1;
  else  m_teleTrigger=0;
  
  m_lastCFId = currentCFId;
  
}
void RpcDataHistogram::extendRange ( TH1 *  hist,
int  xBinsAdd,
int  yBinsAdd = 0 
) [private]

Definition at line 688 of file DaqDataHistogram.cc.

{
  // Automatically extend the histogram range, and replace
  //  Currently works for TH1F and TH2F
  info() << "Extending histogram range: " << hist->GetName() << endreq;
  TH1* extension = 0;
  if(hist->IsA() == TH2F::Class()){
    extension = new TH2F("","",
                hist->GetNbinsX(), // Keep the bin number fixed 
                //xBinsAdd + hist->GetNbinsX(), 
                         hist->GetXaxis()->GetXmin(),
                         hist->GetXaxis()->GetXmax() + xBinsAdd*hist->GetXaxis()->GetBinWidth(0),
                         yBinsAdd + hist->GetNbinsY(),
                         hist->GetYaxis()->GetXmin(),
                         hist->GetYaxis()->GetXmax() + yBinsAdd*hist->GetYaxis()->GetBinWidth(0));
  }else if(hist->IsA() == TH1F::Class()){
    extension = new TH1F("","",
                         xBinsAdd,
                         hist->GetXaxis()->GetXmax(),
                         hist->GetXaxis()->GetXmax() + xBinsAdd*hist->GetXaxis()->GetBinWidth(0));
  }else{
    error() << "Cannot extend range of type: " << hist->ClassName() << endreq;
    return;
  }
  TList list;
  list.Add(extension);
  hist->Merge(&list);
  delete extension;
  return;
}
double RpcDataHistogram::calInterval ( unsigned int  firstSec,
unsigned int  firstNanoSec,
unsigned int  secondSec,
unsigned int  secondNanoSec 
) [private]

Definition at line 1024 of file RpcDataHistogram.cc.

{
  double first = firstSec*1.0 + (firstNanoSec*1.0)/(NANOSECRANGE*1.0);
  double second = secondSec*1.0 + (secondNanoSec*1.0)/(NANOSECRANGE*1.0);

  return (second - first);
}

Member Data Documentation

IStatisticsSvc* RpcDataHistogram::m_statsSvc [private]

Definition at line 49 of file RpcDataHistogram.h.

ICableSvc* RpcDataHistogram::m_cableSvc [private]

Definition at line 50 of file RpcDataHistogram.h.

std::map<int, TH1**> RpcDataHistogram::m_rpcHist [private]

Definition at line 56 of file RpcDataHistogram.h.

std::map<int, std::string> RpcDataHistogram::m_rpcHistPath [private]

Definition at line 57 of file RpcDataHistogram.h.

Definition at line 69 of file RpcDataHistogram.h.

Definition at line 70 of file RpcDataHistogram.h.

int RpcDataHistogram::NROW [private]

Definition at line 71 of file RpcDataHistogram.h.

Definition at line 72 of file RpcDataHistogram.h.

Definition at line 73 of file RpcDataHistogram.h.

Definition at line 74 of file RpcDataHistogram.h.

Definition at line 75 of file RpcDataHistogram.h.

Definition at line 76 of file RpcDataHistogram.h.

int RpcDataHistogram::m_trigger[99][4] [private]

Definition at line 77 of file RpcDataHistogram.h.

int RpcDataHistogram::m_triggerEff[99][4] [private]

Definition at line 78 of file RpcDataHistogram.h.

int RpcDataHistogram::m_noiseCount[99][4] [private]

Definition at line 79 of file RpcDataHistogram.h.

int RpcDataHistogram::m_4foldCount[99] [private]

Definition at line 81 of file RpcDataHistogram.h.

Definition at line 82 of file RpcDataHistogram.h.

Definition at line 83 of file RpcDataHistogram.h.

Definition at line 84 of file RpcDataHistogram.h.

double RpcDataHistogram::m_noiseTime[99][4] [private]

Definition at line 85 of file RpcDataHistogram.h.

double RpcDataHistogram::m_effRes [private]

Definition at line 86 of file RpcDataHistogram.h.

double RpcDataHistogram::m_runTime [private]

Definition at line 87 of file RpcDataHistogram.h.

Definition at line 88 of file RpcDataHistogram.h.

Definition at line 89 of file RpcDataHistogram.h.

unsigned int RpcDataHistogram::m_firstRtmTrigSec [private]

Definition at line 90 of file RpcDataHistogram.h.

Definition at line 91 of file RpcDataHistogram.h.

unsigned int RpcDataHistogram::m_firstFecTrigSec [private]

Definition at line 92 of file RpcDataHistogram.h.

Definition at line 93 of file RpcDataHistogram.h.

unsigned int RpcDataHistogram::m_lastRtmTrigSec [private]

Definition at line 94 of file RpcDataHistogram.h.

Definition at line 95 of file RpcDataHistogram.h.

unsigned int RpcDataHistogram::m_last4FoldSec [private]

Definition at line 96 of file RpcDataHistogram.h.

unsigned int RpcDataHistogram::m_last4FoldNanoSec [private]

Definition at line 97 of file RpcDataHistogram.h.

unsigned long RpcDataHistogram::m_eventCount [private]

Definition at line 98 of file RpcDataHistogram.h.

char* RpcDataHistogram::m_fecErrType[6] [private]

Definition at line 99 of file RpcDataHistogram.h.

char* RpcDataHistogram::m_rtmErrType[6] [private]

Definition at line 100 of file RpcDataHistogram.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:02:12 for DQMRawData by doxygen 1.7.4