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
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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 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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 27 of file CTPPSAcceptancePlotter.cc.

Constructor & Destructor Documentation

◆ CTPPSAcceptancePlotter()

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

Definition at line 131 of file CTPPSAcceptancePlotter.cc.

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  };

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

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 157 of file CTPPSAcceptancePlotter.cc.

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  }

References protons_cff::arm, doubleArmConfigurations, doubleArmPlots, edm::HepMCProduct::GetEvent(), iEvent, profile_2016_postTS2_cff::rpId, year_2016_cff::rpIds, singleArmConfigurations, singleArmPlots, tokenHepMC_, tokenTracks_, and protons_cff::xi.

◆ beginJob()

void CTPPSAcceptancePlotter::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 34 of file CTPPSAcceptancePlotter.cc.

◆ endJob()

void CTPPSAcceptancePlotter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 255 of file CTPPSAcceptancePlotter.cc.

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  }

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

Member Data Documentation

◆ doubleArmConfigurations

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

Definition at line 121 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and CTPPSAcceptancePlotter().

◆ doubleArmPlots

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

Definition at line 122 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and endJob().

◆ outputFile_

std::string CTPPSAcceptancePlotter::outputFile_
private

Definition at line 43 of file CTPPSAcceptancePlotter.cc.

Referenced by endJob().

◆ rpId_45_F_

unsigned int CTPPSAcceptancePlotter::rpId_45_F_
private

Definition at line 41 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

◆ rpId_45_N_

unsigned int CTPPSAcceptancePlotter::rpId_45_N_
private

Definition at line 41 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

◆ rpId_56_F_

unsigned int CTPPSAcceptancePlotter::rpId_56_F_
private

Definition at line 41 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

◆ rpId_56_N_

unsigned int CTPPSAcceptancePlotter::rpId_56_N_
private

Definition at line 41 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

◆ singleArmConfigurations

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

Definition at line 65 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and CTPPSAcceptancePlotter().

◆ singleArmPlots

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

Definition at line 66 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and endJob().

◆ tokenHepMC_

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

Definition at line 38 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze().

◆ tokenTracks_

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

Definition at line 39 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze().

CTPPSAcceptancePlotter::tokenTracks_
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tokenTracks_
Definition: CTPPSAcceptancePlotter.cc:39
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CTPPSAcceptancePlotter::doubleArmPlots
std::map< std::set< unsigned int >, DoubleArmPlots > doubleArmPlots
Definition: CTPPSAcceptancePlotter.cc:122
edm::Handle< edm::HepMCProduct >
year_2016_cff.rpIds
rpIds
Definition: year_2016_cff.py:30
CTPPSAcceptancePlotter::tokenHepMC_
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_
Definition: CTPPSAcceptancePlotter.cc:38
CTPPSAcceptancePlotter::rpId_56_F_
unsigned int rpId_56_F_
Definition: CTPPSAcceptancePlotter.cc:41
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
part
part
Definition: HCALResponse.h:20
CTPPSAcceptancePlotter::rpId_45_N_
unsigned int rpId_45_N_
Definition: CTPPSAcceptancePlotter.cc:41
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
iEvent
int iEvent
Definition: GenABIO.cc:224
CTPPSAcceptancePlotter::singleArmPlots
std::map< std::set< unsigned int >, SingleArmPlots > singleArmPlots
Definition: CTPPSAcceptancePlotter.cc:66
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
CTPPSAcceptancePlotter::outputFile_
std::string outputFile_
Definition: CTPPSAcceptancePlotter.cc:43
protons_cff.arm
arm
Definition: protons_cff.py:43
profile_2016_postTS2_cff.rpId
rpId
Definition: profile_2016_postTS2_cff.py:21
protons_cff.xi
xi
Definition: protons_cff.py:35
CTPPSAcceptancePlotter::rpId_56_N_
unsigned int rpId_56_N_
Definition: CTPPSAcceptancePlotter.cc:41
CTPPSAcceptancePlotter::rpId_45_F_
unsigned int rpId_45_F_
Definition: CTPPSAcceptancePlotter.cc:41
CTPPSAcceptancePlotter::singleArmConfigurations
std::vector< std::set< unsigned int > > singleArmConfigurations
Definition: CTPPSAcceptancePlotter.cc:65
TrackerOfflineValidation_Dqm_cff.dirName
dirName
Definition: TrackerOfflineValidation_Dqm_cff.py:55
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CTPPSAcceptancePlotter::doubleArmConfigurations
std::vector< std::set< unsigned int > > doubleArmConfigurations
Definition: CTPPSAcceptancePlotter.cc:121
edm::InputTag
Definition: InputTag.h:15