RetrieveAndCompare.cpp

00001 #include "SctData/FullBypassTestResult.h"
00002 #include "../../AnalysisTestFramework.h"
00003 #include "../../TestFileUtil.h"
00004 #include "../../CutUtils.h"
00005 
00006 //#include <TTree.h>
00007 //#include <TFile.h>
00008 //#include "ipc/core.h"
00009 
00010 struct Info {
00011     unsigned int runNumber;
00012     unsigned int scanNumber;
00013     unsigned int chip;
00014     unsigned int nScans;
00015     float SCTDAQVersion;
00016     char serial[15];    
00017 };
00018 string InfoStr = "Run/i:Scan:Chip:NScans:SCTDAQVersion/F:Serial/C";
00019 
00020 struct FBData {
00021     double vddDirect;
00022     double vddBypass;
00023     int statusDirect;
00024     int statusBypass;
00025     int pass;
00026 };
00027 string DataStr = "VddDirect/D:VddBypass:StatusDirect/I:StatusBypass:Pass";
00028 
00029 //Globals variables:
00030 FBData RodDaq;                    //Our data
00031 FBData SctDaq;                    //SCTDAQ data
00032 struct Info info;                          //Some info
00033 
00034 //Noise Occupancy stuff
00035 string Ext = "_FullByPass.dat";
00036 string Output = "${SCT_DAQ_ROOT}/SystemTests/logs/FullBypass.root";
00037 string Arg = "-2";
00038 
00039 class FullBypassCompare : public AnalysisTestFramework<FullBypassTestResult> {
00040 public:
00041     virtual void publishData();
00042     virtual void downloadData(string serialNumber);
00043     virtual void compare(const FullBypassTestResult& t);   
00044     virtual void summaryOutput();
00045     virtual void setup();
00046 };
00047 
00048 
00049 string getFileName(string serial) {
00050     ostringstream oss;
00051     oss << serial << Ext;
00052     
00053     return oss.str();
00054 }
00055 
00056 void FullBypassCompare::summaryOutput() {
00057     if (cut(*tree, "pass", "(RodDaq.Pass-SctDaq.Pass)", 0.1, 0.1, 0, true) > 0) {
00058         ++exitCode;
00059     cout << "Failed pass check" << endl;
00060     }
00061     if (cut(*tree, "VddDirect", "(RodDaq.VddDirect-SctDaq.VddDirect)", 0.1, 0.1, 0, true) > 0) {
00062         ++exitCode;
00063     cout << "Failed VddDirect check" << endl;
00064     }
00065     if (cut(*tree, "VddBypass", "(RodDaq.VddBypass-SctDaq.VddBypass)", 0.1, 0.1, 0, true) > 0) {
00066         ++exitCode;
00067     cout << "Failed VddBypass check" << endl;
00068     }
00069     if (cut(*tree, "StatusDirect", "(RodDaq.StatusDirect-SctDaq.StatusDirect)", 0.1, 0.1, 0, true) > 0) {
00070         ++exitCode;
00071     cout << "Failed StatusDirect check" << endl;
00072     }
00073     if (cut(*tree, "StatusBypass", "(RodDaq.StatusBypass-SctDaq.StatusBypass)", 0.1, 0.1, 0, true) > 0) {
00074         ++exitCode;
00075     cout << "Failed StatusBypass check" << endl;
00076     }
00077     exitCode += errorCode;
00078 }
00079 
00080 int getStatus(string comment) {
00081     if (comment == "Minimal tested") return 1;
00082     if (comment == "Not Tested") return -2;
00083     return -4;
00084 }
00085 
00086 void FullBypassCompare::compare(const FullBypassTestResult& sd) {
00087     strncpy(info.serial, sd.getModuleName().c_str(), 14);
00088     info.runNumber = sd.getRunNumber();
00089     info.scanNumber = sd.getScanNumberAt(0);
00090     info.nScans = sd.getNScans();
00091     
00092     string fileName = getFileName(sd.getModuleName());
00093     ifstream file (fileName.c_str());
00094     if (!file.good())
00095         throw IllegalStateError("Failed to open comparison file: " + fileName, __FILE__, __LINE__);
00096  
00097     std::cout << "AJB debug output comparing "<< fileName << std::endl;
00098     
00099     SctDaq.pass = TestFileUtil::getPass(file);
00100     info.SCTDAQVersion = TestFileUtil::skipHeader(file);
00101     char buffer[1024];
00102 
00103     for (unsigned int chip = 0; chip<nChipModule; ++chip) {
00104     info.chip = chip;
00105     string chipStr;
00106     string directComment;
00107     string bypassComment;
00108         
00109     file >> chipStr >> SctDaq.vddDirect >> SctDaq.vddBypass;
00110         
00111     //Skip an initial tab character
00112     file.ignore(1, '\t');
00113     file.getline(buffer, 1024, '\t');
00114     directComment = buffer;
00115     file.getline(buffer, 1024, '\n');
00116     bypassComment = buffer;
00117     
00118     SctDaq.statusBypass = getStatus(bypassComment);
00119     SctDaq.statusDirect = getStatus(directComment);
00120     
00121     RodDaq.pass = sd.getPassed();
00122     RodDaq.statusBypass = sd.getChipResult(chip).status_bypass;
00123     RodDaq.statusDirect = sd.getChipResult(chip).status_direct;
00124     RodDaq.vddBypass = sd.getChipResult(chip).vdd_bypass;
00125     RodDaq.vddDirect = sd.getChipResult(chip).vdd_direct;
00126     
00127         tree->Fill();
00128     }
00129 }
00130 
00131 
00135 void FullBypassCompare::setup() {
00136     string name = Sct::Env::substituteVariables(Output);
00137     std::cout << "Atempting to recreate ["<<name<<"] in AnalysisTests/FullBypassTests/SCTDAQComparison/RetrieveAndCompare.cpp " << std::endl;
00138     file = new TFile(name.c_str(), "RECREATE");
00139     std::cout << " ... recreated successfully."<<std::endl;
00140     tree = new TTree("FBData", "FullBypass Comparison Data");
00141     tree->Branch("RodDaq", &RodDaq, DataStr.c_str());
00142     tree->Branch("SctDaq", &SctDaq, DataStr.c_str());
00143     tree->Branch("Info", &info, InfoStr.c_str());
00144     info.serial[14] = '\0';
00145 }
00146 
00150 void FullBypassCompare::downloadData(string serialNumber) {
00151     ostringstream oss;
00152     SctTest::TestInfo info = moduleData.getFullBypassInfo(serialNumber);
00153     oss << "java -Dtdaq.ipc.init.ref=$TDAQ_IPC_INIT_REF ProdDatabase/getDBfiles " << Arg << " -d -r " << info.runNumber << " -s " << info.scanNumber << "  " << serialNumber;
00154     std::cout << __FILE__ <<" is issuing system command: ["<< oss.str() <<"]"<<std::endl;
00155     if (system(oss.str().c_str())){
00156        std::cerr << " system command failed [" << oss.str() << "]" << std::endl;
00157        exit(1);
00158     }
00159 }
00160 
00165 void FullBypassCompare::publishData() {
00166     try {
00167         highLevelApi->fullBypass();
00168     } catch (...) {
00169     std::cout << "Oh dear ... things are going wrong lkhfskhdflkhdlfkh in " << __FILE__ << std::endl;
00170     throw;
00171     };
00172 }
00173 
00174 
00175 int main(int argc, char** argv) {
00176     IPCCore::init(argc,argv);
00177     FullBypassCompare sdc;
00178     sdc.analyzeAll(argc, argv);
00179     return sdc.getExitCode();
00180 }

Generated on Mon Feb 6 14:01:26 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6