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 ()
 
ModuleDescription const & moduleDescription () const
 
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 ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) 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
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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 51 of file HcalForwardLibWriter.h.

Constructor & Destructor Documentation

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

Definition at line 21 of file HcalForwardLibWriter.cc.

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

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

Definition at line 39 of file HcalForwardLibWriter.cc.

39 {}

Member Function Documentation

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

Definition at line 171 of file HcalForwardLibWriter.cc.

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

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

Implements edm::EDProducer.

Definition at line 41 of file HcalForwardLibWriter.cc.

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

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

Definition at line 145 of file HcalForwardLibWriter.cc.

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

Referenced by HcalForwardLibWriter().

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

Member Data Documentation

std::string HcalForwardLibWriter::fDataFile
private

Definition at line 71 of file HcalForwardLibWriter.h.

Referenced by HcalForwardLibWriter(), and readUserData().

TFile* HcalForwardLibWriter::fFile
private

Definition at line 73 of file HcalForwardLibWriter.h.

Referenced by produce().

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

Definition at line 72 of file HcalForwardLibWriter.h.

Referenced by produce(), and readUserData().

TTree* HcalForwardLibWriter::fTree
private

Definition at line 74 of file HcalForwardLibWriter.h.

Referenced by produce().