]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/Macros/AliTRDcheckConfig.C
Protection for undefined objects at SOR and EOR and automatic setting of OCDB path
[u/mrichter/AliRoot.git] / TRD / Macros / AliTRDcheckConfig.C
index e1b3b2ffb3c0a6f821c6f3d44ef35b4807658ea5..53daf4088082780d5b2d48dbb9d4c5cbe09d3c4f 100644 (file)
-//===================================================================================
-// 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 AliTRDcheckConfigv2.C(60111)
-//
-// An example for quickly checking a local file:
-// .x AliTRDcheckConfigv2.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/");
-TString alienOcdbPath("alien://folder=/alice/data/2010/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  calVer = 0;
-
-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(TObject* 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;  
-  }
-  
-
-  Int_t feeArrSiz = 0;
-  if (calVer == 1) feeArrSiz = ((AliTRDCalDCS*)calDCSObj)->GetFEEArr()->GetSize();
-  if (calVer == 2) feeArrSiz = ((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr()->GetSize();
-
-  for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {
-    TObject* idcsfee;
-    if (calVer == 1) idcsfee = ((AliTRDCalDCS*)calDCSObj)->GetCalDCSFEEObj(i);
-    if (calVer == 2) idcsfee = ((AliTRDCalDCSv2*)calDCSObj)->GetCalDCSFEEObj(i);
-
-    if (idcsfee == NULL) continue;
-
-    Int_t sbit = 0;
-    if (calVer == 1) ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
-    if (calVer == 2) ((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);
-       }
-       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); 
-      }
-    }
-  }
-  
-  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) {
-  
-  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;  
-  }
-
-  Int_t feeArrSiz1 = 0;
-  Int_t feeArrSiz2 = 0;
-  if (calVer == 1) {
-    feeArrSiz1 = ((AliTRDCalDCS*)calDCSObj)->GetFEEArr()->GetSize();
-    feeArrSiz2 = ((AliTRDCalDCS*)calDCSObj2)->GetFEEArr()->GetSize();
-  }
-  if (calVer == 2) {
-    feeArrSiz1 = ((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr()->GetSize();
-    feeArrSiz2 = ((AliTRDCalDCSv2*)calDCSObj2)->GetFEEArr()->GetSize();
-  }
-
-  for (Int_t i=0; i<nROC && i<feeArrSiz1 && i<feeArrSiz2; i++) {
-    TObject* idcsfee;
-    TObject* idcsfee2;
-    if (calVer == 1) {
-      idcsfee  = ((AliTRDCalDCS*)calDCSObj)->GetCalDCSFEEObj(i);
-      idcsfee2 = ((AliTRDCalDCS*)calDCSObj2)->GetCalDCSFEEObj(i);
-    }
-    if (calVer == 2) {
-      idcsfee  = ((AliTRDCalDCSv2*)calDCSObj)->GetCalDCSFEEObj(i);
-      idcsfee2 = ((AliTRDCalDCSv2*)calDCSObj2)->GetCalDCSFEEObj(i);
-    }
-    Int_t sbit = 0;
-    if (calVer == 1) ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
-    if (calVer == 1) ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();
-    if ((idcsfee == NULL) || (idcsfee2 == NULL) || (sbit != 0) /*|| (idcsfee2->GetStatusBit() != 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);
-       }
-       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 negitives
-       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); 
-      }
-    }
-  }
-  
-  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 AliTRDcheckConfig(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 2010 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();
-  }
-  
-  if (!strcmp(objArrayCDB->At(0)->ClassName(),"AliTRDCalDCS"))   calVer = 1;
-  if (!strcmp(objArrayCDB->At(0)->ClassName(),"AliTRDCalDCSv2")) calVer = 2;
-
-  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 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 feeArrSiz = 0;
-  if (calVer == 1) feeArrSiz = ((AliTRDCalDCS*)caldcs)->GetFEEArr()->GetSize();
-  if (calVer == 2) feeArrSiz = ((AliTRDCalDCSv2*)caldcs)->GetFEEArr()->GetSize();
-
-  Int_t nSB1=0, nSB2=0, nSB3=0, nSB4=0, nSB5=0, nTot=0;
-  for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {
-    TObject* idcsfee;
-    if (calVer == 1) idcsfee = ((AliTRDCalDCS*)caldcs)->GetCalDCSFEEObj(i);
-    if (calVer == 2) idcsfee = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(i);
-    if (idcsfee != NULL) {
-      Int_t sb;
-      if (calVer == 1) sb = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
-      if (calVer == 2) sb = ((AliTRDCalDCSFEEv2*)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<feeArrSiz; i++) {
-    TObject* idcsfee;
-    TObject* idcsfee2;
-    if (calVer == 1) {
-      idcsfee  = ((AliTRDCalDCS*)caldcs)->GetCalDCSFEEObj(i);
-      idcsfee2 = ((AliTRDCalDCS*)caldcs2)->GetCalDCSFEEObj(i);
-    }
-    if (calVer == 2) {
-      idcsfee  = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(i);
-      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;
-    }
-  }
-  
-  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();
-  }
-  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: "<< gsn << 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;
-  }
-  
-
-}
+//===================================================================================\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
+// If you want to analyze data from the grid, please don't forget to\r
+// have a valid alien token initialized\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
+// Please contact Frederick Kramer or Hans Beck in case of problems\r
+//===================================================================================\r
+\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 = false;\r
+Int_t  calVer = 0;\r
+\r
+Int_t AnalyzeArray(Int_t states[cArraySize], Int_t occur[cArraySize]) {\r
+  long long 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
+\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 negitive 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
+  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
+  for (Int_t i=0; i<cArraySize; i++) {\r
+    gsmStates[i] = 0; gsmOccur[i]  = 0;\r
+    nimStates[i] = 0; nimOccur[i]  = 0;\r
+    nevStates[i] = 0; nevOccur[i]  = 0;\r
+    nptStates[i] = 0; nptOccur[i]  = 0;  \r
+  }\r
+  \r
+\r
+  Int_t feeArrSiz = 0;\r
+  if (calVer == 1) feeArrSiz = ((AliTRDCalDCS*)calDCSObj)->GetFEEArr()->GetSize();\r
+  if (calVer == 2) feeArrSiz = ((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr()->GetSize();\r
+\r
+  for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {\r
+    TObject* idcsfee;\r
+    if (calVer == 1) idcsfee = ((AliTRDCalDCS*)calDCSObj)->GetCalDCSFEEObj(i);\r
+    if (calVer == 2) idcsfee = ((AliTRDCalDCSv2*)calDCSObj)->GetCalDCSFEEObj(i);\r
+\r
+    if (idcsfee == NULL) continue;\r
+\r
+    Int_t sbit = 0;\r
+    if (calVer == 1) ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();\r
+    if (calVer == 2) ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();\r
+\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
+       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
+      }\r
+    }\r
+  }\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
+\r
+\r
+void GetMajorityDifferences(TObject* calDCSObj, TObject* calDCSObj2) {\r
+  \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
+  for (Int_t i=0; i<cArraySize; i++) {\r
+    gsmStates[i] = 0; gsmOccur[i]  = 0;\r
+    nimStates[i] = 0; nimOccur[i]  = 0;\r
+    nevStates[i] = 0; nevOccur[i]  = 0;\r
+    nptStates[i] = 0; nptOccur[i]  = 0;  \r
+  }\r
+\r
+  Int_t feeArrSiz1 = 0;\r
+  Int_t feeArrSiz2 = 0;\r
+  if (calVer == 1) {\r
+    feeArrSiz1 = ((AliTRDCalDCS*)calDCSObj)->GetFEEArr()->GetSize();\r
+    feeArrSiz2 = ((AliTRDCalDCS*)calDCSObj2)->GetFEEArr()->GetSize();\r
+  }\r
+  if (calVer == 2) {\r
+    feeArrSiz1 = ((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr()->GetSize();\r
+    feeArrSiz2 = ((AliTRDCalDCSv2*)calDCSObj2)->GetFEEArr()->GetSize();\r
+  }\r
+\r
+  for (Int_t i=0; i<nROC && i<feeArrSiz1 && i<feeArrSiz2; i++) {\r
+    TObject* idcsfee;\r
+    TObject* idcsfee2;\r
+\r
+    if (calVer == 1) {\r
+      idcsfee  = ((AliTRDCalDCS*)calDCSObj)->GetCalDCSFEEObj(i);\r
+      idcsfee2 = ((AliTRDCalDCS*)calDCSObj2)->GetCalDCSFEEObj(i);\r
+    }\r
+    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 = 0;\r
+    if (calVer == 1) sbit = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();\r
+    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
+       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 negitives\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
+      }\r
+    }\r
+  }\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
+\r
+void AliTRDcheckConfig(Int_t runNr=0, char *pathfile="nopathgiven"){\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 from the OCDB for run number " << runNr << "." << endl;\r
+      return;\r
+    }\r
+  } else {\r
+    cout << "I : Accessing local storage" << endl;\r
+    TFile *f = new TFile(pathfile);\r
+    if(f != NULL) {\r
+      entry = (AliCDBEntry*) f->Get("AliCDBEntry");\r
+    }\r
+    else {\r
+      cout << "E : Cannot open file" << endl;\r
+      return;\r
+    }\r
+  }\r
+  \r
+  TObject *objectCDB = (TObject*)entry->GetObject();\r
+  if (objectCDB->IsA()->InheritsFrom("TObjArray")) {\r
+    TObjArray *objArrayCDB = (TObjArray*)entry->GetObject();\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
+  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
+  Int_t feeArrSiz = 0;\r
+  if (calVer == 1) feeArrSiz = ((AliTRDCalDCS*)caldcs)->GetFEEArr()->GetSize();\r
+  if (calVer == 2) feeArrSiz = ((AliTRDCalDCSv2*)caldcs)->GetFEEArr()->GetSize();\r
+\r
+  Int_t nSB1=0, nSB2=0, nSB3=0, nSB4=0, nSB5=0, nTot=0;\r
+  for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {\r
+    TObject* idcsfee;\r
+    if (calVer == 1) idcsfee = ((AliTRDCalDCS*)caldcs)->GetCalDCSFEEObj(i);\r
+    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
+      if (calVer == 2) sb = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();\r
+      if (sb == 5) { bitfivestr  += i; bitfivestr  += "  "; nSB5++; }\r
+      if (sb == 4) { bitfourstr  += i; bitfourstr  += "  "; nSB4++; errors = true; }\r
+      if (sb == 3) { bitthreestr += i; bitthreestr += "  "; nSB3++; errors = true; }\r
+      if (sb == 2) { bittwostr   += i; bittwostr   += "  "; nSB2++; }\r
+      if (sb == 1) { bitonestr   += i; bitonestr   += "  "; nSB1++; errors = true; }\r
+      nTot += 1;\r
+    }\r
+  }\r
+\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
+  Int_t nChanged=0, nTot=0;\r
+  for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {\r
+    TObject* idcsfee;\r
+    TObject* idcsfee2;\r
+    if (calVer == 1) {\r
+      if (caldcs)  idcsfee  = ((AliTRDCalDCS*)caldcs)->GetCalDCSFEEObj(i);\r
+      if (caldcs2) idcsfee2 = ((AliTRDCalDCS*)caldcs2)->GetCalDCSFEEObj(i);\r
+    }\r
+    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
+  }\r
+  \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
+  if (calVer == 2) {\r
+    gtb = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetNumberOfTimeBins();\r
+    gct = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetConfigTag();\r
+    gsh = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetSingleHitThres();\r
+    gtc = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetThreePadClustThres();\r
+    gsz = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetSelectiveNoZS();\r
+    gfw = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetTCFilterWeight();\r
+    gfs = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetTCFilterShortDecPar();\r
+    gfl = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetTCFilterLongDecPar();\r
+    gcv = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetConfigVersion();\r
+    gcn = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetConfigName();\r
+    gft = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetFilterType();\r
+    grp = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetReadoutParam();\r
+    gtp = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetTestPattern();\r
+    gtm = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetTrackletMode();\r
+    gtd = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetTrackletDef();\r
+    gts = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetTriggerSetup();\r
+    gao = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(0)->GetAddOptions();\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: "<< gsn << 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
+}\r