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 Attributes
SimAnalyzerMinbias Class Reference
Inheritance diagram for SimAnalyzerMinbias:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  myInfo
 

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void beginRun (const edm::Run &r, const edm::EventSetup &iSetup)
 
virtual void endJob ()
 
virtual void endRun (const edm::Run &r, const edm::EventSetup &iSetup)
 
 SimAnalyzerMinbias (const edm::ParameterSet &)
 
 ~SimAnalyzerMinbias ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

int cells
 
int depth
 
std::string fOutputFileName
 
TFile * hOutputFile
 
int ieta
 
int iphi
 
float mom0_MB
 
float mom1_MB
 
float mom2_MB
 
float mom3_MB
 
float mom4_MB
 
int mydet
 
std::map< HcalDetId, myInfomyMap
 
int mysubd
 
TTree * myTree
 
double timeCut
 
edm::EDGetTokenT
< edm::HepMCProduct
tok_evt_
 
edm::EDGetTokenT
< edm::PCaloHitContainer
tok_hcal_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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

Definition at line 38 of file SimAnalyzerMinbias.cc.

Constructor & Destructor Documentation

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

Definition at line 73 of file SimAnalyzerMinbias.cc.

References gather_cfg::cout, fOutputFileName, edm::ParameterSet::getUntrackedParameter(), HLT_25ns14e33_v1_cff::InputTag, AlCaHLTBitMon_QueryRunRegistry::string, timeCut, tok_evt_, and tok_hcal_.

73  {
74  // get name of output file with histogramms
75  fOutputFileName = iConfig.getUntrackedParameter<std::string>("HistOutFile", "simOutput.root");
76  timeCut = iConfig.getUntrackedParameter<double>("TimeCut", 500);
77 
78  // get token names of modules, producing object collections
79  tok_evt_ = consumes<edm::HepMCProduct>(edm::InputTag("generator"));
80  tok_hcal_ = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits","HcalHits"));
81 
82 #ifdef debugLog
83  std::cout << "Use Time cut of " << timeCut << " ns and store o/p in "
84  << fOutputFileName << std::endl;
85 #endif
86 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > tok_evt_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hcal_
tuple cout
Definition: gather_cfg.py:121
SimAnalyzerMinbias::~SimAnalyzerMinbias ( )

Definition at line 88 of file SimAnalyzerMinbias.cc.

88  {
89  // do anything here that needs to be done at desctruction time
90  // (e.g. close files, deallocate resources etc.)
91 }

Member Function Documentation

void SimAnalyzerMinbias::analyze ( const edm::Event iEvent,
const edm::EventSetup  
)
virtual

Implements edm::EDAnalyzer.

Definition at line 171 of file SimAnalyzerMinbias.cc.

References gather_cfg::cout, edm::EventID::event(), edm::Event::getByToken(), edm::EventBase::id(), info(), edm::HandleBase::isValid(), myMap, edm::Handle< T >::product(), mathSSE::return(), edm::EventID::run(), cond::rpcobgas::time, timeCut, tok_evt_, and tok_hcal_.

172  {
173 #ifdef debugLog
174  std::cout << " Start SimAnalyzerMinbias::analyze " << iEvent.id().run()
175  << ":" << iEvent.id().event() << std::endl;
176 #endif
177 
179  iEvent.getByToken(tok_evt_, evtMC);
180  if (!evtMC.isValid()) {
181  edm::LogInfo("AnalyzerMB") << "no HepMCProduct found";
182 #ifdef debugLog
183  std::cout << "no HepMCProduct found" << std::endl;
184 #endif
185  } else {
186  const HepMC::GenEvent * myGenEvent = evtMC->GetEvent();
187  edm::LogInfo("AnalyzerMB") << "Event with " << myGenEvent->particles_size()
188  << " particles + " << myGenEvent->vertices_size()
189  << " vertices";
190 #ifdef debugLog
191  std::cout << "Event with " << myGenEvent->particles_size()
192  << " particles + " << myGenEvent->vertices_size()
193  << " vertices" << std::endl;
194 #endif
195  }
196 
197 
199  iEvent.getByToken(tok_hcal_,hcalHits);
200  if (!hcalHits.isValid()) {
201  edm::LogInfo("AnalyzerMB") << "Error! can't get HcalHits product!";
202 #ifdef debugLog
203  std::cout << "Error! can't get HcalHits product!"
204  << std::endl;
205 #endif
206  return ;
207  }
208 
209  const edm::PCaloHitContainer * HitHcal = hcalHits.product () ;
210  std::map<HcalDetId,double> hitMap;
211  for (std::vector<PCaloHit>::const_iterator hcalItr = HitHcal->begin ();
212  hcalItr != HitHcal->end(); ++hcalItr) {
213  double time = hcalItr->time();
214  if (time < timeCut) {
215  double energyhit = hcalItr->energy();
216  HcalDetId hid = HcalDetId(hcalItr->id());
217  std::map<HcalDetId,double>::iterator itr1 = hitMap.find(hid);
218  if (itr1 == hitMap.end()) {
219  hitMap[hid] = 0;
220  itr1 = hitMap.find(hid);
221  }
222  itr1->second += energyhit;
223  }
224  }
225 #ifdef debugLog
226  std::cout << "extract information of " << hitMap.size() << " towers from "
227  << HitHcal->size() << " hits" << std::endl;
228 #endif
229 
230  for (std::map<HcalDetId,double>::const_iterator hcalItr=hitMap.begin();
231  hcalItr != hitMap.end(); ++hcalItr) {
232  HcalDetId hid = hcalItr->first;
233  double energyhit = hcalItr->second;
234  std::map<HcalDetId,myInfo>::iterator itr1 = myMap.find(hid);
235  if (itr1 == myMap.end()) {
236  myInfo info;
237  myMap[hid] = info;
238  itr1 = myMap.find(hid);
239  }
240  itr1->second.theMB0++;
241  itr1->second.theMB1 += energyhit;
242  itr1->second.theMB2 += (energyhit*energyhit);
243  itr1->second.theMB3 += (energyhit*energyhit*energyhit);
244  itr1->second.theMB4 += (energyhit*energyhit*energyhit*energyhit);
245 #ifdef debugLog
246  std::cout << "ID " << hid << " with energy " << energyhit << std::endl;
247 #endif
248  }
249 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
std::vector< PCaloHit > PCaloHitContainer
static const TGPicture * info(bool iBackgroundIsBlack)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
return((rh^lh)&mask)
edm::EDGetTokenT< edm::HepMCProduct > tok_evt_
bool isValid() const
Definition: HandleBase.h:75
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hcal_
T const * product() const
Definition: Handle.h:81
edm::EventID id() const
Definition: EventBase.h:60
tuple cout
Definition: gather_cfg.py:121
std::map< HcalDetId, myInfo > myMap
void SimAnalyzerMinbias::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 99 of file SimAnalyzerMinbias.cc.

References cells, depth, fOutputFileName, hOutputFile, ieta, iphi, mom0_MB, mom1_MB, mom2_MB, mom4_MB, mydet, myMap, mysubd, myTree, and mathSSE::return().

99  {
100  hOutputFile = new TFile( fOutputFileName.c_str(), "RECREATE" ) ;
101 
102  myTree = new TTree("SimJet","SimJet Tree");
103  myTree->Branch("mydet", &mydet, "mydet/I");
104  myTree->Branch("mysubd", &mysubd, "mysubd/I");
105  myTree->Branch("cells", &cells, "cells");
106  myTree->Branch("depth", &depth, "depth/I");
107  myTree->Branch("ieta", &ieta, "ieta/I");
108  myTree->Branch("iphi", &iphi, "iphi/I");
109  myTree->Branch("mom0_MB", &mom0_MB, "mom0_MB/F");
110  myTree->Branch("mom1_MB", &mom1_MB, "mom1_MB/F");
111  myTree->Branch("mom2_MB", &mom2_MB, "mom2_MB/F");
112  myTree->Branch("mom3_MB", &mom2_MB, "mom3_MB/F");
113  myTree->Branch("mom4_MB", &mom4_MB, "mom4_MB/F");
114 
115  myMap.clear();
116  return ;
117 }
return((rh^lh)&mask)
std::map< HcalDetId, myInfo > myMap
void SimAnalyzerMinbias::beginRun ( const edm::Run r,
const edm::EventSetup iSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 93 of file SimAnalyzerMinbias.cc.

93  {
94 }
void SimAnalyzerMinbias::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 121 of file SimAnalyzerMinbias.cc.

References cells, gather_cfg::cout, depth, hOutputFile, ieta, info(), iphi, mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB, myMap, mysubd, myTree, mathSSE::return(), SimAnalyzerMinbias::myInfo::theMB0, SimAnalyzerMinbias::myInfo::theMB1, SimAnalyzerMinbias::myInfo::theMB2, SimAnalyzerMinbias::myInfo::theMB3, and SimAnalyzerMinbias::myInfo::theMB4.

121  {
122 
123  cells = 0;
124  // std::cout << " Hello me here" << std::endl;
125  for (std::map<HcalDetId,myInfo>::const_iterator itr=myMap.begin();
126  itr != myMap.end(); ++itr) {
127  // std::cout << " Hello me here" << std::endl;
128  mysubd = itr->first.subdet();
129  depth = itr->first.depth();
130  iphi = itr->first.iphi();
131  ieta = itr->first.ieta();
132  myInfo info = itr->second;
133  if (info.theMB0 > 0) {
134  mom0_MB = info.theMB0;
135  mom1_MB = info.theMB1;
136  mom2_MB = info.theMB2;
137  mom3_MB = info.theMB3;
138  mom4_MB = info.theMB4;
139  cells++;
140 
141  edm::LogInfo("AnalyzerMB") << " Result= " << mysubd << " " << ieta << " "
142  << iphi << " mom0 " << mom0_MB << " mom1 "
143  << mom1_MB << " mom2 " << mom2_MB << " mom3 "
144  << mom3_MB << " mom4 " << mom4_MB;
145 #ifdef debugLog
146  std::cout << " Result= " << mysubd << " " << ieta << " "
147  << iphi << " mom0 " << mom0_MB << " mom1 "
148  << mom1_MB << " mom2 " << mom2_MB << " mom3 "
149  << mom3_MB << " mom4 " << mom4_MB << std::endl;
150 #endif
151  myTree->Fill();
152  }
153  }
154  edm::LogInfo("AnalyzerMB") << "cells " << cells;
155 #ifdef debugLog
156  std::cout << "cells " << cells << std::endl;
157 #endif
158  hOutputFile->cd();
159  myTree->Write();
160  hOutputFile->Write();
161  hOutputFile->Close() ;
162  return ;
163 }
static const TGPicture * info(bool iBackgroundIsBlack)
return((rh^lh)&mask)
tuple cout
Definition: gather_cfg.py:121
std::map< HcalDetId, myInfo > myMap
void SimAnalyzerMinbias::endRun ( const edm::Run r,
const edm::EventSetup iSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 96 of file SimAnalyzerMinbias.cc.

96  {
97 }

Member Data Documentation

int SimAnalyzerMinbias::cells
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

int SimAnalyzerMinbias::depth
private
std::string SimAnalyzerMinbias::fOutputFileName
private

Definition at line 52 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and SimAnalyzerMinbias().

TFile* SimAnalyzerMinbias::hOutputFile
private

Definition at line 54 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

int SimAnalyzerMinbias::ieta
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

int SimAnalyzerMinbias::iphi
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

float SimAnalyzerMinbias::mom0_MB
private

Definition at line 59 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

float SimAnalyzerMinbias::mom1_MB
private

Definition at line 59 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

float SimAnalyzerMinbias::mom2_MB
private

Definition at line 59 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

float SimAnalyzerMinbias::mom3_MB
private

Definition at line 59 of file SimAnalyzerMinbias.cc.

Referenced by endJob().

float SimAnalyzerMinbias::mom4_MB
private

Definition at line 59 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

int SimAnalyzerMinbias::mydet
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob().

std::map<HcalDetId,myInfo> SimAnalyzerMinbias::myMap
private

Definition at line 66 of file SimAnalyzerMinbias.cc.

Referenced by analyze(), beginJob(), and endJob().

int SimAnalyzerMinbias::mysubd
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

TTree* SimAnalyzerMinbias::myTree
private

Definition at line 55 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

double SimAnalyzerMinbias::timeCut
private

Definition at line 53 of file SimAnalyzerMinbias.cc.

Referenced by analyze(), and SimAnalyzerMinbias().

edm::EDGetTokenT<edm::HepMCProduct> SimAnalyzerMinbias::tok_evt_
private

Definition at line 67 of file SimAnalyzerMinbias.cc.

Referenced by analyze(), and SimAnalyzerMinbias().

edm::EDGetTokenT<edm::PCaloHitContainer> SimAnalyzerMinbias::tok_hcal_
private

Definition at line 68 of file SimAnalyzerMinbias.cc.

Referenced by analyze(), and SimAnalyzerMinbias().