/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 Attributes
RPCCalibAlg Class Reference

#include <RPCCalibAlg.h>

Collaboration diagram for RPCCalibAlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RPCCalibAlg (const std::string &name, ISvcLocator *svcloc)
 Constructor has to be in this form.
virtual ~RPCCalibAlg ()
StatusCode initialize ()
 Three mandatory member functions of any algorithm.
StatusCode execute ()
StatusCode finalize ()
void getFecRowCol (int EH, int cfId, int fecId, int &row, int &col)
void getRtmRowCol (int EH, int cfId, int bit, int &row, int &col)

Private Attributes

MsgStream m_log
int m_execNum
float m_RPC_layer_square
int isWP_check
int ArrayRow
int EH
int m_output
int m_physics
int m_forced_trigger
int m_forced_trigger_times
int m_count_RPC
int m_Coincidence4 [11][10]
int m_Coincidence3 [11][10][5]
int m_4FoldCount [11][10]
int m_3FoldCount [11][10]
int m_sample_times [11][10]
int m_hit [11][10][5]
float m_readout_timewindow
TimeStamp m_begin_time
TimeStamp m_end_time
ofstream m_rpcoutdat
string m_rpctxtfile
ofstream m_hitmapoutdat
string m_hitmaptxtfile
IDataProviderSvc * m_archiveSvc
string m_muonloc
NTuple::Tuple * m_ntuple
NTuple::Tuple * n_ntuple
NTuple::Tuple * t_ntuple
NTuple::Item< long > m_RPC_Layer_SensorId
NTuple::Item< double > m_Layer_eff
NTuple::Item< double > m_Layer_eff_error
NTuple::Item< double > m_Layer_noise
NTuple::Item< double > m_Layer_noise_error
NTuple::Item< int > m_RPC_Module_Id
NTuple::Item< double > m_ThreeFoldRate
NTuple::Item< double > m_FourFoldRate
NTuple::Item< double > m_runTime
IStatisticsSvc * m_statsSvc
ICableSvcm_cableSvc
string m_rpcToolName
IRPCToolm_rpcTool
TimeStamp m_firstTime

Detailed Description

Definition at line 34 of file RPCCalibAlg.h.


Constructor & Destructor Documentation

RPCCalibAlg::RPCCalibAlg ( const std::string &  name,
ISvcLocator *  svcloc 
)

Constructor has to be in this form.

Definition at line 60 of file RPCCalibAlg.cc.

  : GaudiAlgorithm(name, svcloc), m_log(msgSvc(), name)
    , m_rpcTool(0)
{
  declareProperty("RPCTxtFile", m_rpctxtfile = "test_RPC.txt",
      "RPCTxt File path of calibration params");
  declareProperty("RPCTool",m_rpcToolName = "RPCTool");
  declareProperty("RPCLayerSquare",m_RPC_layer_square = 4.41);
  declareProperty("ReadoutTimeWindow",m_readout_timewindow = 550E-9);
  declareProperty("RpcOutput",m_output = 1,"output RPC Calibration file");
  declareProperty("first_muon_location", m_muonloc = "/Event/Tag/Muon/MuonAll",
      "path for first muon trigger tag");
  declareProperty("isWP_check",isWP_check = 0,
      "water pool check flag");
  declareProperty("ForcedTrigger",m_forced_trigger = 1); 
  m_execNum = 0;
  m_ntuple  = 0;
  n_ntuple  = 0;
  t_ntuple  = 0;
}
RPCCalibAlg::~RPCCalibAlg ( ) [virtual]

Definition at line 81 of file RPCCalibAlg.cc.

{
  cout << "" << endreq;
}

Member Function Documentation

StatusCode RPCCalibAlg::initialize ( )

Three mandatory member functions of any algorithm.

Definition at line 86 of file RPCCalibAlg.cc.

{
  m_log << MSG::DEBUG << "initialize()" << endreq;
  IRPCTool* rpcTool = 0;
  try
  {
    rpcTool = tool<IRPCTool>(m_rpcToolName);
  }
  catch(const GaudiException& exg)
  {
    fatal()<< "Failed to get rpc tool: \""<< m_rpcToolName<< "\""<< endreq;
    return StatusCode::FAILURE;
  }

  StatusCode sc = service("CableSvc", m_cableSvc);
  if( sc.isFailure() ) {
          error() << "Can't get CableSvc" << endreq;
          return sc;
  }

  m_rpcTool = rpcTool;
  for(int i = 0;i <= 10;i++)
    for(int j = 0;j <= 9;j++)
    {
      m_Coincidence4[i][j] = 0;
      m_4FoldCount[i][j] = 0;
      m_3FoldCount[i][j] = 0;
      for(int k = 0;k < 5;k++)
      {
        m_Coincidence3[i][j][k] = 0;
        m_hit[i][j][k] = 0;
      }
    }

  m_count_RPC = 0;

  m_begin_time = 0;
  m_end_time = 0; 

  StatusCode status = service("EventDataArchiveSvc", m_archiveSvc);
  if (status.isFailure()) {
    Error("Service [EventDataArchiveSvc] not found", status);
    return status;
  }

  if(m_output)
  {
    NTuplePtr nt(ntupleSvc(), "FILE1/calibration");
    if ( nt ) m_ntuple = nt;
    else {
      m_ntuple = ntupleSvc()->book("FILE1/calibration", CLID_ColumnWiseTuple, "calibration");
      if ( m_ntuple )    {
        debug() << "Start m_ntuple addItem successful!" << endmsg;
        m_ntuple->addItem ("RPC_Layer_SensorId",m_RPC_Layer_SensorId);
        m_ntuple->addItem ("Layer_efficiency",m_Layer_eff);
        m_ntuple->addItem ("Layer_efficiency_error",m_Layer_eff_error);
        m_ntuple->addItem ("Layer_noise",m_Layer_noise);
        m_ntuple->addItem ("Layer_noise_error",m_Layer_noise_error);
      }
      else { // Did not manage to book the NTuple....
        error() << "Can not book NTuple:" << long(m_ntuple) << endmsg;
        return StatusCode::FAILURE;
      }
    }  
   NTuplePtr nf(ntupleSvc(), "FILE1/nFold");
   if ( nf ) n_ntuple = nf;
   else 
   {

           n_ntuple = ntupleSvc()->book("FILE1/nFold", CLID_ColumnWiseTuple, "nFold");
           if ( n_ntuple )    
           {
                   debug() << "Start n_ntuple addItem successful!" << endmsg;
                   n_ntuple->addItem ("RPC_Module_Id",m_RPC_Module_Id);
                   n_ntuple->addItem ("3FoldRate",m_ThreeFoldRate);
                   n_ntuple->addItem ("4FoldRate",m_FourFoldRate);
           }
           else { // Did not manage to book the NTuple....
                   error() << "Can not book NTuple:" << long(n_ntuple) << endmsg;
                   return StatusCode::FAILURE;
           }
   }
   NTuplePtr nd(ntupleSvc(), "FILE1/runTime");
   if ( nd ) t_ntuple = nd;
   else
   {

           t_ntuple = ntupleSvc()->book("FILE1/runTime", CLID_ColumnWiseTuple, "runTime");
           if ( t_ntuple )
           {
                   debug() << "Start n_ntuple addItem successful!" << endmsg;
                   t_ntuple->addItem ("runTime",m_runTime);
           }
           else { // Did not manage to book the NTuple....
                   error() << "Can not book NTuple:" << long(t_ntuple) << endmsg;
                   return StatusCode::FAILURE;
           }
   }
    m_rpcoutdat.open(m_rpctxtfile.c_str(), ios::out|ios::trunc);
    if(!m_rpcoutdat)
    {    
      error()<< "Open"<< m_rpctxtfile<< " file error!"<< endreq;
      return StatusCode::FAILURE;
    }
  }
  return StatusCode::SUCCESS;
}
StatusCode RPCCalibAlg::execute ( )

Definition at line 194 of file RPCCalibAlg.cc.

{
  m_log << MSG::DEBUG << "execute() ______________________________ start" << endreq;
  debug() << "@ excute" <<endreq;
  //----------------------------------------------------------------------------------------
  
  m_execNum++;

  std::vector<int> hit_module,hit_layer,trigger_module,neighbor,noise_module;
  int layer_hitnumber[11][10] = {0},strip_hitnumber[11][10][5] = {0};
   int x_strip[11][10][9] = {0},y_strip[11][10][9] = {0};
  int module_hitnumber[11][10] = {0};// calculate the total hit layer number of hit modules in each event
  int rpcRow, rpcCol,rpcLayer,rpcStrip;
  int layer_number;
  bool isWP_trigger = false;
  bool isRPC_trigger = false;
  
  std::vector<int> FEC_trigger;
  
  std::vector<const IHeader*> rhs;
  ReadoutHeader* readoutHeader;
  int size = 0;
  if(!isWP_check)
  {
    isWP_trigger = true;
    size = 1;
  }
 // if(isWP_check&&exist<HeaderObject>(m_muonloc))// calculate eff and if force trigger is not active calculate noise  
  if(exist<HeaderObject>(m_muonloc))// calculate eff and if force trigger is not active calculate noise  
    {   
    HeaderObject *muonAllTag = get<HeaderObject>(m_muonloc);
    rhs = muonAllTag->findHeaders(ReadoutHeader::classID());
    size = rhs.size();
    }
   for(int i = 0; i < size; i++)
   {
      if(!isWP_check) 
        { 
          readoutHeader = get<ReadoutHeader>("/Event/Readout/ReadoutHeader"); 
        } 

      else
      {
       IHeader* rHeader = const_cast<IHeader*>(rhs[i]);
       readoutHeader = dynamic_cast<ReadoutHeader*>(rHeader);
       }
    if ( readoutHeader == 0 ) 
    {
      error() << "Failed to get ReadoutHeader" << endreq;
      return StatusCode::FAILURE;
    
    }
    if (m_begin_time.GetSec() == 0) m_begin_time = readoutHeader->context().GetTimeStamp();
    else m_end_time = readoutHeader->context().GetTimeStamp();

    if(readoutHeader->context().GetDetId() == DetectorId::kOWS || readoutHeader->context().GetDetId() == DetectorId::kIWS)
    {
      isWP_trigger = true;
    }

    if(readoutHeader->context().GetDetId() == DetectorId::kRPC)
    {
      isRPC_trigger = true;
      m_count_RPC++;
      debug()<<"RPC event number = "<<m_count_RPC<<endreq;
    }
    const EventReadout* event = 0;
    const DaqCrate* daqCrate = readoutHeader->daqCrate();
    if ( daqCrate == 0 ) {
      const Readout* readout = readoutHeader->readout();
      if ( readout == 0 ) {
        error() << "Failed to get DAQ readout or readout from header" << endreq;
        return StatusCode::FAILURE;
      }
      event = readout->eventReadout();
      if ( event ==  0 ) {
        error() << "Failed to get event readout from readout" << endreq;
        return StatusCode::FAILURE;
      }
    }
    else {
      event = &(daqCrate->eventReadout());
    }
    const DybDaq::EventHeader* eventHeader = &(event->header());
    EH = eventHeader->site();
    if(EH<1||EH>3)
    {
     error() <<"EH is wrong! EH = " << EH << endreq;        
          return StatusCode::FAILURE;
    }
    if(isRPC_trigger)
    {       
    static const EventTraits& eventTraits = dynamic_cast<const EventTraits&>(event->header().daqTraits());
    static const unsigned int kRpcRomModuleType = eventTraits.moduleType(EventTraits::kRpcRomModule);
    static const unsigned int kRpcRtmModuleType = eventTraits.moduleType(EventTraits::kRpcRtmModule);

    const EventReadout::RomFragmentPtrList& fragments = event->romFragments();
 
    for (EventReadout::RomFragmentPtrList::const_iterator fragment = fragments.begin();
        fragment != fragments.end(); ++fragment) {
      const RomHeader& header = (*fragment)->header();
      if ( kRpcRomModuleType == header.moduleType() ) {
         ServiceMode svcMode(readoutHeader->context(),0 );     
        const FecReadout& fecReadout = dynamic_cast<const FecReadout&>((*fragment)->unwrappedData());
        const FecReadout::FecDataPtrList& fecList = fecReadout.fecDataList();
        FecReadout::FecDataPtrList::const_iterator fecData = fecList.begin();
        while ( fecData != fecList.end() )
        {
          int cfId=(*fecData)->rpcCFId();
          int fecId=(*fecData)->rpcFecId();
          //getFecRowCol(EH, cfId, fecId,rpcRow,rpcCol);
          //the following two lines are  for the electronics bug that sometime rtm data is lost.
          if((*fecData)->trigType()==3&&find(trigger_module.begin(),trigger_module.end(),rpcRow*10 + rpcCol) == trigger_module.end())
                                            trigger_module.push_back(rpcRow*10 + rpcCol);
          if((*fecData)->trigType()==3) 
          for(int i = 0;i<32;i++)
          {
            if(((*fecData)->hitMap()>>i)&1 == 1)
            {
              debug()<<std::dec<<((*fecData)->hitMap()>>i&1)<<endreq;
              //rpcLayer =i/8 + 1;
              //rpcStrip =i%8 + 1;// the index starts from 1 to 8
              DayaBay::FecChannelId* fecChId;
              if(EH==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(EH),DetectorId::DetectorId_t(7));
              DayaBay::RpcSensor sensor = m_cableSvc->rpcSensor(*fecChId, svcMode);
              rpcRow = sensor.panelRow();
              rpcCol = sensor.panelColumn();
              rpcLayer = sensor.layer();
              rpcStrip = sensor.strip();
              debug()<<std::dec<<"rpcRow="<<rpcRow<<",rpcCol="<<rpcCol<<",rpcLayer="<<rpcLayer<<",rpcStrip="<<rpcStrip<<endreq;
              layer_number = rpcRow*100+rpcCol*10+rpcLayer;
              if(find(hit_layer.begin(),hit_layer.end(),layer_number) == hit_layer.end())// find different layers in each module 
              {
                hit_layer.push_back(layer_number);// push the differnet hit layer number into a vector
                module_hitnumber[rpcRow][rpcCol]++;// calculate the layer hit number in one module of each event
                layer_hitnumber[rpcRow][rpcCol] +=  rpcLayer;
                if(rpcLayer == 1 || rpcLayer == 4)
                {
                        x_strip[rpcRow][rpcCol][rpcStrip]++;
                }
                else
                {
                        y_strip[rpcRow][rpcCol][rpcStrip]++;
                }
              }

              if(find(hit_module.begin(),hit_module.end(),rpcRow*10 + rpcCol) == hit_module.end())
                hit_module.push_back(rpcRow*10 + rpcCol);

              strip_hitnumber[rpcRow][rpcCol][rpcLayer]++;// calculate the strip hit number of each layer in each event 
            }
          } 

          ++fecData;
        }
      }
      else if(kRpcRtmModuleType == header.moduleType()){
        const RtmReadout& rtmReadout = dynamic_cast<const RtmReadout&>((*fragment)->unwrappedData());
        const RtmReadout::RtmDataPtrList& rtmList = rtmReadout.rtmDataList();
        RtmReadout::RtmDataPtrList::const_iterator rtmData = rtmList.begin();
        while ( rtmData != rtmList.end() ) {
          if((*rtmData)->triggerRot() != 0)
            for(int i=0;i<32;i++)
            {
              if(i == 15 || i ==31)
                continue;
                 
              if(((*rtmData)->triggerRot()>>i)&1==1)
              {
                int cfId=(*rtmData)->rpcCFId();      
                if(cfId==2&&i==30) continue;// deal with a bug in the 3rd CF in EH3
                getRtmRowCol(EH,cfId,i,rpcRow,rpcCol);
                if(find(trigger_module.begin(),trigger_module.end(),rpcRow*10 + rpcCol) == trigger_module.end())
                  trigger_module.push_back(rpcRow*10 + rpcCol);
              }
            }
          ++rtmData;
        }
      }
    }
   }
   }
   for(vector<int>::const_iterator it = hit_module.begin();it != hit_module.end();++it)
   {
           int r = *it/10;
           int c = *it%10;
           if(module_hitnumber[r][c] == 4)
           {
                   m_4FoldCount[r][c]++;

           }
           if(module_hitnumber[r][c] >= 3)
           {
                   m_3FoldCount[r][c]++;
           }
   }
  if(isWP_trigger)
  {
    for(vector<int>::const_iterator it = hit_module.begin();it != hit_module.end();++it)
    {
      int r = *it/10;
      int c = *it%10;
      // use a cut to to select gold muons for efficiency calculation.
      // 1. the total number of strip  hit for each layer should not be over 3
     // 2. the average strip  hit number for the active layers should be not over 2.0
     int flag = 1;
    for(int l=1;l<5;l++)
     {
     if(strip_hitnumber[r][c][l]>1)
         {
                 flag = 0;
                 break;
         }
     }
     
  //   if((strip_hitnumber[r][c][1]+strip_hitnumber[r][c][2]+strip_hitnumber[r][c][3]+strip_hitnumber[r][c][4])*1.0/module_hitnumber[r][c] > 2.0)
 //          flag = 0;
  
     if(flag==1)
       {
             if(module_hitnumber[r][c] == 4)
             {
                     for(int i = 1;i <= 8;i++)
                     {    if(y_strip[r][c][i] == 2||x_strip[r][c][i] == 2) 
                             {
                                  m_Coincidence4[r][c]++;
                                  break;
                             }
                       }
             }
             else if(module_hitnumber[r][c] == 3)
             {
                             for(int i = 1;i <= 8;i++) 
                             { 
                                     if(x_strip[r][c][i] == 2||y_strip[r][c][i] == 2) 
                                     { 
                                             m_Coincidence3[r][c][10 - layer_hitnumber[r][c]]++; 
                                             break; 
                                     } 
                             }
             }
      }

    }
 }

  if(!m_forced_trigger)// need improvement
  {
  /*  for(int i = 0;i <= ArrayRow + 1;i++)
            for(int j = 0;j <= 9;j++)
            {
                    if(j==5&&(i==0||i==ArrayRow+1)) noise_module.push_back(i*10+j);
                    else if(i!=ArrayRow+1&&i!=0&&j!=0) noise_module.push_back(i*10+j);
            }
    for(vector<int>::const_iterator it = noise_module.begin();it != noise_module.end();++it)
    {
            //make sure that it's not  an accidental 3(4)-fold muon
            if(module_hitnumber[*it/10][*it%10] < 3)
            {
                    m_sample_times[*it/10][*it%10]++; //sampling times for a module
            }
    }

    //std::cout<<"num of hits in a forced trigger evt : "<<hit_layer.size()<<std::endl;
    for(vector<int>::const_iterator it = hit_layer.begin();it != hit_layer.end();++it)
    {
            rpcRow = *it/100;
            rpcCol = (*it/10)%10;
            rpcLayer = *it%10;
            if(module_hitnumber[rpcRow][rpcCol] < 3)
            {
                    m_hit[rpcRow][rpcCol][rpcLayer]++;// calculate the layer noise
            }
    }*/
    } 
  
  if(m_forced_trigger)
  {
   readoutHeader = get<ReadoutHeader>("/Event/Readout/ReadoutHeader");
   if ( readoutHeader == 0 )
   {
           error() << "Failed to get ReadoutHeader" << endreq;
           return StatusCode::FAILURE;
   }     
   const EventReadout* event = 0;
   const DaqCrate* daqCrate = readoutHeader->daqCrate();
   if ( daqCrate == 0 ) 
   {
           const Readout* readout = readoutHeader->readout();
           if ( readout == 0 ) {
                   error() << "Failed to get DAQ readout or readout from header" << endreq;
                   return StatusCode::FAILURE;}
           event = readout->eventReadout();
           if ( event ==  0 ) {
                   error() << "Failed to get event readout from readout" << endreq;
                   return StatusCode::FAILURE; }
   }
   else {
           event = &(daqCrate->eventReadout()); }
   static const EventTraits& eventTraits = dynamic_cast<const EventTraits&>(event->header().daqTraits());
   static const unsigned int kRpcRomModuleType = eventTraits.moduleType(EventTraits::kRpcRomModule);
   static const unsigned int kRpcRtmModuleType = eventTraits.moduleType(EventTraits::kRpcRtmModule);

   const EventReadout::RomFragmentPtrList& fragments = event->romFragments();
   for (EventReadout::RomFragmentPtrList::const_iterator fragment = fragments.begin();
                   fragment != fragments.end(); ++fragment) 
   {
           const RomHeader& header = (*fragment)->header();
           if ( kRpcRomModuleType == header.moduleType() )
           {
                   const FecReadout& fecReadout = dynamic_cast<const FecReadout&>((*fragment)->unwrappedData());
                   const FecReadout::FecDataPtrList& fecList = fecReadout.fecDataList();
                   FecReadout::FecDataPtrList::const_iterator fecData = fecList.begin();
                   while ( fecData != fecList.end() ) 
                   {
                        if((*fecData)->forceTrigger()&&(*fecData)->trigType()!=3)
                         { int cfId=(*fecData)->rpcCFId();
                           int fecId=(*fecData)->rpcFecId();
                           getFecRowCol(EH, cfId, fecId,rpcRow,rpcCol);
                           
                           m_sample_times[rpcRow][rpcCol]++; //sampling times for a module
                           for(int i = 0;i<32;i++)
                           {
                            if(((*fecData)->hitMap()>>i)&1 == 1)
                            { 
                             rpcLayer =i/8 + 1;
                             m_hit[rpcRow][rpcCol][rpcLayer]++;
                             debug()<<std::dec<<"rpcRow="<<rpcRow<<",rpcCol="<<rpcCol<<",rpcLayer="<<rpcLayer<<",rpcStrip="<<rpcStrip<<endreq;
                           }
                          }
                         }  
                           ++fecData;
                   }
           }
     }
  
   }
  //----------------------------------------------------------------------------------------

  m_log << MSG::DEBUG << "execute() ______________________________ end" << endreq;
  return StatusCode::SUCCESS;
}
StatusCode RPCCalibAlg::finalize ( )

Definition at line 540 of file RPCCalibAlg.cc.

{ 
  double layer_efficiency[5],layer_noise_rate[5];
  double layer_efficiency_error[5],layer_noise_rate_error[5];
  int range = 1000000000;
  double runTime = m_end_time.GetSec()-m_begin_time.GetSec() + (m_end_time.GetNanoSec()-m_begin_time.GetNanoSec())/range;
  
  if(m_output = 1)
  {
    m_rpcoutdat<<"#Table"<<endl;
//    m_rpcoutdat<<"EH"<<EH<<"#";
//    m_rpcoutdat<<" RPC Calibration result"<<endl;
//    m_rpcoutdat<<"Run Time (Seconds):"<<runTime<<endl;
    m_rpcoutdat<<"#[RpcSensorId]\t[Efficiency]\t[EfficiencyError]\t[NoiseRate]\t[NoiseRateError]"<<endl;
    if((EH == 1)||(EH == 2))
                    ArrayRow = 6;
      else if(EH == 3)
                     ArrayRow = 9;
    for(int i = 0;i <= ArrayRow + 1;i++)
      for(int j = 1;j <= 9;j++)
      {
              
          if((i == 0)&&(j != 5)||(i == ArrayRow + 1)&&(j != 5))
                  continue;
        for(int k = 1;k <= 4;k++)
        { 
          if((m_Coincidence3[i][j][k] + m_Coincidence4[i][j]) == 0)
          {
            layer_efficiency[k] = 0.0;
          }
          else
          {
            layer_efficiency[k] = m_Coincidence4[i][j]*1.0/(m_Coincidence3[i][j][k]+m_Coincidence4[i][j]);
            layer_efficiency_error[k] = sqrt(layer_efficiency[k]*(1.0-layer_efficiency[k])/(m_Coincidence3[i][j][k]+m_Coincidence4[i][j]));
          }
        }
        for(int k = 1;k <= 4;k++)
        {
          if(m_sample_times[i][j] > 0) 
          {
            layer_noise_rate[k] = m_hit[i][j][k]*1.0/(m_readout_timewindow * m_sample_times[i][j] * m_RPC_layer_square);
            layer_noise_rate_error[k] = sqrt(m_hit[i][j][k]*1.0)/(m_readout_timewindow * m_sample_times[i][j] * m_RPC_layer_square);
          }
          else {
            layer_noise_rate[k] = 0.0;
            layer_noise_rate_error[k] = 0.0; 
          }

          DayaBay::RpcSensor rpcSensor(i,j,k,0,kDayaBay,kRPC);// which Hall ?
          m_RPC_Layer_SensorId = rpcSensor.fullPackedData();
          m_Layer_eff = layer_efficiency[k];
          m_Layer_eff_error = layer_efficiency_error[k];
          m_Layer_noise = layer_noise_rate[k];
          m_Layer_noise_error = layer_noise_rate_error[k];

          m_ntuple->write(); 

          m_rpcoutdat<<rpcSensor.fullPackedData()<<"\t";
//          m_rpcoutdat<<"  "<<i<<"  "<<j<<"  "<<k<<"  ";
          m_rpcoutdat<<setiosflags(ios::fixed)<<setprecision(4);
          m_rpcoutdat<<layer_efficiency[k]<<"\t";
          m_rpcoutdat<<setiosflags(ios::fixed)<<setprecision(4);
          m_rpcoutdat<<layer_efficiency_error[k]<<"\t";
          m_rpcoutdat<<setiosflags(ios::fixed)<<setprecision(1);
          m_rpcoutdat<<layer_noise_rate[k]<<"\t";
          m_rpcoutdat<<setiosflags(ios::fixed)<<setprecision(1);
          m_rpcoutdat<<layer_noise_rate_error[k]<<endl;
        }
        m_RPC_Module_Id  = i*10+j;
        m_ThreeFoldRate = m_3FoldCount[i][j]/runTime/m_RPC_layer_square ;
        m_FourFoldRate = m_4FoldCount[i][j]/runTime/m_RPC_layer_square ;
        n_ntuple->write();
      }
    m_runTime = runTime;
    t_ntuple->write();
    m_rpcoutdat.close();
  }
  debug() << MSG::DEBUG << "finalize()" << endreq;
  return StatusCode::SUCCESS;
}
void RPCCalibAlg::getFecRowCol ( int  EH,
int  cfId,
int  fecId,
int &  row,
int &  col 
)

Definition at line 620 of file RPCCalibAlg.cc.

{
        if (EH==1||EH==2)
        {
                int cfRow = cfId/2;
                if(cfId%2 == 0) //left
                {
                        row = 6 - (fecId/5 + cfRow * 3);
                        col = fecId%5 + 1; 
                }
                else   //right
                {
                        if(fecId == 14)
                        {
                                if(cfId == 3)
                                {
                                        row = 0;
                                        col = 5;
                                }
                                else if(cfId == 1)
                                {
                                        row = 7;
                                        col = 5;
                                }
                        }
                        else
                        {
                                row = 6 - (fecId/4 +cfRow * 3);// the index starts from 1
                                col =  fecId%4 + 6;// the index starts from 1
                        }
                }
        }
        else
        {
                if(cfId ==3&&fecId==14)
                {
                        row = 0; 
                        col = 5; 
                }   
                else if(cfId==1&&fecId==14)
                {
                        row = 10;
                        col = 5;
                }
                else
                {

                        int cfC = cfId/2;
                        if(cfC!=1)
                        {
                                if(cfId%2==0) //bottom
                                {
                                        col = fecId/5 + cfC * 3;
                                        row = fecId%5;
                                }
                                else    //top 
                                {
                                        col = fecId/4 +cfC*3;
                                        row =  fecId%4 + 5;
                                }
                        }
                        else //rot2 and rot3 in EH3
                        {
                                if(cfId%2==0) //top
                                {
                                        col = fecId/5 + cfC * 3;
                                        row = (4-fecId%5) + 4;
                                }
                                else    //bottom 
                                {
                                        col = fecId/4 +cfC*3;
                                        row =  (3-fecId%4);
                                }
                        }
                        row = row + 1;
                        col = col + 1;
                }
        }

}
void RPCCalibAlg::getRtmRowCol ( int  EH,
int  cfId,
int  bit,
int &  row,
int &  col 
)

Definition at line 700 of file RPCCalibAlg.cc.

{
        if(EH==1||EH==2)
        {
                if(bit<15)
                {
                        row = 5-( bit/5 + cfId * 3) + 1;
                        col = bit%5 +1;
                }
                else
                {
                        if( bit==30 && cfId == 0)
                        {
                                row = 7;
                                col = 5;
                        }
                        else if (bit==30 && cfId == 1)
                        {
                                row = 0;
                                col = 5;
                        }
                        else
                        {
                                row = 5- ((bit-16)/4 + cfId * 3) +1;
                                col = 5+(bit-16)%4 +1 ;
                        }

                }
        }
        else //Hall #3
        {
                if(cfId!=1)
                {
                        if(bit<15)
                        {
                                col = bit/5 + cfId * 3 + 1;
                                row = bit%5 +1;
                        }
                        else
                        {
                                if( bit==30 && cfId == 0)
                                {
                                        row = 10;
                                        col = 5;
                                }
                                else if(bit<28)
                                {
                                        col = (bit-16)/4 + cfId * 3 +1;
                                        row = 5+(bit-16)%4 +1 ;
                                }

                        }
                }
                else //cfId ==1
                {

                        if(bit<15)
                        {
                                col = bit/5 + cfId * 3 + 1;
                                row = 10 - bit%5 -1;
                        }
                        else
                        {
                                if( bit==30 && cfId == 1)
                                {
                                        row = 0;
                                        col = 5;
                                }
                                else if(bit<28)
                                {
                                        col = (bit-16)/4 + cfId * 3 +1;
                                        row = 10 - 5 - (bit-16)%4 -1 ;
                                }

                        }

                }
        }

}

Member Data Documentation

MsgStream RPCCalibAlg::m_log [mutable, private]

Definition at line 48 of file RPCCalibAlg.h.

int RPCCalibAlg::m_execNum [private]

Definition at line 49 of file RPCCalibAlg.h.

Definition at line 50 of file RPCCalibAlg.h.

int RPCCalibAlg::isWP_check [private]

Definition at line 51 of file RPCCalibAlg.h.

int RPCCalibAlg::ArrayRow [private]

Definition at line 52 of file RPCCalibAlg.h.

int RPCCalibAlg::EH [private]

Definition at line 53 of file RPCCalibAlg.h.

int RPCCalibAlg::m_output [private]

Definition at line 54 of file RPCCalibAlg.h.

int RPCCalibAlg::m_physics [private]

Definition at line 55 of file RPCCalibAlg.h.

Definition at line 56 of file RPCCalibAlg.h.

Definition at line 57 of file RPCCalibAlg.h.

int RPCCalibAlg::m_count_RPC [private]

Definition at line 58 of file RPCCalibAlg.h.

int RPCCalibAlg::m_Coincidence4[11][10] [private]

Definition at line 60 of file RPCCalibAlg.h.

int RPCCalibAlg::m_Coincidence3[11][10][5] [private]

Definition at line 61 of file RPCCalibAlg.h.

int RPCCalibAlg::m_4FoldCount[11][10] [private]

Definition at line 62 of file RPCCalibAlg.h.

int RPCCalibAlg::m_3FoldCount[11][10] [private]

Definition at line 63 of file RPCCalibAlg.h.

int RPCCalibAlg::m_sample_times[11][10] [private]

Definition at line 64 of file RPCCalibAlg.h.

int RPCCalibAlg::m_hit[11][10][5] [private]

Definition at line 65 of file RPCCalibAlg.h.

Definition at line 68 of file RPCCalibAlg.h.

Definition at line 70 of file RPCCalibAlg.h.

Definition at line 71 of file RPCCalibAlg.h.

ofstream RPCCalibAlg::m_rpcoutdat [private]

Definition at line 73 of file RPCCalibAlg.h.

string RPCCalibAlg::m_rpctxtfile [private]

Definition at line 74 of file RPCCalibAlg.h.

ofstream RPCCalibAlg::m_hitmapoutdat [private]

Definition at line 75 of file RPCCalibAlg.h.

string RPCCalibAlg::m_hitmaptxtfile [private]

Definition at line 76 of file RPCCalibAlg.h.

IDataProviderSvc* RPCCalibAlg::m_archiveSvc [private]

Definition at line 78 of file RPCCalibAlg.h.

string RPCCalibAlg::m_muonloc [private]

Definition at line 79 of file RPCCalibAlg.h.

NTuple::Tuple* RPCCalibAlg::m_ntuple [private]

Definition at line 82 of file RPCCalibAlg.h.

NTuple::Tuple* RPCCalibAlg::n_ntuple [private]

Definition at line 83 of file RPCCalibAlg.h.

NTuple::Tuple* RPCCalibAlg::t_ntuple [private]

Definition at line 84 of file RPCCalibAlg.h.

NTuple::Item<long> RPCCalibAlg::m_RPC_Layer_SensorId [private]

Definition at line 85 of file RPCCalibAlg.h.

NTuple::Item<double> RPCCalibAlg::m_Layer_eff [private]

Definition at line 86 of file RPCCalibAlg.h.

NTuple::Item<double> RPCCalibAlg::m_Layer_eff_error [private]

Definition at line 87 of file RPCCalibAlg.h.

NTuple::Item<double> RPCCalibAlg::m_Layer_noise [private]

Definition at line 88 of file RPCCalibAlg.h.

NTuple::Item<double> RPCCalibAlg::m_Layer_noise_error [private]

Definition at line 89 of file RPCCalibAlg.h.

NTuple::Item<int> RPCCalibAlg::m_RPC_Module_Id [private]

Definition at line 90 of file RPCCalibAlg.h.

NTuple::Item<double> RPCCalibAlg::m_ThreeFoldRate [private]

Definition at line 91 of file RPCCalibAlg.h.

NTuple::Item<double> RPCCalibAlg::m_FourFoldRate [private]

Definition at line 92 of file RPCCalibAlg.h.

NTuple::Item<double> RPCCalibAlg::m_runTime [private]

Definition at line 93 of file RPCCalibAlg.h.

IStatisticsSvc* RPCCalibAlg::m_statsSvc [private]

Definition at line 97 of file RPCCalibAlg.h.

Definition at line 98 of file RPCCalibAlg.h.

string RPCCalibAlg::m_rpcToolName [private]

Definition at line 100 of file RPCCalibAlg.h.

Definition at line 103 of file RPCCalibAlg.h.

Definition at line 105 of file RPCCalibAlg.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:09:35 for RPCCalib by doxygen 1.7.4