CMS 3D CMS Logo

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

Classes

struct  ArmPlots
 
struct  RPPlots
 

Public Member Functions

 CTPPSTrackDistributionPlotter (const edm::ParameterSet &)
 
 ~CTPPSTrackDistributionPlotter () override
 
- 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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const 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
 
bool wantsStreamRuns () const
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

std::map< unsigned int, ArmPlotsarmPlots
 
std::map< unsigned int, unsigned int > events_per_arm_
 
unsigned int events_total_
 
std::string outputFile_
 
std::map< unsigned int, RPPlotsrpPlots
 
edm::EDGetTokenT< CTPPSLocalTrackLiteCollectiontracksToken_
 
double x_pitch_pixels_
 

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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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 34 of file CTPPSTrackDistributionPlotter.cc.

Constructor & Destructor Documentation

◆ CTPPSTrackDistributionPlotter()

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

Definition at line 246 of file CTPPSTrackDistributionPlotter.cc.

References armPlots, and edm::ParameterSet::getParameter().

247  : tracksToken_(consumes<CTPPSLocalTrackLiteCollection>(iConfig.getParameter<edm::InputTag>("tagTracks"))),
248  x_pitch_pixels_(iConfig.getUntrackedParameter<double>("x_pitch_pixels", 150E-3)),
249  outputFile_(iConfig.getParameter<std::string>("outputFile")),
250  events_total_(0) {
251  armPlots[0].rpId_N = iConfig.getParameter<unsigned int>("rpId_45_N");
252  armPlots[0].rpId_F = iConfig.getParameter<unsigned int>("rpId_45_F");
253 
254  armPlots[1].rpId_N = iConfig.getParameter<unsigned int>("rpId_56_N");
255  armPlots[1].rpId_F = iConfig.getParameter<unsigned int>("rpId_56_F");
256 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::map< unsigned int, ArmPlots > armPlots
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tracksToken_

◆ ~CTPPSTrackDistributionPlotter()

CTPPSTrackDistributionPlotter::~CTPPSTrackDistributionPlotter ( )
inlineoverride

Definition at line 38 of file CTPPSTrackDistributionPlotter.cc.

38 {}

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 260 of file CTPPSTrackDistributionPlotter.cc.

References protons_cff::arm, CTPPSDetId::arm(), armPlots, events_per_arm_, events_total_, mps_fire::i, iEvent, dqmiolumiharvest::j, rpPlots, CTPPSDetId::sdTrackingPixel, RandomServiceHelper::t1, RandomServiceHelper::t2, tracks, tracksToken_, and x_pitch_pixels_.

260  {
261  // get input
263  iEvent.getByToken(tracksToken_, tracks);
264 
265  // process tracks
266  std::map<unsigned int, unsigned int> m_mult;
267 
268  for (const auto& trk : *tracks) {
269  CTPPSDetId rpId(trk.rpId());
270  unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
271  bool rpPixel = (rpId.subdetId() == CTPPSDetId::sdTrackingPixel);
272 
273  auto& pl = rpPlots[rpDecId];
274  if (!pl.initialized)
275  pl.init(rpPixel, x_pitch_pixels_);
276 
277  pl.fillOneTrack(trk.x(), trk.y(), trk.time());
278 
279  m_mult[rpId.arm()]++;
280  }
281 
282  for (unsigned int arm = 0; arm < 2; ++arm) {
283  auto& st = armPlots[arm].m_stat[iEvent.id().run()][iEvent.id().luminosityBlock()];
284  st.s1++;
285  st.sN += m_mult[arm];
286  }
287 
288  for (const auto& t1 : *tracks) {
289  const CTPPSDetId rpId1(t1.rpId());
290 
291  for (const auto& t2 : *tracks) {
292  const CTPPSDetId rpId2(t2.rpId());
293 
294  if (rpId1.arm() != rpId2.arm())
295  continue;
296 
297  auto& ap = armPlots[rpId1.arm()];
298 
299  const unsigned int rpDecId1 = rpId1.arm() * 100 + rpId1.station() * 10 + rpId1.rp();
300  const unsigned int rpDecId2 = rpId2.arm() * 100 + rpId2.station() * 10 + rpId2.rp();
301 
302  if (rpDecId1 == ap.rpId_N && rpDecId2 == ap.rpId_F)
303  ap.fill(t1.x(), t1.y(), t2.x(), t2.y());
304  }
305  }
306 
307  for (unsigned int i = 0; i < tracks->size(); ++i) {
308  for (unsigned int j = 0; j < tracks->size(); ++j) {
309  if (i == j)
310  continue;
311 
312  const auto& tr_i = tracks->at(i);
313  const auto& tr_j = tracks->at(j);
314 
315  if (tr_i.rpId() != tr_j.rpId())
316  continue;
317 
318  CTPPSDetId rpId(tr_i.rpId());
319  unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
320 
321  auto& pl = rpPlots[rpDecId];
322 
323  pl.h2_de_x_vs_x->Fill(tr_i.x(), tr_j.x() - tr_i.x());
324  pl.h2_de_x_vs_y->Fill(tr_i.y(), tr_j.x() - tr_i.x());
325  pl.h2_de_y_vs_x->Fill(tr_i.x(), tr_j.y() - tr_i.y());
326  pl.h2_de_y_vs_y->Fill(tr_i.y(), tr_j.y() - tr_i.y());
327  }
328  }
329 
330  // update counters
331  events_total_++;
332 
333  if (m_mult[0] > 0)
334  events_per_arm_[0]++;
335  if (m_mult[1] > 0)
336  events_per_arm_[1]++;
337 }
std::map< unsigned int, unsigned int > events_per_arm_
uint32_t arm() const
Definition: CTPPSDetId.h:51
std::map< unsigned int, ArmPlots > armPlots
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tracksToken_
std::map< unsigned int, RPPlots > rpPlots
auto const & tracks
cannot be loose
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32

◆ endJob()

void CTPPSTrackDistributionPlotter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 341 of file CTPPSTrackDistributionPlotter.cc.

References armPlots, events_per_arm_, events_total_, outputFile_, and rpPlots.

341  {
342  edm::LogInfo("CTPPSTrackDistributionPlotter")
343  << " events processed: " << events_total_ << " (" << std::scientific << double(events_total_) << ")\n"
344  << " events with tracks in sector 45: " << events_per_arm_[0] << " (" << double(events_per_arm_[0]) << ")\n"
345  << " events with tracks in sector 56: " << events_per_arm_[1] << " (" << double(events_per_arm_[1]) << ")";
346 
347  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
348 
349  for (const auto& it : rpPlots) {
350  gDirectory = f_out->mkdir(Form("RP %u", it.first));
351  it.second.write();
352  }
353 
354  for (const auto& it : armPlots) {
355  gDirectory = f_out->mkdir(Form("arm %u", it.first));
356  it.second.write();
357  }
358 }
std::map< unsigned int, unsigned int > events_per_arm_
std::map< unsigned int, ArmPlots > armPlots
std::map< unsigned int, RPPlots > rpPlots
Log< level::Info, false > LogInfo

Member Data Documentation

◆ armPlots

std::map<unsigned int, ArmPlots> CTPPSTrackDistributionPlotter::armPlots
private

◆ events_per_arm_

std::map<unsigned int, unsigned int> CTPPSTrackDistributionPlotter::events_per_arm_
private

Definition at line 51 of file CTPPSTrackDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ events_total_

unsigned int CTPPSTrackDistributionPlotter::events_total_
private

Definition at line 50 of file CTPPSTrackDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ outputFile_

std::string CTPPSTrackDistributionPlotter::outputFile_
private

Definition at line 48 of file CTPPSTrackDistributionPlotter.cc.

Referenced by endJob().

◆ rpPlots

std::map<unsigned int, RPPlots> CTPPSTrackDistributionPlotter::rpPlots
private

Definition at line 118 of file CTPPSTrackDistributionPlotter.cc.

Referenced by analyze(), and endJob().

◆ tracksToken_

edm::EDGetTokenT<CTPPSLocalTrackLiteCollection> CTPPSTrackDistributionPlotter::tracksToken_
private

Definition at line 44 of file CTPPSTrackDistributionPlotter.cc.

Referenced by analyze().

◆ x_pitch_pixels_

double CTPPSTrackDistributionPlotter::x_pitch_pixels_
private

Definition at line 46 of file CTPPSTrackDistributionPlotter.cc.

Referenced by analyze().