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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 31 of file CFWriter.h.

Member Typedef Documentation

Definition at line 56 of file CFWriter.h.

Constructor & Destructor Documentation

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

Definition at line 36 of file CFWriter.cc.

References branchesActivate(), edm::InputTag::encode(), edm::ParameterSet::exists(), flagHepMCProduct_, flagPCaloHit_, flagPSimHit_, flagSimTrack_, flagSimVertex_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), cuy::ii, labCaloHit, diffTwoXMLs::label, labSimHit, cscdqm::h::names, muonDTDigis_cfi::pset, AlCaHLTBitMon_QueryRunRegistry::string, fireworks::subdets, and GlobalPosition_Frontier_DevDB_cff::tag.

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

Definition at line 148 of file CFWriter.cc.

148 {}

Member Function Documentation

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

Definition at line 143 of file CFWriter.cc.

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

Definition at line 244 of file CFWriter.cc.

References EgammaHLTValidationUtils::getProcessName(), edm::InputTag::instance(), edm::InputTag::label(), modifiedElectrons_cfi::processName, AlCaHLTBitMon_QueryRunRegistry::string, useCurrentProcessOnly_, and wantedBranches_.

Referenced by CFWriter(), and fctTest().

244  {
245 
246  label=tag.label()+tag.instance();
247  wantedBranches_.push_back(friendlyName + '_' +
248  tag.label() + '_' +
249  tag.instance());
250 
251  //if useCurrentProcessOnly, we have to change the input tag
254  tag = InputTag(tag.label(),tag.instance(),processName);
255  }
256 
257 }
bool useCurrentProcessOnly_
Definition: CFWriter.h:49
std::string friendlyName(std::string const &iFullName)
std::vector< std::string > wantedBranches_
Definition: CFWriter.h:48
def getProcessName(pdgGen, requiredNumberOfGeneratedObjects)
PCrossingFrame<SimTrack> edm::CFWriter::fctTest ( const PCrossingFrame< SimTrack > &  p)
inlineprivate
void CFWriter::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 151 of file CFWriter.cc.

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

152 {
153 
154  if (flagSimTrack_){
155  bool gotTracks;
157  gotTracks = iEvent.getByLabel("mix","g4SimHits",cf_simtrack);
158 
159  if (gotTracks){
160  PCrossingFrame<SimTrack> * PCFbis = new PCrossingFrame<SimTrack>(*cf_simtrack.product());
161  std::unique_ptr<PCrossingFrame<SimTrack> > pOutTrack(PCFbis);
162  iEvent.put(std::move(pOutTrack),"g4SimHits");
163  }
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  }
180  else{
181  LogInfo("MixingModule") << " Please, check if the object <SimVertex> has been mixed by the MixingModule!";
182  }
183  }
184 
185  // PCaloHit
186  if (flagPCaloHit_){
187 
188  for (unsigned int ii=0;ii<labCaloHit.size();ii++){
189  bool gotPCaloHit;
191  gotPCaloHit=iEvent.getByLabel("mix",labCaloHit[ii],cf_calohit);
192 
193  if (gotPCaloHit){
194  PCrossingFrame<PCaloHit> * PCFPhCaloHit = new PCrossingFrame<PCaloHit>(*cf_calohit.product());
195  std::unique_ptr<PCrossingFrame<PCaloHit> > pOutHCalo(PCFPhCaloHit);
196  iEvent.put(std::move(pOutHCalo),labCaloHit[ii]);
197  }
198  else{
199  LogInfo("MixingModule") << " Please, check if the object <PCaloHit> " << labCaloHit[ii] << " has been mixed by the MixingModule!";
200  }
201  }
202 
203  }
204 
205  if (flagPSimHit_){
206 
207  for (unsigned int ii=0;ii<labSimHit.size();ii++) {
208  bool gotPSimHit;
210  gotPSimHit=iEvent.getByLabel("mix",labSimHit[ii],cf_simhit);
211 
212  if (gotPSimHit){
213  PCrossingFrame<PSimHit> * PCFSimHit = new PCrossingFrame<PSimHit>(*cf_simhit.product());
214  std::unique_ptr<PCrossingFrame<PSimHit> > pOutSimHit(PCFSimHit);
215  iEvent.put(std::move(pOutSimHit),labSimHit[ii]);
216  }
217  else{
218  LogInfo("MixingModule") << " Please, check if the object <PSimHit> " << labSimHit[ii] << " has been mixed by the MixingModule!";
219  }
220 
221  }
222  }
223 
224 
225  //HepMCProduct
226  if (flagHepMCProduct_){
227  bool gotHepMCProduct;
229  gotHepMCProduct=iEvent.getByLabel("mix","generatorSmeared",cf_hepmc);
230  if (gotHepMCProduct){
232  std::unique_ptr<PCrossingFrame<edm::HepMCProduct> > pOuthepmcpr(PCFHepMC);
233  iEvent.put(std::move(pOuthepmcpr),"generator");
234  }
235  else{
236  LogInfo("MixingModule") << " Please, check if the object <HepMCProduct> has been mixed by the MixingModule!";
237  }
238 
239  }// end if flagHepMCProduct_
240 
241 }
std::vector< std::string > labCaloHit
Definition: CFWriter.h:58
bool flagSimVertex_
Definition: CFWriter.h:51
bool flagPSimHit_
Definition: CFWriter.h:54
int iEvent
Definition: GenABIO.cc:230
std::vector< std::string > labSimHit
Definition: CFWriter.h:57
bool flagPCaloHit_
Definition: CFWriter.h:53
ii
Definition: cuy.py:588
T const * product() const
Definition: Handle.h:81
bool flagHepMCProduct_
Definition: CFWriter.h:52
bool flagSimTrack_
Definition: CFWriter.h:50
def move(src, dest)
Definition: eostools.py:510
virtual void edm::CFWriter::put ( edm::Event e)
inlinevirtual

Definition at line 42 of file CFWriter.h.

42 {;}

Member Data Documentation

bool edm::CFWriter::flagHepMCProduct_
private

Definition at line 52 of file CFWriter.h.

Referenced by CFWriter(), and produce().

bool edm::CFWriter::flagPCaloHit_
private

Definition at line 53 of file CFWriter.h.

Referenced by CFWriter(), and produce().

bool edm::CFWriter::flagPSimHit_
private

Definition at line 54 of file CFWriter.h.

Referenced by CFWriter(), and produce().

bool edm::CFWriter::flagSimTrack_
private

Definition at line 50 of file CFWriter.h.

Referenced by CFWriter(), and produce().

bool edm::CFWriter::flagSimVertex_
private

Definition at line 51 of file CFWriter.h.

Referenced by CFWriter(), and produce().

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

Definition at line 58 of file CFWriter.h.

Referenced by CFWriter(), and produce().

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

Definition at line 57 of file CFWriter.h.

Referenced by CFWriter(), and produce().

bool edm::CFWriter::useCurrentProcessOnly_
private

Definition at line 49 of file CFWriter.h.

Referenced by branchesActivate().

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

Definition at line 48 of file CFWriter.h.

Referenced by branchesActivate().