CMS 3D CMS Logo

CTPPSProtonReconstructionValidator.cc
Go to the documentation of this file.
1 /****************************************************************************
2  * Authors:
3  * Jan Kašpar
4  ****************************************************************************/
5 
11 
14 
16 
19 
23 
24 #include "TFile.h"
25 #include "TH1D.h"
26 
27 #include <map>
28 #include <string>
29 
30 //----------------------------------------------------------------------------------------------------
31 
33 public:
35 
36 private:
37  void analyze(const edm::Event&, const edm::EventSetup&) override;
38  void endJob() override;
39 
42  double chiSqCut_;
44 
45  struct RPPlots {
46  std::unique_ptr<TH1D> h_de_x, h_de_y;
48  : h_de_x(new TH1D("", ";#Deltax (mm)", 1000, -1., +1.)),
49  h_de_y(new TH1D("", ";#Deltay (mm)", 1000, -1., +1.)) {}
50 
51  void fill(double de_x, double de_y) {
52  h_de_x->Fill(de_x);
53  h_de_y->Fill(de_y);
54  }
55 
56  void write() const {
57  h_de_x->Write("h_de_x");
58  h_de_y->Write("h_de_y");
59  }
60  };
61 
62  std::map<unsigned int, RPPlots> rp_plots_;
63 };
64 
65 //----------------------------------------------------------------------------------------------------
66 
67 using namespace std;
68 using namespace edm;
69 
70 //----------------------------------------------------------------------------------------------------
71 
73  : tokenRecoProtons_(consumes<reco::ForwardProtonCollection>(iConfig.getParameter<edm::InputTag>("tagRecoProtons"))),
74  opticsESToken_(esConsumes()),
75  chiSqCut_(iConfig.getParameter<double>("chiSqCut")),
76  outputFile_(iConfig.getParameter<string>("outputFile")) {}
77 
78 //----------------------------------------------------------------------------------------------------
79 
81  // get conditions
82  const auto& opticalFunctions = iSetup.getData(opticsESToken_);
83 
84  // stop if conditions invalid
85  if (opticalFunctions.empty())
86  return;
87 
88  // get input
90  iEvent.getByToken(tokenRecoProtons_, hRecoProtons);
91 
92  // process tracks
93  for (const auto& pr : *hRecoProtons) {
94  if (!pr.validFit())
95  continue;
96 
97  if (pr.chi2() > chiSqCut_)
98  continue;
99 
100  for (const auto& tr : pr.contributingLocalTracks()) {
101  CTPPSDetId rpId(tr->rpId());
102  unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
103 
104  // skip other than tracking RPs
105  if (rpId.subdetId() != CTPPSDetId::sdTrackingStrip && rpId.subdetId() != CTPPSDetId::sdTrackingPixel)
106  continue;
107 
108  // try to get optics for the RP
109  if (opticalFunctions.count(rpId) == 0)
110  continue;
111  const auto& func = opticalFunctions.at(rpId);
112 
113  // do propagation
114  LHCInterpolatedOpticalFunctionsSet::Kinematics k_in_beam = {0., 0., 0., 0., 0.};
116  func.transport(k_in_beam, k_out_beam);
117 
119  -pr.vx(), -pr.thetaX(), pr.vy(), pr.thetaY(), pr.xi()}; // conversions: CMS --> LHC convention
121  func.transport(k_in, k_out);
122 
123  // fill plots
124  const double de_x = (k_out.x - k_out_beam.x) * 10. - tr->x(); // conversions: cm --> mm
125  const double de_y = (k_out.y - k_out_beam.y) * 10. - tr->y(); // conversions: cm --> mm
126 
127  rp_plots_[rpDecId].fill(de_x, de_y);
128  }
129  }
130 }
131 
132 //----------------------------------------------------------------------------------------------------
133 
135  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
136 
137  for (const auto& p : rp_plots_) {
138  gDirectory = f_out->mkdir(Form("%u", p.first));
139  p.second.write();
140  }
141 }
142 
143 //----------------------------------------------------------------------------------------------------
144 
EDAnalyzer.h
CTPPSProtonReconstructionValidator::endJob
void endJob() override
Definition: CTPPSProtonReconstructionValidator.cc:133
LHCInterpolatedOpticalFunctionsSet::Kinematics
proton kinematics description
Definition: LHCInterpolatedOpticalFunctionsSet.h:28
ESHandle.h
CTPPSProtonReconstructionValidator::RPPlots::fill
void fill(double de_x, double de_y)
Definition: CTPPSProtonReconstructionValidator.cc:52
edm::EDGetTokenT< reco::ForwardProtonCollection >
CTPPSProtonReconstructionValidator::RPPlots::RPPlots
RPPlots()
Definition: CTPPSProtonReconstructionValidator.cc:48
edm
HLT enums.
Definition: AlignableModifier.h:19
CTPPSLocalTrackLite.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Handle
Definition: AssociativeIterator.h:50
CTPPSDetId::sdTrackingStrip
Definition: CTPPSDetId.h:44
MakerMacros.h
CTPPSProtonReconstructionValidator::CTPPSProtonReconstructionValidator
CTPPSProtonReconstructionValidator(const edm::ParameterSet &)
Definition: CTPPSProtonReconstructionValidator.cc:71
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CTPPSProtonReconstructionValidator::tokenRecoProtons_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtons_
Definition: CTPPSProtonReconstructionValidator.cc:41
LHCInterpolatedOpticalFunctionsSet::Kinematics::y
double y
Definition: LHCInterpolatedOpticalFunctionsSet.h:31
CTPPSProtonReconstructionValidator::rp_plots_
std::map< unsigned int, RPPlots > rp_plots_
Definition: CTPPSProtonReconstructionValidator.cc:63
LHCInterpolatedOpticalFunctionsSetCollection.h
ForwardProtonFwd.h
LHCInterpolatedOpticalFunctionsSet::Kinematics::x
double x
Definition: LHCInterpolatedOpticalFunctionsSet.h:29
CTPPSDetId::sdTrackingPixel
Definition: CTPPSDetId.h:44
CTPPSProtonReconstructionValidator::RPPlots::write
void write() const
Definition: CTPPSProtonReconstructionValidator.cc:57
CTPPSProtonReconstructionValidator::RPPlots::h_de_x
std::unique_ptr< TH1D > h_de_x
Definition: CTPPSProtonReconstructionValidator.cc:47
CTPPSProtonReconstructionValidator
Definition: CTPPSProtonReconstructionValidator.cc:31
reco::ForwardProtonCollection
std::vector< ForwardProton > ForwardProtonCollection
Collection of ForwardProton objects.
Definition: ForwardProtonFwd.h:25
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CTPPSProtonReconstructionValidator::opticsESToken_
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd > opticsESToken_
Definition: CTPPSProtonReconstructionValidator.cc:42
sipixeldigitoraw
Definition: SiPixelDigiToRaw.cc:32
Event.h
ForwardProton.h
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
iEvent
int iEvent
Definition: GenABIO.cc:224
CTPPSInterpolatedOpticsRcd.h
CTPPSProtonReconstructionValidator::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: CTPPSProtonReconstructionValidator.cc:79
edm::EventSetup
Definition: EventSetup.h:58
alignCSCRings.de_y
de_y
Definition: alignCSCRings.py:86
TrackCollections2monitor_cff.func
func
Definition: TrackCollections2monitor_cff.py:359
CTPPSProtonReconstructionValidator::chiSqCut_
double chiSqCut_
Definition: CTPPSProtonReconstructionValidator.cc:43
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd >
CTPPSProtonReconstructionValidator::outputFile_
std::string outputFile_
Definition: CTPPSProtonReconstructionValidator.cc:44
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
profile_2016_postTS2_cff.rpId
rpId
Definition: profile_2016_postTS2_cff.py:21
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
ESWatcher.h
alignCSCRings.de_x
de_x
Definition: alignCSCRings.py:85
EventSetup.h
CTPPSDetId.h
CTPPSProtonReconstructionValidator::RPPlots
Definition: CTPPSProtonReconstructionValidator.cc:46
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
OpticalFunctionsConfig_cfi.opticalFunctions
opticalFunctions
Definition: OpticalFunctionsConfig_cfi.py:16
CTPPSProtonReconstructionValidator::RPPlots::h_de_y
std::unique_ptr< TH1D > h_de_y
Definition: CTPPSProtonReconstructionValidator.cc:47