CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 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 beginJob () override
 
void endJob () override
 

Private Attributes

std::vector< std::set
< unsigned int > > 
doubleArmConfigurations
 
std::map< std::set< unsigned
int >, DoubleArmPlots
doubleArmPlots
 
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 >, SingleArmPlots
singleArmPlots
 
edm::EDGetTokenT
< edm::HepMCProduct
tokenHepMC_
 
edm::EDGetTokenT
< CTPPSLocalTrackLiteCollection
tokenTracks_
 

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< B > consumes (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 () noexcept
 
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...
 
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 ( 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 }
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_
std::vector< std::set< unsigned int > > singleArmConfigurations
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tokenTracks_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< std::set< unsigned int > > doubleArmConfigurations

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 158 of file CTPPSAcceptancePlotter.cc.

References CTPPSDetId::arm(), doubleArmConfigurations, doubleArmPlots, edm::Event::getByToken(), year_2016_cff::rpIds, singleArmConfigurations, singleArmPlots, tokenHepMC_, and tokenTracks_.

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 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
Log< level::Error, false > LogError
std::map< std::set< unsigned int >, SingleArmPlots > singleArmPlots
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_
std::vector< std::set< unsigned int > > singleArmConfigurations
uint32_t arm() const
Definition: CTPPSDetId.h:51
std::map< std::set< unsigned int >, DoubleArmPlots > doubleArmPlots
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
void CTPPSAcceptancePlotter::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 33 of file CTPPSAcceptancePlotter.cc.

33 {}
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

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

Definition at line 120 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and CTPPSAcceptancePlotter().

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

Definition at line 121 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and endJob().

std::string CTPPSAcceptancePlotter::outputFile_
private

Definition at line 42 of file CTPPSAcceptancePlotter.cc.

Referenced by endJob().

unsigned int CTPPSAcceptancePlotter::rpId_45_F_
private

Definition at line 40 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

unsigned int CTPPSAcceptancePlotter::rpId_45_N_
private

Definition at line 40 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

unsigned int CTPPSAcceptancePlotter::rpId_56_F_
private

Definition at line 40 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

unsigned int CTPPSAcceptancePlotter::rpId_56_N_
private

Definition at line 40 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

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

Definition at line 64 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and CTPPSAcceptancePlotter().

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

Definition at line 65 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and endJob().

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

Definition at line 37 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze().

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

Definition at line 38 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze().