Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optical function method for PPS proton transport #29857

Merged
merged 4 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Configuration/Eras/python/Modifier_ctpps_2021_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import FWCore.ParameterSet.Config as cms

ctpps_2021 = cms.Modifier()
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from CalibCalorimetry.HcalPlugins.Hcal_Conditions_forGlobalTag_cff import *
from CalibCalorimetry.CastorCalib.CastorDbProducer_cfi import *
from CalibTracker.Configuration.Tracker_DependentRecords_forGlobalTag_nofakes_cff import *
from SimTransport.PPSProtonTransport.PPSTransportESSources_cfi import *
2 changes: 1 addition & 1 deletion Configuration/StandardSequences/python/Eras.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self):
'phase2_hgcal', 'phase2_muon', 'phase2_timing', 'phase2_hgcalV9', 'phase2_hfnose', 'phase2_hgcalV10', 'phase2_hgcalV11',
'phase2_timing_layer', 'phase2_hcal',
'phase2_trigger',
'trackingLowPU', 'trackingPhase1', 'ctpps_2016', 'ctpps_2017', 'ctpps_2018', 'trackingPhase2PU140','highBetaStar_2018',
'trackingLowPU', 'trackingPhase1', 'ctpps_2016', 'ctpps_2017', 'ctpps_2018', 'ctpps_2021', 'trackingPhase2PU140','highBetaStar_2018',
'tracker_apv_vfp30_2016', 'pf_badHcalMitigation', 'run2_miniAOD_80XLegacy','run2_miniAOD_94XFall17', 'run2_nanoAOD_92X',
'run2_nanoAOD_94XMiniAODv1', 'run2_nanoAOD_94XMiniAODv2', 'run2_nanoAOD_94X2016',
'run2_miniAOD_devel', 'run2_nanoAOD_102Xv1', 'run2_nanoAOD_106Xv1',
Expand Down
37 changes: 15 additions & 22 deletions SimPPS/PPSSimTrackProducer/plugins/PPSSimTrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
#include "SimDataFormats/Forward/interface/LHCTransportLink.h"
#include "SimDataFormats/Forward/interface/LHCTransportLinkContainer.h"

#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "SimTransport/PPSProtonTransport/interface/TotemTransport.h"
#include "SimTransport/PPSProtonTransport/interface/HectorTransport.h"
#include "SimTransport/PPSProtonTransport/interface/ProtonTransport.h"
#include "TRandom3.h"
#include "IOMC/RandomEngine/src/TRandomAdaptor.h"

//
// class declaration
//
Expand All @@ -47,7 +49,7 @@ class PPSSimTrackProducer : public edm::stream::EDProducer<> {
explicit PPSSimTrackProducer(const edm::ParameterSet&);
~PPSSimTrackProducer() override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
//static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please delete the commented lines of code.


private:
void beginStream(edm::StreamID) override;
Expand All @@ -56,7 +58,7 @@ class PPSSimTrackProducer : public edm::stream::EDProducer<> {

// ----------member data ---------------------------
bool m_verbosity;
ProtonTransport* theTransporter = nullptr;
ProtonTransport* theTransporter;
edm::InputTag m_InTag;
edm::EDGetTokenT<edm::HepMCProduct> m_InTagToken;

Expand All @@ -78,28 +80,17 @@ class PPSSimTrackProducer : public edm::stream::EDProducer<> {
PPSSimTrackProducer::PPSSimTrackProducer(const edm::ParameterSet& iConfig) {
//now do what ever other initialization is needed
// TransportHector
theTransporter = new ProtonTransport(iConfig);

m_InTag = iConfig.getParameter<edm::InputTag>("HepMCProductLabel");
m_InTagToken = consumes<edm::HepMCProduct>(m_InTag);

m_verbosity = iConfig.getParameter<bool>("Verbosity");
m_transportMethod = iConfig.getParameter<std::string>("TransportMethod");
//m_transportMethod = iConfig.getParameter<std::string>("TransportMethod");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here


produces<edm::HepMCProduct>();
produces<edm::LHCTransportLinkContainer>();

theTransporter = nullptr;

if (m_transportMethod == "Totem") {
theTransporter = new TotemTransport(iConfig, m_verbosity);
} else if (m_transportMethod == "Hector") {
theTransporter = new HectorTransport(iConfig, m_verbosity);
} else {
throw cms::Exception("Configuration")
<< "LHCTransport (ProtonTransport) requires a Method (Hector or Totem) \n"
"which is not present in the configuration file. You should add one of the method\n"
"above in the configuration file or remove the module that requires it.";
}

edm::Service<edm::RandomNumberGenerator> rng;
if (!rng.isAvailable()) {
throw cms::Exception("Configuration")
Expand Down Expand Up @@ -143,12 +134,12 @@ void PPSSimTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
}

if (HepMCEvt.provenance()->moduleLabel() == "LHCTransport") {
throw cms::Exception("LogicError") << "HectorTrasported HepMCProduce already exists\n";
throw cms::Exception("LogicError") << "LHCTrasport HepMCProduce already exists\n";
}

evt = new HepMC::GenEvent(*HepMCEvt->GetEvent());

theTransporter->clear();
//theTransporter->clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here

theTransporter->process(evt, iSetup, engine);

if (m_verbosity)
Expand All @@ -165,7 +156,8 @@ void PPSSimTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe

if (m_verbosity) {
for (unsigned int i = 0; i < (*NewCorrespondenceMap).size(); i++)
LogDebug("HectorEventProcessing") << "Hector correspondence table: " << (*NewCorrespondenceMap)[i];
LogDebug("ProtonTransportEventProcessing")
<< "ProtonTransport correspondence table: " << (*NewCorrespondenceMap)[i];
}

iEvent.put(std::move(NewCorrespondenceMap));
Expand All @@ -181,13 +173,14 @@ void PPSSimTrackProducer::beginStream(edm::StreamID) {}
void PPSSimTrackProducer::endStream() {}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
/*
void PPSSimTrackProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
desc.setUnknown();
descriptions.addDefault(desc);
}

*/
Comment on lines 175 to +184
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps you can delete all this part

//define this as a plug-in
DEFINE_FWK_MODULE(PPSSimTrackProducer);
25 changes: 15 additions & 10 deletions SimTransport/PPSProtonTransport/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="SimDataFormats/GeneratorProducts"/>
<use name="SimGeneral/HepPDTRecord"/>
<use name="Utilities/PPS"/>
<use name="SimTransport/TotemRPProtonTransportParametrization"/>
<use name="hector"/>
<use name="hepmc"/>
<use name="clhep"/>
<use name="rootcore"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="CommonTools/Utils"/>
<use name="SimDataFormats/GeneratorProducts"/>
<use name="SimGeneral/HepPDTRecord"/>
<use name="Utilities/PPS"/>
<use name="SimTransport/TotemRPProtonTransportParametrization"/>
<use name="CondFormats/PPSObjects"/>
<use name="CondFormats/RunInfo"/>
<use name="CondFormats/DataRecord"/>
<use name="hector"/>
<use name="hepmc"/>
<use name="clhep"/>
<use name="rootcore"/>
<export>
<lib name="1"/>
</export>

78 changes: 78 additions & 0 deletions SimTransport/PPSProtonTransport/interface/BaseProtonTransport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#ifndef BASEPROTONTRANSPORT
#define BASEPROTONTRANSPORT
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "HepMC/GenEvent.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "Utilities/PPS/interface/PPSUnitConversion.h"
#include "SimDataFormats/Forward/interface/LHCTransportLink.h"
#include <vector>
#include <map>
#include <string>
#include "TLorentzVector.h"

namespace CLHEP {
class HepRandomEngine;
}
class BaseProtonTransport {
public:
BaseProtonTransport(const edm::ParameterSet& iConfig);
virtual ~BaseProtonTransport() { this->clear(); };

std::vector<LHCTransportLink>& getCorrespondenceMap() { return m_CorrespondenceMap; }
virtual void process(const HepMC::GenEvent* ev, const edm::EventSetup& es, CLHEP::HepRandomEngine* engine) = 0;

void clear();

void addPartToHepMC(HepMC::GenEvent*);

void ApplyBeamCorrection(HepMC::GenParticle* p);
void ApplyBeamCorrection(TLorentzVector& p);

void setBeamEnergy(double e) {
beamEnergy_ = e;
beamMomentum_ = sqrt(beamEnergy_ * beamEnergy_ - ProtonMassSQ);
}

double beamEnergy() { return beamEnergy_; };
double beamMomentum() { return beamMomentum_; };

protected:
enum class TransportMode { HECTOR, TOTEM, OPTICALFUNCTIONS };
TransportMode MODE;

int NEvent;
CLHEP::HepRandomEngine* engine_;
std::vector<LHCTransportLink> m_CorrespondenceMap;
std::map<unsigned int, TLorentzVector> m_beamPart;
std::map<unsigned int, double> m_xAtTrPoint;
std::map<unsigned int, double> m_yAtTrPoint;

bool verbosity_;
bool bApplyZShift;

std::string beam1Filename_;
std::string beam2Filename_;

double fPPSRegionStart_45;
double fPPSRegionStart_56;
double fCrossingAngle_45;
double fCrossingAngle_56;

double beamMomentum_;
double beamEnergy_;
double etaCut_;
double momentumCut_;
double fVtxMeanX;
double fVtxMeanY;
double fVtxMeanZ;

double m_sigmaSTX;
double m_sigmaSTY;
double m_sigmaSX;
double m_sigmaSY;
double m_sig_E;
double fBeamXatIP;
double fBeamYatIP;
};
#endif
40 changes: 9 additions & 31 deletions SimTransport/PPSProtonTransport/interface/HectorTransport.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef HECTOR_TRANSPORT
#define HECTOR_TRANSPORT
#include "SimTransport/PPSProtonTransport/interface/ProtonTransport.h"
#include "SimTransport/PPSProtonTransport/interface/BaseProtonTransport.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
Expand Down Expand Up @@ -32,52 +32,30 @@ namespace CLHEP {
class H_BeamParticle;
class H_BeamLine;

class HectorTransport : public ProtonTransport {
class HectorTransport : public BaseProtonTransport {
public:
HectorTransport();
HectorTransport(const edm::ParameterSet &ps, bool verbosity);
HectorTransport(const edm::ParameterSet& ps);
~HectorTransport() override;
void process(const HepMC::GenEvent *, const edm::EventSetup &, CLHEP::HepRandomEngine *) override;

void process(const HepMC::GenEvent* ev, const edm::EventSetup& es, CLHEP::HepRandomEngine* engine) override;

private:
//!propagate the particles through a beamline to PPS
bool transportProton(const HepMC::GenParticle *);
/*!Adds the stable protons from the event \a ev to a beamline*/
bool m_verbosity;
static constexpr double fPPSBeamLineLength_ = 250.; // default beam line length

//!Clears BeamParticle, prepares PPSHector for a next Aperture check or/and a next event
void genProtonsLoop(const HepMC::GenEvent *, const edm::EventSetup &);
//!propagate the particles through a beamline to PPS
bool transportProton(const HepMC::GenParticle*);

// New function to calculate the LorentzBoost
void setBeamEnergy(double e) {
fBeamEnergy = e;
fBeamMomentum = sqrt(fBeamEnergy * fBeamEnergy - ProtonMassSQ);
}

double getBeamEnergy() { return fBeamEnergy; }

double getBeamMomentum() { return fBeamMomentum; }

bool setBeamLine();
/*
*
* ATTENTION: DATA MEMBERS AND FUNCTIONS COMMON TO BOTH METHODS SHOULD BE MOVED TO THE BASE CLASS
*
*/
// Defaults
edm::ESHandle<ParticleDataTable> m_pdt;

double m_fEtacut;
double m_fMomentumMin;

double m_lengthctpps;
double m_f_ctpps_f;
double m_b_ctpps_b;

// PPSHector
std::unique_ptr<H_BeamLine> m_beamline45;
std::unique_ptr<H_BeamLine> m_beamline56;

std::string m_beam1filename;
std::string m_beam2filename;
};
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef OPTICALFUNCTION_TRANSPORT
#define OPTICALFUNCTION_TRANSPORT
#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h"
#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h"
#include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
#include "CondFormats/PPSObjects/interface/CTPPSBeamParameters.h"
#include "CondFormats/PPSObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h"
#include "CondFormats/RunInfo/interface/LHCInfo.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "SimTransport/PPSProtonTransport/interface/BaseProtonTransport.h"

#include <array>
#include <unordered_map>

#include <cmath>

class OpticalFunctionsTransport : public BaseProtonTransport {
public:
OpticalFunctionsTransport(const edm::ParameterSet& ps);
~OpticalFunctionsTransport() override{};

void process(const HepMC::GenEvent* ev, const edm::EventSetup& es, CLHEP::HepRandomEngine* engine) override;

private:
bool transportProton(const HepMC::GenParticle*);

std::string lhcInfoLabel_;
std::string opticsLabel_;

edm::ESHandle<LHCInfo> lhcInfo_;
edm::ESHandle<CTPPSBeamParameters> beamParameters_;
edm::ESHandle<LHCInterpolatedOpticalFunctionsSetCollection> opticalFunctions_;

bool useEmpiricalApertures_;
double empiricalAperture45_xi0_int_, empiricalAperture45_xi0_slp_, empiricalAperture45_a_int_,
empiricalAperture45_a_slp_;
double empiricalAperture56_xi0_int_, empiricalAperture56_xi0_slp_, empiricalAperture56_a_int_,
empiricalAperture56_a_slp_;

bool produceHitsRelativeToBeam_;
};
#endif