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 236 of file MicrorocSCReader.cpp.

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

00237 {
00238         return bits[bitsIndex][bitNum-1];
00239 }

ui16 MicrorocSCReader::getChannelDac ( ui16  channelId  )  const

Definition at line 257 of file MicrorocSCReader.cpp.

Referenced by parseSC().

00258 {
00259   ui16 bit0Pos = dac_channel_pos + (channelId * dac_channel_nbits );
00260   ui16 bit0 = getBit(bit0Pos);
00261   ui16 bit1 = getBit(bit0Pos+1);
00262   ui16 bit2 = getBit(bit0Pos+2);
00263   ui16 bit3 = getBit(bit0Pos+3);
00264 
00265 
00266  return ( bit0 + bit1*2 + bit2 *4 + bit3*8 );
00267 }

ui16 MicrorocSCReader::getLowShaper (  )  const

Definition at line 270 of file MicrorocSCReader.cpp.

Referenced by parseSC().

00271 {
00272         ui16 bit0 = getBit(low_shaper_bit_0);
00273         ui16 bit1 = getBit(low_shaper_bit_1);
00274         return bit0 + bit1*2;
00275 }

ui16 MicrorocSCReader::getHighShaper (  )  const

Definition at line 278 of file MicrorocSCReader.cpp.

Referenced by parseSC().

00279 {
00280         ui16 bit0 = getBit(high_shaper_bit_0);
00281         ui16 bit1 = getBit(high_shaper_bit_1);
00282         return bit0 + bit1*2;
00283 }

ui32 MicrorocSCReader::getChipDac ( ui16  dac  )  const

Definition at line 286 of file MicrorocSCReader.cpp.

Referenced by parseSC().

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

ui16 MicrorocSCReader::getChipId (  )  const

Definition at line 243 of file MicrorocSCReader.cpp.

Referenced by parseSC().

00244 {
00245   ui16 result = getBit(chip_id) << 7;  // bit0
00246 FILE_LOG(logDEBUG1) <<  "MicrorocSCReader::getChipId bit0[" << getBit(chip_id) << "]"  << endl;
00247 
00248   for ( ui16 bit = 1 ; bit <= 7 ; bit++)
00249   {
00250 FILE_LOG(logDEBUG1) <<  "MicrorocSCReader::getChipId bit" << bit <<"[" <<  getBit(chip_id+bit) << "]"  << endl;
00251     result = result + ( getBit(chip_id+bit) << 7-bit ); 
00252   }
00253 
00254  return result;
00255 }

void MicrorocSCReader::parseSC ( ui16  difId  ) 

Definition at line 179 of file MicrorocSCReader.cpp.

Referenced by CalibMicrorocParser::getNextEvent(), and MicrorocLabviewReader::getScData().

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

void MicrorocSCReader::parseSCFromDb ( IlcConfDb ilcconf  ) 

Definition at line 57 of file MicrorocSCReader.cpp.

Referenced by MicrorocXDaqReader::getNextEvent().

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

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 120 of file MicrorocSCReader.cpp.

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


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 Jun 11 16:58:49 2012 for MicromegasFramework by  doxygen 1.4.7