]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSOnlineCalibrationSPDhandler.cxx
adding arguments to AddTaskPhysicsSelection for MC and BG identification (Antonin)
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineCalibrationSPDhandler.cxx
index d9449a005b43ac6372d2cfdcebabdd9967c8be1e..aa96915b184249d852b2d3aa5cf8d8726bdb0e91 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++) {
@@ -249,15 +252,15 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromFileName(const char *fileN
          UInt_t row = GetRowFromKey(key);
          SetDeadPixel(eq,hs,chip,col,row);
        }
-       UInt_t eq = calib->GetEqNr();
-       if (calib->IsDeadEq()) SetDeadEq(eq);
-       else                   SetDeadEq(eq,kFALSE);
+       UInt_t eq1 = calib->GetEqNr();
+       if (calib->IsDeadEq()) SetDeadEq(eq1);
+       else                   SetDeadEq(eq1,kFALSE);
        for (UInt_t hs=0; hs<6; hs++) {
-         if (calib->IsDeadHS(hs)) SetDeadHS(eq,hs);
-         else                     SetDeadHS(eq,hs,kFALSE);
+         if (calib->IsDeadHS(hs)) SetDeadHS(eq1,hs);
+         else                     SetDeadHS(eq1,hs,kFALSE);
          for (UInt_t chip=0; chip<10; chip++) {
-           if (calib->IsDeadChip(hs,chip)) SetDeadChip(eq,hs,chip);
-           else                            SetDeadChip(eq,hs,chip,kFALSE);
+           if (calib->IsDeadChip(hs,chip)) SetDeadChip(eq1,hs,chip);
+           else                            SetDeadChip(eq1,hs,chip,kFALSE);
          }
        }
        if (inactive) {
@@ -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("local://%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,13 +537,13 @@ 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 {
@@ -558,13 +590,13 @@ 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 {
@@ -599,20 +631,20 @@ 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 {
@@ -662,14 +694,14 @@ 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 {
@@ -708,14 +740,14 @@ 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 {
@@ -797,20 +829,20 @@ 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 {
@@ -850,14 +882,14 @@ 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 {
@@ -897,14 +929,14 @@ 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 {
@@ -2902,3 +2934,67 @@ 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("local://%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;
+}
+
+