Error accessing the database

Hello!
I am having issues accessing the Database.
For the analysis I am studying, I had to request access to the Database and followed the suggested tutorials. However, when executing ‘cmsRun’, the following error is displayed:

----- Begin Fatal Exception 10-Apr-2023 10:12:54 -05-----------------------
An exception of category ‘StdException’ occurred while
[0] Constructing the EventProcessor
[1] Constructing ESSource: class=PoolDBESSource label=‘GlobalTag’
Exception Message:
A std::exception was thrown.
Could not open file /home/cms-opendata/CMSSW_5_3_32/src/BAnalysis/BPAnalyzer/./START53_LV6A1/GBRForest_PFEcalEnergyResolution_v2_offline.db ( CORAL : “Session::startUserSession” from “CORAL/RelationalPlugins/sqlite” )
----- End Fatal Exception -------------------------------------------------

I have been experiencing this issue for some time now and do not know how to proceed.
Just some additional information on the issue, I have tried to open the file which the program could not open with the ‘vi’ command, but this file specifically could not be opened, unlike any other in this same directory.

Could someone please help me?

Hi! Many thanks for your interest in the CMS open data and for reporting the issue!

To help in debugging we would need to know the following:

  • Which tutorial are you following (please give a link)?
  • Are you running the job in the CMSSW container or in the CMS VM image?
  • Can you confirm that you want to access 2011 MonteCarlo data (the CMSSW version CMSSW_5_3_32 that you’ve chosen and the Global tag your code is accessing START53_LV6A1 are only valid for them)?

Thanks!

Best, Kati
for the CMS open data team

Hi Kati, thanks for the reply!

Answering the topics:

  • This is the tutorial I am following:
    CERN Open Data Portal
  • I am using a CMS VM image, specifically 1.5.3
  • I am trying to reconstruct secondary vertices, analysing 2011 MC data, which was the reason why I decided to access this database, though I am not sure if this would be the only one with the information I need to do so.

Hi Kati, how are you doing?
I am still having the same issue when trying to access the DataBase.
I tried reconstructing the same analysis on a different VM, but still on the same image, cms 1.5.3, it is. It ended up resulting in the very same error I was having before, though. Now, I am reconstructing the analysis on a Docker, just to see if anything different shows up.
If there is any additional information I could provide you to help me, don’t hesitate to ask!

Hi!

I’m sorry for the delay.

Indeed the file is in the condition database, and, technically, it should be usable for these data.
Would you have a minimal code example to reproduce the issue so I could check further?

Normally, the db files are binary files so I would not expect them to open properly in an editor. However, the sqlite dump of this particular file looks a bit unexpected so there may be some problems with its content. We will check.

Best, Kati

Hi Kati!
Thanks for the reply!
The sample code you asked for:
The following sample code is from my ‘_cfg.py’ file

#Imports
import FWCore.ParameterSet.Config as cms
import FWCore.Utilities.FileUtils as FileUtils
import TrackingTools.TransientTrack.TransientTrackBuilder_cfi
import TrackingTools
process = cms.Process(“Demo”)
process.load(“FWCore.MessageService.MessageLogger_cfi”)
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(100))
#The following six lines of code are the ones that caused the issue, but are necessary for the code to run, according to the Guide I mentioned earlier
process.load(“TrackingTools/TransientTrack/TransientTrackBuilder_cfi”)
process.load(“Configuration.Geometry.GeometryIdeal_cff”)
process.load(“Configuration.StandardSequences.MagneticField_cff”)
process.load(‘Configuration.StandardSequences.FrontierConditions_GlobalTag_cff’)
process.GlobalTag.connect = cms.string(‘sqlite_file:/cvmfs/cms-opendata- conddb.cern.ch/START53_LV6A1.db’)
process.GlobalTag.globaltag = ‘START53_LV6A1::All’
#From here, everything was doing OK
process.options = cms.untracked.PSet(
SkipEvent = cms.untracked.vstring(‘ProductNotFound’)
)
files2011data = FileUtils.loadListFromFile (‘/home/cms-opendata/CMSSW_5_3_32/src/BAnalysis/BPAnalyzer/datasets/AnaliseFelipe/Simulacao/BuToKJPsi/CMS_MonteCarlo2011_Summer11LegDR_BuToJPsiKV2_2MuPtEtaFilterKPtEtaFilter_7TeV-pythia6-evtgen_AODSIM_PU_S13_START53_LV6-v1_00000_file_index.txt’)
process.source = cms.Source(“PoolSource”,
fileNames = cms.untracked.vstring(*files2011data
)
)
process.demo = cms.EDAnalyzer(‘BPAnalyzer’
)
process.TFileService = cms.Service(“TFileService”,
fileName = cms.string(‘BuKJPsi00000.root’)
)
process.p = cms.Path(process.demo)
#This is the end of the ‘_cfg.py’ code

Regardless of the content of the ‘.cc’ file, the ‘scram b’ is doing just fine. Let me know if you also need a sample code from the ‘.cc’ file, though.
If there is anything more I could provide, don’t hesitate to ask!
Best, Diogo

Hi Diogo,

thanks, to be able to help, we would need the actual cc code.

I see that you want to use transient tracks. We have instructions for the 2015 MiniAOD data/MC and you need to use CMSSW_7_6_7 for them. What is valid for 2015 MiniAOD data is not necessarily usable for 2011/2012 AOD in CMSSW_5_3_32. Maybe @jmhogan or @caredg can follow up once you point us to the code.

Best, Kati

Hi Kati, sorry for the confusion!
Here is the sample code for the .cc file:

// ---------------------------------------------------Begining of Sample Code--------------------------------------------------
// extra header files
#include “math.h”
#include “FWCore/Framework/interface/EventSetup.h”
#include “FWCore/Framework/interface/ESHandle.h”
#include “FWCore/MessageLogger/interface/MessageLogger.h”
#include “FWCore/ServiceRegistry/interface/Service.h”
#include “CommonTools/UtilAlgos/interface/TFileService.h”
#include “DataFormats/Common/interface/Ref.h”

// for vertexing
#include “FWCore/Framework/interface/ESHandle.h”
#include “TrackingTools/TransientTrack/interface/TransientTrack.h”
#include “TrackingTools/TransientTrack/interface/TransientTrackBuilder.h”
#include “TrackingTools/Records/interface/TransientTrackRecord.h”
#include “RecoVertex/VertexPrimitives/interface/TransientVertex.h”
#include “RecoVertex/KalmanVertexFit/interface/KalmanVertexFitter.h”
#include “SimTracker/Records/interface/TrackAssociatorRecord.h”
#include “SimTracker/TrackAssociation/interface/TrackAssociatorBase.h”
#include “SimTracker/TrackAssociation/interface/TrackAssociatorByHits.h”

using namespace reco;
using namespace std;
using namespace edm;
class BPAnalyzer : public edm::EDAnalyzer {

public:
explicit BPAnalyzer(const edm::ParameterSet&);
~BPAnalyzer();
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
virtual void beginJob() ;
virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void endJob() ;
virtual void beginRun(edm::Run const&, edm::EventSetup const&);
virtual void endRun(edm::Run const&, edm::EventSetup const&);
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
};
BPAnalyzer::BPAnalyzer(const edm::ParameterSet& iConfig){
edm::Service fs;
}
BPAnalyzer::~BPAnalyzer()
{
}
// method called for each event
void
BPAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
using namespace edm;
using namespace reco;
using namespace std;

// Getting general tracks collection
Handlereco::TrackCollection MyTracks;
iEvent.getByLabel(“generalTracks”, MyTracks);

// Vertex Reconstruction Loop
ESHandle transientTrackBuilder;
iSetup.get().get(“TransientTrackBuilder”, transientTrackBuilder);
std::vectorreco::TrackBase trackCollection;
for (std::vectorreco::Track::const_iterator first = MyTracks->begin(); first != MyTracks->end(); ++first){
for (std::vectorreco::Track::const_iterator second = MyTracks->begin(); second != MyTracks->end(); ++second){
for (std::vectorreco::Track::const_iterator third = MyTracks->begin(); third != MyTracks->end(); ++third){
if (first != second && second != third && first != third){
std::vectorreco::TransientTrack tracksToVertex;
tracksToVertex.push_back(transientTrackBuilder->build(*first));
tracksToVertex.push_back(transientTrackBuilder->build(*second));
tracksToVertex.push_back(transientTrackBuilder->build(*third));
KalmanVertexFitter vertexFitter;
CachingVertex<5> fittedVertex = vertexFitter.vertex(tracksToVertex);
if (fittedVertex.isValid() && fittedVertex.totalChiSquared() >= 0. && fittedVertex.degreesOfFreedom() > 0){
std::cout<<“Test”<<std::endl;
}
}
}
}
}
// End of Vertex Reconstruction Loop
}
// method called once each job just before starting event loop
void
BPAnalyzer::beginJob()
{
}
// method called once each job just after ending the event loop
void
BPAnalyzer::endJob()
{
}
// method called when starting to processes a run
void
BPAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
{
}
// method called when ending the processing of a run
void
BPAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
{
}
// method called when starting to processes a luminosity block
void
BPAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
// method called when ending the processing of a luminosity block
void
BPAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
// method fills ‘descriptions’ with the allowed parameters for the module
void
BPAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
}
//define this as a plug-in
DEFINE_FWK_MODULE(BPAnalyzer);
// ------------------------------------------------------End of Sample Code-----------------------------------------------------

Sorry for its size, but if I were to take anything else out, I fear it would not work properly.
The error message continues the same with the sample code above.
Here is the message:

----- Begin Fatal Exception 05-May-2023 11:30:59 -05-----------------------
An exception of category ‘StdException’ occurred while
[0] Constructing the EventProcessor
[1] Constructing ESSource: class=PoolDBESSource label=‘GlobalTag’
Exception Message:
A std::exception was thrown.
Could not open file /home/cms-opendata/CMSSW_5_3_32/src/BAnalysis/BPAnalyzer/./START53_LV6A1/GBRForest_PFEcalEnergyResolution_v2_offline.db ( CORAL : “Session::startUserSession” from “CORAL/RelationalPlugins/sqlite” )
----- End Fatal Exception -------------------------------------------------

I hope it helps out
Best, Diogo

Hi Diogo,

the code displays broken, please put it between ``` and ``` in your message so that it becomes:


preformatted text

Thanks!

Best, Kati

Hi Kati!
Sorry about that!
Here is the code:

// Begining of Sample Code

// extra header files
#include "math.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/Common/interface/Ref.h"

// for vertexing
#include "FWCore/Framework/interface/ESHandle.h"
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
#include "TrackingTools/Records/interface/TransientTrackRecord.h"
#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
#include "RecoVertex/KalmanVertexFit/interface/KalmanVertexFitter.h"
#include "SimTracker/Records/interface/TrackAssociatorRecord.h"
#include "SimTracker/TrackAssociation/interface/TrackAssociatorBase.h"
#include "SimTracker/TrackAssociation/interface/TrackAssociatorByHits.h"

using namespace reco;
using namespace std;
using namespace edm;
class BPAnalyzer : public edm::EDAnalyzer {

   public:
      explicit BPAnalyzer(const edm::ParameterSet&);
      ~BPAnalyzer();
      static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

   private:
      virtual void beginJob() ;
      virtual void analyze(const edm::Event&, const edm::EventSetup&);
      virtual void endJob() ;
      virtual void beginRun(edm::Run const&, edm::EventSetup const&);
      virtual void endRun(edm::Run const&, edm::EventSetup const&);
      virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
      virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
};
BPAnalyzer::BPAnalyzer(const edm::ParameterSet& iConfig){
edm::Service<TFileService> fs;
}
BPAnalyzer::~BPAnalyzer()
{
}
// ------------ method called for each event  ------------
void
BPAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
  using namespace edm;
  using namespace reco;
  using namespace std;

// Getting general tracks collection
  Handle<reco::TrackCollection> MyTracks;
  iEvent.getByLabel("generalTracks", MyTracks);

//  Vertex Reconstruction Loop
  ESHandle<TransientTrackBuilder> transientTrackBuilder;
  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", transientTrackBuilder);
  std::vector<reco::TrackBase> trackCollection;
  for (std::vector<reco::Track>::const_iterator first = MyTracks->begin(); first != MyTracks->end(); ++first){
    for (std::vector<reco::Track>::const_iterator second = MyTracks->begin(); second != MyTracks->end(); ++second){
      for (std::vector<reco::Track>::const_iterator third = MyTracks->begin(); third != MyTracks->end(); ++third){
        if (first != second && second != third && first != third){
          std::vector<reco::TransientTrack> tracksToVertex;
          tracksToVertex.push_back(transientTrackBuilder->build(*first));
          tracksToVertex.push_back(transientTrackBuilder->build(*second));
          tracksToVertex.push_back(transientTrackBuilder->build(*third));
          KalmanVertexFitter vertexFitter;
          CachingVertex<5> fittedVertex = vertexFitter.vertex(tracksToVertex);
          if (fittedVertex.isValid() && fittedVertex.totalChiSquared() >= 0. && fittedVertex.degreesOfFreedom() > 0){
            std::cout<<"Test"<<std::endl;
          }
        }
      }
    }
  }
//  End of Vertex Reconstruction Loop
}
// ------------ method called once each job just before starting event loop  ------------
void
BPAnalyzer::beginJob()
{
}
// ------------ method called once each job just after ending the event loop  ------------
void
BPAnalyzer::endJob()
{
}
// ------------ method called when starting to processes a run  ------------
void
BPAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
{
}
// ------------ method called when ending the processing of a run  ------------
void
BPAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
{
}
// ------------ method called when starting to processes a luminosity block  ------------
void
BPAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
// ------------ method called when ending the processing of a luminosity block  ------------
void
BPAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
// ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
void
BPAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
}
//define this as a plug-in
DEFINE_FWK_MODULE(BPAnalyzer);

Thanks for the patience
Let me know if anything else is needed

Best, Diogo

OK, that’s better, thanks!
I’m testing in the docker container, and for another input file, I do not see that error but just a huge amount of cout “Test” printouts.

What do you have in BuildFile.xml?

Best, Kati

Yes, these “Test” outputs are printed for each event. I was using it just to be able to know when/if a loop is being accessed, and well, if you are being able to get these, it means that you got it through the error message!

Here is my BuildFile.xml :

<buildfile>
<use name="FWCore/Framework"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/ParameterSet"/>
<use name="DataFormats/TrackReco"/>
<use name="CommonTools/UtilAlgos"/>
<use name="PhysicsTools/UtilAlgos"/>
<use name="DataFormats/MuonReco"/>
<use name="RecoMuon/TrackingTools"/>
<flags EDM_PLUGIN="1"/>
</buildfile>

Best, Diogo

OK, that’s very good, but you need to get through it as well :slight_smile:
I do not see why that particular condition database file would need to be accessed for your case.

Indeed, that database file is not among the local selection in the container.

Could you check that you do not have some spurious imports or includes somewhere else in your code?

Best, Kati

Yes, I have some. I took these out of the sample code so that it would not get much bigger than it already was.

This is the list of all includes there are in my .cc file:

// system include files
#include <memory>
#include <vector>
#include <iostream>
#include <TLorentzVector.h>
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

// extra header files
#include "math.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/Common/interface/Ref.h"

// for Root histogramming
#include "TH1.h"
#include "TH2.h"
#include "TNtuple.h"

// for simmulated data information
#include "SimDataFormats/Track/interface/SimTrackContainer.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h"
#include "SimDataFormats/Vertex/interface/SimVertex.h"
#include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
#include "SimDataFormats/Track/interface/SimTrack.h"
#include "SimTracker/TrackHistory/interface/TrackHistory.h"

// for tracking information
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/TrackReco/interface/HitPattern.h"

// for vertex studies
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

// for vertexing
#include "FWCore/Framework/interface/ESHandle.h"
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
#include "TrackingTools/Records/interface/TransientTrackRecord.h"
#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
#include "RecoVertex/KalmanVertexFit/interface/KalmanVertexFitter.h"
#include "SimTracker/Records/interface/TrackAssociatorRecord.h"
#include "SimTracker/TrackAssociation/interface/TrackAssociatorBase.h"
#include "SimTracker/TrackAssociation/interface/TrackAssociatorByHits.h"

And here is the list of all imports there are in my cfg.py file:

import FWCore.ParameterSet.Config as cms
import FWCore.Utilities.FileUtils as FileUtils
import TrackingTools.TransientTrack.TransientTrackBuilder_cfi
import TrackingTools

Best, Diogo