Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:09

0001 // Example of accessing HCAL conditions from DB directly
0002 // F.Ratnikov (UMd)  Oct 11, 2006
0003 
0004 #include <stdlib.h>
0005 #include <vector>
0006 #include <string>
0007 
0008 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0009 #include "CondFormats/HcalObjects/interface/HcalPedestals.h"
0010 #include "CondTools/Hcal/interface/HcalDbTool.h"
0011 
0012 
0013 int main () {
0014   std::string tag_pedestals = "pedestals_mtcc2_v1";
0015   unsigned long long run = 1;
0016 
0017   std::string dbcon = "oracle://orcon/CMS_COND_HCAL";
0018   ::setenv ("POOL_CATALOG", "relationalcatalog_oracle://orcon/CMS_COND_GENERAL", 1);
0019   // std::string dbcon = "oracle://cms_orcoff/CMS_COND_HCAL";
0020   //::setenv ("POOL_CATALOG", "relationalcatalog_oracle://cms_orcoff/CMS_COND_GENERAL", 1);
0021 
0022   ::setenv ("CORAL_AUTH_PATH", "/afs/cern.ch/cms/DB/conddb", 1);
0023 
0024   HcalDbTool db (dbcon, false, true);
0025 
0026   HcalPedestals peds;
0027   if (db.getObject (&peds, tag_pedestals, run)) {
0028     std::vector<DetId> ids = peds.getAllChannels ();
0029     std::cout << "Pedestal values" << std::endl;
0030     for (unsigned i = 0; i < ids.size(); i++) {
0031       const HcalPedestal* ped = peds.getValues (ids[i]);
0032       std:: cout << "channel: " << HcalDetId (ids[i]) << ",  values: " 
0033          << ped->getValue (0) << " / "
0034          << ped->getValue (1) << " / "
0035          << ped->getValue (2) << " / "
0036          << ped->getValue (3) << std::endl;
0037     }
0038   }
0039   else {
0040     std::cerr << "can not get pedestals for tag " <<  tag_pedestals << ", run " << run << std::endl;
0041   }
0042   return 0;
0043 }