CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Attributes
SimAnalyzerMinbias Class Reference
Inheritance diagram for SimAnalyzerMinbias:
edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  myInfo
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void beginRun (const edm::Run &r, const edm::EventSetup &iSetup) override
 
void endJob () override
 
void endRun (const edm::Run &r, const edm::EventSetup &iSetup) override
 
 SimAnalyzerMinbias (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

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

Private Attributes

int cells
 
int depth
 
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_
 
const double timeCut_
 
const edm::EDGetTokenT< edm::HepMCProducttok_evt_
 
const edm::EDGetTokenT< edm::PCaloHitContainertok_hcal_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 39 of file SimAnalyzerMinbias.cc.

Constructor & Destructor Documentation

◆ SimAnalyzerMinbias()

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

Definition at line 68 of file SimAnalyzerMinbias.cc.

References TFileService::kSharedResource, and timeCut_.

69  : timeCut_(iConfig.getUntrackedParameter<double>("TimeCut", 500)),
70  tok_evt_(consumes<edm::HepMCProduct>(edm::InputTag("generator"))),
71  tok_hcal_(consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", "HcalHits"))) {
72  usesResource(TFileService::kSharedResource);
73  edm::LogVerbatim("AnalyzerMB") << "Use Time cut of " << timeCut_ << " ns";
74 }
static const std::string kSharedResource
Definition: TFileService.h:76
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
const edm::EDGetTokenT< edm::HepMCProduct > tok_evt_
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_hcal_

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 133 of file SimAnalyzerMinbias.cc.

References edm::HepMCProduct::GetEvent(), iEvent, info(), edm::HandleBase::isValid(), myMap_, edm::Handle< T >::product(), protons_cff::time, timeCut_, tok_evt_, and tok_hcal_.

133  {
134  edm::LogVerbatim("SimAnalyzerMinbias") << " Start SimAnalyzerMinbias::analyze " << iEvent.id().run() << ":"
135  << iEvent.id().event();
136 
137  const edm::Handle<edm::HepMCProduct>& evtMC = iEvent.getHandle(tok_evt_);
138  if (!evtMC.isValid()) {
139  edm::LogWarning("SimAnalyzerMinbias") << "no HepMCProduct found";
140  } else {
141  const HepMC::GenEvent* myGenEvent = evtMC->GetEvent();
142  edm::LogVerbatim("SimAnalyzerMinbias") << "Event with " << myGenEvent->particles_size() << " particles + "
143  << myGenEvent->vertices_size() << " vertices";
144  }
145 
146  const edm::Handle<edm::PCaloHitContainer>& hcalHits = iEvent.getHandle(tok_hcal_);
147  if (!hcalHits.isValid()) {
148  edm::LogWarning("SimAnalyzerMinbias") << "Error! can't get HcalHits product!";
149  return;
150  }
151 
152  const edm::PCaloHitContainer* HitHcal = hcalHits.product();
153  std::map<HcalDetId, double> hitMap;
154  for (std::vector<PCaloHit>::const_iterator hcalItr = HitHcal->begin(); hcalItr != HitHcal->end(); ++hcalItr) {
155  double time = hcalItr->time();
156  if (time < timeCut_) {
157  double energyhit = hcalItr->energy();
158  HcalDetId hid = HcalDetId(hcalItr->id());
159  std::map<HcalDetId, double>::iterator itr1 = hitMap.find(hid);
160  if (itr1 == hitMap.end()) {
161  hitMap[hid] = 0;
162  itr1 = hitMap.find(hid);
163  }
164  itr1->second += energyhit;
165  }
166  }
167  edm::LogVerbatim("SimAnalyzerMinbias") << "extract information of " << hitMap.size() << " towers from "
168  << HitHcal->size() << " hits";
169 
170  for (std::map<HcalDetId, double>::const_iterator hcalItr = hitMap.begin(); hcalItr != hitMap.end(); ++hcalItr) {
171  HcalDetId hid = hcalItr->first;
172  double energyhit = hcalItr->second;
173  std::map<HcalDetId, myInfo>::iterator itr1 = myMap_.find(hid);
174  if (itr1 == myMap_.end()) {
175  myInfo info;
176  myMap_[hid] = info;
177  itr1 = myMap_.find(hid);
178  }
179  itr1->second.theMB0++;
180  itr1->second.theMB1 += energyhit;
181  itr1->second.theMB2 += (energyhit * energyhit);
182  itr1->second.theMB3 += (energyhit * energyhit * energyhit);
183  itr1->second.theMB4 += (energyhit * energyhit * energyhit * energyhit);
184  edm::LogVerbatim("SimAnalyzerMinbias") << "ID " << hid << " with energy " << energyhit;
185  }
186 }
Log< level::Info, true > LogVerbatim
std::vector< PCaloHit > PCaloHitContainer
static const TGPicture * info(bool iBackgroundIsBlack)
T const * product() const
Definition: Handle.h:70
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< edm::HepMCProduct > tok_evt_
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
const edm::EDGetTokenT< edm::PCaloHitContainer > tok_hcal_
bool isValid() const
Definition: HandleBase.h:70
std::map< HcalDetId, myInfo > myMap_
Log< level::Warning, false > LogWarning

◆ beginJob()

void SimAnalyzerMinbias::beginJob ( )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 82 of file SimAnalyzerMinbias.cc.

References cells, depth, compareTotals::fs, ieta, iphi, mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB, mydet, myMap_, mysubd, and myTree_.

82  {
84  myTree_ = fs->make<TTree>("SimJet", "SimJet Tree");
85  myTree_->Branch("mydet", &mydet, "mydet/I");
86  myTree_->Branch("mysubd", &mysubd, "mysubd/I");
87  myTree_->Branch("cells", &cells, "cells");
88  myTree_->Branch("depth", &depth, "depth/I");
89  myTree_->Branch("ieta", &ieta, "ieta/I");
90  myTree_->Branch("iphi", &iphi, "iphi/I");
91  myTree_->Branch("mom0_MB", &mom0_MB, "mom0_MB/F");
92  myTree_->Branch("mom1_MB", &mom1_MB, "mom1_MB/F");
93  myTree_->Branch("mom2_MB", &mom2_MB, "mom2_MB/F");
94  myTree_->Branch("mom3_MB", &mom3_MB, "mom3_MB/F");
95  myTree_->Branch("mom4_MB", &mom4_MB, "mom4_MB/F");
96 
97  myMap_.clear();
98 }
std::map< HcalDetId, myInfo > myMap_

◆ beginRun()

void SimAnalyzerMinbias::beginRun ( const edm::Run r,
const edm::EventSetup iSetup 
)
inlineoverride

Definition at line 46 of file SimAnalyzerMinbias.cc.

46 {};

◆ endJob()

void SimAnalyzerMinbias::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 102 of file SimAnalyzerMinbias.cc.

References cells, depth, ieta, info(), iphi, mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB, myMap_, mysubd, and myTree_.

Referenced by o2olib.O2ORunMgr::executeJob().

102  {
103  cells = 0;
104  for (std::map<HcalDetId, myInfo>::const_iterator itr = myMap_.begin(); itr != myMap_.end(); ++itr) {
105  mysubd = itr->first.subdet();
106  depth = itr->first.depth();
107  iphi = itr->first.iphi();
108  ieta = itr->first.ieta();
109  myInfo info = itr->second;
110  if (info.theMB0 > 0) {
111  mom0_MB = info.theMB0;
112  mom1_MB = info.theMB1;
113  mom2_MB = info.theMB2;
114  mom3_MB = info.theMB3;
115  mom4_MB = info.theMB4;
116  cells++;
117 
118  edm::LogVerbatim("SimAnalyzerMinbias")
119  << " Result= " << mysubd << " " << ieta << " " << iphi << " mom0 " << mom0_MB << " mom1 " << mom1_MB
120  << " mom2 " << mom2_MB << " mom3 " << mom3_MB << " mom4 " << mom4_MB;
121  myTree_->Fill();
122  }
123  }
124  edm::LogVerbatim("SimAnalyzerMinbias") << "cells " << cells;
125 }
Log< level::Info, true > LogVerbatim
static const TGPicture * info(bool iBackgroundIsBlack)
std::map< HcalDetId, myInfo > myMap_

◆ endRun()

void SimAnalyzerMinbias::endRun ( const edm::Run r,
const edm::EventSetup iSetup 
)
inlineoverride

Definition at line 47 of file SimAnalyzerMinbias.cc.

47 {};

◆ fillDescriptions()

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

Definition at line 76 of file SimAnalyzerMinbias.cc.

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

76  {
78  desc.addUntracked<double>("TimeCut", 500);
79  descriptions.add("simAnalyzerMinbias", desc);
80 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ cells

int SimAnalyzerMinbias::cells
private

Definition at line 55 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ depth

int SimAnalyzerMinbias::depth
private

◆ ieta

int SimAnalyzerMinbias::ieta
private

Definition at line 55 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ iphi

int SimAnalyzerMinbias::iphi
private

Definition at line 55 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mom0_MB

float SimAnalyzerMinbias::mom0_MB
private

Definition at line 56 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mom1_MB

float SimAnalyzerMinbias::mom1_MB
private

Definition at line 56 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mom2_MB

float SimAnalyzerMinbias::mom2_MB
private

Definition at line 56 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mom3_MB

float SimAnalyzerMinbias::mom3_MB
private

Definition at line 56 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mom4_MB

float SimAnalyzerMinbias::mom4_MB
private

Definition at line 56 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mydet

int SimAnalyzerMinbias::mydet
private

Definition at line 55 of file SimAnalyzerMinbias.cc.

Referenced by beginJob().

◆ myMap_

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

Definition at line 61 of file SimAnalyzerMinbias.cc.

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

◆ mysubd

int SimAnalyzerMinbias::mysubd
private

Definition at line 55 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ myTree_

TTree* SimAnalyzerMinbias::myTree_
private

Definition at line 52 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ timeCut_

const double SimAnalyzerMinbias::timeCut_
private

Definition at line 47 of file SimAnalyzerMinbias.cc.

Referenced by analyze(), and SimAnalyzerMinbias().

◆ tok_evt_

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

Definition at line 62 of file SimAnalyzerMinbias.cc.

Referenced by analyze().

◆ tok_hcal_

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

Definition at line 63 of file SimAnalyzerMinbias.cc.

Referenced by analyze().