MicrorocSCReader Class Reference

#include <MicrorocSCReader.hh>

Collaboration diagram for MicrorocSCReader:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MicrorocSCReader (Run &aRun, std::string &data, ui16 difId)
 MicrorocSCReader (Run &aRun)
 MicrorocSCReader (Run &aRun, std::vector< int >, ui16 difId)
 ~MicrorocSCReader ()
ui16 getBit (ui16 bitNum) const
ui16 getChannelDac (ui16 channelId) const
ui16 getLowShaper () const
ui16 getHighShaper () const
ui32 getChipDac (ui16 dac) const
ui16 getChipId () const
void parseSC (ui16 difId)
void parseSCFromDb (IlcConfDb &ilcconf)

Private Types

 low_shaper_bit_1 = 69
 low_shaper_bit_0 = 70
 high_shaper_bit_1 = 73
 high_shaper_bit_0 = 74
 dac_channel_pos = 75
 chip_id = 530
 chip_dac0 = 542
 chip_dac1 = 552
 chip_dac2 = 562
 dac_chip_nbits = 10
 dac_channel_nbits = 4
enum  index_t {
  low_shaper_bit_1 = 69, low_shaper_bit_0 = 70, high_shaper_bit_1 = 73, high_shaper_bit_0 = 74,
  dac_channel_pos = 75, chip_id = 530, chip_dac0 = 542, chip_dac1 = 552,
  chip_dac2 = 562, dac_chip_nbits = 10, dac_channel_nbits = 4
}

Private Member Functions

std::vector< bool > convertCTEST (std::string chaine)
void init (std::string)
void init (std::vector< int >)

Private Attributes

unsigned int bitsSize
unsigned int bitsIndex
Runrun
bool initialised
std::vector< std::bitset< 592 > > bits

Detailed Description

Definition at line 23 of file MicrorocSCReader.hh.


Member Enumeration Documentation

enum MicrorocSCReader::index_t [private]

Enumerator:
low_shaper_bit_1 
low_shaper_bit_0 
high_shaper_bit_1 
high_shaper_bit_0 
dac_channel_pos 
chip_id 
chip_dac0 
chip_dac1 
chip_dac2 
dac_chip_nbits 
dac_channel_nbits 

Definition at line 58 of file MicrorocSCReader.hh.

00058             {
00059   low_shaper_bit_1  = 69,  // poids fort
00060   low_shaper_bit_0  = 70 , // poids faible
00061 
00062   high_shaper_bit_1 = 73,  // poids fort
00063   high_shaper_bit_0 = 74 , // poids faible
00064 
00065   dac_channel_pos   = 75,
00066   chip_id           = 530,
00067   chip_dac0         = 542,
00068   chip_dac1         = 552,
00069   chip_dac2         = 562,
00070   dac_chip_nbits    = 10,
00071   dac_channel_nbits = 4
00072 } index_t;


Constructor & Destructor Documentation

MicrorocSCReader::MicrorocSCReader ( Run aRun,
std::string &  data,
ui16  difId 
)

MicrorocSCReader::MicrorocSCReader ( Run aRun  ) 

Definition at line 43 of file MicrorocSCReader.cpp.

00044 : run(aRun), initialised(false) , bitsSize(0), bitsIndex(0)
00045 {
00046 }

MicrorocSCReader::MicrorocSCReader ( Run aRun,
std::vector< int >  ,
ui16  difId 
)

Definition at line 35 of file MicrorocSCReader.cpp.

00036 : run(aRun), initialised(false)  , bitsSize(0), bitsIndex(0)
00037 {
00038   init(aData);
00039  // parseSC(difId);
00040   
00041 }

MicrorocSCReader::~MicrorocSCReader (  ) 

Definition at line 49 of file MicrorocSCReader.cpp.

00051 {
00052 }


Member Function Documentation

ui16 MicrorocSCReader::getBit ( ui16  bitNum  )  const

Definition at line 242 of file MicrorocSCReader.cpp.

Referenced by getChannelDac(), getChipDac(), getChipId(), getHighShaper(), and getLowShaper().

00243 {
00244         return bits[bitsIndex][bitNum-1];
00245 }

ui16 MicrorocSCReader::getChannelDac ( ui16  channelId  )  const

Definition at line 263 of file MicrorocSCReader.cpp.

Referenced by parseSC().

00264 {
00265   ui16 bit0Pos = dac_channel_pos + (channelId * dac_channel_nbits );
00266   ui16 bit0 = getBit(bit0Pos);
00267   ui16 bit1 = getBit(bit0Pos+1);
00268   ui16 bit2 = getBit(bit0Pos+2);
00269   ui16 bit3 = getBit(bit0Pos+3);
00270 
00271 
00272  return ( bit0 + bit1*2 + bit2 *4 + bit3*8 );
00273 }

ui16 MicrorocSCReader::getLowShaper (  )  const

Definition at line 276 of file MicrorocSCReader.cpp.

Referenced by parseSC().

00277 {
00278         ui16 bit0 = getBit(low_shaper_bit_0);
00279         ui16 bit1 = getBit(low_shaper_bit_1);
00280         return bit0 + bit1*2;
00281 }

ui16 MicrorocSCReader::getHighShaper (  )  const

Definition at line 284 of file MicrorocSCReader.cpp.

Referenced by parseSC().

00285 {
00286         ui16 bit0 = getBit(high_shaper_bit_0);
00287         ui16 bit1 = getBit(high_shaper_bit_1);
00288         return bit0 + bit1*2;
00289 }

ui32 MicrorocSCReader::getChipDac ( ui16  dac  )  const

Definition at line 292 of file MicrorocSCReader.cpp.

Referenced by parseSC().

00293 {
00294 
00295 //complemant a 1 sur chaque bit.
00296 // bit 9 est le bt de poids faible, le bit 0 est le bit de poids fort
00297 
00298   ui16 index = 0;
00299   if ( dac == 0 ) { index = chip_dac0; }
00300   else if ( dac == 1 ) { index = chip_dac1; }
00301   else if ( dac == 2 ) { index = chip_dac2; }
00302   else {  FILE_LOG(logINFO) << "dac"<< dac << " does not exist" << endl; exit(-1) ;   }
00303 
00304         ui16 bit0 = !getBit(index);
00305         ui16 bit1 = !getBit(index+1);
00306         ui16 bit2 = !getBit(index+2);
00307         ui16 bit3 = !getBit(index+3);
00308         ui16 bit4 = !getBit(index+4);
00309         ui16 bit5 = !getBit(index+5);
00310         ui16 bit6 = !getBit(index+6);
00311         ui16 bit7 = !getBit(index+7);
00312         ui16 bit8 = !getBit(index+8);
00313         ui16 bit9 = !getBit(index+9);
00314 
00315 
00316   ui32 result =  bit9 + bit8*2 + bit7*4 + bit6*8 + bit5*16 + bit4*32 + bit3*64 + bit2*128 + bit1*256 + bit0*512 ;
00317 
00318     
00319   return result;
00320 }

ui16 MicrorocSCReader::getChipId (  )  const

Definition at line 249 of file MicrorocSCReader.cpp.

Referenced by parseSC().

00250 {
00251   ui16 result = getBit(chip_id) << 7;  // bit0
00252 FILE_LOG(logDEBUG1) <<  "MicrorocSCReader::getChipId bit0[" << getBit(chip_id) << "]"  << endl;
00253 
00254   for ( ui16 bit = 1 ; bit <= 7 ; bit++)
00255   {
00256 FILE_LOG(logDEBUG1) <<  "MicrorocSCReader::getChipId bit" << bit <<"[" <<  getBit(chip_id+bit) << "]"  << endl;
00257     result = result + ( getBit(chip_id+bit) << 7-bit ); 
00258   }
00259 
00260  return result;
00261 }

void MicrorocSCReader::parseSC ( ui16  difId  ) 

Definition at line 184 of file MicrorocSCReader.cpp.

Referenced by CalibMicrorocParser::getNextEvent(), MicrorocOldLabviewReader::getScData(), and MicrorocMergeReader::getScData().

00185 {
00186 
00187     FILE_LOG(logDEBUG) << "MicrorocSCReader::parseSC sizeof bits[" <<bits.size() << "]" << endl;
00188 // get chip then store its information
00189     Detector& detector = run.getDetector();
00190     bitsIndex= 0;
00191 
00192     for ( unsigned int index = 0; index <  bits.size() ; index++ )
00193     {
00194             ui16 chipId = getChipId();
00195             try {
00196         //          ChamberMap_t chambers = detector.getChambers();
00197         //          Chamber& chamber = *(chambers.begin()->second);
00198 
00199         //        ui16 chipId = getChipId();
00200                   Dif& dif = detector.getDifById(difId);
00201                   MicrorocChip &chip = dynamic_cast<MicrorocChip &> (dif.getChipById(chipId));
00202 
00203                   chip.setShaper_lg(getLowShaper());
00204                   chip.setShaper_hg(getHighShaper());
00205                   ui32 dac0 = getChipDac(0);
00206                   ui32 dac1 = getChipDac(1);
00207                   ui32 dac2 = getChipDac(2);
00208                   // en mode calibration les données DAC change dans le fichier mais pas de le SlowControl
00209                   if ( ! run.isCalibrationRun() )
00210                   {
00211                     chip.setThresholdDac_0(dac0);
00212                     chip.setThresholdDac_1(dac1);
00213                     chip.setThresholdDac_2(dac2);
00214                   }
00215 
00216                   FILE_LOG(logDEBUG1) << "wanted[" << chipId << "] found chip[" << chip.getChipSoftId().toString()  <<endl;
00217                         MicrorocChip &microChip = dynamic_cast<MicrorocChip &> (chip);
00218                   microChip.setBypassed(false);  // if chip SC exist the chip is not bypassed
00219      FILE_LOG(logDEBUG) << "chip[" << chipId << "] set bypass to False"<< endl;
00220                   microChip.setConfigured(true);
00221                   FILE_LOG(logDEBUG) << "chip Id[" << microChip.getId() << "], DAC 0[" << dac0 << "]" << endl;
00222                   FILE_LOG(logDEBUG) << "chip Id[" << microChip.getId() << "], DAC 1[" << dac1 << "]" << endl;
00223                   FILE_LOG(logDEBUG) << "chip Id[" << microChip.getId() << "], DAC 2[" << dac2 << "]" << endl;
00224               for ( int channelNum = 0 ; channelNum <=63; channelNum++)
00225                               {
00226                                       MicrorocChannel &microChannel = dynamic_cast<MicrorocChannel &> (microChip.getChannelById(channelNum));
00227                     ui16 dac = getChannelDac(channelNum);
00228                                       microChannel.setStimulate(true);
00229                                       microChannel.setEnable(true);
00230                                       microChannel.setPedestalOffset(dac);
00231                              }
00232             }
00233             catch (MicroException& e){
00234                   FILE_LOG(logERROR) << "no chip with id[" << dec <<  chipId << "] found " <<endl;
00235           }
00236 
00237         bitsIndex++;
00238         }
00239 }

void MicrorocSCReader::parseSCFromDb ( IlcConfDb ilcconf  ) 

Definition at line 57 of file MicrorocSCReader.cpp.

Referenced by MicrorocXDaqReader::getNextEvent().

00058 {
00059     FILE_LOG(logINFO) << "Get Slowcontrol for run "<< run.getId() << " from IPNL database, it may take a while ..." << endl;
00060     try
00061     {
00062       AsicConfiguration& asicConf = ilcconf.getAsicConfiguration(run.getId() ) ;
00063       vector<ConfigObject*> asics = asicConf.getVector();
00064       FILE_LOG(logDEBUG) <<  "nb asic sc in db[" << asics.size() << "]"  << endl;
00065       for ( unsigned int i = 0 ; i <  asics.size() ; i++ )
00066       {
00067         FILE_LOG(logDEBUG) <<  "asic index[" << i << "]" << endl;
00068         int chipId, difId = 0;
00069         ui32 dac0, dac1 ,dac2 ,shaperLg ,shaperHg = 0;
00070         vector<int> pedestal_offset;
00071         string sstimulate, mask0, mask1, mask2;
00072         vector<bool> stimulate;
00073         try 
00074         {
00075           chipId = asics[i]->getInt("HEADER");
00076           difId = asics[i]->getInt("DIF_ID");
00077           FILE_LOG(logDEBUG) <<  "asic DIF_ID[" << difId << "], Chip ID[" << chipId << "]"  << endl;
00078           dac0 =  asics[i]->getInt("BB0");
00079           dac1 =  asics[i]->getInt("BB1");
00080           dac2 =  asics[i]->getInt("BB2");
00081           shaperLg = asics[i]->getInt("SWLG");
00082           shaperHg = asics[i]->getInt("SWHG");
00083           pedestal_offset =  asics[i]->getIntVector("B0B3");
00084           sstimulate =  asics[i]->getString("CTEST");
00085           stimulate = convertCTEST(sstimulate);
00086           mask0 =  asics[i]->getString("MASK0");
00087           mask1 =  asics[i]->getString("MASK1");
00088           mask2 =  asics[i]->getString("MASK2");
00089 
00090           try {
00091             Dif& dif = run.getDetector().getDifById(difId);
00092 
00093             MicrorocChip &chip = dynamic_cast<MicrorocChip &> (dif.getChipById(chipId));
00094 
00095             chip.setShaper_lg(shaperLg);
00096             chip.setShaper_hg(shaperHg);
00097             chip.setThresholdDac_0(dac0);
00098             chip.setThresholdDac_1(dac1);
00099             chip.setThresholdDac_2(dac2);
00100 
00101             FILE_LOG(logDEBUG1) << "wanted[" << chipId << "] found chip[" << chip.getChipSoftId().toString()  <<endl;
00102             MicrorocChip &microChip = dynamic_cast<MicrorocChip &> (chip);
00103             microChip.setBypassed(false);  // if chip SC exist the chip is not bypassed
00104             microChip.setConfigured(true);
00105             for ( int channelNum = 0 ; channelNum <=63; channelNum++)
00106             {
00107               MicrorocChannel &microChannel = dynamic_cast<MicrorocChannel &> (microChip.getChannelById(channelNum));
00108               microChannel.setStimulate(stimulate[channelNum]);
00109               microChannel.setEnable(true);
00110               microChannel.setPedestalOffset(pedestal_offset[channelNum]);
00111             }
00112           }
00113           catch (MicroException& e)
00114           {
00115             FILE_LOG(logERROR) << "no chip with id[" << dec <<  chipId << "] for Dif[" << difId << "],  found " <<endl;
00116           }
00117           initialised = true;
00118         }
00119         catch  (Exception e){ FILE_LOG(logDEBUG) << "DEBUG Slow control parameter name error fost chip difId[" << difId << "], chipId["<< chipId << "]" << endl;} // Chip is not a microroc
00120       }
00121     }
00122     catch ( MicroException e ) {  FILE_LOG(logERROR) << e.getMessage(); } 
00123 }

std::vector<bool> MicrorocSCReader::convertCTEST ( std::string  chaine  )  [private]

Referenced by parseSCFromDb().

void MicrorocSCReader::init ( std::string   )  [private]

Referenced by MicrorocSCReader().

void MicrorocSCReader::init ( std::vector< int >   )  [private]

Definition at line 125 of file MicrorocSCReader.cpp.

00126 {
00127   ostringstream oss;
00128   unsigned long data;
00129   initialised = true;
00130   
00131   for ( long i = 0 ; i < vec.size()     ;i++ )  // + 1 carcteres ascii ->  4 octets
00132   {
00133     {  // convertit caractere acsii en  uint hexa decimal
00134       data = vec[i];
00135       oss << bitset<8>(data);
00136       data = 0;
00137     }
00138   }
00139 
00140   bitset<592> b(oss.str());
00141   bits.push_back( b);
00142 
00143 
00144 }


Member Data Documentation

unsigned int MicrorocSCReader::bitsSize [private]

Definition at line 45 of file MicrorocSCReader.hh.

unsigned int MicrorocSCReader::bitsIndex [private]

Definition at line 46 of file MicrorocSCReader.hh.

Referenced by getBit(), and parseSC().

Run& MicrorocSCReader::run [private]

Definition at line 51 of file MicrorocSCReader.hh.

Referenced by parseSC(), and parseSCFromDb().

bool MicrorocSCReader::initialised [private]

Definition at line 56 of file MicrorocSCReader.hh.

Referenced by init(), and parseSCFromDb().

std::vector<std::bitset<592> > MicrorocSCReader::bits [private]

Definition at line 75 of file MicrorocSCReader.hh.

Referenced by getBit(), init(), and parseSC().


The documentation for this class was generated from the following files:
Generated on Mon Jan 7 13:18:47 2013 for MicromegasFramework by  doxygen 1.4.7