RetrieveAndCompare.cpp

00001 #include "SctData/StrobeDelayTestResult.h"
00002 #include "../../AnalysisTestFramework.h"
00003 #include "../../CutUtils.h"
00004 #include "../../TestFileUtil.h"
00005 #include "ipc/core.h"
00006 
00007 struct Info {
00008     unsigned int runNumber;
00009     unsigned int scanNumber;
00010     unsigned int chip;
00011     unsigned int nScans;
00012     char serial[15];    
00013 };
00014 string InfoStr = "Run/i:Scan:Chip:NScans:Serial/C";
00015 
00016 struct SDData {
00017     double delay;
00018     int pass;
00019 };
00020 string DataStr = "Delay/D:Pass/I";
00021 
00022 //Globals variables:
00023 SDData RodDaq;                    //Our data
00024 SDData SctDaq;                    //SCTDAQ data
00025 struct Info info;                          //Some info
00026 
00027 //Noise Occupancy stuff
00028 string Ext = "_StrobeDelay.dat";
00029 string Output = "${SCT_DAQ_ROOT}/SystemTests/logs/StrobeDelay.root";
00030 string Arg = "-4";
00031 
00032 class StrobeDelayCompare : public AnalysisTestFramework<StrobeDelayTestResult> {
00033 public:
00034     virtual void publishData();
00035     virtual void downloadData(string serialNumber);
00036     virtual void compare(const StrobeDelayTestResult& t);       
00037     virtual void setup();
00038     virtual void summaryOutput();
00039 };
00040 
00041 
00042 string getFileName(string serial) {
00043     ostringstream oss;
00044     oss << serial << Ext;
00045     
00046     return oss.str();
00047 }
00048 
00049 void StrobeDelayCompare::compare(const StrobeDelayTestResult& sd) {
00050     strncpy(info.serial, sd.getModuleName().c_str(), 14);
00051     info.runNumber = sd.getRunNumber();
00052     info.scanNumber = sd.getScanNumberAt(0);
00053     info.nScans = sd.getNScans();
00054     
00055     string fileName = getFileName(sd.getModuleName());
00056     ifstream file (fileName.c_str());
00057     if (!file.good())
00058         throw IllegalStateError("Failed to open comparison file: " + fileName, __FILE__, __LINE__);
00059     
00060     SctDaq.pass = TestFileUtil::getPass(file);
00061     TestFileUtil::skipHeader(file);
00062 
00063     for (unsigned int chip = 0; chip<nChipModule; ++chip) {
00064     string chipStr;
00065     info.chip = chip;
00066     file >> chipStr >> SctDaq.delay;
00067     //Ignore rest of line
00068     file.ignore(256, '\n');
00069 
00070     RodDaq.delay = sd.getOptimum(chip);
00071     RodDaq.pass = sd.getPassed();
00072 
00073         tree->Fill();
00074     }
00075 }
00076 
00077 void StrobeDelayCompare::summaryOutput() {
00078     if (cut(*tree, "delay", "(RodDaq.Delay-SctDaq.Delay)", 0.5, 0.5, 1.1, true) > 0) {
00079     ++exitCode;
00080     cout << "Failed delay tail check" << endl;
00081     }   
00082     if (cut(*tree, "pass", "(RodDaq.Pass-SctDaq.Pass)", 0.01, 0.01, 0.01, true) > 0) {
00083     ++exitCode;
00084     cout << "Failed pass tail check" << endl;
00085     }
00086     exitCode += errorCode;
00087 }
00088 
00089 
00093 void StrobeDelayCompare::setup() {
00094     string name = Env::substituteVariables(Output);
00095     file = new TFile(name.c_str(), "RECREATE");
00096     tree = new TTree("SDData", "StrobeDelay Comparison Data");
00097     tree->Branch("RodDaq", &RodDaq, DataStr.c_str());
00098     tree->Branch("SctDaq", &SctDaq, DataStr.c_str());
00099     tree->Branch("Info", &info, InfoStr.c_str());
00100     info.serial[14] = '\0';
00101 }
00102 
00106 void StrobeDelayCompare::downloadData(string serialNumber) {
00107     ostringstream oss;
00108     SctTest::TestInfo info = moduleData.getStrobeDelayInfo(serialNumber);
00109     oss << "java -Dtdaq.ipc.init.ref=$TDAQ_IPC_INIT_REF ProdDatabase/getDBfiles " << Arg << " -d -r " << info.runNumber << " -s " << info.scanNumber << "  " << serialNumber;
00110     system(oss.str().c_str());
00111 }
00112 
00117 void StrobeDelayCompare::publishData() {
00118     highLevelApi->strobeDelay();
00119 }
00120 
00121 
00122 int main(int argc, char** argv) {
00123         IPCCore::init(argc,argv);
00124     StrobeDelayCompare sdc;
00125     sdc.analyzeAll(argc, argv);
00126     return sdc.getExitCode();
00127 }
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 

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