CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
edm::CFWriter Class Reference

#include <CFWriter.h>

Inheritance diagram for edm::CFWriter:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (const edm::Run &run, const edm::EventSetup &es) override
 
 CFWriter (const edm::ParameterSet &conf)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
virtual void put (edm::Event &e)
 
 ~CFWriter () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Types

typedef std::vector< edm::HepMCProductHepMCProductContainer
 

Private Member Functions

virtual void branchesActivate (const std::string &friendlyName, std::string subdet, InputTag &tag, std::string &label)
 
PCrossingFrame< SimTrackfctTest (const PCrossingFrame< SimTrack > &p)
 

Private Attributes

bool flagHepMCProduct_
 
bool flagPCaloHit_
 
bool flagPSimHit_
 
bool flagSimTrack_
 
bool flagSimVertex_
 
std::vector< std::string > labCaloHit
 
std::vector< std::string > labSimHit
 
bool useCurrentProcessOnly_
 
std::vector< std::string > wantedBranches_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 30 of file CFWriter.h.

Member Typedef Documentation

◆ HepMCProductContainer

Definition at line 59 of file CFWriter.h.

Constructor & Destructor Documentation

◆ CFWriter()

CFWriter::CFWriter ( const edm::ParameterSet conf)
explicit

Definition at line 34 of file CFWriter.cc.

References branchesActivate(), flagHepMCProduct_, flagPCaloHit_, flagPSimHit_, flagSimTrack_, flagSimVertex_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), cuy::ii, labCaloHit, label, labSimHit, names, muonDTDigis_cfi::pset, AlCaHLTBitMon_QueryRunRegistry::string, fireworks::subdets, makeGlobalPositionRcd_cfg::tag, and triggerMatcherToHLTDebug_cfi::tags.

35  : flagSimTrack_(false),
36  flagSimVertex_(false),
37  flagHepMCProduct_(false),
38  flagPCaloHit_(false),
39  flagPSimHit_(false) {
40  //register your products
41  ParameterSet ps = iConfig.getParameter<ParameterSet>("mixObjects");
42  std::vector<std::string> names = ps.getParameterNames();
43  for (std::vector<std::string>::iterator it = names.begin(); it != names.end(); ++it) {
44  ParameterSet pset = ps.getParameter<ParameterSet>((*it));
45  if (!pset.exists("type"))
46  continue; //to allow replacement by empty pset
47 
48  std::string object = pset.getParameter<std::string>("type");
49  std::vector<InputTag> tags = pset.getParameter<std::vector<InputTag>>("input");
50 
51  //SimTracks
52  if (object == "SimTrack") {
53  flagSimTrack_ = true;
54 
55  InputTag tag;
56  if (!tags.empty())
57  tag = tags[0];
59  branchesActivate(TypeID(typeid(std::vector<SimTrack>)).friendlyClassName(), std::string(""), tag, label);
60  produces<PCrossingFrame<SimTrack>>(label);
61  consumes<std::vector<SimTrack>>(tag);
62  LogInfo("MixingModule") << "Add PCrossingFrame<SimTrack> " << object << "s with InputTag= " << tag.encode()
63  << ", label will be " << label;
64 
65  }
66  //SimVertices
67  else if (object == "SimVertex") {
68  flagSimVertex_ = true;
69 
70  InputTag tag;
71  if (!tags.empty())
72  tag = tags[0];
74  branchesActivate(TypeID(typeid(std::vector<SimVertex>)).friendlyClassName(), std::string(""), tag, label);
75  produces<PCrossingFrame<SimVertex>>(label);
76  consumes<std::vector<SimVertex>>(tag);
77  LogInfo("MixingModule") << "Add SimVertexContainer " << object << "s with InputTag= " << tag.encode()
78  << ", label will be " << label;
79 
80  }
81  // PCaloHit
82  else if (object == "PCaloHit") {
83  flagPCaloHit_ = true;
84 
85  std::vector<std::string> subdets = pset.getParameter<std::vector<std::string>>("subdets");
86  for (unsigned int ii = 0; ii < subdets.size(); ii++) {
87  InputTag tag;
88  if (tags.size() == 1)
89  tag = tags[0];
90  else if (tags.size() > 1)
91  tag = tags[ii];
93 
94  branchesActivate(TypeID(typeid(std::vector<PCaloHit>)).friendlyClassName(), subdets[ii], tag, label);
95  produces<PCrossingFrame<PCaloHit>>(label);
96  consumes<std::vector<PCaloHit>>(tag);
97  LogInfo("MixingModule") << "Add PCrossingFrame<PCaloHit> " << object << "s with InputTag= " << tag.encode()
98  << ", label will be " << label;
99 
100  // fill table with labels
101  labCaloHit.push_back(label);
102  }
103  }
104 
105  // PSimHit
106  else if (object == "PSimHit") {
107  flagPSimHit_ = true;
108 
109  std::vector<std::string> subdets = pset.getParameter<std::vector<std::string>>("subdets");
110  for (unsigned int ii = 0; ii < subdets.size(); ii++) {
111  InputTag tag;
112  if (tags.size() == 1)
113  tag = tags[0];
114 
115  else if (tags.size() > 1)
116  tag = tags[ii];
118 
119  branchesActivate(TypeID(typeid(std::vector<PSimHit>)).friendlyClassName(), subdets[ii], tag, label);
120  produces<PCrossingFrame<PSimHit>>(label);
121  consumes<std::vector<PSimHit>>(tag);
122  LogInfo("MixingModule") << "Add PSimHitContainer " << object << "s with InputTag= " << tag.encode()
123  << ", label will be " << label;
124 
125  // fill table with labels
126  labSimHit.push_back(label);
127  } //end for
128  }
129 
130  // HepMCProduct
131  else if (object == "HepMCProduct") {
132  flagHepMCProduct_ = true;
133 
134  InputTag tag;
135  if (!tags.empty())
136  tag = tags[0];
138 
139  branchesActivate(TypeID(typeid(HepMCProduct)).friendlyClassName(), std::string(""), tag, label);
140  produces<PCrossingFrame<edm::HepMCProduct>>(label);
141  consumes<HepMCProduct>(tag);
142  LogInfo("MixingModule") << "Add HepMCProduct " << object << "s with InputTag= " << tag.encode()
143  << ", label will be " << label;
144  } else
145  LogWarning("MixingModule") << "You did not mix a type of object(" << object << ").";
146 
147  } //end for
148  }
std::vector< std::string > labCaloHit
Definition: CFWriter.h:61
bool flagSimVertex_
Definition: CFWriter.h:54
bool flagPSimHit_
Definition: CFWriter.h:57
const std::string names[nVars_]
char const * label
std::vector< std::string > labSimHit
Definition: CFWriter.h:60
bool flagPCaloHit_
Definition: CFWriter.h:56
virtual void branchesActivate(const std::string &friendlyName, std::string subdet, InputTag &tag, std::string &label)
Definition: CFWriter.cc:235
ii
Definition: cuy.py:589
Log< level::Info, false > LogInfo
bool flagHepMCProduct_
Definition: CFWriter.h:55
bool flagSimTrack_
Definition: CFWriter.h:53
Log< level::Warning, false > LogWarning
static const std::string subdets[7]
Definition: TrackUtils.cc:60

◆ ~CFWriter()

CFWriter::~CFWriter ( )
override

Definition at line 152 of file CFWriter.cc.

152 {}

Member Function Documentation

◆ beginRun()

void CFWriter::beginRun ( const edm::Run run,
const edm::EventSetup es 
)
override

Definition at line 150 of file CFWriter.cc.

150 {}

◆ branchesActivate()

void CFWriter::branchesActivate ( const std::string &  friendlyName,
std::string  subdet,
InputTag tag,
std::string &  label 
)
privatevirtual

Definition at line 235 of file CFWriter.cc.

References edm::friendlyname::friendlyName(), EgammaHLTValidationUtils::getProcessName(), HLT_2022v14_cff::InputTag, label, SimL1EmulatorRepack_CalouGT_cff::processName, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, useCurrentProcessOnly_, and wantedBranches_.

Referenced by CFWriter().

238  {
239  label = tag.label() + tag.instance();
240  wantedBranches_.push_back(friendlyName + '_' + tag.label() + '_' + tag.instance());
241 
242  //if useCurrentProcessOnly, we have to change the input tag
245  tag = InputTag(tag.label(), tag.instance(), processName);
246  }
247  }
bool useCurrentProcessOnly_
Definition: CFWriter.h:52
char const * label
std::string friendlyName(std::string const &iFullName)
std::vector< std::string > wantedBranches_
Definition: CFWriter.h:51
def getProcessName(pdgGen, requiredNumberOfGeneratedObjects)

◆ fctTest()

PCrossingFrame<SimTrack> edm::CFWriter::fctTest ( const PCrossingFrame< SimTrack > &  p)
inlineprivate

Definition at line 42 of file CFWriter.h.

References gather_cfg::cout, and AlCaHLTBitMon_ParallelJobs::p.

42  {
43  return p;
44  std::cout << " call PCrossingFrame object" << std::endl;
45  };

◆ produce()

void CFWriter::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 154 of file CFWriter.cc.

References flagHepMCProduct_, flagPCaloHit_, flagPSimHit_, flagSimTrack_, flagSimVertex_, iEvent, cuy::ii, labCaloHit, labSimHit, eostools::move(), and edm::Handle< T >::product().

154  {
155  if (flagSimTrack_) {
156  bool gotTracks;
158  gotTracks = iEvent.getByLabel("mix", "g4SimHits", cf_simtrack);
159 
160  if (gotTracks) {
161  PCrossingFrame<SimTrack>* PCFbis = new PCrossingFrame<SimTrack>(*cf_simtrack.product());
162  std::unique_ptr<PCrossingFrame<SimTrack>> pOutTrack(PCFbis);
163  iEvent.put(std::move(pOutTrack), "g4SimHits");
164  } else {
165  LogInfo("MixingModule") << " Please, check if the object <SimTrack> has been mixed by the MixingModule!";
166  }
167  } //end if flagSimTrack_
168 
169  //SimVertex
170  if (flagSimVertex_) {
171  bool gotSimVertex;
173  gotSimVertex = iEvent.getByLabel("mix", "g4SimHits", cf_simvtx);
174 
175  if (gotSimVertex) {
176  PCrossingFrame<SimVertex>* PCFvtx = new PCrossingFrame<SimVertex>(*cf_simvtx.product());
177  std::unique_ptr<PCrossingFrame<SimVertex>> pOutVertex(PCFvtx);
178  iEvent.put(std::move(pOutVertex), "g4SimHits");
179  } else {
180  LogInfo("MixingModule") << " Please, check if the object <SimVertex> has been mixed by the MixingModule!";
181  }
182  }
183 
184  // PCaloHit
185  if (flagPCaloHit_) {
186  for (unsigned int ii = 0; ii < labCaloHit.size(); ii++) {
187  bool gotPCaloHit;
189  gotPCaloHit = iEvent.getByLabel("mix", labCaloHit[ii], cf_calohit);
190 
191  if (gotPCaloHit) {
192  PCrossingFrame<PCaloHit>* PCFPhCaloHit = new PCrossingFrame<PCaloHit>(*cf_calohit.product());
193  std::unique_ptr<PCrossingFrame<PCaloHit>> pOutHCalo(PCFPhCaloHit);
194  iEvent.put(std::move(pOutHCalo), labCaloHit[ii]);
195  } else {
196  LogInfo("MixingModule") << " Please, check if the object <PCaloHit> " << labCaloHit[ii]
197  << " has been mixed by the MixingModule!";
198  }
199  }
200  }
201 
202  if (flagPSimHit_) {
203  for (unsigned int ii = 0; ii < labSimHit.size(); ii++) {
204  bool gotPSimHit;
206  gotPSimHit = iEvent.getByLabel("mix", labSimHit[ii], cf_simhit);
207 
208  if (gotPSimHit) {
209  PCrossingFrame<PSimHit>* PCFSimHit = new PCrossingFrame<PSimHit>(*cf_simhit.product());
210  std::unique_ptr<PCrossingFrame<PSimHit>> pOutSimHit(PCFSimHit);
211  iEvent.put(std::move(pOutSimHit), labSimHit[ii]);
212  } else {
213  LogInfo("MixingModule") << " Please, check if the object <PSimHit> " << labSimHit[ii]
214  << " has been mixed by the MixingModule!";
215  }
216  }
217  }
218 
219  //HepMCProduct
220  if (flagHepMCProduct_) {
221  bool gotHepMCProduct;
223  gotHepMCProduct = iEvent.getByLabel("mix", "generatorSmeared", cf_hepmc);
224  if (gotHepMCProduct) {
226  std::unique_ptr<PCrossingFrame<edm::HepMCProduct>> pOuthepmcpr(PCFHepMC);
227  iEvent.put(std::move(pOuthepmcpr), "generator");
228  } else {
229  LogInfo("MixingModule") << " Please, check if the object <HepMCProduct> has been mixed by the MixingModule!";
230  }
231 
232  } // end if flagHepMCProduct_
233  }
std::vector< std::string > labCaloHit
Definition: CFWriter.h:61
T const * product() const
Definition: Handle.h:70
bool flagSimVertex_
Definition: CFWriter.h:54
bool flagPSimHit_
Definition: CFWriter.h:57
int iEvent
Definition: GenABIO.cc:224
std::vector< std::string > labSimHit
Definition: CFWriter.h:60
bool flagPCaloHit_
Definition: CFWriter.h:56
ii
Definition: cuy.py:589
Log< level::Info, false > LogInfo
bool flagHepMCProduct_
Definition: CFWriter.h:55
bool flagSimTrack_
Definition: CFWriter.h:53
def move(src, dest)
Definition: eostools.py:511

◆ put()

virtual void edm::CFWriter::put ( edm::Event e)
inlinevirtual

Definition at line 39 of file CFWriter.h.

39 { ; }

Member Data Documentation

◆ flagHepMCProduct_

bool edm::CFWriter::flagHepMCProduct_
private

Definition at line 55 of file CFWriter.h.

Referenced by CFWriter(), and produce().

◆ flagPCaloHit_

bool edm::CFWriter::flagPCaloHit_
private

Definition at line 56 of file CFWriter.h.

Referenced by CFWriter(), and produce().

◆ flagPSimHit_

bool edm::CFWriter::flagPSimHit_
private

Definition at line 57 of file CFWriter.h.

Referenced by CFWriter(), and produce().

◆ flagSimTrack_

bool edm::CFWriter::flagSimTrack_
private

Definition at line 53 of file CFWriter.h.

Referenced by CFWriter(), and produce().

◆ flagSimVertex_

bool edm::CFWriter::flagSimVertex_
private

Definition at line 54 of file CFWriter.h.

Referenced by CFWriter(), and produce().

◆ labCaloHit

std::vector<std::string> edm::CFWriter::labCaloHit
private

Definition at line 61 of file CFWriter.h.

Referenced by CFWriter(), and produce().

◆ labSimHit

std::vector<std::string> edm::CFWriter::labSimHit
private

Definition at line 60 of file CFWriter.h.

Referenced by CFWriter(), and produce().

◆ useCurrentProcessOnly_

bool edm::CFWriter::useCurrentProcessOnly_
private

Definition at line 52 of file CFWriter.h.

Referenced by branchesActivate().

◆ wantedBranches_

std::vector<std::string> edm::CFWriter::wantedBranches_
private

Definition at line 51 of file CFWriter.h.

Referenced by branchesActivate().