Adding macros to create Calibration objects
authorcoppedis <Chiara.Oppedisano@to.infn.it>
Thu, 26 Feb 2015 20:35:13 +0000 (21:35 +0100)
committercoppedis <Chiara.Oppedisano@to.infn.it>
Thu, 26 Feb 2015 20:35:13 +0000 (21:35 +0100)
ZDC/MakeZDCChMapCalib.C [new file with mode: 0644]
ZDC/MakeZDCEnergyCalib.C [new file with mode: 0644]
ZDC/MakeZDCPedestalCalib.C [new file with mode: 0644]

diff --git a/ZDC/MakeZDCChMapCalib.C b/ZDC/MakeZDCChMapCalib.C
new file mode 100644 (file)
index 0000000..3c7f926
--- /dev/null
@@ -0,0 +1,65 @@
+MakeZDCChMapCalib(){
+   // Create OCDB object for ZDC pedestal
+   const char* macroname = "MakeZDCChMapCalib.C";
+   const int kNch=48; //const int kNScch=32;
+   Int_t readMap[kNch][6]; 
+
+   FILE *file;
+   if((file = fopen("./ShuttleInput/ZDCChMapping.dat","r")) != NULL){
+     for(Int_t j=0; j<kNch; j++){       
+       for(Int_t k=0; k<6; k++){
+        int read = fscanf(file,"%d",&readMap[j][k]);
+        if(read == 0) printf(" Failing in reading data from mapping file\n");
+       }
+     }
+     fclose(file);
+   }
+
+   AliZDCChMap *mapCalib = new AliZDCChMap();
+   for(Int_t k=0; k<kNch; k++){
+      mapCalib->SetADCModule(k,readMap[k][1]);
+      mapCalib->SetADCChannel(k,readMap[k][2]);
+      mapCalib->SetDetector(k,readMap[k][4]);
+      mapCalib->SetSector(k,readMap[k][5]);
+    }
+  
+   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
+     // save in file
+     const char* filename = "ZDCChMap.root";
+     TFile f(filename, "RECREATE");
+     if(!f){
+       Error(macroname,"cannot open file for output\n");
+       return;
+     }
+     Info(macroname,"Saving alignment objects to the file %s", filename);
+     f.cd();
+     f.WriteObject(mapCalib,"ZDCPedestals","kSingleKey");
+     f.Close();
+   }
+   else{
+     // save in CDB storage
+     TString Storage = gSystem->Getenv("STORAGE");
+     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
+       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
+       return;
+     }
+     Info(macroname,"Saving alignment objects in CDB storage %s", Storage.Data());
+     AliCDBManager* cdb = AliCDBManager::Instance();
+     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
+     if(!storage){
+       Error(macroname,"Unable to open storage %s\n",Storage.Data());
+       return;
+     }
+     AliCDBMetaData* md = new AliCDBMetaData();
+     md->SetResponsible("Chiara Oppedisano");
+     md->SetComment("Calibration objects for ZDC mapping");
+     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
+     md->SetObjectClassName("AliZDCPedestals");
+     AliCDBId id("ZDC/Calib/ChMap",0,AliCDBRunRange::Infinity());
+     storage->Put(mapCalib,id,md);
+   }
+   
+   mapCalib->Delete(); 
+
+}
diff --git a/ZDC/MakeZDCEnergyCalib.C b/ZDC/MakeZDCEnergyCalib.C
new file mode 100644 (file)
index 0000000..a960136
--- /dev/null
@@ -0,0 +1,51 @@
+MakeZDCEnergyCalib(){
+   // Create OCDB object for ZDC pedestal
+   const char* macroname = "MakeZDCEnergyCalib.C";
+   AliZDCEnCalib *enCalib = new AliZDCEnCalib();
+   enCalib->SetEnCalib(0, 1.);
+   enCalib->SetEnCalib(1, 1.);
+   enCalib->SetEnCalib(2, 1.);
+   enCalib->SetEnCalib(3, 1.);
+   enCalib->SetEnCalib(4, 1.);
+   enCalib->SetEnCalib(5, 1.);
+  
+   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
+     // save in file
+     const char* filename = "ZDCEnergyCalib.root";
+     TFile f(filename, "RECREATE");
+     if(!f){
+       Error(macroname,"cannot open file for output\n");
+       return;
+     }
+     Info(macroname,"Saving alignment objects to the file %s", filename);
+     f.cd();
+     f.WriteObject(enCalib,"ZDCPedestals","kSingleKey");
+     f.Close();
+   }
+   else{
+     // save in CDB storage
+     TString Storage = gSystem->Getenv("STORAGE");
+     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
+       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
+       return;
+     }
+     Info(macroname,"Saving alignment objects in CDB storage %s", Storage.Data());
+     AliCDBManager* cdb = AliCDBManager::Instance();
+     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
+     if(!storage){
+       Error(macroname,"Unable to open storage %s\n",Storage.Data());
+       return;
+     }
+     AliCDBMetaData* md = new AliCDBMetaData();
+     md->SetResponsible("Chiara Oppedisano");
+     md->SetComment("Calibration objects for ZDC mapping");
+     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
+     md->SetObjectClassName("AliZDCPedestals");
+     AliCDBId id("ZDC/Calib/EnergyCalib",0,AliCDBRunRange::Infinity());
+     storage->Put(enCalib,id,md);
+   }
+   
+   enCalib->Delete(); 
+
+}
diff --git a/ZDC/MakeZDCPedestalCalib.C b/ZDC/MakeZDCPedestalCalib.C
new file mode 100644 (file)
index 0000000..8487c25
--- /dev/null
@@ -0,0 +1,69 @@
+MakeZDCPedestalCalib(){
+   // Create OCDB object for ZDC pedestal
+   const char* macroname = "MakeZDCPedestalCalib.C";
+   const Int_t nch = 24;
+   Float_t MeanPed[2*nch], MeanPedWidth[2*nch], 
+           MeanPedOOT[2*nch], MeanPedWidthOOT[2*nch],
+           CorrCoeff0[2*nch], CorrCoeff1[2*nch];
+   for(int j=0; j<2*nch; j++){
+     if(j<nch){
+       MeanPed[j] = MeanPedOOT[j] = 50.;
+       MeanPedWidth[j] = MeanPedWidthOOT[j] = 4.;
+       CorrCoeff0[j] = 0.;
+       CorrCoeff1[j] = 1.;
+     }
+     else{
+       MeanPed[j] = MeanPedOOT[j] = 8.*50.;
+       MeanPedWidth[j] = MeanPedWidthOOT[j] = 8.*4..;
+       CorrCoeff0[j] = 0.;
+       CorrCoeff1[j] = 1.;
+     }
+   }
+  
+   AliZDCPedestals *calibPed = new AliZDCPedestals("ZDC");
+   calibPed->SetMeanPed(MeanPed);
+   calibPed->SetMeanPedWidth(MeanPedWidth);
+   calibPed->SetOOTPed(MeanPedOOT);
+   calibPed->SetOOTPedWidth(MeanPedWidthOOT);
+   calibPed->SetPedCorrCoeff(CorrCoeff0, CorrCoeff1); 
+
+   if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
+     // save in file
+     const char* filename = "ZDCPedestals.root";
+     TFile f(filename, "RECREATE");
+     if(!f){
+       Error(macroname,"cannot open file for output\n");
+       return;
+     }
+     Info(macroname,"Saving alignment objects to the file %s", filename);
+     f.cd();
+     f.WriteObject(calibPed,"ZDCPedestals","kSingleKey");
+     f.Close();
+   }
+   else{
+     // save in CDB storage
+     TString Storage = gSystem->Getenv("STORAGE");
+     if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
+       Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
+       return;
+     }
+     Info(macroname,"Saving alignment objects in CDB storage %s", Storage.Data());
+     AliCDBManager* cdb = AliCDBManager::Instance();
+     AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
+     if(!storage){
+       Error(macroname,"Unable to open storage %s\n",Storage.Data());
+       return;
+     }
+     AliCDBMetaData* md = new AliCDBMetaData();
+     md->SetResponsible("Chiara Oppedisano");
+     md->SetComment("Calibration objects for ZDC pedestals");
+     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
+     md->SetObjectClassName("AliZDCPedestals");
+     AliCDBId id("ZDC/Calib/Pedestals",0,AliCDBRunRange::Infinity());
+     storage->Put(calibPed,id,md);
+   }
+   
+   calibPed->Delete(); 
+
+}