Macros to handle OADB files
authorprsnko <prsnko@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Oct 2011 12:47:02 +0000 (12:47 +0000)
committerprsnko <prsnko@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Oct 2011 12:47:02 +0000 (12:47 +0000)
PHOS/macros/FillOADB/AddPHOSBadMaps.C [new file with mode: 0644]
PHOS/macros/FillOADB/AddPHOSCalibration.C [new file with mode: 0644]
PHOS/macros/FillOADB/MakePHOSBadMaps.C [new file with mode: 0644]
PHOS/macros/FillOADB/MakePHOSCalibration.C [new file with mode: 0644]
PHOS/macros/FillOADB/MakePHOSGeometry.C [new file with mode: 0644]

diff --git a/PHOS/macros/FillOADB/AddPHOSBadMaps.C b/PHOS/macros/FillOADB/AddPHOSBadMaps.C
new file mode 100644 (file)
index 0000000..a7b7116
--- /dev/null
@@ -0,0 +1,37 @@
+void AddPHOSBadMaps(){
+  //Add OADB entry with PHOS bad map 
+  //You probably will need alien connection
+  
+  //Init Bad channels map
+  AliOADBContainer badmapContainer("phosBadMap");
+  badmapContainer.InitFromFile("$ALICE_ROOT/OADB/PHOS/PHOSBadMaps.root","phosBadMap");
+
+  printf("So far we stored the following list of bad maps\n") ;
+  Int_t n=badmapContainer.GetNumberOfEntries() ;
+  for(Int_t i=0;i<n;i++){
+    TObjArray* a= (TObjArray*)badmapContainer.GetObjectByIndex(i);
+    printf("Entry(%d): %s,  runs %d-%d \n",i,a->GetName(),badmapContainer.LowerLimit(i),badmapContainer.UpperLimit(i)) ;
+  }
+  
+  
+  TGrid::Connect("alien://") ;
+  
+  //For the period LHC10e we use map same as LHC10b
+  TObjArray * lhc10e = new TObjArray(5) ;
+  lhc10e->SetName("LHC10e") ;
+  TFile * fLHC10e = TFile::Open("alien:///alice/cern.ch/user/p/prsnko/BadMaps/BadMap_LHC10b.root") ;
+  char key[55] ;
+  if(fLHC10e->IsOpen()){
+    for(Int_t mod=1;mod<4; mod++){
+      sprintf(key,"PHOS_BadMap_mod%d",mod) ;
+      TH2I * h = (TH2I*)fLHC10e->Get(key) ;
+      if(!h)
+        lhc10e->AddAt(0x0,mod);
+      else     
+        lhc10e->AddAt(new TH2I(*h),mod) ;
+    }
+    badmapContainer.AppendObject(lhc10e,127712,130850) ;
+  }
+
+  badmapContainer.WriteToFile("PHOSBadMaps.root");
+}
\ No newline at end of file
diff --git a/PHOS/macros/FillOADB/AddPHOSCalibration.C b/PHOS/macros/FillOADB/AddPHOSCalibration.C
new file mode 100644 (file)
index 0000000..54660e6
--- /dev/null
@@ -0,0 +1,79 @@
+void AddPHOSCalibration(){
+
+   //Fills PHOS re-calibration parameters into OADB
+   //Each run-dependent object contains list of 3 objects:
+   //calibration parameters for pass1, pass2 and pass3 reconstruction.
+   //"$ALICE_ROOT/OADB/PHOS/PHOSRecalibration.root"
+
+  //Init existing calibrations
+  AliOADBContainer calibContainer("phosRecalibration");
+  calibContainer.InitFromFile("$ALICE_ROOT/OADB/PHOS/PHOSCalibrations.root","phosRecalibration");
+
+  printf("So far we stored the following list of calibrations\n") ;
+  Int_t n=calibContainer.GetNumberOfEntries() ;
+  printf("-------------------------------------------------------\n") ;
+  for(Int_t i=0;i<n;i++){
+    TObjArray* a= (TObjArray*)calibContainer.GetObjectByIndex(i);
+    printf("Entry(%d): %s,  runs %d-%d \n",i,a->GetName(),calibContainer.LowerLimit(i),calibContainer.UpperLimit(i)) ;
+    printf("      pass 1: ("); 
+    if(a->At(0)) printf("OK"); else printf("no") ;
+    printf(")     pass 2: ("); 
+    if(a->At(1)) printf("OK"); else printf("no") ;
+    printf(")     pass 3: ("); 
+    if(a->At(2)) printf("OK"); else printf("no") ;
+    printf(")\n"); 
+  }
+  printf("--------------------------------------------------------\n") ;
+
+  
+  AliCDBManager * man = AliCDBManager::Instance();
+  man->SetRun(140000) ;
+  man->SetDefaultStorage("local://OCDB");
+  AliPHOSCalibData* phosCalibData = new AliPHOSCalibData(-1);
+
+/*  
+  // -- LHC10c --
+  TObjArray * lhc10cAll = new TObjArray(3); 
+  lhc10cAll->SetName("PHOSRecalibration_LHC10c");
+  lhc10cAll->AddAt(phosCalibData,1) ; //pass 2 reconstruction
+  lhc10cAll->AddAt(phosCalibData,2) ; //pass 2 reconstruction
+  calibContainer.AppendObject(lhc10cAll,118503,121040) ;
+
+  // -- LHC10d --
+  TObjArray * lhc10dAll = new TObjArray(3); 
+  lhc10dAll->SetName("PHOSRecalibration_LHC10d");
+  lhc10dAll->AddAt(phosCalibData,1) ; //pass 2 reconstruction
+  lhc10dAll->AddAt(phosCalibData,2) ; //pass 2 reconstruction
+  calibContainer.AppendObject(lhc10dAll,122195,126437) ;
+
+  // -- LHC10e --
+  TObjArray * lhc10eAll = new TObjArray(3); 
+  lhc10eAll->SetName("PHOSRecalibration_LHC10e");
+  lhc10eAll->AddAt(phosCalibData,0) ; //pass 2 reconstruction
+  lhc10eAll->AddAt(phosCalibData,1) ; //pass 2 reconstruction
+  calibContainer.AppendObject(lhc10eAll,127712,130850) ;
+
+  // -- LHC10f --
+  TObjArray * lhc10fAll = new TObjArray(3); 
+  lhc10fAll->SetName("PHOSRecalibration_LHC10f");
+  lhc10fAll->AddAt(phosCalibData,0) ; //pass 2 reconstruction
+  lhc10fAll->AddAt(phosCalibData,1) ; //pass 2 reconstruction
+  calibContainer.AppendObject(lhc10eAll,133004,135029) ;
+  // -- LHC10g --
+  TObjArray * lhc10gAll = new TObjArray(3); 
+  lhc10gAll->SetName("PHOSRecalibration_LHC10g");
+  lhc10gAll->AddAt(phosCalibData,0) ; //pass 2 reconstruction
+  lhc10gAll->AddAt(phosCalibData,1) ; //pass 2 reconstruction
+  calibContainer.AppendObject(lhc10gAll,135654,136377) ;
+*/
+  // -- LHC10g --
+  TObjArray * lhc10hAll = new TObjArray(3); 
+  lhc10hAll->SetName("PHOSRecalibration_LHC10h");
+  lhc10hAll->AddAt(phosCalibData,1) ; //pass 2 reconstruction
+  calibContainer.AppendObject(lhc10hAll,136851,139517) ;
+  
+  calibContainer.WriteToFile("PHOSCalibrations.root");
+
+
+}
\ No newline at end of file
diff --git a/PHOS/macros/FillOADB/MakePHOSBadMaps.C b/PHOS/macros/FillOADB/MakePHOSBadMaps.C
new file mode 100644 (file)
index 0000000..252eadb
--- /dev/null
@@ -0,0 +1,60 @@
+void MakePHOSBadMaps(){
+  //Creates OADB entry with PHOS bad maps for different periods
+  //You probably will need alien connection
+  
+  
+  //Init Bad channels map
+  AliOADBContainer badmapContainer(Form("phosBadMap"));
+
+  TGrid::Connect("alien://") ;
+  
+  char key[55] ;
+  //For the period LHC10b
+  TObjArray * lhc10b = new TObjArray(5) ;
+  lhc10b->SetName("LHC10b_pass1") ;
+  TFile * fLHC10b = TFile::Open("alien:///alice/cern.ch/user/p/prsnko/BadMaps/BadMap_LHC10b.root") ;
+  if(fLHC10b->IsOpen()){
+    for(Int_t mod=1;mod<4; mod++){
+      sprintf(key,"PHOS_BadMap_mod%d",mod) ;
+      TH2I * h = (TH2I*)fLHC10b->Get(key) ;
+      if(!h)
+        lhc10b->AddAt(0x0,mod);
+      else     
+        lhc10b->AddAt(new TH2I(*h),mod) ;
+    }
+    badmapContainer.AppendObject(lhc10b,114737,117223) ;
+  }
+
+  //For the period LHC10h
+  TObjArray * lhc10h1 = new TObjArray(5) ;
+  lhc10h1->SetName("LHC10h_period1") ;
+  TFile * fLHC10h1 = TFile::Open("alien:///alice/cern.ch/user/p/prsnko/BadMaps/BadMap_LHC10h_period1.root") ;
+  if(fLHC10h1->IsOpen()){
+    for(Int_t mod=1;mod<4; mod++){
+      sprintf(key,"PHOS_BadMap_mod%d",mod) ;
+      TH2I * h = (TH2I*)fLHC10h1->Get(key) ;
+      if(!h)
+        lhc10h1->AddAt(0x0,mod);
+      else     
+        lhc10h1->AddAt(new TH2I(*h),mod) ;
+    }
+    badmapContainer.AppendObject(lhc10h1,136851,137848) ;
+  }
+  TObjArray * lhc10h234 = new TObjArray(5) ;
+  lhc10h234->SetName("LHC10h_period234") ;
+  TFile * fLHC10h234 = TFile::Open("alien:///alice/cern.ch/user/p/prsnko/BadMaps/BadMap_LHC10h_period234.root") ;
+  if(fLHC10h234->IsOpen()){
+    for(Int_t mod=1;mod<4; mod++){
+      sprintf(key,"PHOS_BadMap_mod%d",mod) ;
+      TH2I * h = (TH2I*)fLHC10h234->Get(key) ;
+      if(!h)
+        lhc10h234->AddAt(0x0,mod);
+      else     
+        lhc10h234->AddAt(new TH2I(*h),mod) ;
+    }
+    badmapContainer.AppendObject(lhc10h234,138732,139517) ;
+  }
+
+  badmapContainer.WriteToFile("PHOSBadMaps.root");
+
+}
\ No newline at end of file
diff --git a/PHOS/macros/FillOADB/MakePHOSCalibration.C b/PHOS/macros/FillOADB/MakePHOSCalibration.C
new file mode 100644 (file)
index 0000000..136eb8c
--- /dev/null
@@ -0,0 +1,24 @@
+void MakePHOSCalibration(){
+
+   //Fills PHOS re-calibration parameters into OADB
+   //Each run-dependent object contains list of 3 objects:
+   //calibration parameters for pass1, pass2 and pass3 reconstruction.
+   //"$ALICE_ROOT/OADB/PHOS/PHOSRecalibration.root"
+   
+  AliOADBContainer calibContainer("phosRecalibration");
+
+  AliCDBManager * man = AliCDBManager::Instance();
+  man->SetRun(140000) ;
+  man->SetDefaultStorage("local://OCDB");
+  AliPHOSCalibData* phosCalibData = new AliPHOSCalibData(-1);
+
+  // -- LHC10h --
+  TObjArray * lhc10aAll = new TObjArray(3); 
+  lhc10aAll->SetName("PHOSRecalibration_LHC10b");
+  lhc10aAll->AddAt(phosCalibData,2) ; //pass 3 reconstruction
+  calibContainer.AppendObject(lhc10aAll,114737,117223) ;
+
+  calibContainer.WriteToFile("PHOSCalibrations.root");
+
+
+}
\ No newline at end of file
diff --git a/PHOS/macros/FillOADB/MakePHOSGeometry.C b/PHOS/macros/FillOADB/MakePHOSGeometry.C
new file mode 100644 (file)
index 0000000..239ce8c
--- /dev/null
@@ -0,0 +1,47 @@
+void MakePHOSGeometry(){
+   //Fill OADB object with PHOS rotation-alignment matrixes
+   //To fill this file you need any AliESD.root from official reconstruction
+   //download it to the current directory
+   
+  AliOADBContainer * geomContainer = new AliOADBContainer("PHOSRotationMatrixes");
+  TObjArray *matrixes = new TObjArray(5) ;
+  matrixes->SetName("PHOSRotationMatrixes");
+
+  //Read them from ESDs
+  TFile* esdFile = TFile::Open("AliESDs.root");
+  if (!esdFile || !esdFile->IsOpen()) {
+    Error("MakePHOSGeometry", "Can not open ESD file, please download any from official reconstruction.");
+    return ;
+  }
+  AliESDEvent * event = new AliESDEvent;
+  TTree* tree = (TTree*) esdFile->Get("esdTree");
+  if (!tree) {
+    Error("MakePHOSGeometry", "no ESD tree found");
+    return ;
+  }
+  event->ReadFromTree(tree);
+  tree->GetEvent(0) ;
+
+  for(Int_t mod=0; mod<5; mod++) {
+    TGeoHMatrix * m = event->GetPHOSMatrix(mod) ;
+    if(!m)
+      matrixes->AddAt(0x0,mod);
+    else
+      matrixes->AddAt(new TGeoHMatrix(*m), mod) ;
+  }
+  esdFile->Close() ;
+
+  //Controll
+  for(Int_t mod=0; mod<5; mod++) {
+     printf("Module %d: \n", mod) ;
+     if(matrixes->At(mod))
+       ((TGeoHMatrix*)matrixes->At(mod))->Print() ;
+     else
+       printf("Maxrix=null \n") ;
+  }
+  //Fill 
+  geomContainer->AppendObject(matrixes,90000,AliCDBRunRange::Infinity()) ;
+  geomContainer->AddDefaultObject(matrixes) ;
+  geomContainer->WriteToFile("PHOSGeometry.root");
+  
+}