CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
CTPPSAcceptancePlotter Class Reference
Inheritance diagram for CTPPSAcceptancePlotter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  DoubleArmPlots
 
struct  SingleArmPlots
 

Public Member Functions

 CTPPSAcceptancePlotter (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

std::vector< std::set< unsigned int > > doubleArmConfigurations
 
std::map< std::set< unsigned int >, DoubleArmPlotsdoubleArmPlots
 
std::string outputFile_
 
unsigned int rpId_45_F_
 
unsigned int rpId_45_N_
 
unsigned int rpId_56_F_
 
unsigned int rpId_56_N_
 
std::vector< std::set< unsigned int > > singleArmConfigurations
 
std::map< std::set< unsigned int >, SingleArmPlotssingleArmPlots
 
edm::EDGetTokenT< edm::HepMCProducttokenHepMC_
 
edm::EDGetTokenT< CTPPSLocalTrackLiteCollectiontokenTracks_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 28 of file CTPPSAcceptancePlotter.cc.

Constructor & Destructor Documentation

◆ CTPPSAcceptancePlotter()

CTPPSAcceptancePlotter::CTPPSAcceptancePlotter ( const edm::ParameterSet iConfig)
explicit

Definition at line 132 of file CTPPSAcceptancePlotter.cc.

References doubleArmConfigurations, rpId_45_F_, rpId_45_N_, rpId_56_F_, rpId_56_N_, and singleArmConfigurations.

133  : tokenHepMC_(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMC"))),
134  tokenTracks_(consumes<CTPPSLocalTrackLiteCollection>(iConfig.getParameter<edm::InputTag>("tagTracks"))),
135  rpId_45_N_(iConfig.getParameter<unsigned int>("rpId_45_N")),
136  rpId_45_F_(iConfig.getParameter<unsigned int>("rpId_45_F")),
137  rpId_56_N_(iConfig.getParameter<unsigned int>("rpId_56_N")),
138  rpId_56_F_(iConfig.getParameter<unsigned int>("rpId_56_F")),
139  outputFile_(iConfig.getParameter<string>("outputFile")) {
141  {rpId_45_N_},
142  {rpId_45_F_},
143  {rpId_56_N_},
144  {rpId_56_F_},
147  };
148 
153  };
154 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_
std::vector< std::set< unsigned int > > singleArmConfigurations
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tokenTracks_
std::vector< std::set< unsigned int > > doubleArmConfigurations

Member Function Documentation

◆ analyze()

void CTPPSAcceptancePlotter::analyze ( const edm::Event iEvent,
const edm::EventSetup  
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 158 of file CTPPSAcceptancePlotter.cc.

References protons_cff::arm, CTPPSDetId::arm(), doubleArmConfigurations, doubleArmPlots, edm::HepMCProduct::GetEvent(), iEvent, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, simPPS2016_cfi::rpIds, singleArmConfigurations, singleArmPlots, tokenHepMC_, tokenTracks_, and protons_cff::xi.

158  {
159  // get input
161  iEvent.getByToken(tokenHepMC_, hHepMC);
162  HepMC::GenEvent *hepMCEvent = (HepMC::GenEvent *)hHepMC->GetEvent();
163 
165  iEvent.getByToken(tokenTracks_, hTracks);
166 
167  // extract protons
168  bool proton_45_set = false;
169  bool proton_56_set = false;
170  FourVector mom_45, mom_56;
171 
172  for (auto it = hepMCEvent->particles_begin(); it != hepMCEvent->particles_end(); ++it) {
173  const auto &part = *it;
174 
175  // accept only stable non-beam protons
176  if (part->pdg_id() != 2212)
177  continue;
178 
179  if (part->status() != 1)
180  continue;
181 
182  if (part->is_beam())
183  continue;
184 
185  const auto &mom = part->momentum();
186 
187  if (mom.e() < 4500.)
188  continue;
189 
190  if (mom.z() > 0) {
191  // 45
192  if (proton_45_set) {
193  LogError("CTPPSAcceptancePlotter") << "Multiple protons found in sector 45.";
194  return;
195  }
196 
197  proton_45_set = true;
198  mom_45 = mom;
199  } else {
200  // 56
201  if (proton_56_set) {
202  LogError("CTPPSAcceptancePlotter") << "Multiple protons found in sector 56.";
203  return;
204  }
205 
206  proton_56_set = true;
207  mom_56 = mom;
208  }
209  }
210 
211  // stop if protons missing
212  if (!proton_45_set || !proton_56_set)
213  return;
214 
215  // calculate xi's
216  const double p_nom = 6500.;
217  const double xi_45 = (p_nom - mom_45.e()) / p_nom;
218  const double xi_56 = (p_nom - mom_56.e()) / p_nom;
219 
220  // process tracks
221  map<unsigned int, bool> trackPresent;
222  for (const auto &trk : *hTracks) {
223  CTPPSDetId rpId(trk.rpId());
224  unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
225  trackPresent[rpDecId] = true;
226  }
227 
228  // update plots
229  for (const auto &rpIds : singleArmConfigurations) {
230  bool acc = true;
231  signed int arm = -1;
232  for (const auto rpId : rpIds) {
233  acc &= trackPresent[rpId];
234  arm = rpId / 100;
235  }
236 
237  if (arm < 0)
238  continue;
239 
240  const double xi = (arm == 0) ? xi_45 : xi_56;
241 
242  singleArmPlots[rpIds].fill(xi, acc);
243  }
244 
245  for (const auto &rpIds : doubleArmConfigurations) {
246  bool acc = true;
247  for (const auto rpId : rpIds)
248  acc &= trackPresent[rpId];
249 
250  doubleArmPlots[rpIds].fill(xi_45, xi_56, acc);
251  }
252 }
uint32_t arm() const
Definition: CTPPSDetId.h:57
Log< level::Error, false > LogError
int iEvent
Definition: GenABIO.cc:224
std::map< std::set< unsigned int >, SingleArmPlots > singleArmPlots
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_
std::vector< std::set< unsigned int > > singleArmConfigurations
std::map< std::set< unsigned int >, DoubleArmPlots > doubleArmPlots
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tokenTracks_
part
Definition: HCALResponse.h:20
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
std::vector< std::set< unsigned int > > doubleArmConfigurations

◆ beginJob()

void CTPPSAcceptancePlotter::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 33 of file CTPPSAcceptancePlotter.cc.

33 {}

◆ endJob()

void CTPPSAcceptancePlotter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 256 of file CTPPSAcceptancePlotter.cc.

References TrackerOfflineValidation_Dqm_cff::dirName, doubleArmPlots, outputFile_, AlCaHLTBitMon_ParallelJobs::p, and singleArmPlots.

256  {
257  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
258 
259  for (const auto &p : singleArmPlots) {
260  string dirName;
261  for (const auto &rpId : p.first) {
262  if (!dirName.empty())
263  dirName += ",";
264  dirName += Form("%u", rpId);
265  }
266 
267  gDirectory = f_out->mkdir(dirName.c_str());
268  p.second.write();
269  }
270 
271  for (const auto &p : doubleArmPlots) {
272  string dirName;
273  for (const auto &rpId : p.first) {
274  if (!dirName.empty())
275  dirName += ",";
276  dirName += Form("%u", rpId);
277  }
278 
279  gDirectory = f_out->mkdir(dirName.c_str());
280  p.second.write();
281  }
282 }
std::map< std::set< unsigned int >, SingleArmPlots > singleArmPlots
std::map< std::set< unsigned int >, DoubleArmPlots > doubleArmPlots

Member Data Documentation

◆ doubleArmConfigurations

std::vector<std::set<unsigned int> > CTPPSAcceptancePlotter::doubleArmConfigurations
private

Definition at line 120 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and CTPPSAcceptancePlotter().

◆ doubleArmPlots

std::map<std::set<unsigned int>, DoubleArmPlots> CTPPSAcceptancePlotter::doubleArmPlots
private

Definition at line 121 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and endJob().

◆ outputFile_

std::string CTPPSAcceptancePlotter::outputFile_
private

Definition at line 42 of file CTPPSAcceptancePlotter.cc.

Referenced by endJob().

◆ rpId_45_F_

unsigned int CTPPSAcceptancePlotter::rpId_45_F_
private

Definition at line 40 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

◆ rpId_45_N_

unsigned int CTPPSAcceptancePlotter::rpId_45_N_
private

Definition at line 40 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

◆ rpId_56_F_

unsigned int CTPPSAcceptancePlotter::rpId_56_F_
private

Definition at line 40 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

◆ rpId_56_N_

unsigned int CTPPSAcceptancePlotter::rpId_56_N_
private

Definition at line 40 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

◆ singleArmConfigurations

std::vector<std::set<unsigned int> > CTPPSAcceptancePlotter::singleArmConfigurations
private

Definition at line 64 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and CTPPSAcceptancePlotter().

◆ singleArmPlots

std::map<std::set<unsigned int>, SingleArmPlots> CTPPSAcceptancePlotter::singleArmPlots
private

Definition at line 65 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and endJob().

◆ tokenHepMC_

edm::EDGetTokenT<edm::HepMCProduct> CTPPSAcceptancePlotter::tokenHepMC_
private

Definition at line 37 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze().

◆ tokenTracks_

edm::EDGetTokenT<CTPPSLocalTrackLiteCollection> CTPPSAcceptancePlotter::tokenTracks_
private

Definition at line 38 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze().