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 | Static Public Member Functions | Private Member Functions | Private Attributes
HcalForwardLibWriter Class Reference

#include <SimG4CMS/ShowerLibraryProducer/plugins/HcalForwardLibWriter.cc>

Inheritance diagram for HcalForwardLibWriter:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase 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 &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &) override
 
void readUserData ()
 

Private Attributes

std::string fDataFile
 
TFile * fFile
 
std::vector< FileHandlefFileHandle
 
TTree * fTree
 

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
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 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

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 52 of file HcalForwardLibWriter.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file HcalForwardLibWriter.cc.

References gather_cfg::cout, fDataFile, edm::ParameterSet::getParameter(), readUserData(), and AlCaHLTBitMon_QueryRunRegistry::string.

22  {
23 
24  edm::ParameterSet theParms = iConfig.getParameter<edm::ParameterSet> ("HcalForwardLibWriterParameters");
25  edm::FileInPath fp = theParms.getParameter<edm::FileInPath> ("FileName");
26  std::string pName = fp.fullPath();
27  std::cout<<pName<<std::endl;
28  fDataFile = pName;
29  readUserData();
30 
31  //register shower library products with label
32  produces<HFShowerPhotonCollection> ("emParticles");
33  produces<std::vector<HFShowerPhotonCollection> > ("emParticlesss");
34  produces< std::vector<int> > ("emParticles");
35  produces<HFShowerPhotonCollection> ("hadParticles");
36  produces< std::vector<int> > ("hadParticles");
37  produces<std::vector<HFShowerLibraryEventInfo> > ("HFShowerLibraryEventInfo");
38 }
T getParameter(std::string const &) const
tuple cout
Definition: gather_cfg.py:121
HcalForwardLibWriter::~HcalForwardLibWriter ( )

Definition at line 40 of file HcalForwardLibWriter.cc.

40 {}

Member Function Documentation

void HcalForwardLibWriter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 172 of file HcalForwardLibWriter.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

172  {
174  desc.setUnknown();
175  descriptions.addDefault(desc);
176 }
void addDefault(ParameterSetDescription const &psetDescription)
void HcalForwardLibWriter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 42 of file HcalForwardLibWriter.cc.

References gather_cfg::cout, edm::hlt::Exception, fFile, fFileHandle, fTree, i, n, pos, edm::Event::put(), AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

42  {
43 
44  std::vector<double> energyBin;
45  double energyBin2[12] = {10,15,20,35,50,80,100,150,250,350,500,1000};
46  for (int z = 0; z< 12; ++z) {energyBin.push_back(energyBin2[z]);}
47 
48  std::vector<HFShowerLibraryEventInfo> Info;
50  std::vector<HFShowerPhotonCollection> emCollsss;
51  HFShowerPhotonCollection fakeColl;
52  HFShowerPhoton afakePhoton(1,3,5,8,480);
53  fakeColl.push_back(afakePhoton);
55  //HFShowerPhotonCollection emCollnphot;
56  //std::vector<HFShowerPhotonCollection> emCollnphot;
57  //std::vector<int> emCollnPhoton;
58  std::vector<int> emCollnPhoton;
59  std::vector<int> hadCollnPhoton;
60 
61  int n = fFileHandle.size();
62  for (int i = 0; i < n; ++i) {
63  std::string fn = fFileHandle[i].name;
64  std::cout<<fn<<std::endl;
65  std::string particle = fFileHandle[i].id;
66  /*
67  int momBin = fFileHandle[i].momentum;
68  energyBin.push_back(momBin);
69  */
70  fFile = new TFile(fn.c_str(), "READ");
71  fTree = (TTree*) fFile->FindObjectAny("CherenkovPhotons");
72  if(!fTree){
73  throw cms::Exception("NullPointer")
74  << "Cannot find TTree with name CherenkovPhotons";
75  }
76  int nphot = 0;
77  float x[10000];
78  float y[10000];
79  float z[10000];
80  float t[10000];
81  float lambda[10000];
82  int fiberId[10000];
83  for (int kk = 0; kk < 10000; ++kk) {
84  x[kk] = 0.;
85  y[kk] = 0.;
86  z[kk] = 0.;
87  t[kk] = 0.;
88  lambda[kk] = 0.;
89  fiberId[kk] = 0;
90  }
91  fTree->SetBranchAddress("nphot", &nphot);
92  fTree->SetBranchAddress("x", &x);
93  fTree->SetBranchAddress("y", &y);
94  fTree->SetBranchAddress("z", &z);
95  fTree->SetBranchAddress("t", &t);
96  fTree->SetBranchAddress("lambda", &lambda);
97  fTree->SetBranchAddress("fiberId", &fiberId);
98  int nentry = int(fTree->GetEntries());
99  std::cout<<"nenetry " << nentry<<std::endl;
100  if (particle == "electron") {
101  for (int iev = 0; iev < nentry; iev++) {
102  fTree->GetEntry(iev);
103  std::cout<<"nphot "<<nphot<<std::endl;
104  emCollnPhoton.push_back(nphot);
105  for (int iph = 0; iph < nphot; ++iph) {
106  HFShowerPhoton::Point pos(x[iph], y[iph], z[iph]);
107  HFShowerPhoton aPhoton(pos, t[iph], lambda[iph]);
108  emColl.push_back(aPhoton);
109  }
110  emCollsss.push_back(emColl);
111  emColl.clear();
112  }
113  }
114  if (particle == "pion") {
115  for (int iev = 0; iev < nentry; iev++) {
116  fTree->GetEntry(iev);
117  hadCollnPhoton.push_back(nphot);
118  for (int iph = 0; iph < nphot; ++iph) {
119  HFShowerPhoton::Point pos(x[iph], y[iph], z[iph]);
120  HFShowerPhoton aPhoton(pos, t[iph], lambda[iph]);
121  hadColl.push_back(aPhoton);
122  }
123  }
124  }
125 
126  }
127 
128  HFShowerLibraryEventInfo aInfo((n/2)*5000,n/2,5000,1,1,energyBin);
129  Info.push_back(aInfo);
130 
131  std::auto_ptr< std::vector<HFShowerLibraryEventInfo> > product_info(new std::vector<HFShowerLibraryEventInfo>(Info) );
132  std::auto_ptr<HFShowerPhotonCollection > product_em(new HFShowerPhotonCollection(fakeColl));
133  std::auto_ptr<std::vector<HFShowerPhotonCollection> > product_emsss(new std::vector<HFShowerPhotonCollection>(emCollsss));
134  std::cout<<"em coll size "<<emCollsss.size()<<std::endl;
135  //std::auto_ptr< std::vector<int> > product_em_nphot(new std::vector<int>(emCollnPhoton));
136  std::auto_ptr<HFShowerPhotonCollection> product_had(new HFShowerPhotonCollection(hadColl));
137  //std::auto_ptr<std::vector<int> > product_had_nphot(new std::vector<int>(hadCollnPhoton));
138  iEvent.put(product_info, "HFShowerLibraryEventInfo");
139  iEvent.put(product_emsss, "emParticles");
140  iEvent.put(product_had, "hadParticles");
141  //iEvent.put(product_em_nphot, "emParticles");
142  //iEvent.put(product_had_nphot, "hadParticles");
143 
144 }
int i
Definition: DBlmapReader.cc:9
math::XYZPointF Point
point in the space
std::vector< FileHandle > fFileHandle
float float float z
std::vector< HFShowerPhoton > HFShowerPhotonCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
void HcalForwardLibWriter::readUserData ( )
private

Definition at line 146 of file HcalForwardLibWriter.cc.

References gather_cfg::cout, edm::hlt::Exception, fDataFile, fFileHandle, HcalForwardLibWriter::FileHandle::id, LaserDQM_cfg::input, HcalForwardLibWriter::FileHandle::momentum, HcalForwardLibWriter::FileHandle::name, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HcalForwardLibWriter().

146  {
147  std::cout << " using " <<std::endl;
148  std::ifstream input(fDataFile.c_str());
149  if (input.fail()) {
150  throw cms::Exception("MissingFile")
151  << "Cannot find file" << fDataFile.c_str();
152  }
153  std::string fFileName, fPID;
154  int fMom;
155  while (!input.eof()) {
156  input >> fFileName >> fPID >> fMom;
157  std::cout << " using " << fFileName << " fPID" << fPID << " fMom" << fMom << std::endl;
158  if (!input.fail()) {
159  std::cout << " using " << fFileName << " " << fPID << " " << fMom << std::endl;
160  FileHandle aFile;
161  aFile.name = fFileName;
162  aFile.id = fPID;
163  aFile.momentum = fMom;
164  fFileHandle.push_back(aFile);
165  } else {
166  input.clear();
167  }
168  input.ignore(999, '\n');
169  }
170 }
std::vector< FileHandle > fFileHandle
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

std::string HcalForwardLibWriter::fDataFile
private

Definition at line 72 of file HcalForwardLibWriter.h.

Referenced by HcalForwardLibWriter(), and readUserData().

TFile* HcalForwardLibWriter::fFile
private

Definition at line 74 of file HcalForwardLibWriter.h.

Referenced by produce().

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

Definition at line 73 of file HcalForwardLibWriter.h.

Referenced by produce(), and readUserData().

TTree* HcalForwardLibWriter::fTree
private

Definition at line 75 of file HcalForwardLibWriter.h.

Referenced by produce().