/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/parser/TestMicrorocParser.cpp

Go to the documentation of this file.
00001 /* @version $Revision: 1328 $ * @modifiedby $Author: jacquem $ * @lastmodified $Date: 2011-10-03 17:04:17 +0200 (Mon, 03 Oct 2011) $ */
00002 #include "tools/MicroException.hh"
00003 #include "tools/Log.hh"
00004 #include "Run.hh"
00005 #include "Detector.hh"
00006 #include "Chamber.hh"
00007 #include "Dif.hh"
00008 #include "Board.hh"
00009 #include "tools/Log.hh"
00010 #include "Chip.hh"
00011 #include "MicrorocChip.hh"
00012 #include "parser/CalibMicrorocParser.hh"
00013 
00014 
00015 #include <sstream>
00016 
00017 
00018 #include <iostream>
00019 
00020 
00021 #include "parser/TestMicrorocParser.hh"
00022 
00023 using namespace std;
00024 
00025 
00026 TestMicrorocParser::TestMicrorocParser(Run& aRun, FILE *aFile, ui32 _firstEventId)
00027 : CalibMicrorocParser(aRun, aFile,  _firstEventId, true), serialNumberReaded(false) 
00028 {
00029   FILE_LOG(logDEBUG1) << "--TestMicrorocParser constructor()"<< endl;
00030   run.setName("Microroc chip test Run");
00031         
00032 }
00033 
00034 
00035 //--------------- Destructeur -------------//
00036 TestMicrorocParser::~TestMicrorocParser()
00037 {
00038   FILE_LOG(logDEBUG1)<< "----CalibMicrorocParser destructeur"<< endl;
00039 }
00040 
00041 
00042 //-------------------------------------------------------------------
00043 int  TestMicrorocParser::getNextEvent(Event& event)
00044 {
00045 
00046 
00047 if ( serialNumberReaded == false)
00048 {
00049 string line;
00050 ui64 result = 0;
00051 unsigned int serialNumber = 0 ;
00052     size_t found;
00053     do
00054     {
00055        if ( getLine ( inputFile, line) == EOF ) { return 0 ;}
00056        found = line.find("CHIP MR1 N =" );
00057     }
00058     while  (found==string::npos);
00059 
00060     string mot;
00061     int equalpos = 0;
00062 
00063     equalpos = line.find('=') ;
00064     if ( equalpos != string::npos )
00065     {
00066         mot = line.substr(equalpos + 2, line.size() -( equalpos + 2)); // + 2 because of the space caractere behind equal // 13 -> lenth of "CHIP MR1 N = "
00067                 unsigned long buffer;
00068 
00069                 stringstream ss;
00070                 ss << mot.substr(0,mot.size());
00071                 ss >> dec >> serialNumber;
00072 
00073                  FILE_LOG(logINFO) << "Chip serial Number[" << serialNumber << "]" << endl;
00074         }
00075 
00076 
00077 
00078     serialNumberReaded = true;
00079 
00080     Detector& detector = run.getDetector();
00081     try {
00082           ChamberMap_t chambers = detector.getChambers();
00083             Chamber& chamber = *(chambers.begin()->second);
00084             DifMap_t difs = chamber.getDifs();
00085               Dif& dif = *difs.begin()->second;
00086               BoardMap_t boards = dif.getBoards();
00087                 Board& b = *boards.begin()->second;
00088                 ChipMap_t chips = b.getChips();
00089                   MicrorocChip &chip = dynamic_cast<MicrorocChip &> (*chips.begin()->second);
00090                   if (chip.getSerialNumber() != serialNumber)
00091                   {
00092                     FILE_LOG(logINFO) << "serial number readed does not correspond to serial number in xml file.Force it" << endl;
00093                     chip.setSerialNumber(serialNumber);
00094                   }
00095         }
00096 
00097         catch (MicroException& e){}
00098 
00099 }
00100   // Call super Class method
00101  CalibMicrorocParser::getNextEvent(event);
00102 
00103 }

Generated on Mon Jan 7 13:15:22 2013 for MicromegasFramework by  doxygen 1.4.7