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
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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::vector< ModuleDescription const * > &modules, 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
 
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)
 
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<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)
 

Detailed Description

Definition at line 32 of file CTPPSTrackDistributionPlotter.cc.

Constructor & Destructor Documentation

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

Definition at line 179 of file CTPPSTrackDistributionPlotter.cc.

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

180  : tracksToken_(consumes<CTPPSLocalTrackLiteCollection>(iConfig.getParameter<edm::InputTag>("tagTracks"))),
181  x_pitch_pixels_(iConfig.getUntrackedParameter<double>("x_pitch_pixels", 150E-3)),
182  outputFile_(iConfig.getParameter<std::string>("outputFile")),
183  events_total_(0) {
184  armPlots[0].rpId_N = iConfig.getParameter<unsigned int>("rpId_45_N");
185  armPlots[0].rpId_F = iConfig.getParameter<unsigned int>("rpId_45_F");
186 
187  armPlots[1].rpId_N = iConfig.getParameter<unsigned int>("rpId_56_N");
188  armPlots[1].rpId_F = iConfig.getParameter<unsigned int>("rpId_56_F");
189 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::map< unsigned int, ArmPlots > armPlots
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tracksToken_
CTPPSTrackDistributionPlotter::~CTPPSTrackDistributionPlotter ( )
inlineoverride

Definition at line 36 of file CTPPSTrackDistributionPlotter.cc.

References analyze(), and endJob().

36 {}

Member Function Documentation

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

Definition at line 193 of file CTPPSTrackDistributionPlotter.cc.

References protons_cff::arm, armPlots, events_per_arm_, events_total_, edm::Event::getByToken(), edm::EventBase::id(), edm::EventID::luminosityBlock(), year_2016_postTS2_cff::rpId, rpPlots, edm::EventID::run(), CTPPSDetId::sdTrackingPixel, l1t::tracks, tracksToken_, and x_pitch_pixels_.

Referenced by ~CTPPSTrackDistributionPlotter().

193  {
194  // get input
196  iEvent.getByToken(tracksToken_, tracks);
197 
198  // process tracks
199  std::map<unsigned int, unsigned int> m_mult;
200 
201  for (const auto& trk : *tracks) {
202  CTPPSDetId rpId(trk.getRPId());
203  unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
204  bool rpPixel = (rpId.subdetId() == CTPPSDetId::sdTrackingPixel);
205 
206  auto& pl = rpPlots[rpDecId];
207  if (!pl.initialized)
208  pl.init(rpPixel, x_pitch_pixels_);
209 
210  pl.fill(trk.getX(), trk.getY(), trk.getTime());
211 
212  m_mult[rpId.arm()]++;
213  }
214 
215  for (unsigned int arm = 0; arm < 2; ++arm) {
216  auto& st = armPlots[arm].m_stat[iEvent.id().run()][iEvent.id().luminosityBlock()];
217  st.s1++;
218  st.sN += m_mult[arm];
219  }
220 
221  for (const auto& t1 : *tracks) {
222  const CTPPSDetId rpId1(t1.getRPId());
223 
224  for (const auto& t2 : *tracks) {
225  const CTPPSDetId rpId2(t2.getRPId());
226 
227  if (rpId1.arm() != rpId2.arm())
228  continue;
229 
230  auto& ap = armPlots[rpId1.arm()];
231 
232  const unsigned int rpDecId1 = rpId1.arm() * 100 + rpId1.station() * 10 + rpId1.rp();
233  const unsigned int rpDecId2 = rpId2.arm() * 100 + rpId2.station() * 10 + rpId2.rp();
234 
235  if (rpDecId1 == ap.rpId_N && rpDecId2 == ap.rpId_F)
236  ap.fill(t1.getX(), t1.getY(), t2.getX(), t2.getY());
237  }
238  }
239 
240  // update counters
241  events_total_++;
242 
243  if (m_mult[0] > 0)
244  events_per_arm_[0]++;
245  if (m_mult[1] > 0)
246  events_per_arm_[1]++;
247 }
RunNumber_t run() const
Definition: EventID.h:39
std::map< unsigned int, unsigned int > events_per_arm_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::map< unsigned int, ArmPlots > armPlots
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tracksToken_
std::map< unsigned int, RPPlots > rpPlots
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
edm::EventID id() const
Definition: EventBase.h:59
void CTPPSTrackDistributionPlotter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 251 of file CTPPSTrackDistributionPlotter.cc.

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

Referenced by ~CTPPSTrackDistributionPlotter().

251  {
252  edm::LogInfo("CTPPSTrackDistributionPlotter")
253  << " events processed: " << events_total_ << " (" << std::scientific << double(events_total_) << ")\n"
254  << " events with tracks in sector 45: " << events_per_arm_[0] << " (" << double(events_per_arm_[0]) << ")\n"
255  << " events with tracks in sector 56: " << events_per_arm_[1] << " (" << double(events_per_arm_[1]) << ")";
256 
257  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
258 
259  for (const auto& it : rpPlots) {
260  gDirectory = f_out->mkdir(Form("RP %u", it.first));
261  it.second.write();
262  }
263 
264  for (const auto& it : armPlots) {
265  gDirectory = f_out->mkdir(Form("arm %u", it.first));
266  it.second.write();
267  }
268 }
std::map< unsigned int, unsigned int > events_per_arm_
std::map< unsigned int, ArmPlots > armPlots
std::map< unsigned int, RPPlots > rpPlots

Member Data Documentation

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

Definition at line 49 of file CTPPSTrackDistributionPlotter.cc.

Referenced by analyze(), and endJob().

unsigned int CTPPSTrackDistributionPlotter::events_total_
private

Definition at line 48 of file CTPPSTrackDistributionPlotter.cc.

Referenced by analyze(), and endJob().

std::string CTPPSTrackDistributionPlotter::outputFile_
private

Definition at line 46 of file CTPPSTrackDistributionPlotter.cc.

Referenced by endJob().

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

Definition at line 97 of file CTPPSTrackDistributionPlotter.cc.

Referenced by analyze(), and endJob().

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

Definition at line 42 of file CTPPSTrackDistributionPlotter.cc.

Referenced by analyze().

double CTPPSTrackDistributionPlotter::x_pitch_pixels_
private

Definition at line 44 of file CTPPSTrackDistributionPlotter.cc.

Referenced by analyze().