Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

RetrieveAndCompare.cpp

00001 #include "SctData/TimeWalkTestResult.h"
00002 #include "../../AnalysisTestFramework.h"
00003 #include "../../CutUtils.h"
00004 #include "../../TestFileUtil.h"
00005 
00006 struct Info {
00007     unsigned int runNumber;
00008     unsigned int scanNumber;
00009     unsigned int chip;
00010     unsigned int nScans;
00011     char serial[15];    
00012 };
00013 string InfoStr = "Run/i:Scan:Chip:NScans:Serial/C";
00014 
00015 struct SDData {
00016     double timeWalk;
00017     double calibration;
00018     int pass;
00019 };
00020 string DataStr = "TimeWalk/D:Calibration:Pass/I";
00021 
00022 //Globals variables:
00023 SDData RodDaq;                    //Our data
00024 SDData SctDaq;                    //SCTDAQ data
00025 Info info;                          //Some info
00026 
00027 //Noise Occupancy stuff
00028 string Ext = "_TimeWalk.dat";
00029 string Output = "${SCT_DAQ_ROOT}/SystemTests/logs/TimeWalk.root";
00030 string Arg = "-9";
00031 
00032 class TimeWalkCompare : public AnalysisTestFramework<TimeWalkTestResult> {
00033 public:
00034     virtual void publishData(SctTestApiStatus* status);
00035     virtual void downloadData(string serialNumber);
00036     virtual void compare(const TimeWalkTestResult& t); 
00037     virtual void summaryOutput();
00038     virtual void setup();
00039 };
00040 
00041 
00042 string getFileName(string serial) {
00043     ostringstream oss;
00044     oss << serial << Ext;
00045     
00046     return oss.str();
00047 }
00048 
00049 void TimeWalkCompare::compare(const TimeWalkTestResult& 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.timeWalk >> SctDaq.calibration;
00067     //Ignore rest of line
00068     file.ignore(256, '\n');
00069 
00070     RodDaq.timeWalk = sd.getChipResult(chip).timewalk;
00071     RodDaq.calibration = sd.getChipResult(chip).calibration;
00072     RodDaq.pass = sd.getPassed();
00073 
00074         tree->Fill();
00075     }
00076 }
00077 
00078 
00079 void TimeWalkCompare::summaryOutput() {
00080     if (cut(*tree, "timewalk", "(RodDaq.TimeWalk-SctDaq.TimeWalk)/SctDaq.TimeWalk*100", 1, 2, 10) > 0) {
00081     ++exitCode;
00082     cout << "Failed timewalk tail check" << endl;
00083     }
00084     if (cut(*tree, "calibration", "(RodDaq.Calibration-SctDaq.Calibration)/SctDaq.Calibration*100", 0.3, 0.5, 2) > 0) {
00085     ++exitCode;
00086     cout << "Failed calibration tail check" << endl;
00087     }
00088     exitCode += errorCode;
00089 }
00090 
00091 
00095 void TimeWalkCompare::setup() {
00096     string name = Env::substituteVariables(Output);
00097     file = new TFile(name.c_str(), "RECREATE");
00098     tree = new TTree("TWData", "TimeWalk Comparison Data");
00099     tree->Branch("RodDaq", &RodDaq, DataStr.c_str());
00100     tree->Branch("SctDaq", &SctDaq, DataStr.c_str());
00101     tree->Branch("Info", &info, InfoStr.c_str());
00102     info.serial[14] = '\0';
00103 }
00104 
00108 void TimeWalkCompare::downloadData(string serialNumber) {
00109     ostringstream oss;
00110     TestInfo info = moduleData.getTimeWalkInfo(serialNumber);
00111     oss << "java ProdDatabase/getDBfiles " << Arg << " -d -r " << info.runNumber << " -s " << info.scanNumber << "  " << serialNumber;
00112     system(oss.str().c_str());
00113 }
00114 
00119 void TimeWalkCompare::publishData(SctTestApiStatus* status) {
00120     highLevelApi->timeWalk(status);
00121 }
00122 
00123 
00124 int main(int argc, char** argv) {
00125     TimeWalkCompare sdc;
00126     sdc.analyzeAll(argc, argv);
00127     return sdc.getExitCode();
00128 }
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 

Generated on Thu Jul 15 09:50:51 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5