-/**************************************************************************\r
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- * *\r
- * Author: The ALICE Off-line Project. *\r
- * Contributors are mentioned in the code where appropriate. *\r
- * *\r
- * Permission to use, copy, modify and distribute this software and its *\r
- * documentation strictly for non-commercial purposes is hereby granted *\r
- * without fee, provided that the above copyright notice appears in all *\r
- * copies and that both the copyright notice and this permission notice *\r
- * appear in the supporting documentation. The authors make no claims *\r
- * about the suitability of this software for any purpose. It is *\r
- * provided "as is" without express or implied warranty. *\r
- **************************************************************************/\r
-\r
-//===================================================================================\r
-// This is a macro to analyze TRD/Calib/DCS OCDB objects either\r
-// from the grid for a given run number or from a local object.\r
-//\r
-// Arguments:\r
-// Either provide a run number as the first argument to access the \r
-// corresponding file on the grid\r
-// or the path + filename as the second argument (and an arbitrary number as the first)\r
-// to access a local file.\r
-//\r
-// Please note that leading zeros in the run number are not supported.\r
-//\r
-// Examples:\r
-// .x AliTRDcheckConfig.C (60111)\r
-// .x AliTRDcheckConfig.C (0, "$ALICE_ROOT/TRD/Calib/DCS/Run0_999999999_v0_s0.root")\r
-//\r
-// Original author:\r
-// Frederick Kramer\r
-// Current maintainer:\r
-// Hans Beck\r
-//===================================================================================\r
-\r
-// Make the macro compile.\r
-#if !defined(__CINT__) || defined(__MAKECINT__)\r
-// Compile me in aliroot with .L AliTRDcheckConfig.C+ or with\r
-// clang -lXMLParser -lGui -lProof -lRAWDatabase -lVMC -lMinuit -lSTEERbase -lANALYSIS -lSTEER -lESD -L$ALICE_BUILD/lib/tgt_`root-config --arch` -lTRDbase -lCDB -lstdc++ `root-config --libs` -I`root-config --incdir` -I$ALICE_ROOT/include AliTRDcheckConfig.C\r
-#include <iostream>\r
-#include <fstream>\r
-#include <TMath.h>\r
-#include <TFile.h>\r
-#include <TGrid.h>\r
-#include <TEnv.h>\r
-#include "../../STEER/CDB/AliCDBEntry.h"\r
-#include "../../STEER/CDB/AliCDBManager.h"\r
-#include "../Cal/AliTRDCalDCS.h"\r
-#include "../Cal/AliTRDCalDCSv2.h"\r
-#include "../Cal/AliTRDCalDCSFEE.h"\r
-#include "../Cal/AliTRDCalDCSFEEv2.h"\r
-\r
-// Not sure where to put it?\r
-using namespace std;\r
-#endif\r
-\r
-const Int_t nROC = 540;\r
-const Int_t nROB = 8;\r
-const Int_t nMCM = 18;\r
-const Int_t cArraySize = 1000;\r
-\r
-Bool_t errors;\r
-Int_t calVer;\r
-//______________________________________________________________________\r
-Int_t AnalyzeArray(Int_t states[cArraySize], Int_t occur[cArraySize]) {\r
- Int_t srtIndx[cArraySize] = {0};\r
- \r
- TMath::Sort(cArraySize, occur, srtIndx);\r
-\r
- Int_t totalSum = 0, subSum = 0, iIndex = 0;\r
- for (Int_t i=0; i<cArraySize; i++) totalSum += occur[i];\r
- \r
- cout << " The majority ("<< occur[srtIndx[0]] << " of " \r
- << totalSum <<") is: " << states[srtIndx[0]] << endl;\r
- subSum = occur[srtIndx[0]];\r
- while (totalSum != subSum) {\r
- if (++iIndex > 999) {\r
- cout << "E : out of bounds." << endl;\r
- break;\r
- }\r
- Printf(" Next: %7d (%d)", states[srtIndx[iIndex]], occur[srtIndx[iIndex]]);\r
- subSum += occur[srtIndx[iIndex]];\r
- }\r
- return states[srtIndx[0]];\r
-}\r
-//______________________________________________________________________\r
-void FillItemInArray(Int_t states[cArraySize], Int_t occur[cArraySize], Int_t item, Bool_t allowNeg) {\r
- for (Int_t iArrPos=0; iArrPos<cArraySize; iArrPos++) {\r
- // if allowNeg is set then we change the number indicating that the item ws not set from -1 to -100\r
- // so that small negative numbers can be sorted too\r
- if ((allowNeg && item == -100000) || (!allowNeg && item == -1)) break; // value not set\r
- if (states[iArrPos] == item) {\r
- occur[iArrPos]++;\r
- break;\r
- } else if (occur[iArrPos] == 0) {\r
- states[iArrPos] = item;\r
- occur[iArrPos]++;\r
- break;\r
- }\r
- }\r
-}\r
-//______________________________________________________________________\r
-void GetMajoritys(TObject* calDCSObj) {\r
- \r
- // Initializes full array with zeros\r
- Int_t gsmStates[cArraySize] = {0}, gsmOccur[cArraySize] = {0};\r
- Int_t nimStates[cArraySize] = {0}, nimOccur[cArraySize] = {0};\r
- Int_t nevStates[cArraySize] = {0}, nevOccur[cArraySize] = {0};\r
- Int_t nptStates[cArraySize] = {0}, nptOccur[cArraySize] = {0};\r
- \r
-\r
- { // Scoped declaration\r
- Int_t feeArrSiz = 0;\r
- if (calVer == 1) {\r
- if(((AliTRDCalDCS*)calDCSObj)->GetFEEArr())\r
- feeArrSiz = ((AliTRDCalDCS*)calDCSObj)->GetFEEArr()->GetSize();\r
- }\r
- else if (calVer == 2) {\r
- if(((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr())\r
- feeArrSiz = ((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr()->GetSize();\r
- }\r
-\r
- TObject* idcsfee;\r
- for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {\r
- if (calVer == 1) idcsfee = ((AliTRDCalDCS*)calDCSObj)->GetCalDCSFEEObj(i);\r
- else if (calVer == 2) idcsfee = ((AliTRDCalDCSv2*)calDCSObj)->GetCalDCSFEEObj(i);\r
- \r
- if (idcsfee == NULL) continue;\r
- \r
- Int_t sbit(-9999);\r
- if (calVer == 1) sbit = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();\r
- else if (calVer == 2) sbit = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();\r
- if (sbit != 0) continue;\r
- \r
- for (Int_t j=0; j<nROB; j++) {\r
- for (Int_t k=0; k<nMCM; k++) {\r
- Int_t igsm = 0;\r
- Int_t inim = 0;\r
- Int_t inev = 0;\r
- Int_t inpt = 0;\r
- if (calVer == 1) {\r
- igsm = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMGlobalState(j,k);\r
- inim = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMStateNI(j,k);\r
- inev = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMEventCnt(j,k);\r
- inpt = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMPtCnt(j,k);\r
- }\r
- else if (calVer == 2) {\r
- igsm = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMGlobalState(j,k);\r
- inim = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMStateNI(j,k);\r
- inev = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMEventCnt(j,k);\r
- inpt = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMPtCnt(j,k);\r
- }\r
-\r
- FillItemInArray(gsmStates, gsmOccur, igsm, false); \r
- FillItemInArray(nimStates, nimOccur, inim, false); \r
- FillItemInArray(nevStates, nevOccur, inev, false); \r
- FillItemInArray(nptStates, nptOccur, inpt, false); \r
- } // End of loop over MCMs\r
- } // End of loop over ROBs\r
- } // End of loop over ROCs\r
- } // End of scoped declaration\r
- \r
- cout << "I : Global MCM state statistics:" << endl;\r
- AnalyzeArray(gsmStates, gsmOccur);\r
- cout << "I : Network interface state statistics:" << endl;\r
- AnalyzeArray(nimStates, nimOccur);\r
- cout << "I : MCM Event counter reading statistics:" << endl;\r
- AnalyzeArray(nevStates, nevOccur);\r
- cout << "I : MCM PreTrigger counter reading statistics:" << endl;\r
- AnalyzeArray(nptStates, nptOccur);\r
- \r
- return;\r
-}\r
-//______________________________________________________________________\r
-void GetMajorityDifferences(TObject* calDCSObj, TObject* calDCSObj2) {\r
- \r
- // Initializes full array with zeros\r
- Int_t gsmStates[cArraySize] = {0}, gsmOccur[cArraySize] = {0};\r
- Int_t nimStates[cArraySize] = {0}, nimOccur[cArraySize] = {0};\r
- Int_t nevStates[cArraySize] = {0}, nevOccur[cArraySize] = {0};\r
- Int_t nptStates[cArraySize] = {0}, nptOccur[cArraySize] = {0};\r
- \r
- \r
- { // Scoped declaration\r
- Int_t feeArrSiz1 = 0;\r
- Int_t feeArrSiz2 = 0;\r
- if (calVer == 1) {\r
- if(((AliTRDCalDCS*)calDCSObj)->GetFEEArr())\r
- feeArrSiz1 = ((AliTRDCalDCS*)calDCSObj)->GetFEEArr()->GetSize();\r
- if(((AliTRDCalDCS*)calDCSObj2)->GetFEEArr())\r
- feeArrSiz2 = ((AliTRDCalDCS*)calDCSObj2)->GetFEEArr()->GetSize();\r
- }\r
- else if (calVer == 2) {\r
- if(((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr())\r
- feeArrSiz1 = ((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr()->GetSize();\r
- if(((AliTRDCalDCSv2*)calDCSObj2)->GetFEEArr())\r
- feeArrSiz2 = ((AliTRDCalDCSv2*)calDCSObj2)->GetFEEArr()->GetSize();\r
- }\r
-\r
- TObject* idcsfee;\r
- TObject* idcsfee2;\r
- for (Int_t i=0; i<nROC && i<feeArrSiz1 && i<feeArrSiz2; i++) {\r
- if (calVer == 1) {\r
- idcsfee = ((AliTRDCalDCS*)calDCSObj)->GetCalDCSFEEObj(i);\r
- idcsfee2 = ((AliTRDCalDCS*)calDCSObj2)->GetCalDCSFEEObj(i);\r
- }\r
- else if (calVer == 2) {\r
- idcsfee = ((AliTRDCalDCSv2*)calDCSObj)->GetCalDCSFEEObj(i);\r
- idcsfee2 = ((AliTRDCalDCSv2*)calDCSObj2)->GetCalDCSFEEObj(i);\r
- }\r
- if ((idcsfee == NULL) || (idcsfee2 == NULL)) continue;\r
- \r
- Int_t sbit(-9999);\r
- if (calVer == 1) sbit = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();\r
- else if (calVer == 2) sbit = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();\r
- if (sbit != 0) continue;\r
- \r
- for (Int_t j=0; j<nROB; j++) {\r
- for (Int_t k=0; k<nMCM; k++) {\r
- Int_t igsm, inim, inev, inpt, igsm1, inim1, inev1, inpt1, igsm2, inim2, inev2, inpt2;\r
- if (calVer == 1) {\r
- igsm1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMGlobalState(j,k);\r
- inim1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMStateNI(j,k);\r
- inev1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMEventCnt(j,k);\r
- inpt1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMPtCnt(j,k);\r
- igsm2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMGlobalState(j,k);\r
- inim2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMStateNI(j,k);\r
- inev2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMEventCnt(j,k);\r
- inpt2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMPtCnt(j,k);\r
- }\r
- else if (calVer == 2) {\r
- igsm1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMGlobalState(j,k);\r
- inim1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMStateNI(j,k);\r
- inev1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMEventCnt(j,k);\r
- inpt1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMPtCnt(j,k);\r
- igsm2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMGlobalState(j,k);\r
- inim2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMStateNI(j,k);\r
- inev2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMEventCnt(j,k);\r
- inpt2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMPtCnt(j,k);\r
- }\r
- \r
- igsm = igsm1 - igsm2;\r
- inim = inim1 - inim2;\r
- inev = inev2 - inev1;\r
- inpt = inpt2 - inpt1;\r
- \r
- // if they were set to -1, it means they were not actauuly set\r
- // change -1 to -100 to mean they werent set since the above \r
- // can give negatives\r
- if (igsm1 == -1 && igsm == 0) igsm =-100000;\r
- if (inim1 == -1 && inim == 0) inim =-100000;\r
- if (inev1 == -1 && inev == 0) inev =-100000;\r
- if (inpt1 == -1 && inpt == 0) inpt =-100000;\r
- \r
- FillItemInArray(gsmStates, gsmOccur, igsm, true); \r
- FillItemInArray(nimStates, nimOccur, inim, true); \r
- FillItemInArray(nevStates, nevOccur, inev, true); \r
- FillItemInArray(nptStates, nptOccur, inpt, true); \r
- } // End of loop over MCMs\r
- } // End of loop over ROBs\r
- } // End of loop over ROCs\r
- } // End of scoped declaration\r
- \r
- cout << "I : Global MCM state difference statistics:" << endl;\r
- AnalyzeArray(gsmStates, gsmOccur);\r
- cout << "I : Network interface state difference statistics:" << endl;\r
- AnalyzeArray(nimStates, nimOccur);\r
- cout << "I : MCM Event counter difference statistics:" << endl;\r
- if (AnalyzeArray(nevStates, nevOccur) < 1) {\r
- cout << "E : There should have been some events recorded, but there weren't" << endl;\r
- errors = true;\r
- }\r
- cout << "I : MCM PreTrigger counter difference statistics:" << endl;\r
- if (AnalyzeArray(nptStates, nptOccur) < 1) {\r
- cout << "E : There should have been some events recorded, but there weren't" << endl;\r
- errors = true;\r
- }\r
- \r
- return;\r
-}\r
-//______________________________________________________________________\r
-void WrappedAliTRDcheckConfig(Int_t runNr, const char *pathfile,TFile *f){\r
- // Reset the 'errors occured' bool as it's global\r
- errors=false;\r
- \r
- AliCDBEntry *entry=0;\r
- TString pathfilets(pathfile);\r
-\r
- // get the source\r
- if(pathfilets.Contains("nopathgiven")) {\r
- cout << "I : Accessing grid storage for run number " << runNr << endl;\r
- cout << "I : Get CDBManager instance." << endl;\r
- AliCDBManager *man = AliCDBManager::Instance();\r
- cout << "I : SetDefaultStorage." << endl;\r
- man->SetDefaultStorageFromRun(runNr);\r
-\r
- cout << "I : Get OCDB Entry." << endl;\r
- entry = man->Get("TRD/Calib/DCS", runNr);\r
- if (entry == NULL) {\r
- cout << endl << "ERROR: Unable to get the AliTRDCalDCS object"\r
- << "from the OCDB for run number " << runNr << "." << endl;\r
- return;\r
- }\r
- } else {\r
- cout << "I : Accessing file directly" << endl;\r
- // Might be we want to check a file on the grid\r
- if(pathfilets.BeginsWith("alien://"))\r
- TGrid::Connect("alien://");\r
- f = TFile::Open(pathfile);\r
- if(f != NULL) {\r
- entry = (AliCDBEntry*) f->Get("AliCDBEntry");\r
- if(!entry){\r
- cout << "E : Can not get the OCDB entry"<<endl;\r
- return;\r
- }\r
- }\r
- else {\r
- cout << "E : Cannot open file" << endl;\r
- return;\r
- }\r
- }\r
- \r
- TObjArray *objArrayCDB = (TObjArray*)entry->GetObject();\r
- if(!objArrayCDB){\r
- cout << "E : Can not get the OCDB object"<<endl;\r
- return;\r
- }\r
- \r
- Int_t iesor=0;\r
- for (iesor=0; iesor<3; iesor++) if(objArrayCDB->At(iesor)) break;\r
- if (iesor > 1) {\r
- cout << "E : Neither the start or end of run objects were in the root file.";\r
- return;\r
- }\r
-\r
- Bool_t hasSOR = (objArrayCDB->At(0));\r
- Bool_t hasEOR = (objArrayCDB->At(1));\r
- printf("SOR entry: %d, EOR entry: %d\n", hasSOR, hasEOR);\r
-\r
- if (!strcmp(objArrayCDB->At(iesor)->ClassName(),"AliTRDCalDCS")) calVer = 1;\r
- else if (!strcmp(objArrayCDB->At(iesor)->ClassName(),"AliTRDCalDCSv2")) calVer = 2;\r
- else { \r
- cout << "E : Object types undefined.";\r
- return;\r
- }\r
-\r
- Bool_t sorandeor = true;\r
- TObject *caldcs = objArrayCDB->At(0);\r
- TObject *caldcs2 = objArrayCDB->At(1);\r
-\r
- if (caldcs == NULL && caldcs2 == NULL) {\r
- cout << "E : Neither the start or end of run objects were in the root file.";\r
- return;\r
- } else if (caldcs != NULL && caldcs2 == NULL) {\r
- cout << "E : The EOR file was not in the root file.";\r
- errors = true;\r
- sorandeor = false;\r
- } else if (caldcs == NULL && caldcs2 != NULL) {\r
- cout << "E : The SOR file was not in the root file.";\r
- errors = true;\r
- sorandeor = false;\r
- caldcs = caldcs2;\r
- }\r
-\r
- cout << endl << "============ Non responding ROC Summary: ============" << endl;\r
- 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: ";\r
- Int_t lengthfive = bitfivestr.Length();\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
- Int_t lengthfour = bitfourstr.Length();\r
- TString bitthreestr = " ROCs with status bit 3! BAD! data from fee server was old or corrupt.\n DCS IDs: ";\r
- Int_t lengththree = bitthreestr.Length();\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
- Int_t lengthtwo = bittwostr.Length();\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
- Int_t lengthone = bitonestr.Length();\r
-\r
-\r
- Int_t nSB1=0, nSB2=0, nSB3=0, nSB4=0, nSB5=0, nTot=0, nChanged=0;\r
- { // Scoped declaration\r
-\r
- // Determine the size of the array\r
- Int_t feeArrSiz = 0;\r
- if (calVer == 1) {\r
- if(((AliTRDCalDCS*)caldcs)->GetFEEArr())\r
- feeArrSiz = ((AliTRDCalDCS*)caldcs)->GetFEEArr()->GetSize();\r
- }\r
- else if (calVer == 2) {\r
- if(((AliTRDCalDCSv2*)caldcs)->GetFEEArr())\r
- feeArrSiz = ((AliTRDCalDCSv2*)caldcs)->GetFEEArr()->GetSize();\r
- }\r
-\r
- // Check the status/error bist for each ROC\r
- TObject* idcsfee;\r
- TObject* idcsfee2;\r
- // Loop over the ROCs / the array\r
- for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {\r
- if (calVer == 1) idcsfee = ((AliTRDCalDCS*)caldcs)->GetCalDCSFEEObj(i);\r
- else if (calVer == 2) idcsfee = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(i);\r
- if (idcsfee != NULL) {\r
- Int_t sb;\r
- if (calVer == 1) sb = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();\r
- else if (calVer == 2) sb = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();\r
- if (sb == 5) { bitfivestr += i; bitfivestr += " "; nSB5++; }\r
- else if (sb == 4) { bitfourstr += i; bitfourstr += " "; nSB4++; errors = true; }\r
- else if (sb == 3) { bitthreestr += i; bitthreestr += " "; nSB3++; errors = true; }\r
- else if (sb == 2) { bittwostr += i; bittwostr += " "; nSB2++; }\r
- else if (sb == 1) { bitonestr += i; bitonestr += " "; nSB1++; errors = true; }\r
- nTot += 1;\r
- }\r
- } // End of loop over ROCs\r
-\r
- // Print the statistcs for the status/error bits\r
- if (lengthfive < bitfivestr.Length()) cout << nSB5 << bitfivestr.Data() << endl << endl;\r
- if (lengthfour < bitfourstr.Length()) cout << nSB4 << bitfourstr.Data() << endl << endl;\r
- if (lengththree < bitthreestr.Length()) cout << nSB3 << bitthreestr.Data() << endl << endl;\r
- if (lengthtwo < bittwostr.Length()) cout << nSB2 << bittwostr.Data() << endl << endl;\r
- if (lengthone < bitonestr.Length()) cout << nSB1 << bitonestr.Data() << endl << endl;\r
- \r
- cout << "The remaining " << nTot-(nSB1+nSB2+nSB3+nSB4+nSB5) << " ROCs responded correctly in the start of run."<<endl;\r
- \r
- // Reusing nTot\r
- nTot=0;\r
- for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {\r
- if (calVer == 1) {\r
- if (caldcs) idcsfee = ((AliTRDCalDCS*)caldcs)->GetCalDCSFEEObj(i);\r
- if (caldcs2) idcsfee2 = ((AliTRDCalDCS*)caldcs2)->GetCalDCSFEEObj(i);\r
- }\r
- else if (calVer == 2) {\r
- if (caldcs) idcsfee = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(i);\r
- if (caldcs2) idcsfee2 = ((AliTRDCalDCSv2*)caldcs2)->GetCalDCSFEEObj(i);\r
- }\r
- if (idcsfee != NULL && idcsfee2 != NULL) {\r
- Int_t sbd1 = 0;\r
- Int_t sbd2 = 0;\r
- if (calVer == 1) {\r
- sbd1 = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();\r
- sbd2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetStatusBit();\r
- }\r
- if (calVer == 2) {\r
- sbd1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();\r
- sbd2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetStatusBit();\r
- }\r
- Int_t sbd = sbd1 - sbd2;\r
- if (sbd != 0) { \r
- cout << "ROC " << i << " changed from state " << sbd1 << " at start of the run to " << sbd2 << " at the end of the run." << endl;\r
- cout << "ROC " << i << " changed from state " << sbd1 << " at start of the run to " << sbd2 << " at the end of the run." << endl;\r
- nChanged++; \r
- }\r
- nTot += 1;\r
- }\r
- } // End of loop over ROCs\r
- } // End of scoped declaration\r
- if (nChanged == 0) {\r
- cout << "No ROCs changed state between the start and end of the run" << endl;\r
- } else {\r
- cout << "E : " << nChanged << " out of " << nTot << " ROCs changed state during the run" << endl;\r
- errors = true; \r
- }\r
-\r
- cout << endl << "============ Statistics from RSTATE: ============" << endl;\r
- cout<<"I : The majority entry is given as well as all other values," << endl;\r
- cout<<" sorted according to their occurrence." << endl << endl;\r
- GetMajoritys(caldcs);\r
- if (sorandeor) GetMajorityDifferences(caldcs,caldcs2);\r
-\r
- cout << endl << "============ Global Configuraton: ============" << endl;\r
- cout<<"I : Anything not listed is not set, mixed numbers are indicated with a" << endl;\r
- cout<<" value of -2 and strings are set to 'mixed' if they're mixed." << endl << endl;\r
- \r
- Int_t gtb, gct, gsh, gtc, gsz, gfw, gfs, gfl, gsn;\r
- TString gcv, gcn, gft, grp, gtp, gtm, gtd, gts, gao;\r
-\r
- if (calVer == 1) {\r
- gtb = ((AliTRDCalDCS*)caldcs)->GetGlobalNumberOfTimeBins();\r
- gct = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigTag();\r
- gsh = ((AliTRDCalDCS*)caldcs)->GetGlobalSingleHitThres();\r
- gtc = ((AliTRDCalDCS*)caldcs)->GetGlobalThreePadClustThres();\r
- gsz = ((AliTRDCalDCS*)caldcs)->GetGlobalSelectiveNoZS();\r
- gfw = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterWeight();\r
- gfs = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterShortDecPar();\r
- gfl = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterLongDecPar();\r
- gsn = ((AliTRDCalDCS*)caldcs)->GetGlobalModeFastStatNoise();\r
- gcv = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigVersion();\r
- gcn = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigName();\r
- gft = ((AliTRDCalDCS*)caldcs)->GetGlobalFilterType();\r
- grp = ((AliTRDCalDCS*)caldcs)->GetGlobalReadoutParam();\r
- gtp = ((AliTRDCalDCS*)caldcs)->GetGlobalTestPattern();\r
- gtm = ((AliTRDCalDCS*)caldcs)->GetGlobalTrackletMode();\r
- gtd = ((AliTRDCalDCS*)caldcs)->GetGlobalTrackletDef();\r
- gts = ((AliTRDCalDCS*)caldcs)->GetGlobalTriggerSetup();\r
- gao = ((AliTRDCalDCS*)caldcs)->GetGlobalAddOptions();\r
- }\r
- else if (calVer == 2) {\r
- gtb = ((AliTRDCalDCSv2*)caldcs)->GetGlobalNumberOfTimeBins();\r
- gct = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigTag();\r
- gsh = ((AliTRDCalDCSv2*)caldcs)->GetGlobalSingleHitThres();\r
- gtc = ((AliTRDCalDCSv2*)caldcs)->GetGlobalThreePadClustThres();\r
- gsz = ((AliTRDCalDCSv2*)caldcs)->GetGlobalSelectiveNoZS();\r
- gfw = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterWeight();\r
- gfs = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterShortDecPar();\r
- gfl = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterLongDecPar();\r
- gsn = ((AliTRDCalDCSv2*)caldcs)->GetGlobalModeFastStatNoise();\r
- gcv = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigVersion();\r
- gcn = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigName();\r
- gft = ((AliTRDCalDCSv2*)caldcs)->GetGlobalFilterType();\r
- grp = ((AliTRDCalDCSv2*)caldcs)->GetGlobalReadoutParam();\r
- gtp = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTestPattern();\r
- gtm = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTrackletMode();\r
- gtd = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTrackletDef();\r
- gts = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTriggerSetup();\r
- gao = ((AliTRDCalDCSv2*)caldcs)->GetGlobalAddOptions();\r
- }\r
-\r
-\r
- if (gtb != -1) cout<<"Global number of time bins.........................: "<< gtb << endl;\r
- if (gct != -1) cout<<"Global configuration tag...........................: "<< gct << endl;\r
- if (gsh != -1) cout<<"Global single hit threshold........................: "<< gsh << endl;\r
- if (gtc != -1) cout<<"Global three pad cluster threshold.................: "<< gtc << endl;\r
- if (gsz != -1) cout<<"Global selective ZS (every i'th event).............: "<< gsz << endl;\r
- if (gfw != -1) cout<<"Global tail cancellation filter weight.............: "<< gfs << endl;\r
- if (gfs != -1) cout<<"Global tail cancellat. filter short decay parameter: "<< gfs << endl;\r
- if (gfl != -1) cout<<"Global tail cancellation filt. long decay parameter: "<< gfl << endl;\r
- if (gsn != -1) cout<<"Global fast statistics mode?.......................: "<< gsn << endl;\r
- if (gcv != "") cout<<"Global configuration tag version...................: "<< gcv << endl;\r
- if (gcn != "") cout<<"Global configuration tag name......................: "<< gcn << endl;\r
- if (gft != "") cout<<"Global filter type.................................: "<< gft << endl;\r
- if (grp != "") cout<<"Global readout parameter...........................: "<< grp << endl;\r
- if (gtp != "") cout<<"Global test pattern................................: "<< gtp << endl;\r
- if (gtm != "") cout<<"Global tracklet mode...............................: "<< gtm << endl;\r
- if (gtd != "") cout<<"Global tracklet definition.........................: "<< gtd << endl;\r
- if (gts != "") cout<<"Global trigger setup...............................: "<< gts << endl;\r
- if (gao != "") cout<<"Global additional options..........................: "<< gao << endl;\r
- \r
- cout << endl << "============ Error Summary: ============" << endl;\r
- if (errors) {\r
- cout<<" I noticed some errors, please see above for the specifics." << endl;\r
- } else {\r
- cout<<" I didn't notice any errors, but that doesn't mean there weren't any!" << endl;\r
- }\r
-//______________________________________________________________________\r
-}\r
-void AliTRDcheckConfig(Int_t runNr=0, const char *pathfile="nopathgiven"){\r
- // Wrapping the function to be able to clean up\r
- TFile *f=0;\r
- WrappedAliTRDcheckConfig(runNr,pathfile,f);\r
- AliCDBManager::Destroy();\r
- if(f){\r
- delete f; // Destructor calls TFile::Close()\r
- f=0;\r
- }\r
-}\r
-//______________________________________________________________________\r
-//\r
-// The stuff below is only for compiling a standalone program,\r
-// i.e., without root / aliroot \r
-//\r
-#if !defined(__CINT__)\r
-//______________________________________________________________________\r
-void reduceTimeOuts(){\r
- // Reduces the grid timeouts\r
- gEnv->SetValue("XNet.ConnectTimeout" , 20);\r
- gEnv->SetValue("XNet.RequestTimeout" , 40);\r
- gEnv->SetValue("XNet.MaxRedirectCount" , 2);\r
- gEnv->SetValue("XNet.ReconnectWait" , 2);\r
- gEnv->SetValue("XNet.FirstConnectMaxCnt", 3);\r
- gEnv->SetValue("XNet.TransactionTimeout",300);\r
-}\r
-//______________________________________________________________________\r
-void printHelp(const char* argv0){\r
- cout <<"Usuage: "<<argv0<< " [arg1 [arg2]]"<<endl\r
- <<"Where arg1 can be:"<<endl\r
- <<" of type int-> gets treated as run number"<<endl\r
- <<" *.txt -> gets treated as list of run numbers"<<endl\r
- <<" *.root -> gets treated as OCDB entry"<<endl\r
- <<" -h,--help -> displays this help"<<endl\r
- <<"and arg2 can be"<<endl\r
- <<" -f, --fast -> reduces grid timeouts"<<endl;\r
-}\r
-//______________________________________________________________________\r
-int main(int argc,char** argv){\r
- // This macro is a standalone program.\r
- \r
- // We change the meaning of the input \r
- // parameters a bit. See the help message\r
-\r
- // Error if too many arguments\r
- if(argc>3){\r
- cout << "Too many arguments!"<<endl;\r
- printHelp(argv[0]);\r
- return 1;\r
- }\r
-\r
- // Check the argument two if any\r
- if(argc>2){\r
- if( (!strcmp("-f",argv[2])) ||\r
- (!strcmp("--fast",argv[2])) ){\r
- reduceTimeOuts();\r
- }\r
- else {\r
- cout <<"Couldn't recognize your argument "\r
- <<argv[2]<<endl;\r
- printHelp(argv[0]);\r
- return 1;\r
- }\r
- }\r
-\r
- // Check argument one\r
- if(argc>1){\r
- // Convert to TString for easier handling\r
- TString input(argv[1]);\r
- // Help message\r
- if( (!strcmp("-h",argv[1])) ||\r
- (!strcmp("--help",argv[1])) ) {\r
- printHelp(argv[0]);\r
- return 0;\r
- }\r
- // int aka run number provided\r
- else if(input.IsDigit()){\r
- AliTRDcheckConfig(input.Atoi());\r
- return 0;\r
- }\r
- // .root aka OCDB file provided\r
- else if(input.EndsWith(".root")){\r
- AliTRDcheckConfig(0,input.Data());\r
- return 0;\r
- }\r
- // .txt aka list of root files provided\r
- else if(input.EndsWith(".txt")){\r
- // Open the text file\r
- ifstream in;\r
- in.open(Form("%s",input.Data()));\r
- if (!in.is_open()){\r
- cout << "F: Could not open file "<<input.Data()<<endl;\r
- return 1;\r
- }\r
- // Loop over entries\r
- string line;\r
- TString Line;\r
- while(in.good()) {\r
- // Reading the line in the .txt file works fine\r
- if(!getline(in,line)) break;\r
- Line=line.data();\r
- if(Line.IsNull()) continue;\r
- // Run number provided\r
- if(Line.IsDigit()){\r
- AliTRDcheckConfig(Line.Atoi());\r
- }\r
- // .root file provided\r
- else if(Line.EndsWith(".root")){\r
- AliTRDcheckConfig(0,Line.Data());\r
- }\r
- else {\r
- cout <<"Bad line in .txt file: "\r
- <<Line.Data()<<endl;\r
- }\r
- } // End of loop over .txt file lines\r
- return 0;\r
- }\r
- // Bad input, neither .root nor .txt nor int\r
- else {\r
- cout <<"Cannot recognize your input"\r
- <<input.Data()<<endl;\r
- printHelp(argv[0]);\r
- return 1;\r
- }\r
- } // End of argc>1\r
- \r
- // Without arguments\r
- AliTRDcheckConfig();\r
- return 0;\r
-}// End of main\r
-\r
-// End of the non-root part\r
-#endif\r
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+//===================================================================================
+// 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.
+//
+// Arguments:
+// Either provide a run number as the first argument to access the
+// corresponding file on the grid
+// or the path + filename as the second argument (and an arbitrary number as the first)
+// to access a local file.
+//
+// Please note that leading zeros in the run number are not supported.
+//
+// Examples:
+// .x AliTRDcheckConfig.C (60111)
+// .x AliTRDcheckConfig.C (0, "$ALICE_ROOT/TRD/Calib/DCS/Run0_999999999_v0_s0.root")
+//
+// Original author:
+// Frederick Kramer
+// Current maintainer:
+// Hans Beck
+//===================================================================================
+
+// Make the macro compile.
+#if !defined(__CINT__) || defined(__MAKECINT__)
+// Compile me in aliroot with .L AliTRDcheckConfig.C+ or with
+// clang -lXMLParser -lGui -lProof -lRAWDatabase -lVMC -lMinuit -lSTEERbase -lANALYSIS -lSTEER -lESD -L$ALICE_BUILD/lib/tgt_`root-config --arch` -lTRDbase -lCDB -lstdc++ `root-config --libs` -I`root-config --incdir` -I$ALICE_ROOT/include AliTRDcheckConfig.C
+#include <iostream>
+#include <fstream>
+#include <TMath.h>
+#include <TFile.h>
+#include <TGrid.h>
+#include <TEnv.h>
+#include "../../STEER/CDB/AliCDBEntry.h"
+#include "../../STEER/CDB/AliCDBManager.h"
+#include "../Cal/AliTRDCalDCS.h"
+#include "../Cal/AliTRDCalDCSv2.h"
+#include "../Cal/AliTRDCalDCSFEE.h"
+#include "../Cal/AliTRDCalDCSFEEv2.h"
+
+// Not sure where to put it?
+using namespace std;
+#endif
+
+const Int_t nROC = 540;
+const Int_t nROB = 8;
+const Int_t nMCM = 18;
+const Int_t cArraySize = 1000;
+
+Bool_t errors;
+Int_t calVer;
+//______________________________________________________________________
+Int_t AnalyzeArray(Int_t states[cArraySize], Int_t occur[cArraySize]) {
+ Int_t 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 negative 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(TObject* calDCSObj) {
+
+ // Initializes full array with zeros
+ 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};
+
+
+ { // Scoped declaration
+ Int_t feeArrSiz = 0;
+ if (calVer == 1) {
+ if(((AliTRDCalDCS*)calDCSObj)->GetFEEArr())
+ feeArrSiz = ((AliTRDCalDCS*)calDCSObj)->GetFEEArr()->GetSize();
+ }
+ else if (calVer == 2) {
+ if(((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr())
+ feeArrSiz = ((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr()->GetSize();
+ }
+
+ TObject* idcsfee;
+ for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {
+ if (calVer == 1) idcsfee = ((AliTRDCalDCS*)calDCSObj)->GetCalDCSFEEObj(i);
+ else if (calVer == 2) idcsfee = ((AliTRDCalDCSv2*)calDCSObj)->GetCalDCSFEEObj(i);
+
+ if (idcsfee == NULL) continue;
+
+ Int_t sbit(-9999);
+ if (calVer == 1) sbit = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
+ else if (calVer == 2) sbit = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();
+ if (sbit != 0) continue;
+
+ for (Int_t j=0; j<nROB; j++) {
+ for (Int_t k=0; k<nMCM; k++) {
+ Int_t igsm = 0;
+ Int_t inim = 0;
+ Int_t inev = 0;
+ Int_t inpt = 0;
+ if (calVer == 1) {
+ igsm = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMGlobalState(j,k);
+ inim = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMStateNI(j,k);
+ inev = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMEventCnt(j,k);
+ inpt = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMPtCnt(j,k);
+ }
+ else if (calVer == 2) {
+ igsm = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMGlobalState(j,k);
+ inim = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMStateNI(j,k);
+ inev = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMEventCnt(j,k);
+ inpt = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMPtCnt(j,k);
+ }
+
+ FillItemInArray(gsmStates, gsmOccur, igsm, false);
+ FillItemInArray(nimStates, nimOccur, inim, false);
+ FillItemInArray(nevStates, nevOccur, inev, false);
+ FillItemInArray(nptStates, nptOccur, inpt, false);
+ } // End of loop over MCMs
+ } // End of loop over ROBs
+ } // End of loop over ROCs
+ } // End of scoped declaration
+
+ 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(TObject* calDCSObj, TObject* calDCSObj2) {
+
+ // Initializes full array with zeros
+ 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};
+
+
+ { // Scoped declaration
+ Int_t feeArrSiz1 = 0;
+ Int_t feeArrSiz2 = 0;
+ if (calVer == 1) {
+ if(((AliTRDCalDCS*)calDCSObj)->GetFEEArr())
+ feeArrSiz1 = ((AliTRDCalDCS*)calDCSObj)->GetFEEArr()->GetSize();
+ if(((AliTRDCalDCS*)calDCSObj2)->GetFEEArr())
+ feeArrSiz2 = ((AliTRDCalDCS*)calDCSObj2)->GetFEEArr()->GetSize();
+ }
+ else if (calVer == 2) {
+ if(((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr())
+ feeArrSiz1 = ((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr()->GetSize();
+ if(((AliTRDCalDCSv2*)calDCSObj2)->GetFEEArr())
+ feeArrSiz2 = ((AliTRDCalDCSv2*)calDCSObj2)->GetFEEArr()->GetSize();
+ }
+
+ TObject* idcsfee;
+ TObject* idcsfee2;
+ for (Int_t i=0; i<nROC && i<feeArrSiz1 && i<feeArrSiz2; i++) {
+ if (calVer == 1) {
+ idcsfee = ((AliTRDCalDCS*)calDCSObj)->GetCalDCSFEEObj(i);
+ idcsfee2 = ((AliTRDCalDCS*)calDCSObj2)->GetCalDCSFEEObj(i);
+ }
+ else if (calVer == 2) {
+ idcsfee = ((AliTRDCalDCSv2*)calDCSObj)->GetCalDCSFEEObj(i);
+ idcsfee2 = ((AliTRDCalDCSv2*)calDCSObj2)->GetCalDCSFEEObj(i);
+ }
+ if ((idcsfee == NULL) || (idcsfee2 == NULL)) continue;
+
+ Int_t sbit(-9999);
+ if (calVer == 1) sbit = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
+ else if (calVer == 2) sbit = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();
+ if (sbit != 0) continue;
+
+ for (Int_t j=0; j<nROB; j++) {
+ for (Int_t k=0; k<nMCM; k++) {
+ Int_t igsm, inim, inev, inpt, igsm1, inim1, inev1, inpt1, igsm2, inim2, inev2, inpt2;
+ if (calVer == 1) {
+ igsm1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMGlobalState(j,k);
+ inim1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMStateNI(j,k);
+ inev1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMEventCnt(j,k);
+ inpt1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMPtCnt(j,k);
+ igsm2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMGlobalState(j,k);
+ inim2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMStateNI(j,k);
+ inev2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMEventCnt(j,k);
+ inpt2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMPtCnt(j,k);
+ }
+ else if (calVer == 2) {
+ igsm1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMGlobalState(j,k);
+ inim1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMStateNI(j,k);
+ inev1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMEventCnt(j,k);
+ inpt1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMPtCnt(j,k);
+ igsm2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMGlobalState(j,k);
+ inim2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMStateNI(j,k);
+ inev2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMEventCnt(j,k);
+ inpt2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMPtCnt(j,k);
+ }
+
+ igsm = igsm1 - igsm2;
+ inim = inim1 - inim2;
+ inev = inev2 - inev1;
+ inpt = inpt2 - inpt1;
+
+ // 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 negatives
+ if (igsm1 == -1 && igsm == 0) igsm =-100000;
+ if (inim1 == -1 && inim == 0) inim =-100000;
+ if (inev1 == -1 && inev == 0) inev =-100000;
+ if (inpt1 == -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);
+ } // End of loop over MCMs
+ } // End of loop over ROBs
+ } // End of loop over ROCs
+ } // End of scoped declaration
+
+ 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 WrappedAliTRDcheckConfig(Int_t runNr, const char *pathfile,TFile *f){
+ // Reset the 'errors occured' bool as it's global
+ errors=false;
+
+ 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->SetDefaultStorageFromRun(runNr);
+
+ 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;
+ return;
+ }
+ } else {
+ cout << "I : Accessing file directly" << endl;
+ // Might be we want to check a file on the grid
+ if(pathfilets.BeginsWith("alien://"))
+ TGrid::Connect("alien://");
+ f = TFile::Open(pathfile);
+ if(f != NULL) {
+ entry = (AliCDBEntry*) f->Get("AliCDBEntry");
+ if(!entry){
+ cout << "E : Can not get the OCDB entry"<<endl;
+ return;
+ }
+ }
+ else {
+ cout << "E : Cannot open file" << endl;
+ return;
+ }
+ }
+
+ TObjArray *objArrayCDB = (TObjArray*)entry->GetObject();
+ if(!objArrayCDB){
+ cout << "E : Can not get the OCDB object"<<endl;
+ return;
+ }
+
+ Int_t iesor=0;
+ for (iesor=0; iesor<3; iesor++) if(objArrayCDB->At(iesor)) break;
+ if (iesor > 1) {
+ cout << "E : Neither the start or end of run objects were in the root file.";
+ return;
+ }
+
+ Bool_t hasSOR = (objArrayCDB->At(0));
+ Bool_t hasEOR = (objArrayCDB->At(1));
+ printf("SOR entry: %d, EOR entry: %d\n", hasSOR, hasEOR);
+
+ if (!strcmp(objArrayCDB->At(iesor)->ClassName(),"AliTRDCalDCS")) calVer = 1;
+ else if (!strcmp(objArrayCDB->At(iesor)->ClassName(),"AliTRDCalDCSv2")) calVer = 2;
+ else {
+ cout << "E : Object types undefined.";
+ return;
+ }
+
+ Bool_t sorandeor = true;
+ TObject *caldcs = objArrayCDB->At(0);
+ TObject *caldcs2 = objArrayCDB->At(1);
+
+ if (caldcs == NULL && caldcs2 == NULL) {
+ cout << "E : Neither the start or end of run objects 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, nChanged=0;
+ { // Scoped declaration
+
+ // Determine the size of the array
+ Int_t feeArrSiz = 0;
+ if (calVer == 1) {
+ if(((AliTRDCalDCS*)caldcs)->GetFEEArr())
+ feeArrSiz = ((AliTRDCalDCS*)caldcs)->GetFEEArr()->GetSize();
+ }
+ else if (calVer == 2) {
+ if(((AliTRDCalDCSv2*)caldcs)->GetFEEArr())
+ feeArrSiz = ((AliTRDCalDCSv2*)caldcs)->GetFEEArr()->GetSize();
+ }
+
+ // Check the status/error bist for each ROC
+ TObject* idcsfee;
+ TObject* idcsfee2;
+ // Loop over the ROCs / the array
+ for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {
+ if (calVer == 1) idcsfee = ((AliTRDCalDCS*)caldcs)->GetCalDCSFEEObj(i);
+ else if (calVer == 2) idcsfee = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(i);
+ if (idcsfee != NULL) {
+ Int_t sb;
+ if (calVer == 1) sb = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
+ else if (calVer == 2) sb = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();
+ if (sb == 5) { bitfivestr += i; bitfivestr += " "; nSB5++; }
+ else if (sb == 4) { bitfourstr += i; bitfourstr += " "; nSB4++; errors = true; }
+ else if (sb == 3) { bitthreestr += i; bitthreestr += " "; nSB3++; errors = true; }
+ else if (sb == 2) { bittwostr += i; bittwostr += " "; nSB2++; }
+ else if (sb == 1) { bitonestr += i; bitonestr += " "; nSB1++; errors = true; }
+ nTot += 1;
+ }
+ } // End of loop over ROCs
+
+ // Print the statistcs for the status/error bits
+ 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;
+
+ // Reusing nTot
+ nTot=0;
+ for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {
+ if (calVer == 1) {
+ if (caldcs) idcsfee = ((AliTRDCalDCS*)caldcs)->GetCalDCSFEEObj(i);
+ if (caldcs2) idcsfee2 = ((AliTRDCalDCS*)caldcs2)->GetCalDCSFEEObj(i);
+ }
+ else if (calVer == 2) {
+ if (caldcs) idcsfee = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(i);
+ if (caldcs2) idcsfee2 = ((AliTRDCalDCSv2*)caldcs2)->GetCalDCSFEEObj(i);
+ }
+ if (idcsfee != NULL && idcsfee2 != NULL) {
+ Int_t sbd1 = 0;
+ Int_t sbd2 = 0;
+ if (calVer == 1) {
+ sbd1 = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
+ sbd2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetStatusBit();
+ }
+ if (calVer == 2) {
+ sbd1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();
+ sbd2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetStatusBit();
+ }
+ Int_t sbd = sbd1 - sbd2;
+ if (sbd != 0) {
+ cout << "ROC " << i << " changed from state " << sbd1 << " at start of the run to " << sbd2 << " at the end of the run." << endl;
+ cout << "ROC " << i << " changed from state " << sbd1 << " at start of the run to " << sbd2 << " at the end of the run." << endl;
+ nChanged++;
+ }
+ nTot += 1;
+ }
+ } // End of loop over ROCs
+ } // End of scoped declaration
+ 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;
+
+ Int_t gtb, gct, gsh, gtc, gsz, gfw, gfs, gfl, gsn;
+ TString gcv, gcn, gft, grp, gtp, gtm, gtd, gts, gao;
+
+ if (calVer == 1) {
+ gtb = ((AliTRDCalDCS*)caldcs)->GetGlobalNumberOfTimeBins();
+ gct = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigTag();
+ gsh = ((AliTRDCalDCS*)caldcs)->GetGlobalSingleHitThres();
+ gtc = ((AliTRDCalDCS*)caldcs)->GetGlobalThreePadClustThres();
+ gsz = ((AliTRDCalDCS*)caldcs)->GetGlobalSelectiveNoZS();
+ gfw = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterWeight();
+ gfs = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterShortDecPar();
+ gfl = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterLongDecPar();
+ gsn = ((AliTRDCalDCS*)caldcs)->GetGlobalModeFastStatNoise();
+ gcv = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigVersion();
+ gcn = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigName();
+ gft = ((AliTRDCalDCS*)caldcs)->GetGlobalFilterType();
+ grp = ((AliTRDCalDCS*)caldcs)->GetGlobalReadoutParam();
+ gtp = ((AliTRDCalDCS*)caldcs)->GetGlobalTestPattern();
+ gtm = ((AliTRDCalDCS*)caldcs)->GetGlobalTrackletMode();
+ gtd = ((AliTRDCalDCS*)caldcs)->GetGlobalTrackletDef();
+ gts = ((AliTRDCalDCS*)caldcs)->GetGlobalTriggerSetup();
+ gao = ((AliTRDCalDCS*)caldcs)->GetGlobalAddOptions();
+ }
+ else if (calVer == 2) {
+ gtb = ((AliTRDCalDCSv2*)caldcs)->GetGlobalNumberOfTimeBins();
+ gct = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigTag();
+ gsh = ((AliTRDCalDCSv2*)caldcs)->GetGlobalSingleHitThres();
+ gtc = ((AliTRDCalDCSv2*)caldcs)->GetGlobalThreePadClustThres();
+ gsz = ((AliTRDCalDCSv2*)caldcs)->GetGlobalSelectiveNoZS();
+ gfw = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterWeight();
+ gfs = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterShortDecPar();
+ gfl = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterLongDecPar();
+ gsn = ((AliTRDCalDCSv2*)caldcs)->GetGlobalModeFastStatNoise();
+ gcv = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigVersion();
+ gcn = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigName();
+ gft = ((AliTRDCalDCSv2*)caldcs)->GetGlobalFilterType();
+ grp = ((AliTRDCalDCSv2*)caldcs)->GetGlobalReadoutParam();
+ gtp = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTestPattern();
+ gtm = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTrackletMode();
+ gtd = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTrackletDef();
+ gts = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTriggerSetup();
+ gao = ((AliTRDCalDCSv2*)caldcs)->GetGlobalAddOptions();
+ }
+
+
+ if (gtb != -1) cout<<"Global number of time bins.........................: "<< gtb << endl;
+ if (gct != -1) cout<<"Global configuration tag...........................: "<< gct << endl;
+ if (gsh != -1) cout<<"Global single hit threshold........................: "<< gsh << endl;
+ if (gtc != -1) cout<<"Global three pad cluster threshold.................: "<< gtc << endl;
+ if (gsz != -1) cout<<"Global selective ZS (every i'th event).............: "<< gsz << endl;
+ if (gfw != -1) cout<<"Global tail cancellation filter weight.............: "<< gfs << endl;
+ if (gfs != -1) cout<<"Global tail cancellat. filter short decay parameter: "<< gfs << endl;
+ if (gfl != -1) cout<<"Global tail cancellation filt. long decay parameter: "<< gfl << endl;
+ if (gsn != -1) cout<<"Global fast statistics mode?.......................: "<< gsn << endl;
+ if (gcv != "") cout<<"Global configuration tag version...................: "<< gcv << endl;
+ if (gcn != "") cout<<"Global configuration tag name......................: "<< gcn << endl;
+ if (gft != "") cout<<"Global filter type.................................: "<< gft << endl;
+ if (grp != "") cout<<"Global readout parameter...........................: "<< grp << endl;
+ if (gtp != "") cout<<"Global test pattern................................: "<< gtp << endl;
+ if (gtm != "") cout<<"Global tracklet mode...............................: "<< gtm << endl;
+ if (gtd != "") cout<<"Global tracklet definition.........................: "<< gtd << endl;
+ if (gts != "") cout<<"Global trigger setup...............................: "<< gts << endl;
+ if (gao != "") cout<<"Global additional options..........................: "<< gao << 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;
+ }
+//______________________________________________________________________
+}
+void AliTRDcheckConfig(Int_t runNr=0, const char *pathfile="nopathgiven"){
+ // Wrapping the function to be able to clean up
+ TFile *f=0;
+ WrappedAliTRDcheckConfig(runNr,pathfile,f);
+ AliCDBManager::Destroy();
+ if(f){
+ delete f; // Destructor calls TFile::Close()
+ f=0;
+ }
+}
+//______________________________________________________________________
+//
+// The stuff below is only for compiling a standalone program,
+// i.e., without root / aliroot
+//
+#if !defined(__CINT__)
+//______________________________________________________________________
+void reduceTimeOuts(){
+ // Reduces the grid timeouts
+ gEnv->SetValue("XNet.ConnectTimeout" , 20);
+ gEnv->SetValue("XNet.RequestTimeout" , 40);
+ gEnv->SetValue("XNet.MaxRedirectCount" , 2);
+ gEnv->SetValue("XNet.ReconnectWait" , 2);
+ gEnv->SetValue("XNet.FirstConnectMaxCnt", 3);
+ gEnv->SetValue("XNet.TransactionTimeout",300);
+}
+//______________________________________________________________________
+void printHelp(const char* argv0){
+ cout <<"Usuage: "<<argv0<< " [arg1 [arg2]]"<<endl
+ <<"Where arg1 can be:"<<endl
+ <<" of type int-> gets treated as run number"<<endl
+ <<" *.txt -> gets treated as list of run numbers"<<endl
+ <<" *.root -> gets treated as OCDB entry"<<endl
+ <<" -h,--help -> displays this help"<<endl
+ <<"and arg2 can be"<<endl
+ <<" -f, --fast -> reduces grid timeouts"<<endl;
+}
+//______________________________________________________________________
+int main(int argc,char** argv){
+ // This macro is a standalone program.
+
+ // We change the meaning of the input
+ // parameters a bit. See the help message
+
+ // Error if too many arguments
+ if(argc>3){
+ cout << "Too many arguments!"<<endl;
+ printHelp(argv[0]);
+ return 1;
+ }
+
+ // Check the argument two if any
+ if(argc>2){
+ if( (!strcmp("-f",argv[2])) ||
+ (!strcmp("--fast",argv[2])) ){
+ reduceTimeOuts();
+ }
+ else {
+ cout <<"Couldn't recognize your argument "
+ <<argv[2]<<endl;
+ printHelp(argv[0]);
+ return 1;
+ }
+ }
+
+ // Check argument one
+ if(argc>1){
+ // Convert to TString for easier handling
+ TString input(argv[1]);
+ // Help message
+ if( (!strcmp("-h",argv[1])) ||
+ (!strcmp("--help",argv[1])) ) {
+ printHelp(argv[0]);
+ return 0;
+ }
+ // int aka run number provided
+ else if(input.IsDigit()){
+ AliTRDcheckConfig(input.Atoi());
+ return 0;
+ }
+ // .root aka OCDB file provided
+ else if(input.EndsWith(".root")){
+ AliTRDcheckConfig(0,input.Data());
+ return 0;
+ }
+ // .txt aka list of root files provided
+ else if(input.EndsWith(".txt")){
+ // Open the text file
+ ifstream in;
+ in.open(Form("%s",input.Data()));
+ if (!in.is_open()){
+ cout << "F: Could not open file "<<input.Data()<<endl;
+ return 1;
+ }
+ // Loop over entries
+ string line;
+ TString Line;
+ while(in.good()) {
+ // Reading the line in the .txt file works fine
+ if(!getline(in,line)) break;
+ Line=line.data();
+ if(Line.IsNull()) continue;
+ // Run number provided
+ if(Line.IsDigit()){
+ AliTRDcheckConfig(Line.Atoi());
+ }
+ // .root file provided
+ else if(Line.EndsWith(".root")){
+ AliTRDcheckConfig(0,Line.Data());
+ }
+ else {
+ cout <<"Bad line in .txt file: "
+ <<Line.Data()<<endl;
+ }
+ } // End of loop over .txt file lines
+ return 0;
+ }
+ // Bad input, neither .root nor .txt nor int
+ else {
+ cout <<"Cannot recognize your input"
+ <<input.Data()<<endl;
+ printHelp(argv[0]);
+ return 1;
+ }
+ } // End of argc>1
+
+ // Without arguments
+ AliTRDcheckConfig();
+ return 0;
+}// End of main
+
+// End of the non-root part
+#endif