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