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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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
 
edm::Service< TFileServicefs_
 
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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 72 of file SimAnalyzerMinbias.cc.

References edm::ParameterSet::getUntrackedParameter(), HLT_FULL_cff::InputTag, timeCut_, tok_evt_, and tok_hcal_.

72  {
73 
74  timeCut_ = iConfig.getUntrackedParameter<double>("TimeCut", 500);
75 
76  // get token names of modules, producing object collections
77  tok_evt_ = consumes<edm::HepMCProduct>(edm::InputTag("generator"));
78  tok_hcal_ = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits","HcalHits"));
79 
80  edm::LogInfo("AnalyzerMB") << "Use Time cut of " << timeCut_ << " ns";
81 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > tok_evt_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hcal_
SimAnalyzerMinbias::~SimAnalyzerMinbias ( )

Definition at line 83 of file SimAnalyzerMinbias.cc.

83  {
84  // do anything here that needs to be done at desctruction time
85  // (e.g. close files, deallocate resources etc.)
86 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 148 of file SimAnalyzerMinbias.cc.

References edm::EventID::event(), edm::Event::getByToken(), edm::EventBase::id(), info(), edm::HandleBase::isValid(), myMap_, edm::Handle< T >::product(), reco::return(), edm::EventID::run(), timeCut_, tok_evt_, and tok_hcal_.

149  {
150  edm::LogInfo("AnalyzerMB") << " Start SimAnalyzerMinbias::analyze "
151  << iEvent.id().run() << ":" <<iEvent.id().event();
152 
153 
155  iEvent.getByToken(tok_evt_, evtMC);
156  if (!evtMC.isValid()) {
157  edm::LogWarning("AnalyzerMB") << "no HepMCProduct found";
158  } else {
159  const HepMC::GenEvent * myGenEvent = evtMC->GetEvent();
160  edm::LogInfo("AnalyzerMB") << "Event with " << myGenEvent->particles_size()
161  << " particles + " <<myGenEvent->vertices_size()
162  << " vertices";
163  }
164 
165 
167  iEvent.getByToken(tok_hcal_,hcalHits);
168  if (!hcalHits.isValid()) {
169  edm::LogWarning("AnalyzerMB") << "Error! can't get HcalHits product!";
170  return ;
171  }
172 
173  const edm::PCaloHitContainer * HitHcal = hcalHits.product () ;
174  std::map<HcalDetId,double> hitMap;
175  for (std::vector<PCaloHit>::const_iterator hcalItr = HitHcal->begin();
176  hcalItr != HitHcal->end(); ++hcalItr) {
177  double time = hcalItr->time();
178  if (time < timeCut_) {
179  double energyhit = hcalItr->energy();
180  HcalDetId hid = HcalDetId(hcalItr->id());
181  std::map<HcalDetId,double>::iterator itr1 = hitMap.find(hid);
182  if (itr1 == hitMap.end()) {
183  hitMap[hid] = 0;
184  itr1 = hitMap.find(hid);
185  }
186  itr1->second += energyhit;
187  }
188  }
189  edm::LogInfo("AnalyzerMB") << "extract information of " << hitMap.size()
190  << " towers from " << HitHcal->size() << " hits";
191 
192  for (std::map<HcalDetId,double>::const_iterator hcalItr=hitMap.begin();
193  hcalItr != hitMap.end(); ++hcalItr) {
194  HcalDetId hid = hcalItr->first;
195  double energyhit = hcalItr->second;
196  std::map<HcalDetId,myInfo>::iterator itr1 = myMap_.find(hid);
197  if (itr1 == myMap_.end()) {
198  myInfo info;
199  myMap_[hid] = info;
200  itr1 = myMap_.find(hid);
201  }
202  itr1->second.theMB0++;
203  itr1->second.theMB1 += energyhit;
204  itr1->second.theMB2 += (energyhit*energyhit);
205  itr1->second.theMB3 += (energyhit*energyhit*energyhit);
206  itr1->second.theMB4 += (energyhit*energyhit*energyhit*energyhit);
207  edm::LogInfo("AnalyzerMB") << "ID " << hid << " with energy " << energyhit;
208  }
209 }
RunNumber_t run() const
Definition: EventID.h:39
std::map< HcalDetId, myInfo > myMap_
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:462
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
return(e1-e2)*(e1-e2)+dp *dp
edm::EventID id() const
Definition: EventBase.h:59
void SimAnalyzerMinbias::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 94 of file SimAnalyzerMinbias.cc.

References cells, depth, fs_, ieta, iphi, TFileService::make(), mom0_MB, mom1_MB, mom2_MB, mom4_MB, mydet, myMap_, mysubd, and myTree_.

94  {
95 
96  myTree_ = fs_->make<TTree>("SimJet","SimJet Tree");
97  myTree_->Branch("mydet", &mydet, "mydet/I");
98  myTree_->Branch("mysubd", &mysubd, "mysubd/I");
99  myTree_->Branch("cells", &cells, "cells");
100  myTree_->Branch("depth", &depth, "depth/I");
101  myTree_->Branch("ieta", &ieta, "ieta/I");
102  myTree_->Branch("iphi", &iphi, "iphi/I");
103  myTree_->Branch("mom0_MB", &mom0_MB, "mom0_MB/F");
104  myTree_->Branch("mom1_MB", &mom1_MB, "mom1_MB/F");
105  myTree_->Branch("mom2_MB", &mom2_MB, "mom2_MB/F");
106  myTree_->Branch("mom3_MB", &mom2_MB, "mom3_MB/F");
107  myTree_->Branch("mom4_MB", &mom4_MB, "mom4_MB/F");
108 
109  myMap_.clear();
110 }
std::map< HcalDetId, myInfo > myMap_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::Service< TFileService > fs_
void SimAnalyzerMinbias::beginRun ( const edm::Run r,
const edm::EventSetup iSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 88 of file SimAnalyzerMinbias.cc.

88  {
89 }
void SimAnalyzerMinbias::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 114 of file SimAnalyzerMinbias.cc.

References cells, depth, ieta, info(), iphi, mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB, myMap_, mysubd, myTree_, SimAnalyzerMinbias::myInfo::theMB0, SimAnalyzerMinbias::myInfo::theMB1, SimAnalyzerMinbias::myInfo::theMB2, SimAnalyzerMinbias::myInfo::theMB3, and SimAnalyzerMinbias::myInfo::theMB4.

114  {
115 
116  cells = 0;
117  for (std::map<HcalDetId,myInfo>::const_iterator itr=myMap_.begin();
118  itr != myMap_.end(); ++itr) {
119  mysubd = itr->first.subdet();
120  depth = itr->first.depth();
121  iphi = itr->first.iphi();
122  ieta = itr->first.ieta();
123  myInfo info = itr->second;
124  if (info.theMB0 > 0) {
125  mom0_MB = info.theMB0;
126  mom1_MB = info.theMB1;
127  mom2_MB = info.theMB2;
128  mom3_MB = info.theMB3;
129  mom4_MB = info.theMB4;
130  cells++;
131 
132  edm::LogInfo("AnalyzerMB") << " Result= " << mysubd << " " << ieta << " "
133  << iphi << " mom0 " << mom0_MB << " mom1 "
134  << mom1_MB << " mom2 " << mom2_MB << " mom3 "
135  << mom3_MB << " mom4 " << mom4_MB;
136  myTree_->Fill();
137  }
138  }
139  edm::LogInfo("AnalyzerMB") << "cells " << cells;
140 }
std::map< HcalDetId, myInfo > myMap_
static const TGPicture * info(bool iBackgroundIsBlack)
void SimAnalyzerMinbias::endRun ( const edm::Run r,
const edm::EventSetup iSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 91 of file SimAnalyzerMinbias.cc.

91  {
92 }

Member Data Documentation

int SimAnalyzerMinbias::cells
private

Definition at line 57 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

int SimAnalyzerMinbias::depth
private
edm::Service<TFileService> SimAnalyzerMinbias::fs_
private

Definition at line 52 of file SimAnalyzerMinbias.cc.

Referenced by beginJob().

int SimAnalyzerMinbias::ieta
private

Definition at line 57 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

int SimAnalyzerMinbias::iphi
private

Definition at line 57 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

float SimAnalyzerMinbias::mom0_MB
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

float SimAnalyzerMinbias::mom1_MB
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

float SimAnalyzerMinbias::mom2_MB
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

float SimAnalyzerMinbias::mom3_MB
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by endJob().

float SimAnalyzerMinbias::mom4_MB
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

int SimAnalyzerMinbias::mydet
private

Definition at line 57 of file SimAnalyzerMinbias.cc.

Referenced by beginJob().

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

Definition at line 65 of file SimAnalyzerMinbias.cc.

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

int SimAnalyzerMinbias::mysubd
private

Definition at line 57 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

TTree* SimAnalyzerMinbias::myTree_
private

Definition at line 54 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 66 of file SimAnalyzerMinbias.cc.

Referenced by analyze(), and SimAnalyzerMinbias().

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

Definition at line 67 of file SimAnalyzerMinbias.cc.

Referenced by analyze(), and SimAnalyzerMinbias().