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
 
- 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 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)
 
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 28 of file CTPPSAcceptancePlotter.cc.

Constructor & Destructor Documentation

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

Definition at line 143 of file CTPPSAcceptancePlotter.cc.

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

143  :
144  tokenHepMC_ (consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("tagHepMC"))),
145  tokenTracks_(consumes<CTPPSLocalTrackLiteCollection>(iConfig.getParameter<edm::InputTag>("tagTracks"))),
146  rpId_45_N_ (iConfig.getParameter<unsigned int>("rpId_45_N")),
147  rpId_45_F_ (iConfig.getParameter<unsigned int>("rpId_45_F")),
148  rpId_56_N_ (iConfig.getParameter<unsigned int>("rpId_56_N")),
149  rpId_56_F_ (iConfig.getParameter<unsigned int>("rpId_56_F")),
150  outputFile_(iConfig.getParameter<string>("outputFile"))
151 {
153  { rpId_45_N_ },
154  { rpId_45_F_ },
155  { rpId_56_N_ },
156  { rpId_56_F_ },
157  { rpId_45_N_, rpId_45_F_ },
158  { rpId_56_N_, rpId_56_F_ },
159  };
160 
162  { rpId_45_N_, rpId_56_N_ },
163  { rpId_45_F_, rpId_56_F_ },
164  { rpId_45_N_, rpId_45_F_, rpId_56_N_, rpId_56_F_ },
165  };
166 }
T getParameter(std::string const &) const
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

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

Definition at line 170 of file CTPPSAcceptancePlotter.cc.

References doubleArmConfigurations, doubleArmPlots, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), year_2016_postTS2_cff::rpId, year_2016_cff::rpIds, singleArmConfigurations, singleArmPlots, tokenHepMC_, tokenTracks_, and hybridSuperClusters_cfi::xi.

Referenced by beginJob().

171 {
172  // get input
174  iEvent.getByToken(tokenHepMC_, hHepMC);
175  HepMC::GenEvent *hepMCEvent = (HepMC::GenEvent *) hHepMC->GetEvent();
176 
178  iEvent.getByToken(tokenTracks_, hTracks);
179 
180  // extract protons
181  bool proton_45_set = false;
182  bool proton_56_set = false;
183  FourVector mom_45, mom_56;
184 
185  for (auto it = hepMCEvent->particles_begin(); it != hepMCEvent->particles_end(); ++it)
186  {
187  const auto &part = *it;
188 
189  // accept only stable non-beam protons
190  if (part->pdg_id() != 2212)
191  continue;
192 
193  if (part->status() != 1)
194  continue;
195 
196  if (part->is_beam())
197  continue;
198 
199  const auto &mom = part->momentum();
200 
201  if (mom.e() < 4500.)
202  continue;
203 
204  if (mom.z() > 0)
205  {
206  // 45
207  if (proton_45_set)
208  {
209  LogError("CTPPSAcceptancePlotter") << "Multiple protons found in sector 45.";
210  return;
211  }
212 
213  proton_45_set = true;
214  mom_45 = mom;
215  } else {
216  // 56
217  if (proton_56_set)
218  {
219  LogError("CTPPSAcceptancePlotter") << "Multiple protons found in sector 56.";
220  return;
221  }
222 
223  proton_56_set = true;
224  mom_56 = mom;
225  }
226  }
227 
228  // stop if protons missing
229  if (!proton_45_set || !proton_56_set)
230  return;
231 
232  // calculate xi's
233  const double p_nom = 6500.;
234  const double xi_45 = (p_nom - mom_45.e()) / p_nom;
235  const double xi_56 = (p_nom - mom_56.e()) / p_nom;
236 
237  // process tracks
238  map<unsigned int, bool> trackPresent;
239  for (const auto& trk : *hTracks)
240  {
241  CTPPSDetId rpId(trk.getRPId());
242  unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp();
243  trackPresent[rpDecId] = true;
244  }
245 
246  // update plots
247  for (const auto rpIds : singleArmConfigurations)
248  {
249  bool acc = true;
250  signed int arm = -1;
251  for (const auto rpId : rpIds)
252  {
253  acc &= trackPresent[rpId];
254  arm = rpId / 100;
255  }
256 
257  if (arm < 0)
258  continue;
259 
260  const double xi = (arm == 0) ? xi_45 : xi_56;
261 
262  singleArmPlots[rpIds].fill(xi, acc);
263  }
264 
265  for (const auto rpIds : doubleArmConfigurations)
266  {
267  bool acc = true;
268  for (const auto rpId : rpIds)
269  acc &= trackPresent[rpId];
270 
271  doubleArmPlots[rpIds].fill(xi_45, xi_56, acc);
272  }
273 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
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
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tokenTracks_
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
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 34 of file CTPPSAcceptancePlotter.cc.

References analyze(), and endJob().

34 {}
void CTPPSAcceptancePlotter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 278 of file CTPPSAcceptancePlotter.cc.

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

Referenced by beginJob().

279 {
280  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
281 
282  for (const auto &p : singleArmPlots) {
283  string dirName;
284  for (const auto &rpId : p.first) {
285  if (!dirName.empty())
286  dirName += ",";
287  dirName += Form("%u", rpId);
288  }
289 
290  gDirectory = f_out->mkdir(dirName.c_str());
291  p.second.write();
292  }
293 
294  for (const auto &p : doubleArmPlots) {
295  string dirName;
296  for (const auto &rpId : p.first) {
297  if (!dirName.empty())
298  dirName += ",";
299  dirName += Form("%u", rpId);
300  }
301 
302  gDirectory = f_out->mkdir(dirName.c_str());
303  p.second.write();
304  }
305 }
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 131 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and CTPPSAcceptancePlotter().

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

Definition at line 132 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and endJob().

std::string CTPPSAcceptancePlotter::outputFile_
private

Definition at line 43 of file CTPPSAcceptancePlotter.cc.

Referenced by endJob().

unsigned int CTPPSAcceptancePlotter::rpId_45_F_
private

Definition at line 41 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

unsigned int CTPPSAcceptancePlotter::rpId_45_N_
private

Definition at line 41 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

unsigned int CTPPSAcceptancePlotter::rpId_56_F_
private

Definition at line 41 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

unsigned int CTPPSAcceptancePlotter::rpId_56_N_
private

Definition at line 41 of file CTPPSAcceptancePlotter.cc.

Referenced by CTPPSAcceptancePlotter().

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

Definition at line 71 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and CTPPSAcceptancePlotter().

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

Definition at line 72 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze(), and endJob().

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

Definition at line 38 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze().

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

Definition at line 39 of file CTPPSAcceptancePlotter.cc.

Referenced by analyze().