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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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
 
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::HepMCProducttok_evt_
 
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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 40 of file SimAnalyzerMinbias.cc.

Constructor & Destructor Documentation

◆ SimAnalyzerMinbias()

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

Definition at line 70 of file SimAnalyzerMinbias.cc.

70  {
71  usesResource(TFileService::kSharedResource);
72  timeCut_ = iConfig.getUntrackedParameter<double>("TimeCut", 500);
73 
74  // get token names of modules, producing object collections
75  tok_evt_ = consumes<edm::HepMCProduct>(edm::InputTag("generator"));
76  tok_hcal_ = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", "HcalHits"));
77 
78  edm::LogVerbatim("AnalyzerMB") << "Use Time cut of " << timeCut_ << " ns";
79 }

References edm::ParameterSet::getUntrackedParameter(), TFileService::kSharedResource, timeCut_, tok_evt_, and tok_hcal_.

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 137 of file SimAnalyzerMinbias.cc.

137  {
138  edm::LogVerbatim("AnalyzerMB") << " Start SimAnalyzerMinbias::analyze " << iEvent.id().run() << ":"
139  << iEvent.id().event();
140 
142  iEvent.getByToken(tok_evt_, evtMC);
143  if (!evtMC.isValid()) {
144  edm::LogWarning("AnalyzerMB") << "no HepMCProduct found";
145  } else {
146  const HepMC::GenEvent* myGenEvent = evtMC->GetEvent();
147  edm::LogVerbatim("AnalyzerMB") << "Event with " << myGenEvent->particles_size() << " particles + "
148  << myGenEvent->vertices_size() << " vertices";
149  }
150 
152  iEvent.getByToken(tok_hcal_, hcalHits);
153  if (!hcalHits.isValid()) {
154  edm::LogWarning("AnalyzerMB") << "Error! can't get HcalHits product!";
155  return;
156  }
157 
158  const edm::PCaloHitContainer* HitHcal = hcalHits.product();
159  std::map<HcalDetId, double> hitMap;
160  for (std::vector<PCaloHit>::const_iterator hcalItr = HitHcal->begin(); hcalItr != HitHcal->end(); ++hcalItr) {
161  double time = hcalItr->time();
162  if (time < timeCut_) {
163  double energyhit = hcalItr->energy();
164  HcalDetId hid = HcalDetId(hcalItr->id());
165  std::map<HcalDetId, double>::iterator itr1 = hitMap.find(hid);
166  if (itr1 == hitMap.end()) {
167  hitMap[hid] = 0;
168  itr1 = hitMap.find(hid);
169  }
170  itr1->second += energyhit;
171  }
172  }
173  edm::LogVerbatim("AnalyzerMB") << "extract information of " << hitMap.size() << " towers from " << HitHcal->size()
174  << " hits";
175 
176  for (std::map<HcalDetId, double>::const_iterator hcalItr = hitMap.begin(); hcalItr != hitMap.end(); ++hcalItr) {
177  HcalDetId hid = hcalItr->first;
178  double energyhit = hcalItr->second;
179  std::map<HcalDetId, myInfo>::iterator itr1 = myMap_.find(hid);
180  if (itr1 == myMap_.end()) {
181  myInfo info;
182  myMap_[hid] = info;
183  itr1 = myMap_.find(hid);
184  }
185  itr1->second.theMB0++;
186  itr1->second.theMB1 += energyhit;
187  itr1->second.theMB2 += (energyhit * energyhit);
188  itr1->second.theMB3 += (energyhit * energyhit * energyhit);
189  itr1->second.theMB4 += (energyhit * energyhit * energyhit * energyhit);
190  edm::LogVerbatim("AnalyzerMB") << "ID " << hid << " with energy " << energyhit;
191  }
192 }

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

◆ beginJob()

void SimAnalyzerMinbias::beginJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 87 of file SimAnalyzerMinbias.cc.

87  {
88  myTree_ = fs_->make<TTree>("SimJet", "SimJet Tree");
89  myTree_->Branch("mydet", &mydet, "mydet/I");
90  myTree_->Branch("mysubd", &mysubd, "mysubd/I");
91  myTree_->Branch("cells", &cells, "cells");
92  myTree_->Branch("depth", &depth, "depth/I");
93  myTree_->Branch("ieta", &ieta, "ieta/I");
94  myTree_->Branch("iphi", &iphi, "iphi/I");
95  myTree_->Branch("mom0_MB", &mom0_MB, "mom0_MB/F");
96  myTree_->Branch("mom1_MB", &mom1_MB, "mom1_MB/F");
97  myTree_->Branch("mom2_MB", &mom2_MB, "mom2_MB/F");
98  myTree_->Branch("mom3_MB", &mom3_MB, "mom3_MB/F");
99  myTree_->Branch("mom4_MB", &mom4_MB, "mom4_MB/F");
100 
101  myMap_.clear();
102 }

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

◆ beginRun()

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

Definition at line 47 of file SimAnalyzerMinbias.cc.

47 {};

◆ endJob()

void SimAnalyzerMinbias::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 106 of file SimAnalyzerMinbias.cc.

106  {
107  cells = 0;
108  for (std::map<HcalDetId, myInfo>::const_iterator itr = myMap_.begin(); itr != myMap_.end(); ++itr) {
109  mysubd = itr->first.subdet();
110  depth = itr->first.depth();
111  iphi = itr->first.iphi();
112  ieta = itr->first.ieta();
113  myInfo info = itr->second;
114  if (info.theMB0 > 0) {
115  mom0_MB = info.theMB0;
116  mom1_MB = info.theMB1;
117  mom2_MB = info.theMB2;
118  mom3_MB = info.theMB3;
119  mom4_MB = info.theMB4;
120  cells++;
121 
122  edm::LogVerbatim("AnalyzerMB") << " Result= " << mysubd << " " << ieta << " " << iphi << " mom0 " << mom0_MB
123  << " mom1 " << mom1_MB << " mom2 " << mom2_MB << " mom3 " << mom3_MB << " mom4 "
124  << mom4_MB;
125  myTree_->Fill();
126  }
127  }
128  edm::LogVerbatim("AnalyzerMB") << "cells " << cells;
129 }

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().

◆ endRun()

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

Definition at line 48 of file SimAnalyzerMinbias.cc.

48 {};

◆ fillDescriptions()

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

Definition at line 81 of file SimAnalyzerMinbias.cc.

81  {
83  desc.addUntracked<double>("TimeCut", 500);
84  descriptions.add("simAnalyzerMinbias", desc);
85 }

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

Member Data Documentation

◆ cells

int SimAnalyzerMinbias::cells
private

Definition at line 57 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ depth

int SimAnalyzerMinbias::depth
private

◆ fs_

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

Definition at line 48 of file SimAnalyzerMinbias.cc.

Referenced by beginJob().

◆ ieta

int SimAnalyzerMinbias::ieta
private

Definition at line 57 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ iphi

int SimAnalyzerMinbias::iphi
private

Definition at line 57 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mom0_MB

float SimAnalyzerMinbias::mom0_MB
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mom1_MB

float SimAnalyzerMinbias::mom1_MB
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mom2_MB

float SimAnalyzerMinbias::mom2_MB
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mom3_MB

float SimAnalyzerMinbias::mom3_MB
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mom4_MB

float SimAnalyzerMinbias::mom4_MB
private

Definition at line 58 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ mydet

int SimAnalyzerMinbias::mydet
private

Definition at line 57 of file SimAnalyzerMinbias.cc.

Referenced by beginJob().

◆ myMap_

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

Definition at line 63 of file SimAnalyzerMinbias.cc.

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

◆ mysubd

int SimAnalyzerMinbias::mysubd
private

Definition at line 57 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ myTree_

TTree* SimAnalyzerMinbias::myTree_
private

Definition at line 54 of file SimAnalyzerMinbias.cc.

Referenced by beginJob(), and endJob().

◆ timeCut_

double SimAnalyzerMinbias::timeCut_
private

Definition at line 53 of file SimAnalyzerMinbias.cc.

Referenced by analyze(), and SimAnalyzerMinbias().

◆ tok_evt_

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

Definition at line 64 of file SimAnalyzerMinbias.cc.

Referenced by analyze(), and SimAnalyzerMinbias().

◆ tok_hcal_

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

Definition at line 65 of file SimAnalyzerMinbias.cc.

Referenced by analyze(), and SimAnalyzerMinbias().

edm::Handle::product
T const * product() const
Definition: Handle.h:70
SimAnalyzerMinbias::tok_hcal_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hcal_
Definition: SimAnalyzerMinbias.cc:65
SimAnalyzerMinbias::mom2_MB
float mom2_MB
Definition: SimAnalyzerMinbias.cc:58
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
SimAnalyzerMinbias::timeCut_
double timeCut_
Definition: SimAnalyzerMinbias.cc:53
protons_cff.time
time
Definition: protons_cff.py:35
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle< edm::HepMCProduct >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
SimAnalyzerMinbias::myMap_
std::map< HcalDetId, myInfo > myMap_
Definition: SimAnalyzerMinbias.cc:63
SimAnalyzerMinbias::mom4_MB
float mom4_MB
Definition: SimAnalyzerMinbias.cc:58
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
SimAnalyzerMinbias::tok_evt_
edm::EDGetTokenT< edm::HepMCProduct > tok_evt_
Definition: SimAnalyzerMinbias.cc:64
SimAnalyzerMinbias::mom0_MB
float mom0_MB
Definition: SimAnalyzerMinbias.cc:58
HcalDetId
Definition: HcalDetId.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
SimAnalyzerMinbias::mom1_MB
float mom1_MB
Definition: SimAnalyzerMinbias.cc:58
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
SimAnalyzerMinbias::mydet
int mydet
Definition: SimAnalyzerMinbias.cc:57
TFileService::make
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
SimAnalyzerMinbias::mom3_MB
float mom3_MB
Definition: SimAnalyzerMinbias.cc:58
SimAnalyzerMinbias::ieta
int ieta
Definition: SimAnalyzerMinbias.cc:57
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
SimAnalyzerMinbias::iphi
int iphi
Definition: SimAnalyzerMinbias.cc:57
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
SimAnalyzerMinbias::mysubd
int mysubd
Definition: SimAnalyzerMinbias.cc:57
SimAnalyzerMinbias::myTree_
TTree * myTree_
Definition: SimAnalyzerMinbias.cc:54
edm::PCaloHitContainer
std::vector< PCaloHit > PCaloHitContainer
Definition: PCaloHitContainer.h:8
SimAnalyzerMinbias::cells
int cells
Definition: SimAnalyzerMinbias.cc:57
SimAnalyzerMinbias::fs_
edm::Service< TFileService > fs_
Definition: SimAnalyzerMinbias.cc:48
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
SimAnalyzerMinbias::depth
int depth
Definition: SimAnalyzerMinbias.cc:57