CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
HcalForwardLibWriter Class Reference

#include <HcalForwardLibWriter.h>

Inheritance diagram for HcalForwardLibWriter:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Classes

struct  FileHandle
 

Public Member Functions

 HcalForwardLibWriter (const edm::ParameterSet &)
 
 ~HcalForwardLibWriter ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
int readUserData ()
 

Private Attributes

std::string theDataFile
 
std::vector< FileHandletheFileHandle
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 23 of file HcalForwardLibWriter.h.

Constructor & Destructor Documentation

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

Definition at line 6 of file HcalForwardLibWriter.cc.

References edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), readUserData(), and theDataFile.

6  {
7  edm::ParameterSet theParms = iConfig.getParameter<edm::ParameterSet> ("HcalForwardLibWriterParameters");
8  edm::FileInPath fp = theParms.getParameter<edm::FileInPath> ("FileName");
9  std::string pName = fp.fullPath();
10  if (pName.find(".") == 0)
11  pName.erase(0, 2);
12  theDataFile = pName;
13  readUserData();
14  produces<HFShowerPhotonCollection> ("emParticles");
15  produces<HFShowerPhotonCollection> ("hadParticles");
16  produces<HFShowerLibraryEventInfo> ("EventInfo");
17 
18 }
T getParameter(std::string const &) const
std::string fullPath() const
Definition: FileInPath.cc:170
HcalForwardLibWriter::~HcalForwardLibWriter ( )

Definition at line 20 of file HcalForwardLibWriter.cc.

20  {
21 
22 }

Member Function Documentation

void HcalForwardLibWriter::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 101 of file HcalForwardLibWriter.cc.

101  {
102 }
void HcalForwardLibWriter::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 159 of file HcalForwardLibWriter.cc.

159  {
160 }
void HcalForwardLibWriter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 24 of file HcalForwardLibWriter.cc.

References i, n, pos, edm::Event::put(), matplotRender::t, interactiveExample::theFile, theFileHandle, x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

24  {
25  std::auto_ptr<HFShowerPhotonCollection> product_em(new HFShowerPhotonCollection);
26  std::auto_ptr<HFShowerPhotonCollection> product_had(new HFShowerPhotonCollection);
27 
28  //EventInfo
29  std::auto_ptr<HFShowerLibraryEventInfo> product_evtInfo(new HFShowerLibraryEventInfo);
30  float hfShowerLibV = 1.1;
31  float phyListV = 3.6;
32  std::vector<double> en;
33  double momBin[12] = { 10., 15., 20., 35., 50., 80., 100., 150., 250., 350., 500., 1000. };
34  for (int i = 0; i < 12; ++i)
35  en.push_back(momBin[i]);
36  HFShowerLibraryEventInfo evtInfo(60000, 12, 5000, hfShowerLibV, phyListV, en);
37  *product_evtInfo = evtInfo;
38  iEvent.put(product_evtInfo, "EventInfo");
39 
40 
41  //shower photons
44 
45  int n = theFileHandle.size();
46  for (int i = 0; i < n; ++i) {
47  std::string fn = theFileHandle[i].name;
48  std::string particle = theFileHandle[i].id;
49  // int momBin = theFileHandle[i].momentum;
50  TFile* theFile = new TFile(fn.c_str(), "READ");
51  TTree* theTree = (TTree*) theFile->FindObjectAny("CherenkovPhotons");
52  int nphot = 0;
53  float x[10000];
54  float y[10000];
55  float z[10000];
56  float t[10000];
57  float lambda[10000];
58  int fiberId[10000];
59  for (int kk = 0; kk < 10000; ++kk) {
60  x[kk] = 0.;
61  y[kk] = 0.;
62  z[kk] = 0.;
63  t[kk] = 0.;
64  lambda[kk] = 0.;
65  fiberId[kk] = 0;
66  }
67  theTree->SetBranchAddress("nphot", &nphot);
68  theTree->SetBranchAddress("x", &x);
69  theTree->SetBranchAddress("y", &y);
70  theTree->SetBranchAddress("z", &z);
71  theTree->SetBranchAddress("t", &t);
72  theTree->SetBranchAddress("lambda", &lambda);
73  theTree->SetBranchAddress("fiberId", &fiberId);
74  int nentry = int(theTree->GetEntries());
75  if (particle == "electron") {
76  for (int iev = 0; iev < nentry; iev++) {
77  for (int iph = 0; iph < nphot; ++iph) {
78  HFShowerPhoton::Point pos(x[iph], y[iph], z[iph]);
79  HFShowerPhoton aPhoton(pos, t[iph], lambda[iph]);
80  emColl.push_back(aPhoton);
81  }
82  }
83  }
84  if (particle == "pion") {
85  }
86  theFile->Close();
87  if (theFile)
88  delete theFile;
89  if (theTree)
90  delete theTree;
91  }
92  *product_em = emColl;
93  *product_had = hadColl;
94 
95  //fillEvent(product_em,product_had);
96  //fillEvent(product_em, product_had);
97  iEvent.put(product_em, "emParticles");
98  iEvent.put(product_had, "hadParticles");
99 }
int i
Definition: DBlmapReader.cc:9
math::XYZPointF Point
point in the space
double double double z
std::vector< HFShowerPhoton > HFShowerPhotonCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
std::vector< FileHandle > theFileHandle
Definition: DDAxes.h:10
int HcalForwardLibWriter::readUserData ( void  )
private

Definition at line 161 of file HcalForwardLibWriter.cc.

References HcalForwardLibWriter::FileHandle::id, collect_tpl::input, gen::k, HcalForwardLibWriter::FileHandle::momentum, HcalForwardLibWriter::FileHandle::name, theDataFile, and theFileHandle.

Referenced by HcalForwardLibWriter().

161  {
162  std::ifstream input(theDataFile.c_str());
163  if (input.fail()) {
164  return 0;
165  }
166  std::string theFileName, thePID;
167  int mom;
168  int k = 0;
169  while (!input.eof()) {
170  input >> theFileName >> thePID >> mom;
171  if (!input.fail()) {
172  FileHandle aFile;
173  aFile.name = theFileName;
174  aFile.id = thePID;
175  aFile.momentum = mom;
176  theFileHandle.push_back(aFile);
177  ++k;
178  } else {
179  input.clear();
180  }
181  input.ignore(999, '\n');
182  }
183  return k;
184 }
tuple input
Definition: collect_tpl.py:10
int k[5][pyjets_maxn]
std::vector< FileHandle > theFileHandle

Member Data Documentation

std::string HcalForwardLibWriter::theDataFile
private

Definition at line 43 of file HcalForwardLibWriter.h.

Referenced by HcalForwardLibWriter(), and readUserData().

std::vector<FileHandle> HcalForwardLibWriter::theFileHandle
private

Definition at line 44 of file HcalForwardLibWriter.h.

Referenced by produce(), and readUserData().