void errCheck(const char *desc="") { char fname[100]; sprintf(fname, "result.root"); TFile *inFile = TFile::Open(fname); const int debug = 1; const bool kTimeFormat = false; //const bool kTimeFormat = true; // can't seem to get the time format to work... // cuts on channel level: should be same as in checklog.pl // const int kMassive = 4; const int kMassive = 30; const float kMinPed = 40; const float kMaxPed = 110; const float kMinRms = 0.6; const float kMaxRms = 1.2; const float kMinGain20mV = 18.6; const float kMaxGain20mV = 20.0; // constants for arrays const int kNChan = 32; const int kNQR = 26; const int kNVRef = 6; const int kNACurr = 5; const int kNSync = 8; TTree *tree = (TTree*) inFile->Get("tree"); //Declaration of leaves types //Declaration of leaves types Char_t filename[200]; Char_t datetime[100]; Int_t iCtime; Int_t iMtime; Char_t cQR[kNQR]; Int_t iChip; Int_t iSta; Float_t fVRef[kNVRef]; Float_t fVCurr[kNACurr]; Float_t fACurr[kNACurr]; Float_t fGain20mV[32]; Float_t fGain30mV[32]; Float_t fRT20mV[32]; Float_t fRT30mV[32]; Float_t fPed20mV[32]; Float_t fPed30mV[32]; Float_t fRms20mV[32]; Float_t fRms30mV[32]; Float_t fPedAna20mV[32]; Float_t fPedAna30mV[32]; Float_t fRmsAna20mV[32]; Float_t fRmsAna30mV[32]; Float_t fX20mVeven; Float_t fX20mVodd; Float_t fX30mVeven; Float_t fX30mVodd; Int_t iSync[kNSync]; Int_t iDFT; Int_t iJtag; Int_t iMem; Float_t fRingOsc; Int_t i2cErr; Int_t iErrCode; Int_t iRCode; // Set branch addresses. tree->SetBranchAddress("filename",filename); tree->SetBranchAddress("datetime",datetime); tree->SetBranchAddress("iCtime",&iCtime); tree->SetBranchAddress("iMtime",&iMtime); tree->SetBranchAddress("cQR",&cQR); tree->SetBranchAddress("iChip",&iChip); tree->SetBranchAddress("iSta",&iSta); tree->SetBranchAddress("fVRef",fVRef); tree->SetBranchAddress("fVCurr",fVCurr); tree->SetBranchAddress("fACurr",fACurr); tree->SetBranchAddress("fGain20mV",fGain20mV); tree->SetBranchAddress("fGain30mV",fGain30mV); tree->SetBranchAddress("fRT20mV",fRT20mV); tree->SetBranchAddress("fRT30mV",fRT30mV); tree->SetBranchAddress("fPed20mV",fPed20mV); tree->SetBranchAddress("fPed30mV",fPed30mV); tree->SetBranchAddress("fRms20mV",fRms20mV); tree->SetBranchAddress("fRms30mV",fRms30mV); tree->SetBranchAddress("fPedAna20mV",fPedAna20mV); tree->SetBranchAddress("fPedAna30mV",fPedAna30mV); tree->SetBranchAddress("fRmsAna20mV",fRmsAna20mV); tree->SetBranchAddress("fRmsAna30mV",fRmsAna30mV); tree->SetBranchAddress("fX20mVeven",&fX20mVeven); tree->SetBranchAddress("fX20mVodd",&fX20mVodd); tree->SetBranchAddress("fX30mVeven",&fX30mVeven); tree->SetBranchAddress("fX30mVodd",&fX30mVodd); tree->SetBranchAddress("iSync",iSync); tree->SetBranchAddress("iDFT",&iDFT); tree->SetBranchAddress("iJtag",&iJtag); tree->SetBranchAddress("iMem",&iMem); tree->SetBranchAddress("fRingOsc",&fRingOsc); tree->SetBranchAddress("i2cErr",&i2cErr); tree->SetBranchAddress("iErrCode",&iErrCode); tree->SetBranchAddress("iRCode",&iRCode); // This is the loop skeleton // To read only selected branches, Insert statements like: // tree->SetBranchStatus("*",0); // disable all branches // TTreePlayer->SetBranchStatus("branchname",1); // activate branchname Long64_t nentries = tree->GetEntries(); tree->GetEntry(0); int firstTime = iCtime; tree->GetEntry(nentries-1); int lastTime = iCtime; int diffTimeSec = lastTime - firstTime; int diffTimeMin = diffTimeSec / 60; int totDiffTimeMin = diffTimeMin; cout << " diffTime : sec " << diffTimeSec << " min " << diffTimeMin << endl; const int kNSta = 2; const int kNErrBits = 14; // check for 14 different errors const char *kBitStr[] = { "FileCount", "VRef", "ACurr", "Sync", // 0x1, 0x2, 0x4, 0x8 "PedAna", "RmsAna", "Gain", "RiseTime", // 0x10, 0x20, 0x40, 0x80 "Xtalk", "RingOsc", "i2c", "Jtag", // 0x100, 0x200, 0x400, 0x800 "Mem", "DFT" // 0x1000, 0x2000 }; TGraphErrors *gRmsChan[kNSta][kNChan]; int nRmsChan[kNSta][kNChan] = {0}; const int kNChips = 100000; // max number of chips so far, for any station const int kChipOffset = 100000; int locChip = 0; int nTestsChip[kNChips] = {0}; for (locChip = 0; locChipSetMarkerStyle(20); gRmsChan[ista][ichan]->SetTitle( Form("RMS vs Time - Station %d Chan %d", ista+1, ichan) ); nRmsChan[ista][ichan] = 0; } } int minChip = 999999; int maxChip = 0; int nbytes = 0; vector errorCodes[kNChips]; vector testStation[kNChips]; for (Long64_t i=0; iGetEntry(i); if (debug>1) cout << " entry i " << i << " iSta " << iSta << endl; ista = iSta - 1; if (ista<0 || ista>1) { cout << " bad entry i " << i << " ista " << ista << endl; } locChip = iChip - kChipOffset; if ( (locChip>=0) && (locChip < kNChips) ) { // right range of chips if (minChip>locChip) minChip = locChip; if (maxChipSetPoint(nRmsChan[ista][ichan], mytime, fRmsAna20mV[ichan]); else gRmsChan[ista][ichan]->SetPoint(nRmsChan[ista][ichan], diffTimeMin, fRmsAna20mV[ichan]); gRmsChan[ista][ichan]->SetPointError(nRmsChan[ista][ichan], 0.3, 0.01); nRmsChan[ista][ichan]++; } nTests[ista]++; if (iErrCode > 0) { nFail[ista]++; for (ibit=0; ibit 0 ) { nFailBit[ista][ibit]++; } } if ( ((iErrCode & 0x00f0)>0) && ((iErrCode & 0x0008)==0) ) { // some channel issue: check pedestal, gain and rms values, and not any Sync errors int nChanErr = 0; for (ichan=0; ichankMaxPed) || (fRmsAna20mV[ichan]kMaxRms) || (fGain20mV[ichan]kMaxGain20mV) ) { nChanErr++; } } if (nChanErr < kMassive) { // not a chip with many channel errors for (ichan=0; ichankMaxPed) || (fRmsAna20mV[ichan]kMaxRms) || (fGain20mV[ichan]kMaxGain20mV) ) { nFailChan[ista][ichan]++; } } } } // channel error } // some error } // entries const int kNChanLines = 8; int chanPerLine = kNChan / kNChanLines; int iline = 0; // report for (ista=0; ista 0) { int nOK = nTests[ista] - nFail[ista]; float percPass = (100.0 * nOK) / nTests[ista]; printf("\nStation %d nTests %d nFail %d -- pass rate %5.2f %% \n", ista+1, nTests[ista], nFail[ista], percPass); for (ibit=0; ibit 0) { nErrCodes = (int) errorCodes[locChip].size(); if (nTestsChip[locChip] == nErrCodes) { nTestedChips++; int nOK = 0; int nBad = 0; for (itest=0; itest 0) && (nBad == 0) ) nOKOnly++; else if ( (nOK == 0) && (nBad > 0) ) nBadOnly++; else nMixed++; if (nErrCodes > 1) { // something to compare between itest = 1; int firstErrCode = errorCodes[locChip][0]; while (itest < nErrCodes) { if (errorCodes[locChip][itest] != firstErrCode) { if (debug>1) printf("iChip %d ErrCode mismatch : firstErr 0x%04x vs 0x%04x for itest %d\n", iChip, firstErrCode, errorCodes[locChip][itest], itest); nErrCodeMismatch++; // which bits are different between the two tests? use bitwise XOR ^ int diff = firstErrCode ^ errorCodes[locChip][itest]; // which bits changed from the first test? and second int changeFirst = diff & firstErrCode; ista = testStation[locChip][0]; for (ibit=0; ibit 0 ) { nMismatchBit[ista][ibit]++; } } // and for the other test int changeOther = diff & errorCodes[locChip][itest]; ista = testStation[locChip][itest]; for (ibit=0; ibit 0 ) { nMismatchBit[ista][ibit]++; } } } // code mismatch itest++; } } } else { printf("iChip %d nErr mismatch : nTests %d nErrorCodes %d\n", iChip, nTestsChip[locChip], nErrCodes); nErrMismatch++; } } } printf("nErrMismatch %d nErrCodeMismatch %d\n", nErrMismatch, nErrCodeMismatch); printf("nTestedChips %d nOKOnly %d nBadOnly %d nMixed %d\n", nTestedChips, nOKOnly, nBadOnly, nMixed); float norm = 100.0 / nTestedChips; printf("=> OK with one pass: %5.2f %%, OK after two passes: %5.2f %% \n", norm*nOKOnly, norm*(nOKOnly + nMixed)); for (ista=0; ista 0) { printf("\nStation %d - bit mismatches to other tests \n", ista+1); for (ibit=0; ibitcd(); gRmsChan[ista][ichan]->Fit("func0","RQ"); fprintf(fout, "%4d %3d %3.2f\n", ista+1, ichan, func0->GetParameter(0)); if ( (ichan%2) == 0 ) { meanEven[ista] += func0->GetParameter(0); nEven[ista] ++; } else { meanOdd[ista] += func0->GetParameter(0); nOdd[ista] ++; } if (kTimeFormat) { gRmsChan[ista][ichan]->GetXaxis()->SetTimeDisplay(1); gRmsChan[ista][ichan]->GetXaxis()->SetTimeOffset(firstTime); gRmsChan[ista][ichan]->GetXaxis()->SetTimeFormat("%a:%H:%M"); } else gRmsChan[ista][ichan]->GetXaxis()->SetTitle("Time (min)"); gRmsChan[ista][ichan]->GetYaxis()->SetTitle("RMS (ADC)"); gRmsChan[ista][ichan]->Draw("A*"); c1->Modified(); sprintf(name, "png/%s/liny/rmsChan_sta%d_chan%02d.png", desc, ista+1, ichan); c1->SaveAs(name); if (func0) delete func0; } } fprintf(fout, "ista type n rms --- averages:\n"); for (ista=0; ista 0) fprintf(fout, "%4d even %2d %3.2f\n", ista+1, nEven[ista], meanEven[ista]/nEven[ista] ); if (nOdd[ista] > 0) fprintf(fout, "%4d odd %2d %3.2f\n", ista+1, nOdd[ista], meanOdd[ista]/nOdd[ista] ); } fclose(fout); }