]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSOnlineCalibrationSPDhandler.cxx
fixed the tainted variables
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineCalibrationSPDhandler.cxx
index 020de9f641f1f6d9ca1d338827674a3fc46c64d5..dfc46cb80ca1a32465ac334c5eb6fe1ff8f5df31 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "AliITSOnlineCalibrationSPDhandler.h"
 #include "AliITSOnlineCalibrationSPD.h"
+#include "AliITSTriggerConditions.h"
 #include "AliITSIntMap.h"
 #include <TObjArray.h>
 #include <TArrayI.h>
@@ -31,7 +32,8 @@
 
 //____________________________________________________________________________________________
 AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler():
-  fFileLocation(".")
+  fFileLocation("."),
+  fTriggerConditions(0)
 {
   // constructor
   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
@@ -45,7 +47,8 @@ AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler():
 }
 //____________________________________________________________________________________________
 AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler(const AliITSOnlineCalibrationSPDhandler& handle): 
-  fFileLocation(".")
+  fFileLocation("."),
+  fTriggerConditions(handle.fTriggerConditions)
 {
   // copy constructor
   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
@@ -382,6 +385,35 @@ UInt_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromText(const char *fileName
   return newNrNoisy;
 }
 //____________________________________________________________________________________________
+void AliITSOnlineCalibrationSPDhandler::ReadPITConditionsFromText(const char *fileName) {
+  // read PIT conditions file from text as printed out at P2
+  //  !!! please note that the chip numbering goes from 9 to 0 in the text. In PVSS panels is the opposite.
+  if(fTriggerConditions) fTriggerConditions->ResetAll();
+  else fTriggerConditions = new AliITSTriggerConditions();
+  fTriggerConditions->ReadFromTextFile(fileName);
+}
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::ReadPITConditionsFromDB(Int_t runNr, const Char_t *storage){
+// read PIT conditions from the OCDB
+
+  AliCDBManager* man = AliCDBManager::Instance();
+  TString storageSTR = Form("%s",storage);
+  if (storageSTR.CompareTo("default")==0) {
+    if(!man->IsDefaultStorageSet()) {
+      man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+    }
+  }
+  else {
+    storageSTR = Form("%s",storage);
+    man->SetDefaultStorage(storageSTR.Data());
+  }
+  AliCDBEntry *cdbEntry = man->Get("TRIGGER/SPD/PITConditions", runNr);
+ if(cdbEntry) {
+  fTriggerConditions = (AliITSTriggerConditions*)cdbEntry->GetObject();
+  return kTRUE;
+  } else return kFALSE;
+}
+//____________________________________________________________________________________________
 void AliITSOnlineCalibrationSPDhandler::WriteToFilesAlways() {
   // write the lists of active,dead,noisy to files
   for (UInt_t eq=0; eq<20; eq++) {
@@ -505,17 +537,17 @@ void AliITSOnlineCalibrationSPDhandler::WriteNoisyToFile(UInt_t eq) {
 }
 //____________________________________________________________________________________________
 #ifndef SPD_DA_OFF
-Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadModuleFromDB(UInt_t module, Int_t runNr, Char_t *storage, Bool_t treeSerial) {
+Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadModuleFromDB(UInt_t module, Int_t runNr, const Char_t *storage, Bool_t treeSerial) {
   // reads dead pixels from DB for given module and runNr
   AliCDBManager* man = AliCDBManager::Instance();
   TString storageSTR = Form("%s",storage);
   if (storageSTR.CompareTo("default")==0) {
     if(!man->IsDefaultStorageSet()) {
-      man->SetDefaultStorage("local://$ALICE_ROOT");
+      man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
     }
   }
   else {
-    storageSTR = Form("local://%s",storage);
+    storageSTR = Form("%s",storage);
     man->SetDefaultStorage(storageSTR.Data());
   }
   AliCDBEntry *cdbEntry = man->Get("ITS/Calib/SPDDead", runNr);
@@ -558,17 +590,17 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadModuleFromDB(UInt_t module, In
   return kTRUE;
 }
 //____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyModuleFromDB(UInt_t module, Int_t runNr, Char_t *storage, Bool_t treeSerial) {
+Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyModuleFromDB(UInt_t module, Int_t runNr, const Char_t *storage, Bool_t treeSerial) {
   // reads noisy pixels from DB for given module and runNr
   AliCDBManager* man = AliCDBManager::Instance();
   TString storageSTR = Form("%s",storage);
   if (storageSTR.CompareTo("default")==0) {
     if(!man->IsDefaultStorageSet()) {
-      man->SetDefaultStorage("local://$ALICE_ROOT");
+      man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
     }
   }
   else {
-    storageSTR = Form("local://%s",storage);
+    storageSTR = Form("%s",storage);
     man->SetDefaultStorage(storageSTR.Data());
   }
   AliCDBEntry *cdbEntry = man->Get("ITS/Calib/SPDNoisy", runNr);
@@ -599,24 +631,24 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyModuleFromDB(UInt_t module, I
   return kTRUE;
 }
 //____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::ReadFromDB(Int_t runNr, Char_t *storage, Bool_t treeSerial) {
+Bool_t AliITSOnlineCalibrationSPDhandler::ReadFromDB(Int_t runNr, const Char_t *storage, Bool_t treeSerial) {
   // reads dead and noisy pixels from DB for given runNr
   // note that you may want to clear the lists (if they are not empty) before reading
   return (ReadNoisyFromDB(runNr,storage,treeSerial) && ReadDeadFromDB(runNr,storage,treeSerial));
 }
 //____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromDB(Int_t runNr, Char_t *storage, Bool_t treeSerial) {
+Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromDB(Int_t runNr, const Char_t *storage, Bool_t treeSerial) {
   // reads dead pixels from DB for given runNr
   // note that you may want to clear the list (if it is not empty) before reading
   AliCDBManager* man = AliCDBManager::Instance();
   TString storageSTR = Form("%s",storage);
   if (storageSTR.CompareTo("default")==0) {
     if(!man->IsDefaultStorageSet()) {
-      man->SetDefaultStorage("local://$ALICE_ROOT");
+      man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
     }
   }
   else {
-    storageSTR = Form("local://%s",storage);
+    storageSTR = Form("%s",storage);
     man->SetDefaultStorage(storageSTR.Data());
   }
   AliCDBEntry *cdbEntry = man->Get("ITS/Calib/SPDDead", runNr);
@@ -662,18 +694,18 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromDB(Int_t runNr, Char_t *st
   return kTRUE;
 }
 //____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromDB(Int_t runNr, Char_t *storage, Bool_t treeSerial) {
+Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromDB(Int_t runNr, const Char_t *storage, Bool_t treeSerial) {
   // reads noisy pixels from DB for given runNr
   // note that you may want to clear the list (if it is not empty) before reading
   AliCDBManager* man = AliCDBManager::Instance();
   TString storageSTR = Form("%s",storage);
   if (storageSTR.CompareTo("default")==0) {
     if(!man->IsDefaultStorageSet()) {
-      man->SetDefaultStorage("local://$ALICE_ROOT");
+      man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
     }
   }
   else {
-    storageSTR = Form("local://%s",storage);
+    storageSTR = Form("%s",storage);
     man->SetDefaultStorage(storageSTR.Data());
   }
   AliCDBEntry *cdbEntry = man->Get("ITS/Calib/SPDNoisy", runNr);
@@ -708,18 +740,18 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromDB(Int_t runNr, Char_t *s
   return kTRUE;
 }
 //____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromDBasNoisy(Int_t runNr, Char_t *storage, Bool_t treeSerial) {
+Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromDBasNoisy(Int_t runNr, const Char_t *storage, Bool_t treeSerial) {
   // reads dead pixels (put as noisy) from DB for given runNr
   // note that you may want to clear the list (if it is not empty) before reading
   AliCDBManager* man = AliCDBManager::Instance();
   TString storageSTR = Form("%s",storage);
   if (storageSTR.CompareTo("default")==0) {
     if(!man->IsDefaultStorageSet()) {
-      man->SetDefaultStorage("local://$ALICE_ROOT");
+      man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
     }
   }
   else {
-    storageSTR = Form("local://%s",storage);
+    storageSTR = Form("%s",storage);
     man->SetDefaultStorage(storageSTR.Data());
   }
   AliCDBEntry *cdbEntry = man->Get("ITS/Calib/SPDNoisy", runNr);
@@ -797,24 +829,24 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromCalibObj(TObjArray* calOb
   return kTRUE;
 }
 //____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::WriteToDB(Int_t runNrStart, Int_t runNrEnd, Char_t *storage) {
+Bool_t AliITSOnlineCalibrationSPDhandler::WriteToDB(Int_t runNrStart, Int_t runNrEnd, const Char_t *storage) {
   // writes dead and noisy pixels to DB for given runNrs
   // overwrites any previous entries
   return (WriteNoisyToDB(runNrStart,runNrEnd,storage) && WriteDeadToDB(runNrStart,runNrEnd,storage));
 }
 //____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::WriteDeadToDB(Int_t runNrStart, Int_t runNrEnd, Char_t *storage) {
+Bool_t AliITSOnlineCalibrationSPDhandler::WriteDeadToDB(Int_t runNrStart, Int_t runNrEnd, const Char_t *storage) {
   // writes dead pixels to DB for given runNrs
   // overwrites any previous entries
   AliCDBManager* man = AliCDBManager::Instance();
   TString storageSTR = Form("%s",storage);
   if (storageSTR.CompareTo("default")==0) {
     if(!man->IsDefaultStorageSet()) {
-      man->SetDefaultStorage("local://$ALICE_ROOT");
+      man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
     }
   }
   else {
-    storageSTR = Form("local://%s",storage);
+    storageSTR = Form("%s",storage);
     man->SetDefaultStorage(storageSTR.Data());
   }
   AliCDBMetaData* metaData = new AliCDBMetaData();
@@ -850,18 +882,18 @@ Bool_t AliITSOnlineCalibrationSPDhandler::WriteDeadToDB(Int_t runNrStart, Int_t
   return kTRUE;
 }
 //____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::WriteDeadToDBasNoisy(Int_t runNrStart, Int_t runNrEnd, Char_t *storage) {
+Bool_t AliITSOnlineCalibrationSPDhandler::WriteDeadToDBasNoisy(Int_t runNrStart, Int_t runNrEnd, const Char_t *storage) {
   // writes dead pixels to DB for given runNrs
   // overwrites any previous entries
   AliCDBManager* man = AliCDBManager::Instance();
   TString storageSTR = Form("%s",storage);
   if (storageSTR.CompareTo("default")==0) {
     if(!man->IsDefaultStorageSet()) {
-      man->SetDefaultStorage("local://$ALICE_ROOT");
+      man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
     }
   }
   else {
-    storageSTR = Form("local://%s",storage);
+    storageSTR = Form("%s",storage);
     man->SetDefaultStorage(storageSTR.Data());
   }
   AliCDBMetaData* metaData = new AliCDBMetaData();
@@ -897,18 +929,18 @@ Bool_t AliITSOnlineCalibrationSPDhandler::WriteDeadToDBasNoisy(Int_t runNrStart,
   return kTRUE;
 }
 //____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::WriteNoisyToDB(Int_t runNrStart, Int_t runNrEnd, Char_t *storage) {
+Bool_t AliITSOnlineCalibrationSPDhandler::WriteNoisyToDB(Int_t runNrStart, Int_t runNrEnd, const Char_t *storage) {
   // writes noisy pixels to DB for given runNrs
   // overwrites any previous entries
   AliCDBManager* man = AliCDBManager::Instance();
   TString storageSTR = Form("%s",storage);
   if (storageSTR.CompareTo("default")==0) {
     if(!man->IsDefaultStorageSet()) {
-      man->SetDefaultStorage("local://$ALICE_ROOT");
+      man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
     }
   }
   else {
-    storageSTR = Form("local://%s",storage);
+    storageSTR = Form("%s",storage);
     man->SetDefaultStorage(storageSTR.Data());
   }
   AliCDBMetaData* metaData = new AliCDBMetaData();
@@ -1422,7 +1454,7 @@ Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisy(UInt_t eq, UInt_t hs, UIn
   // is the pixel noisy?
   UInt_t gloChip = GetGloChip(eq,hs,chip);
   if (gloChip>=1200 || col>=32 || row>=256) {
-    Error("AliITSOnlineCalibrationSPDhandler::IsPixelNoisy", "eq,hs,chip,col,row nrs (%d,%d,%d) out of bounds.",eq,hs,chip,col,row);
+    Error("AliITSOnlineCalibrationSPDhandler::IsPixelNoisy",Form("eq,hs,chip,col,row nrs (%d,%d,%d,%d,%d) out of bounds.",eq,hs,chip,col,row));
     return kFALSE;
   }
   UInt_t key = GetKey(eq,hs,chip,col,row);
@@ -2902,3 +2934,163 @@ Bool_t AliITSOnlineCalibrationSPDhandler::IsSilentChip(UInt_t eq, UInt_t hs, UIn
   }
   return (!IsActiveEq(eq) || IsDeadEq(eq) || !IsActiveHS(eq,hs) || IsDeadHS(eq,hs) || !IsActiveChip(eq,hs,chip) || IsDeadChip(eq,hs,chip));
 }
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::IsNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip) const {
+  // returns true if there is at least a noisy pixel in the chip
+
+  if (eq>=20 || hs>=6 || chip>=10) {
+    Error("AliITSOnlineCalibrationSPDhandler::IsNoisyChip", "eq,hs,chip (%d,%d,%d) out of bounds.",eq,hs,chip);
+    return kFALSE;
+  }
+  Bool_t isNoisy = kFALSE;
+
+  UInt_t nrNoisy = GetNrNoisy();
+  for (UInt_t i=0; i<nrNoisy; i++) {
+    if(eq  == GetNoisyEqIdAt(i)){
+      if(hs  == GetNoisyHSAt(i)){
+        if(chip == GetNoisyChipAt(i)) {
+            UInt_t col  = GetNoisyColAt(i);
+            UInt_t row  = GetNoisyRowAt(i);
+            if (IsPixelNoisy(eq,hs,chip,col,row)) isNoisy = kTRUE;
+        }
+      }
+    }
+  }
+  return isNoisy;
+}
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::WritePITConditionsToDB(Int_t runNrStart, Int_t runNrEnd, const Char_t *storage) {
+  // writes noisy pixels to DB for given runNrs
+  // overwrites any previous entries
+  AliCDBManager* man = AliCDBManager::Instance();
+  TString storageSTR = Form("%s",storage);
+  if (storageSTR.CompareTo("default")==0) {
+    if(!man->IsDefaultStorageSet()) {
+      man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+    }
+  }
+  else {
+    storageSTR = Form("%s",storage);
+    man->SetDefaultStorage(storageSTR.Data());
+  }
+  AliCDBMetaData* metaData = new AliCDBMetaData();
+  metaData->SetResponsible("Annalisa Mastroserio");
+  metaData->SetComment("Created by AliITSOnlineCalibrationSPDhandler.");
+  AliCDBId idCalSPD("TRIGGER/SPD/PITConditions",runNrStart,runNrEnd);
+  AliCDBEntry* cdbEntry = new AliCDBEntry((TObject*)fTriggerConditions,idCalSPD,metaData);
+  man->Put(cdbEntry);
+  delete cdbEntry;
+  delete metaData;
+  return kTRUE;
+}
+
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::SetInactiveChipInPITmask(UInt_t eq, UInt_t hs, UInt_t chip){
+  //
+  fTriggerConditions->SetInActiveChip(eq,hs,chip);
+  return kTRUE;
+}
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::UnSetInactiveChipInPITmask(UInt_t eq, UInt_t hs, UInt_t chip){
+  //
+  fTriggerConditions->SetInActiveChip(eq,hs,chip);
+  return kTRUE;
+}
+//____________________________________________________________________________________________
+void AliITSOnlineCalibrationSPDhandler::PrintDiffInDead(AliITSOnlineCalibrationSPDhandler *other) const {
+  //
+  // Printout of the differences between two ocdb files for SPD Dead channel map
+  //
+  UInt_t nrChipOk=0;
+  UInt_t nrDeadChipOk=0; 
+  UInt_t nrDeadHsOk=0;
+  UInt_t nrDeadHs =0;
+  UInt_t nrDeadChip=0;
+  UInt_t nrDeadHsInOther =0;
+  UInt_t nrDeadChipInOther=0;
+  UInt_t nrMismatch =0;
+  UInt_t nrMismatchInOther =0;
+  printf("\n\n ****** loop over chips ***** \n");
+  for(Int_t eq=0; eq<20; eq++){
+   if(TMath::Abs((Int_t)GetNrBadEq(eq) - (Int_t)other->GetNrBadEq(eq)) >0) printf("-----> dead pixels differ in eq %i!   %i - %i in the other \n",eq,GetNrBadEq(eq),other->GetNrBadEq(eq));
+   for(Int_t hs=0; hs<6; hs++){
+    Short_t nchips =0;
+    Short_t nchipsOther =0;
+    Short_t nok=0;
+    for(Int_t chip=0; chip<10; chip++){
+      UInt_t chipkey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
+     // test if everything is coherent
+     if(IsDeadChip(eq,hs,chip) && other->IsDeadChip(eq,hs,chip)) {
+      nok++;
+      nrChipOk++;
+      nrDeadChipOk++;
+     }
+     if(!IsDeadChip(eq,hs,chip) && !other->IsDeadChip(eq,hs,chip)) nrChipOk++;
+     // now testing if mismatches
+     if(IsDeadChip(eq,hs,chip)) {
+      nrDeadChip++;
+      nchips++;
+      if(!other->IsDeadChip(eq,hs,chip)) {
+        nrMismatch++;
+        printf("  mismatch -> eq %i  hs %i  chip %i is DEAD  - ALIVE in the other (chipkey %i)\n",eq,hs,chip,chipkey);
+       }
+      }
+     if(other->IsDeadChip(eq,hs,chip)){
+      nrDeadChipInOther++;
+      nchipsOther++;
+      if(!IsDeadChip(eq,hs,chip)) {
+       nrMismatchInOther++;
+       printf("  mismatch -> eq %i  hs %i  chip %i is ALIVE -  DEAD in the other (chipkey %i)\n",eq,hs,chip,chipkey);
+      }
+     }
+    }
+    if(nok==10) nrDeadHsOk++;
+    if(nchips==10) nrDeadHs++;
+    if(nchipsOther==10) nrDeadHsInOther++;
+   }
+  }
+
+printf("\n\n\n*************SUMMARY****************\n");
+printf(" BOTH have : %i Dead HS and %i Dead chips  with %i coherent chips \n",nrDeadHsOk,nrDeadChipOk,nrChipOk);
+printf("\n_________MISMATCH RESULTS___________\n");
+printf(" THIS  : Nr Dead HS %i - Nr Dead Chip %i \n",nrDeadHs,nrDeadChip);
+printf(" OTHER : Nr Dead HS %i - Nr Dead Chip %i \n",nrDeadHsInOther,nrDeadChipInOther);
+printf(" N Mismatches in Dead  chips (=ALIVE in the other) %i \n",nrMismatch);
+printf(" N Mismatches in Alive chips (=DEAD  in the other) %i \n",nrMismatchInOther);
+}
+//____________________________________________________________________________________________
+void AliITSOnlineCalibrationSPDhandler::PrintDiffInPITmask(AliITSOnlineCalibrationSPDhandler *other) const {
+  //
+  // Printout of the differences between two ocdb files for SPD Dead channel map
+  //
+
+Int_t nOk =0;
+Int_t nMismatch =0;
+Int_t nMismatchInOther =0;
+
+printf("\n\n ****** loop over chips in PIT mask***** \n");
+for(Int_t eq=0; eq<20; eq++){
+  for(Int_t hs=0; hs<6; hs++){
+   for(Int_t chip=0; chip<10; chip++){
+
+  UInt_t chipkey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
+
+  if(fTriggerConditions->IsChipActive(eq,hs,chip) && (other->GetTriggerConditions())->IsChipActive(eq,hs,chip)) nOk++;
+  if(fTriggerConditions->IsChipActive(eq,hs,chip) && !(other->GetTriggerConditions())->IsChipActive(eq,hs,chip)) {
+   nMismatch++;
+   printf("Mismatch -> eq %i  hs %i chip %i is ACTIVE - INACTIVE in the other (chipkey %i) \n",eq,hs,chip,chipkey);
+  }
+  if(!fTriggerConditions->IsChipActive(eq,hs,chip) && (other->GetTriggerConditions())->IsChipActive(eq,hs,chip)) {
+   nMismatchInOther++;
+   printf("Mismatch -> eq %i  hs %i chip %i is INACTIVE - ACTIVE in the other (chipkey %i) \n",eq,hs,chip,chipkey);
+   }
+  if(!fTriggerConditions->IsChipActive(eq,hs,chip) && !(other->GetTriggerConditions())->IsChipActive(eq,hs,chip)) nOk++;
+  }
+ }
+}
+
+printf("n Chips OK %i : ACTIVE mismatch %i  - INACTIVE mismatch in %i \n",nOk,nMismatch,nMismatchInOther);
+
+}
+
+