-//===================================================================================\r\r
-// This is a macro to analyze TRD/Calib/DCS OCDB objects either\r\r
-// from the grid for a given run number or from a local object.\r\r
-// If you want to analyze data from the grid, please don't forget to\r\r
-// have a valid alien token initialized and the file /tmp/gclient_env_$UID source'd.\r\r
-//\r\r
-// Arguments:\r\r
-// The first argument is the runnumber (this is ignored in case of a local file),\r\r
-// the second is a string that needs to contain either "grid" or "local". Further\r\r
-// you can add either verbose or quiet to that string. If you don't, you'll be asked\r\r
-// for all stuff individually wether you want to see it or not\r\r
-// the thrid argument is the number of the ROC you (eventually) want to dump its data\r\r
-// member of.\r\r
-// The fourth one is the path and name of the local file you might want to look at.\r\r
-//\r\r
-// So the simplest way to use this macro is if you want to check the output of a given\r\r
-// run from the OCDB:\r\r
-// .x AliTRDcheckConfig.C(60111)\r\r
-//\r\r
-// An example for quickly checking a local file:\r\r
-// .x AliTRDcheckConfig.C(0, "local quiet", 533, "$ALICE_ROOT/TRD/Calib/DCS/Run0_999999999_v0_s0.root")\r\r
-//\r\r
-// Please contact Frederick Kramer in case of problems\r\r
-//===================================================================================\r\r
-\r\r
-\r\r
-const Int_t nROC = 540;\r\r
-const Int_t nROB = 8;\r\r
-const Int_t nMCM = 18;\r\r
-const Int_t cArraySize = 1000;\r\r
-\r\r
-\r\r
-\r\r
-void AnalyzeArray(Int_t states[cArraySize], Int_t occur[cArraySize]) {\r\r
- long long srtIndx[cArraySize] = 0;\r\r
- \r\r
- TMath::Sort(cArraySize, occur, srtIndx);\r\r
-\r\r
- Int_t totalSum = 0, subSum = 0, iIndex = 0;\r\r
- for (Int_t i=0; i<cArraySize; i++) totalSum += occur[i];\r\r
- \r\r
- cout << " The majority ("<< occur[srtIndx[0]] << " of " \r\r
- << totalSum <<") is: " << states[srtIndx[0]] << endl;\r\r
- subSum = occur[srtIndx[0]];\r\r
- while (totalSum != subSum) {\r\r
- if (++iIndex > 999) {\r\r
- cout << "E : out of bounds." << endl;\r\r
- break;\r\r
- }\r\r
- Printf(" Next: %7d (%d)", states[srtIndx[iIndex]], occur[srtIndx[iIndex]]);\r\r
- subSum += occur[srtIndx[iIndex]];\r\r
- }\r\r
-}\r\r
-\r\r
-\r\r
-\r\r
-void FillItemInArray(Int_t states[cArraySize], Int_t occur[cArraySize], Int_t item) {\r\r
- for (Int_t iArrPos=0; iArrPos<cArraySize; iArrPos++) {\r\r
- if (item == -1) break; // value not set\r\r
- if (states[iArrPos] == item) {\r\r
- occur[iArrPos]++;\r\r
- break;\r\r
- } else if (occur[iArrPos] == 0) {\r\r
- states[iArrPos] = item;\r\r
- occur[iArrPos]++;\r\r
- break;\r\r
- }\r\r
- }\r\r
-}\r\r
-\r\r
-\r\r
-\r\r
-void GetMajoritys(AliTRDCalDCS* calDCSObj) {\r\r
-\r\r
- Int_t gsmStates[cArraySize] = {0}, gsmOccur[cArraySize] = {0};\r\r
- Int_t nimStates[cArraySize] = {0}, nimOccur[cArraySize] = {0};\r\r
- Int_t nevStates[cArraySize] = {0}, nevOccur[cArraySize] = {0};\r\r
- Int_t nptStates[cArraySize] = {0}, nptOccur[cArraySize] = {0};\r\r
-\r\r
- for (Int_t i=0; i<cArraySize; i++) {\r\r
- gsmStates[i] = 0;\r\r
- gsmOccur[i] = 0;\r\r
- nimStates[i] = 0;\r\r
- nimOccur[i] = 0;\r\r
- nevStates[i] = 0;\r\r
- nevOccur[i] = 0;\r\r
- nptStates[i] = 0;\r\r
- nptOccur[i] = 0; \r\r
- }\r\r
- \r\r
- for (Int_t i=0; i<nROC; i++) {\r\r
- AliTRDCalDCSFEE *idcsfee = calDCSObj->GetCalDCSFEEObj(i);\r\r
- if ((idcsfee == NULL) || (idcsfee->GetStatusBit() != 0)) continue;\r\r
- for (Int_t j=0; j<nROB; j++) {\r\r
- for (Int_t k=0; k<nMCM; k++) {\r\r
- Int_t igsm = idcsfee->GetMCMGlobalState(j,k);\r\r
- Int_t inim = idcsfee->GetMCMStateNI(j,k);\r\r
- Int_t inev = idcsfee->GetMCMEventCnt(j,k);\r\r
- Int_t inpt = idcsfee->GetMCMPtCnt(j,k);\r\r
- \r\r
- FillItemInArray(gsmStates, gsmOccur, igsm); \r\r
- FillItemInArray(nimStates, nimOccur, inim); \r\r
- FillItemInArray(nevStates, nevOccur, inev); \r\r
- FillItemInArray(nptStates, nptOccur, inpt); \r\r
- }\r\r
- }\r\r
- }\r\r
- \r\r
- cout << "I : Global MCM state statistics:" << endl;\r\r
- AnalyzeArray(gsmStates, gsmOccur);\r\r
- cout << "I : Network interface state statistics:" << endl;\r\r
- AnalyzeArray(nimStates, nimOccur);\r\r
- cout << "I : MCM Event counter reading statistics:" << endl;\r\r
- AnalyzeArray(nevStates, nevOccur);\r\r
- cout << "I : MCM PreTrigger counter reading statistics:" << endl;\r\r
- AnalyzeArray(nptStates, nptOccur);\r\r
- \r\r
- return;\r\r
-}\r\r
-\r\r
-\r\r
-void AliTRDcheckConfig(Int_t runNr=0, TString source="grid", Int_t dumpid=0, char *pathfile="nopathgiven"){\r\r
-\r\r
- AliCDBEntry *entry=0;\r\r
-\r\r
- // get the source\r\r
- if(source.Contains("grid")) {\r\r
- cout << "I : Accessing grid storage for run number " << runNr << endl;\r\r
- cout << "I : Get CDBManager instance." << endl;\r\r
- AliCDBManager *man = AliCDBManager::Instance();\r\r
- cout << "I : SetDefaultStorage." << endl;\r\r
- man->SetDefaultStorage("alien://folder=/alice/data/2008/LHC08d/OCDB/");\r\r
- cout << "I : Get OCDB Entry." << endl;\r\r
- entry = man->Get("TRD/Calib/DCSCONFIG", runNr);\r\r
- } else if(source.Contains("local")) {\r\r
- cout << "I : Accessing local storage" << endl;\r\r
- TFile *f = new TFile(pathfile);\r\r
- if(f != NULL) {\r\r
- entry = (AliCDBEntry*) f->Get("AliCDBEntry");\r\r
- }\r\r
- else {\r\r
- cout << "E : Cannot open file" << endl;\r\r
- return;\r\r
- }\r\r
- } else {\r\r
- cout << "E : Please specify a correct source (grid/local)" << endl;\r\r
- return;\r\r
- }\r\r
-\r\r
-\r\r
- Int_t dump[20], contSelect=-1;\r\r
- for(Int_t i=0; i<20; i++) dump[i]=0;\r\r
- if(!source.Contains("quiet") && !source.Contains("verbose")) {\r\r
- cout << "Q : Do you want to dump the AliCDBEntry? (1/0) ";\r\r
- cin >> dump[0];\r\r
- cout << "Q : Do you want to dump the AliTRDCalDCS Object? (1/0) ";\r\r
- cin >> dump[1];\r\r
- cout << "Q : Do you want to dump the AliTRDCalDCSFEE Object? (1/0) ";\r\r
- cin >> dump[2];\r\r
- if(dump[2] == 1) {\r\r
- cout << "Q : Which Detector ID? (0..540) ";\r\r
- cin >> dumpid;\r\r
- }\r\r
- cout << "Q : Do you want to get a status bit summary? (1/0) ";\r\r
- cin >> dump[3];\r\r
- cout << "Q : Do you want to get a status bit histogram? (1/0) ";\r\r
- cin >> dump[4];\r\r
- cout << "Q : Do you want to get a check on data integrity? (1/0) ";\r\r
- cin >> dump[5];\r\r
- }\r\r
- if(source.Contains("verbose")) for(Int_t i=0; i<20; i++) dump[i]=1;\r\r
-\r\r
- // check version\r\r
- //TObject *objectCDB = (TObject*)entry->GetObject();\r\r
- TObject *objectCDB = (TObject*)entry->GetObject();\r\r
- if (objectCDB->IsA()->InheritsFrom("TObjArray")) {\r\r
- cout << "I : It seems like you are checking a file containing both SOR and EOR informations." << endl;\r\r
- cout << "Q : Do you want to check SOR (0), EOR (1) or their differences (2)? ";\r\r
- cin >> contSelect;\r\r
- TObjArray *objArrayCDB = (TObjArray*)entry->GetObject();\r\r
- }\r\r
-\r\r
-\r\r
-\r\r
- // the AliCDBEntry\r\r
- if(dump[0] > 0) {\r\r
- cout << endl << "============ Dumping the AliCDBEntry ============" << endl;\r\r
- entry->Dump();\r\r
- }\r\r
-\r\r
- \r\r
- // the CalDCS object\r\r
- AliTRDCalDCS *caldcs;\r\r
- switch(contSelect) {\r\r
- case -1:\r\r
- caldcs = (AliTRDCalDCS*) entry->GetObject();\r\r
- break; \r\r
- case 0:\r\r
- caldcs = (AliTRDCalDCS*) objArrayCDB->At(0);\r\r
- break; \r\r
- case 1:\r\r
- caldcs = (AliTRDCalDCS*) objArrayCDB->At(1);\r\r
- break; \r\r
- case 2:\r\r
- cout << "I : Sorry, not implemented yet. Stop." << endl;\r\r
- return;\r\r
- break; \r\r
- default:\r\r
- cout << "E : Invalid key. Stop." << endl;\r\r
- return;\r\r
- }\r\r
-\r\r
- \r\r
-\r\r
- if(dump[1] > 0) {\r\r
- cout << endl << "============ Dumping the AliTRDCalDCS Object ============" << endl;\r\r
- caldcs->Dump();\r\r
- }\r\r
-\r\r
- // one CalDCSFEE object\r\r
- if(dump[2] > 0) {\r\r
- AliTRDCalDCSFEE *dcsfee;\r\r
- dcsfee = caldcs->GetCalDCSFEEObj(dumpid);\r\r
- cout <<endl<< "============ Dumping the AliTRDCalDCSFEE Object Nr. " << dumpid << " ============" << endl;\r\r
- if (dcsfee != NULL) {\r\r
- dcsfee->Dump();\r\r
- }\r\r
- }\r\r
-\r\r
- // fill histograms\r\r
- TH1F *hStatusBits = new TH1F("hStatusBits", "DCS FEE Status Bits", 10, -.5, 9.5);\r\r
- hStatusBits->SetFillColor(38);\r\r
- hStatusBits->GetXaxis()->SetTitle("Status Bit Value");\r\r
- hStatusBits->GetYaxis()->SetTitle("Occurrence");\r\r
-\r\r
- // get a status bit summary\r\r
- if(dump[3] > 0) {\r\r
- cout << endl << "============ Status Bit Summary: ============" << endl;\r\r
- TString bitfivestr = " ROCs with status bit 5. These have been not even responding to any DIM communication attempt. Most probably they just were off.\n DCS IDs: ";\r\r
- Int_t lengthfive = bitfivestr.Length();\r\r
- TString bitfourstr = " ROCs with status bit 4! BAD! This might be due to a communication problem between fxsproxy and the feeserver(s) \n DCS IDs: ";\r\r
- Int_t lengthfour = bitfourstr.Length();\r\r
- TString bitthreestr = " ROCs with status bit 3!!! VERY BAD! This might be due to a serious communication error between the fxsproxy program and the FEEservers.\n DCS IDs: ";\r\r
- Int_t lengththree = bitthreestr.Length();\r\r
- TString bittwostr = " ROCs with status bit 2. These have been in states in which they cannot be read out, e.g. Standby.\n DCS IDs: ";\r\r
- Int_t lengthtwo = bittwostr.Length();\r\r
- TString bitonestr = " ROCs with status bit 1! BAD! This means the chamber(s) didn't respont even though is should have been in a good state.\n DCS IDs: ";\r\r
- Int_t lengthone = bitonestr.Length();\r\r
-\r\r
- Int_t nSB1=0, nSB2=0, nSB3=0, nSB4=0, nSB5=0;\r\r
- for (Int_t i=0; i<540; i++) {\r\r
- AliTRDCalDCSFEE *idcsfee;\r\r
- idcsfee = caldcs->GetCalDCSFEEObj(i);\r\r
- if (idcsfee != NULL) {\r\r
- Int_t sb = idcsfee->GetStatusBit();\r\r
- if (sb == 5) { bitfivestr += i; bitfivestr += " "; nSB5++; }\r\r
- if (sb == 4) { bitfourstr += i; bitfourstr += " "; nSB4++; }\r\r
- if (sb == 3) { bitthreestr += i; bitthreestr += " "; nSB3++; }\r\r
- if (sb == 2) { bittwostr += i; bittwostr += " "; nSB2++; }\r\r
- if (sb == 1) { bitonestr += i; bitonestr += " "; nSB1++; }\r\r
- hStatusBits->Fill(sb);\r\r
- }\r\r
- }\r\r
-\r\r
- if (lengthfive < bitfivestr.Length()) cout << nSB5 << bitfivestr.Data() << endl << endl;\r\r
- else cout << "GOOD: No ROCs with status bit 5" << endl;\r\r
- if (lengthfour < bitfourstr.Length()) cout << nSB4 << bitfourstr.Data() << endl << endl;\r\r
- else cout << "GOOD: No ROCs with status bit 4" << endl;\r\r
- if (lengththree < bitthreestr.Length()) cout << nSB3 << bitthreestr.Data() << endl << endl;\r\r
- else cout << "GOOD: No ROCs with status bit 3" << endl;\r\r
- if (lengthtwo < bittwostr.Length()) cout << nSB2 << bittwostr.Data() << endl << endl;\r\r
- else cout << "GOOD: No ROCs with status bit 2" << endl;\r\r
- if (lengthone < bitonestr.Length()) cout << nSB1 << bitonestr.Data() << endl << endl;\r\r
- else cout << "GOOD: No ROCs with status bit 1" << endl;\r\r
- }\r\r
-\r\r
-\r\r
- // get a status bit histogram\r\r
- if(dump[4] > 0) {\r\r
- TCanvas *c1 = new TCanvas("c1");\r\r
- gPad->SetLogy();\r\r
- hStatusBits->Draw("HIST");\r\r
- }\r\r
-\r\r
-\r\r
-\r\r
- // get a check on data integrity\r\r
- if(dump[5] > 0) {\r\r
- cout << endl << "============ Data Integrity: ============" << endl;\r\r
- TH1F *tb = new TH1F("tbs", "", 100000, 0, 100000);\r\r
- TH1F *ct = new TH1F("cts", "", 100000, 0, 100000);\r\r
- const Int_t ngsm = nROB * nMCM;\r\r
-\r\r
- Int_t gsm_occ[nROC][ngsm][2];\r\r
- Int_t ni_occ[nROC][ngsm][2];\r\r
- Int_t ev_occ[nROC][ngsm][2];\r\r
- Int_t pt_occ[nROC][ngsm][2];\r\r
-\r\r
- for (Int_t i=0; i<nROC; i++) {\r\r
- for (Int_t j=0; j<ngsm; j++) {\r\r
- gsm_occ[i][j][0] = 0; // values\r\r
- gsm_occ[i][j][1] = 0; // counter\r\r
- ni_occ[i][j][0] = 0; // values\r\r
- ni_occ[i][j][1] = 0; // counter\r\r
- ev_occ[i][j][0] = 0; // values\r\r
- ev_occ[i][j][1] = 0; // counter\r\r
- pt_occ[i][j][0] = 0; // values\r\r
- pt_occ[i][j][1] = 0; // counter\r\r
- }\r\r
- }\r\r
-\r\r
- Int_t majGSM[2], majNI[2], majEV[2], majPT[2];\r\r
- majGSM[0] = 0; // value\r\r
- majGSM[1] = 0; // count\r\r
- majNI[0] = 0; // value\r\r
- majNI[1] = 0; // count\r\r
- majEV[0] = 0; // value\r\r
- majEV[1] = 0; // count\r\r
- majPT[0] = 0; // value\r\r
- majPT[1] = 0; // count\r\r
-\r\r
-\r\r
- // find the majority states/counters\r\r
- for (Int_t i=0; i<nROC; i++) {\r\r
- AliTRDCalDCSFEE *idcsfee;\r\r
- idcsfee = caldcs->GetCalDCSFEEObj(i);\r\r
- if (idcsfee != NULL) {\r\r
- if(idcsfee->GetStatusBit() == 0) {\r\r
- tb->Fill(idcsfee->GetNumberOfTimeBins()-1);\r\r
- ct->Fill(idcsfee->GetConfigTag()-1);\r\r
- for (Int_t j=0; j<nROB; j++) {\r\r
- for (Int_t k=0; k<nMCM; k++) {\r\r
- Int_t igsm = idcsfee->GetMCMGlobalState(j, k);\r\r
- Int_t ini = idcsfee->GetMCMStateNI(j, k);\r\r
- Int_t iev = idcsfee->GetMCMEventCnt(j, k);\r\r
- Int_t ipt = idcsfee->GetMCMPtCnt(j, k);\r\r
- // gsm\r\r
- for (Int_t l=0; l<nROB*nMCM; l++) {\r\r
- if (gsm_occ[i][l][1] == 0){\r\r
- gsm_occ[i][l][1] = 1;\r\r
- gsm_occ[i][l][0] = igsm;\r\r
- break;\r\r
- }\r\r
- else if (gsm_occ[i][l][0] == igsm) {\r\r
- gsm_occ[i][l][1]++;\r\r
- break;\r\r
- }\r\r
- }\r\r
- // ni\r\r
- for (Int_t l=0; l<nROB*nMCM; l++) {\r\r
- if (ni_occ[i][l][1] == 0){\r\r
- ni_occ[i][l][1] = 1;\r\r
- ni_occ[i][l][0] = ini;\r\r
- break;\r\r
- }\r\r
- else if (ni_occ[i][l][0] == ini) {\r\r
- ni_occ[i][l][1]++;\r\r
- break;\r\r
- }\r\r
- }\r\r
- // ev\r\r
- for (Int_t l=0; l<nROB*nMCM; l++) {\r\r
- if (ev_occ[i][l][1] == 0){\r\r
- ev_occ[i][l][1] = 1;\r\r
- ev_occ[i][l][0] = iev;\r\r
- break;\r\r
- }\r\r
- else if (ev_occ[i][l][0] == iev) {\r\r
- ev_occ[i][l][1]++;\r\r
- break;\r\r
- }\r\r
- }\r\r
- // pt\r\r
- for (Int_t l=0; l<nROB*nMCM; l++) {\r\r
- if (pt_occ[i][l][1] == 0){\r\r
- pt_occ[i][l][1] = 1;\r\r
- pt_occ[i][l][0] = ipt;\r\r
- break;\r\r
- }\r\r
- else if (pt_occ[i][l][0] == ipt) {\r\r
- pt_occ[i][l][1]++;\r\r
- break;\r\r
- }\r\r
- }\r\r
- }\r\r
- }\r\r
-\r\r
- for (Int_t j=0; j<ngsm; j++) {\r\r
- // gsm\r\r
- if (gsm_occ[i][j][1] > 0) {\r\r
- if (gsm_occ[i][j][1] > majGSM[1]) {\r\r
- majGSM[0] = gsm_occ[i][j][0];\r\r
- majGSM[1] = gsm_occ[i][j][1];\r\r
- }\r\r
- }\r\r
- // ni\r\r
- if (ni_occ[i][j][1] > 0) {\r\r
- if (ni_occ[i][j][1] > majNI[1]) {\r\r
- majNI[0] = ni_occ[i][j][0];\r\r
- majNI[1] = ni_occ[i][j][1];\r\r
- }\r\r
- }\r\r
- // ev\r\r
- if (ev_occ[i][j][1] > 0) {\r\r
- if (ev_occ[i][j][1] > majEV[1]) {\r\r
- majEV[0] = ev_occ[i][j][0];\r\r
- majEV[1] = ev_occ[i][j][1];\r\r
- }\r\r
- }\r\r
- // pt\r\r
- if (pt_occ[i][j][1] > 0) {\r\r
- if (pt_occ[i][j][1] > majPT[1]) {\r\r
- majPT[0] = pt_occ[i][j][0];\r\r
- majPT[1] = pt_occ[i][j][1];\r\r
- }\r\r
- } \r\r
- }\r\r
- }\r\r
- }\r\r
- }\r\r
-\r\r
- Int_t maxBinCT = ct->GetMaximumBin();\r\r
- //cout << "Majority number of configuration tags: " << maxBinCT << endl;\r\r
- Int_t maxBinTB = tb->GetMaximumBin();\r\r
- //cout << "Majority number of timebins: " << maxBinTB << endl;\r\r
- Int_t integrityProblem = 0;\r\r
-\r\r
- for (Int_t i=0; i<nROC; i++) {\r\r
- AliTRDCalDCSFEE *idcsfee;\r\r
- idcsfee = caldcs->GetCalDCSFEEObj(i);\r\r
- if (idcsfee != NULL) {\r\r
- if(idcsfee->GetStatusBit() == 0) {\r\r
- Int_t ict = idcsfee->GetConfigTag();\r\r
- if(ict != maxBinCT) {\r\r
- cout << "ROB " << i << " has the config tag = " << ict \r\r
- << " what differs from the majority (=" << maxBinCT << ")!" << endl;\r\r
- integrityProblem++;\r\r
- }\r\r
- Int_t itb = idcsfee->GetNumberOfTimeBins();\r\r
- if(itb != maxBinTB) {\r\r
- cout << "ROB " << i << " has number of time bins = " << itb \r\r
- << " what differs from the majority (=" << maxBinTB << ")!" << endl;\r\r
- integrityProblem++;\r\r
- }\r\r
-\r\r
-\r\r
- for (Int_t j=0; j<ngsm; j++) {\r\r
- // gsm\r\r
- if ((gsm_occ[i][j][1] > 0) && (gsm_occ[i][j][0] != majGSM[0])) {\r\r
- if (!((gsm_occ[i][j][0] == -1) && ((gsm_occ[i][j][1] == 6) || (gsm_occ[i][j][1] == 40)))) { \r\r
- printf("ROC %3d %3d inconstistent global rstates found with value %2d\n",\r\r
- i,gsm_occ[i][j][1],gsm_occ[i][j][0]);\r\r
- integrityProblem++;\r\r
- }\r\r
- }\r\r
- // ni\r\r
- if ((ni_occ[i][j][1] > 0) && (ni_occ[i][j][0] != majNI[0])) {\r\r
- if (!((ni_occ[i][j][0] == -1) && ((ni_occ[i][j][1] == 6) || (ni_occ[i][j][1] == 40)))) { \r\r
- printf("ROC %3d %3d inconstistent network interface states found with value %2d\n",\r\r
- i,ni_occ[i][j][1],ni_occ[i][j][0]);\r\r
- integrityProblem++;\r\r
- }\r\r
- }\r\r
- // ev\r\r
- if ((ev_occ[i][j][1] > 0) && (ev_occ[i][j][0] != majEV[0])) {\r\r
- if (!((ev_occ[i][j][0] == -1) && ((ev_occ[i][j][1] == 6) || (ev_occ[i][j][1] == 40)))) { \r\r
- printf("ROC %3d %3d inconstistent event counters found with value %2d\n",\r\r
- i,ev_occ[i][j][1],ev_occ[i][j][0]);\r\r
- integrityProblem++;\r\r
- }\r\r
- }\r\r
- // pt\r\r
- if ((pt_occ[i][j][1] > 0) && (pt_occ[i][j][0] != majPT[0])) {\r\r
- if (!((pt_occ[i][j][0] == -1) && ((pt_occ[i][j][1] == 6) || (pt_occ[i][j][1] == 40)))) { \r\r
- printf("ROC %3d %3d inconstistent pretrigger counters found with value %2d\n",\r\r
- i,pt_occ[i][j][1],pt_occ[i][j][0]);\r\r
- integrityProblem++;\r\r
- }\r\r
- }\r\r
-\r\r
- }\r\r
- }\r\r
- }\r\r
- }\r\r
-\r\r
- if(integrityProblem == 0) cout << "No problem with data integrity found." << endl;\r\r
- else cout << endl << "There were in total " << integrityProblem << " inconsistencies!" << endl;\r\r
- }\r\r
-\r\r
-\r\r
- cout << endl << "============ Statistics from RSTATE: ============" << endl;\r\r
- cout<<"I : The majority entry is given as well as all other values," << endl;\r\r
- cout<<" sorted according to their occurrence." << endl << endl;\r\r
- GetMajoritys(caldcs);\r\r
- \r\r
-\r\r
- cout << endl << "============ Global Configuraton: ============" << endl;\r\r
- cout<<"I : Numbers are -1 if not set and -2 if mixed," << endl;\r\r
- cout<<" strings are empty if not set and 'mixed' if so." << endl << endl;\r\r
- cout<<"Global number of time bins.........................: "<<caldcs->GetGlobalNumberOfTimeBins() << endl;\r\r
- cout<<"Global configuration tag...........................: "<<caldcs->GetGlobalConfigTag() << endl;\r\r
- cout<<"Global single hit threshold........................: "<<caldcs->GetGlobalSingleHitThres() << endl;\r\r
- cout<<"Global three pad cluster threshold.................: "<<caldcs->GetGlobalThreePadClustThres()<<endl;\r\r
- cout<<"Global selective ZS (every i'th event).............: "<<caldcs->GetGlobalSelectiveNoZS() << endl;\r\r
- cout<<"Global tail cancellation filter weight.............: "<<caldcs->GetGlobalTCFilterWeight() << endl;\r\r
- cout<<"Global tail cancellat. filter short decay parameter: "<<caldcs->GetGlobalTCFilterShortDecPar()<<endl;\r\r
- cout<<"Global tail cancellation filt. long decay parameter: "<<caldcs->GetGlobalTCFilterLongDecPar()<<endl;\r\r
- cout<<"Global fast statistics mode?.......................: "<<caldcs->GetGlobalModeFastStatNoise() << endl;\r\r
- cout<<"Global configuration tag version...................: "<<caldcs->GetGlobalConfigVersion() << endl;\r\r
- cout<<"Global configuration tag name......................: "<<caldcs->GetGlobalConfigName() << endl;\r\r
- cout<<"Global filter type.................................: "<<caldcs->GetGlobalFilterType() << endl;\r\r
- cout<<"Global readout parameter...........................: "<<caldcs->GetGlobalReadoutParam() << endl;\r\r
- cout<<"Global test pattern................................: "<<caldcs->GetGlobalTestPattern() << endl;\r\r
- cout<<"Global tracklet mode...............................: "<<caldcs->GetGlobalTrackletMode() << endl;\r\r
- cout<<"Global tracklet definition.........................: "<<caldcs->GetGlobalTrackletDef() << endl;\r\r
- cout<<"Global trigger setup...............................: "<<caldcs->GetGlobalTriggerSetup() << endl;\r\r
- cout<<"Global additional options..........................: "<<caldcs->GetGlobalAddOptions() << endl;\r\r
-\r\r
-}\r\r
+//===================================================================================
+// This is a macro to analyze TRD/Calib/DCS OCDB objects either
+// from the grid for a given run number or from a local object.
+// If you want to analyze data from the grid, please don't forget to
+// have a valid alien token initialized and the file /tmp/gclient_env_$UID source'd.
+//
+// Arguments:
+// The first argument is the runnumber (this is ignored in case of a local file),
+// the second is a string that needs to contain either "grid" or "local". Further
+// you can add either verbose or quiet to that string. If you don't, you'll be asked
+// for all stuff individually wether you want to see it or not
+// the thrid argument is the number of the ROC you (eventually) want to dump its data
+// member of.
+// The fourth one is the path and name of the local file you might want to look at.
+//
+// So the simplest way to use this macro is if you want to check the output of a given
+// run from the OCDB:
+// .x AliTRDcheckConfig.C(60111)
+//
+// An example for quickly checking a local file:
+// .x AliTRDcheckConfig.C(0, "local quiet", 533, "$ALICE_ROOT/TRD/Calib/DCS/Run0_999999999_v0_s0.root")
+//
+// Please contact Frederick Kramer in case of problems
+//===================================================================================
+
+// This is the path one needs to change if the year is no longer 2009
+// and the runnumber cannot be found
+TString alienOcdbPath("alien://folder=/alice/data/2009/OCDB/");
+
+// Do not make changes below here unless you know what your doing
+
+const Int_t nROC = 540;
+const Int_t nROB = 8;
+const Int_t nMCM = 18;
+const Int_t cArraySize = 1000;
+
+Bool_t errors = false;
+
+Int_t AnalyzeArray(Int_t states[cArraySize], Int_t occur[cArraySize]) {
+ long long srtIndx[cArraySize] = 0;
+
+ TMath::Sort(cArraySize, occur, srtIndx);
+
+ Int_t totalSum = 0, subSum = 0, iIndex = 0;
+ for (Int_t i=0; i<cArraySize; i++) totalSum += occur[i];
+
+ cout << " The majority ("<< occur[srtIndx[0]] << " of "
+ << totalSum <<") is: " << states[srtIndx[0]] << endl;
+ subSum = occur[srtIndx[0]];
+ while (totalSum != subSum) {
+ if (++iIndex > 999) {
+ cout << "E : out of bounds." << endl;
+ break;
+ }
+ Printf(" Next: %7d (%d)", states[srtIndx[iIndex]], occur[srtIndx[iIndex]]);
+ subSum += occur[srtIndx[iIndex]];
+ }
+ return states[srtIndx[0]];
+}
+
+
+
+void FillItemInArray(Int_t states[cArraySize], Int_t occur[cArraySize], Int_t item, Bool_t allowNeg) {
+ for (Int_t iArrPos=0; iArrPos<cArraySize; iArrPos++) {
+ // if allowNeg is set then we change the number indicating that the item ws not set from -1 to -100
+ // so that small negitive numbers can be sorted too
+ if ((allowNeg && item == -100000) || (!allowNeg && item == -1)) break; // value not set
+ if (states[iArrPos] == item) {
+ occur[iArrPos]++;
+ break;
+ } else if (occur[iArrPos] == 0) {
+ states[iArrPos] = item;
+ occur[iArrPos]++;
+ break;
+ }
+ }
+}
+
+void GetMajoritys(AliTRDCalDCS* calDCSObj) {
+
+ Int_t gsmStates[cArraySize] = {0}, gsmOccur[cArraySize] = {0};
+ Int_t nimStates[cArraySize] = {0}, nimOccur[cArraySize] = {0};
+ Int_t nevStates[cArraySize] = {0}, nevOccur[cArraySize] = {0};
+ Int_t nptStates[cArraySize] = {0}, nptOccur[cArraySize] = {0};
+
+ for (Int_t i=0; i<cArraySize; i++) {
+ gsmStates[i] = 0; gsmOccur[i] = 0;
+ nimStates[i] = 0; nimOccur[i] = 0;
+ nevStates[i] = 0; nevOccur[i] = 0;
+ nptStates[i] = 0; nptOccur[i] = 0;
+ }
+
+ for (Int_t i=0; i<nROC && i<calDCSObj->GetFEEArr()->GetSize(); i++) {
+ AliTRDCalDCSFEE *idcsfee = calDCSObj->GetCalDCSFEEObj(i);
+ if ((idcsfee == NULL) || (idcsfee->GetStatusBit() != 0)) continue;
+ for (Int_t j=0; j<nROB; j++) {
+ for (Int_t k=0; k<nMCM; k++) {
+ Int_t igsm = idcsfee->GetMCMGlobalState(j,k);
+ Int_t inim = idcsfee->GetMCMStateNI(j,k);
+ Int_t inev = idcsfee->GetMCMEventCnt(j,k);
+ Int_t inpt = idcsfee->GetMCMPtCnt(j,k);
+
+ FillItemInArray(gsmStates, gsmOccur, igsm, false);
+ FillItemInArray(nimStates, nimOccur, inim, false);
+ FillItemInArray(nevStates, nevOccur, inev, false);
+ FillItemInArray(nptStates, nptOccur, inpt, false);
+ }
+ }
+ }
+
+ cout << "I : Global MCM state statistics:" << endl;
+ AnalyzeArray(gsmStates, gsmOccur);
+ cout << "I : Network interface state statistics:" << endl;
+ AnalyzeArray(nimStates, nimOccur);
+ cout << "I : MCM Event counter reading statistics:" << endl;
+ AnalyzeArray(nevStates, nevOccur);
+ cout << "I : MCM PreTrigger counter reading statistics:" << endl;
+ AnalyzeArray(nptStates, nptOccur);
+
+ return;
+}
+
+
+
+void GetMajorityDifferences(AliTRDCalDCS* calDCSObj, AliTRDCalDCS* calDCSObj2) {
+
+ Int_t gsmStates[cArraySize] = {0}, gsmOccur[cArraySize] = {0};
+ Int_t nimStates[cArraySize] = {0}, nimOccur[cArraySize] = {0};
+ Int_t nevStates[cArraySize] = {0}, nevOccur[cArraySize] = {0};
+ Int_t nptStates[cArraySize] = {0}, nptOccur[cArraySize] = {0};
+
+ for (Int_t i=0; i<cArraySize; i++) {
+ gsmStates[i] = 0; gsmOccur[i] = 0;
+ nimStates[i] = 0; nimOccur[i] = 0;
+ nevStates[i] = 0; nevOccur[i] = 0;
+ nptStates[i] = 0; nptOccur[i] = 0;
+ }
+
+ for (Int_t i=0; i<nROC && i<calDCSObj->GetFEEArr()->GetSize() && i<calDCSObj2->GetFEEArr()->GetSize(); i++) {
+ AliTRDCalDCSFEE *idcsfee = calDCSObj->GetCalDCSFEEObj(i);
+ AliTRDCalDCSFEE *idcsfee2 = calDCSObj2->GetCalDCSFEEObj(i);
+ if ((idcsfee == NULL) || (idcsfee2 == NULL) ||
+ (idcsfee->GetStatusBit() != 0) /*|| (idcsfee2->GetStatusBit() != 0)*/) continue;
+ for (Int_t j=0; j<nROB; j++) {
+ for (Int_t k=0; k<nMCM; k++) {
+ Int_t igsm = idcsfee->GetMCMGlobalState(j,k)-idcsfee2->GetMCMGlobalState(j,k);
+ Int_t inim = idcsfee->GetMCMStateNI(j,k)-idcsfee2->GetMCMStateNI(j,k);
+ Int_t inev = idcsfee->GetMCMEventCnt(j,k)-idcsfee2->GetMCMEventCnt(j,k);
+ Int_t inpt = idcsfee->GetMCMPtCnt(j,k)-idcsfee2->GetMCMPtCnt(j,k);
+
+ // if they were set to -1, it means they were not actauuly set
+ // change -1 to -100 to mean they werent set since the above
+ // can give negitives
+ if (idcsfee->GetMCMGlobalState(j,k) == -1 && igsm == 0) igsm =-100000;
+ if (idcsfee->GetMCMStateNI(j,k) == -1 && inim == 0) inim =-100000;
+ if (idcsfee->GetMCMEventCnt(j,k) == -1 && inev == 0) inev =-100000;
+ if (idcsfee->GetMCMPtCnt(j,k) == -1 && inpt == 0) inpt =-100000;
+
+ FillItemInArray(gsmStates, gsmOccur, igsm, true);
+ FillItemInArray(nimStates, nimOccur, inim, true);
+ FillItemInArray(nevStates, nevOccur, inev, true);
+ FillItemInArray(nptStates, nptOccur, inpt, true);
+ }
+ }
+ }
+
+ cout << "I : Global MCM state difference statistics:" << endl;
+ AnalyzeArray(gsmStates, gsmOccur);
+ cout << "I : Network interface state difference statistics:" << endl;
+ AnalyzeArray(nimStates, nimOccur);
+ cout << "I : MCM Event counter difference statistics:" << endl;
+ if (AnalyzeArray(nevStates, nevOccur) < 1) {
+ cout << "E : There should have been some events recorded, but there weren't" << endl;
+ errors = true;
+ }
+ cout << "I : MCM PreTrigger counter difference statistics:" << endl;
+ if (AnalyzeArray(nptStates, nptOccur) < 1) {
+ cout << "E : There should have been some events recorded, but there weren't" << endl;
+ errors = true;
+ }
+
+ return;
+}
+
+
+void AliTRDcheckConfigSimple(Int_t runNr=0, char *pathfile="nopathgiven"){
+
+ AliCDBEntry *entry=0;
+ TString pathfilets(pathfile);
+
+ // get the source
+ if(pathfilets.Contains("nopathgiven")) {
+ cout << "I : Accessing grid storage for run number " << runNr << endl;
+ cout << "I : Get CDBManager instance." << endl;
+ AliCDBManager *man = AliCDBManager::Instance();
+ cout << "I : SetDefaultStorage." << endl;
+ man->SetDefaultStorage(alienOcdbPath);
+ cout << "I : Get OCDB Entry." << endl;
+ entry = man->Get("TRD/Calib/DCS", runNr);
+ if (entry == NULL) {
+ cout << endl << "ERROR: Unable to get the AliTRDCalDCS object from the OCDB for run number " << runNr << endl << endl;
+ cout << "If the run number is correct, it could be that the year is no longer 2009 and" << endl;
+ cout << "the path where the objects is stored has changed, check the top of this macro " << endl;
+ cout << "to change the path." << endl;
+ return;
+ }
+ } else {
+ cout << "I : Accessing local storage" << endl;
+ TFile *f = new TFile(pathfile);
+ if(f != NULL) {
+ entry = (AliCDBEntry*) f->Get("AliCDBEntry");
+ }
+ else {
+ cout << "E : Cannot open file" << endl;
+ return;
+ }
+ }
+
+ TObject *objectCDB = (TObject*)entry->GetObject();
+ if (objectCDB->IsA()->InheritsFrom("TObjArray")) {
+ TObjArray *objArrayCDB = (TObjArray*)entry->GetObject();
+ }
+
+ // the CalDCS object
+ AliTRDCalDCS *caldcs;
+ AliTRDCalDCS *caldcs2;
+
+ Bool_t sorandeor = true;
+
+ caldcs = (AliTRDCalDCS*) objArrayCDB->At(0);
+ caldcs2 = (AliTRDCalDCS*) objArrayCDB->At(1);
+
+ if (caldcs == NULL && caldcs2 == NULL) {
+ cout << "E : Niether the start or end of run files were in the root file.";
+ return;
+ } else if (caldcs != NULL && caldcs2 == NULL) {
+ cout << "E : The EOR file was not in the root file.";
+ errors = true;
+ sorandeor = false;
+ } else if (caldcs == NULL && caldcs2 != NULL) {
+ cout << "E : The SOR file was not in the root file.";
+ errors = true;
+ sorandeor = false;
+ caldcs = caldcs2;
+ }
+
+ cout << endl << "============ Non responding ROC Summary: ============" << endl;
+ TString bitfivestr = " ROCs with status bit 5. These havn't responded to communication\nattempts over DIM. Most probably they just were off this is ok.\n DCS IDs: ";
+ Int_t lengthfive = bitfivestr.Length();
+ TString bitfourstr = " ROCs with status bit 4! BAD! This might be due to a communication problem between fxsproxy and the feeserver(s) \n DCS IDs: ";
+ Int_t lengthfour = bitfourstr.Length();
+ TString bitthreestr = " ROCs with status bit 3! BAD! data from fee server was old or corrupt.\n DCS IDs: ";
+ Int_t lengththree = bitthreestr.Length();
+ TString bittwostr = " ROCs with status bit 2. These have been in states in which they cannot be read out, e.g. Standby.\n DCS IDs: ";
+ Int_t lengthtwo = bittwostr.Length();
+ TString bitonestr = " ROCs with status bit 1! BAD! This means the chamber(s) didn't respont even though is should have been in a good state.\n DCS IDs: ";
+ Int_t lengthone = bitonestr.Length();
+
+ Int_t nSB1=0, nSB2=0, nSB3=0, nSB4=0, nSB5=0, nTot=0;
+ for (Int_t i=0; i<nROC && i<caldcs->GetFEEArr()->GetSize(); i++) {
+ AliTRDCalDCSFEE *idcsfee;
+ idcsfee = caldcs->GetCalDCSFEEObj(i);
+ if (idcsfee != NULL) {
+ Int_t sb = idcsfee->GetStatusBit();
+ if (sb == 5) { bitfivestr += i; bitfivestr += " "; nSB5++; }
+ if (sb == 4) { bitfourstr += i; bitfourstr += " "; nSB4++; errors = true; }
+ if (sb == 3) { bitthreestr += i; bitthreestr += " "; nSB3++; errors = true; }
+ if (sb == 2) { bittwostr += i; bittwostr += " "; nSB2++; }
+ if (sb == 1) { bitonestr += i; bitonestr += " "; nSB1++; errors = true; }
+ nTot += 1;
+ }
+ }
+
+ if (lengthfive < bitfivestr.Length()) cout << nSB5 << bitfivestr.Data() << endl << endl;
+ if (lengthfour < bitfourstr.Length()) cout << nSB4 << bitfourstr.Data() << endl << endl;
+ if (lengththree < bitthreestr.Length()) cout << nSB3 << bitthreestr.Data() << endl << endl;
+ if (lengthtwo < bittwostr.Length()) cout << nSB2 << bittwostr.Data() << endl << endl;
+ if (lengthone < bitonestr.Length()) cout << nSB1 << bitonestr.Data() << endl << endl;
+
+ cout << "The remaining " << nTot-(nSB1+nSB2+nSB3+nSB4+nSB5) << " ROCs responded correctly in the start of run."<<endl;
+
+ Int_t nChanged=0, nTot=0;
+ for (Int_t i=0; i<nROC && i<caldcs->GetFEEArr()->GetSize(); i++) {
+ AliTRDCalDCSFEE *idcsfee;
+ idcsfee = caldcs->GetCalDCSFEEObj(i);
+ idcsfee2 = caldcs2->GetCalDCSFEEObj(i);
+ if (idcsfee != NULL && idcsfee2 != NULL) {
+ Int_t sbd = idcsfee->GetStatusBit() - idcsfee2->GetStatusBit();
+ if (sbd != 0) {
+ cout << "ROC " << i << " changed from state " << idcsfee->GetStatusBit() << " at start of the run to " << idcsfee2->GetStatusBit() << " at the end of the run." << endl;
+ nChanged++;
+ }
+ nTot += 1;
+ }
+ }
+
+ if (nChanged == 0) {
+ cout << "No ROCs changed state between the start and end of the run" << endl;
+ } else {
+ cout << "E : " << nChanged << " out of " << nTot << " ROCs changed state during the run" << endl;
+ errors = true;
+ }
+
+ cout << endl << "============ Statistics from RSTATE: ============" << endl;
+ cout<<"I : The majority entry is given as well as all other values," << endl;
+ cout<<" sorted according to their occurrence." << endl << endl;
+ GetMajoritys(caldcs);
+ if (sorandeor) GetMajorityDifferences(caldcs,caldcs2);
+
+ cout << endl << "============ Global Configuraton: ============" << endl;
+ cout<<"I : Anything not listed is not set, mixed numbers are indicated with a" << endl;
+ cout<<" value of -2 and strings are set to 'mixed' if they're mixed." << endl << endl;
+ if (caldcs->GetGlobalNumberOfTimeBins() != -1)
+ cout<<"Global number of time bins.........................: "<<caldcs->GetGlobalNumberOfTimeBins() << endl;
+ if (caldcs->GetGlobalConfigTag() != -1)
+ cout<<"Global configuration tag...........................: "<<caldcs->GetGlobalConfigTag() << endl;
+ if (caldcs->GetGlobalSingleHitThres() != -1)
+ cout<<"Global single hit threshold........................: "<<caldcs->GetGlobalSingleHitThres() << endl;
+ if (caldcs->GetGlobalThreePadClustThres() != -1)
+ cout<<"Global three pad cluster threshold.................: "<<caldcs->GetGlobalThreePadClustThres()<<endl;
+ if (caldcs->GetGlobalSelectiveNoZS() != -1)
+ cout<<"Global selective ZS (every i'th event).............: "<<caldcs->GetGlobalSelectiveNoZS() << endl;
+ if (caldcs->GetGlobalTCFilterWeight() != -1)
+ cout<<"Global tail cancellation filter weight.............: "<<caldcs->GetGlobalTCFilterWeight() << endl;
+ if (caldcs->GetGlobalTCFilterShortDecPar() != -1)
+ cout<<"Global tail cancellat. filter short decay parameter: "<<caldcs->GetGlobalTCFilterShortDecPar()<<endl;
+ if (caldcs->GetGlobalTCFilterLongDecPar() != -1)
+ cout<<"Global tail cancellation filt. long decay parameter: "<<caldcs->GetGlobalTCFilterLongDecPar()<<endl;
+ if (caldcs->GetGlobalModeFastStatNoise() != -1)
+ cout<<"Global fast statistics mode?.......................: "<<caldcs->GetGlobalModeFastStatNoise() << endl;
+ if (caldcs->GetGlobalConfigVersion() != "")
+ cout<<"Global configuration tag version...................: "<<caldcs->GetGlobalConfigVersion() << endl;
+ if (caldcs->GetGlobalConfigName() != "")
+ cout<<"Global configuration tag name......................: "<<caldcs->GetGlobalConfigName() << endl;
+ if (caldcs->GetGlobalFilterType() != "")
+ cout<<"Global filter type.................................: "<<caldcs->GetGlobalFilterType() << endl;
+ if (caldcs->GetGlobalReadoutParam() != "")
+ cout<<"Global readout parameter...........................: "<<caldcs->GetGlobalReadoutParam() << endl;
+ if (caldcs->GetGlobalTestPattern() != "")
+ cout<<"Global test pattern................................: "<<caldcs->GetGlobalTestPattern() << endl;
+ if (caldcs->GetGlobalTrackletMode() != "")
+ cout<<"Global tracklet mode...............................: "<<caldcs->GetGlobalTrackletMode() << endl;
+ if (caldcs->GetGlobalTrackletDef() != "")
+ cout<<"Global tracklet definition.........................: "<<caldcs->GetGlobalTrackletDef() << endl;
+ if (caldcs->GetGlobalTriggerSetup() != "")
+ cout<<"Global trigger setup...............................: "<<caldcs->GetGlobalTriggerSetup() << endl;
+ if (caldcs->GetGlobalAddOptions() != "")
+ cout<<"Global additional options..........................: "<<caldcs->GetGlobalAddOptions() << endl;
+
+ cout << endl << "============ Error Summary: ============" << endl;
+ if (errors) {
+ cout<<" I noticed some errors, please see above for the specifics." << endl;
+ } else {
+ cout<<" I didn't notice any errors, but that doesn't mean there weren't any!" << endl;
+ }
+
+
+}