CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
CastorClusterProducer Class Reference

#include <RecoLocalCalo/Castor/src/CastorClusterProducer.cc>

Inheritance diagram for CastorClusterProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CastorClusterProducer (const edm::ParameterSet &)
 
 ~CastorClusterProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef std::vector< reco::CastorClusterCastorClusterCollection
 
typedef std::vector< reco::CastorTowerCastorTowerCollection
 
typedef ROOT::Math::RhoZPhiPoint CellPoint
 
typedef math::XYZPointD Point
 
typedef ROOT::Math::RhoEtaPhiPoint TowerPoint
 

Private Member Functions

void beginJob () override
 
void endJob () override
 
double phiangle (double testphi) const
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

std::string basicjets_
 
bool clusteralgo_
 
std::string input_
 
edm::EDGetTokenT< CastorTowerCollectiontok_input_
 
edm::EDGetTokenT< reco::BasicJetCollectiontok_jets_
 
edm::EDGetTokenT< CastorTowerCollectiontok_tower_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- 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 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

Description: CastorCluster Reconstruction Producer. Produces Clusters from Towers Implementation:

Definition at line 48 of file CastorClusterProducer.cc.

Member Typedef Documentation

◆ CastorClusterCollection

Definition at line 64 of file CastorClusterProducer.cc.

◆ CastorTowerCollection

Definition at line 63 of file CastorClusterProducer.cc.

◆ CellPoint

typedef ROOT::Math::RhoZPhiPoint CastorClusterProducer::CellPoint
private

Definition at line 62 of file CastorClusterProducer.cc.

◆ Point

Definition at line 60 of file CastorClusterProducer.cc.

◆ TowerPoint

typedef ROOT::Math::RhoEtaPhiPoint CastorClusterProducer::TowerPoint
private

Definition at line 61 of file CastorClusterProducer.cc.

Constructor & Destructor Documentation

◆ CastorClusterProducer()

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

Definition at line 84 of file CastorClusterProducer.cc.

References basicjets_, input_, ProducerED_cfi::InputTag, tok_input_, tok_jets_, and tok_tower_.

85  : input_(iConfig.getUntrackedParameter<std::string>("inputtowers", "")),
86  basicjets_(iConfig.getUntrackedParameter<std::string>("basicjets", "")),
87  clusteralgo_(iConfig.getUntrackedParameter<bool>("ClusterAlgo", false)) {
88  // register for data access
89  tok_input_ = consumes<CastorTowerCollection>(edm::InputTag(input_));
90  tok_jets_ = consumes<reco::BasicJetCollection>(edm::InputTag(basicjets_));
91  tok_tower_ = consumes<CastorTowerCollection>(edm::InputTag("CastorTowerReco"));
92  // register your products
93  produces<CastorClusterCollection>();
94  // now do what ever other initialization is needed
95 }
edm::EDGetTokenT< CastorTowerCollection > tok_input_
edm::EDGetTokenT< CastorTowerCollection > tok_tower_
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::BasicJetCollection > tok_jets_

◆ ~CastorClusterProducer()

CastorClusterProducer::~CastorClusterProducer ( )
override

Definition at line 97 of file CastorClusterProducer.cc.

97  {
98  // do anything here that needs to be done at desctruction time
99  // (e.g. close files, deallocate resources etc.)
100 }

Member Function Documentation

◆ beginJob()

void CastorClusterProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::global::EDProducerBase.

Definition at line 252 of file CastorClusterProducer.cc.

References LogDebug.

252 { LogDebug("CastorClusterProducer") << "Starting CastorClusterProducer"; }
#define LogDebug(id)

◆ endJob()

void CastorClusterProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::global::EDProducerBase.

Definition at line 255 of file CastorClusterProducer.cc.

References LogDebug.

255 { LogDebug("CastorClusterProducer") << "Ending CastorClusterProducer"; }
#define LogDebug(id)

◆ phiangle()

double CastorClusterProducer::phiangle ( double  testphi) const
private

Definition at line 242 of file CastorClusterProducer.cc.

References M_PI, and phi.

Referenced by produce().

242  {
243  double phi = testphi;
244  while (phi > M_PI)
245  phi -= (2 * M_PI);
246  while (phi < -M_PI)
247  phi += (2 * M_PI);
248  return phi;
249 }
#define M_PI

◆ produce()

void CastorClusterProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 107 of file CastorClusterProducer.cc.

References funct::abs(), basicjets_, gpuPixelDoublets::cc, clusteralgo_, hgcalPlots::ct, hcalRecHitTable_cff::depth, reco::CastorTower::depth(), reco::CastorTower::emEnergy(), hcalRecHitTable_cff::energy, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), reco::CastorTower::fhot(), reco::Jet::getJetConstituents(), reco::CastorTower::hadEnergy(), mps_fire::i, edm::Ref< C, T, F >::id(), iEvent, input_, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, MainPageGenerator::l, LogDebug, eostools::move(), ecaldqm::nTowers, reco::LeafCandidate::phi(), phiangle(), position, funct::pow(), edm::RefVector< C, T, F >::push_back(), reco::CastorTower::rechitsBegin(), reco::CastorTower::rechitsEnd(), mathSSE::sqrt(), groupFilesInBlocks::temp, tok_input_, tok_jets_, tok_tower_, and ApeEstimator_cff::width.

107  {
108  using namespace edm;
109  using namespace reco;
110  using namespace TMath;
111 
112  LogDebug("CastorClusterProducer") << "3. entering CastorClusterProducer";
113 
114  if (!input_.empty()) {
115  // Produce CastorClusters from CastorTowers
116 
118  iEvent.getByToken(tok_input_, InputTowers);
119 
120  auto OutputClustersfromClusterAlgo = std::make_unique<CastorClusterCollection>();
121 
122  // get and check input size
123  int nTowers = InputTowers->size();
124 
125  if (nTowers == 0)
126  LogDebug("CastorClusterProducer") << "Warning: You are trying to run the Cluster algorithm with 0 input towers.";
127 
128  CastorTowerRefVector posInputTowers, negInputTowers;
129 
130  for (size_t i = 0; i < InputTowers->size(); ++i) {
131  reco::CastorTowerRef tower_p = reco::CastorTowerRef(InputTowers, i);
132  if (tower_p->eta() > 0.)
133  posInputTowers.push_back(tower_p);
134  if (tower_p->eta() < 0.)
135  negInputTowers.push_back(tower_p);
136  }
137 
138  // build cluster from ClusterAlgo
139  if (clusteralgo_ == true) {
140  // code
141  iEvent.put(std::move(OutputClustersfromClusterAlgo));
142  }
143  }
144 
145  if (!basicjets_.empty()) {
146  Handle<BasicJetCollection> bjCollection;
147  iEvent.getByToken(tok_jets_, bjCollection);
148 
149  Handle<CastorTowerCollection> ctCollection;
150  iEvent.getByToken(tok_tower_, ctCollection);
151 
152  auto OutputClustersfromBasicJets = std::make_unique<CastorClusterCollection>();
153 
154  if (bjCollection->empty())
155  LogDebug("CastorClusterProducer")
156  << "Warning: You are trying to run the Cluster algorithm with 0 input basicjets.";
157 
158  for (unsigned i = 0; i < bjCollection->size(); i++) {
159  const BasicJet* bj = &(*bjCollection)[i];
160 
161  double energy = bj->energy();
162  TowerPoint temp(88.5, bj->eta(), bj->phi());
164  double emEnergy = 0.;
165  double hadEnergy = 0.;
166  double width = 0.;
167  double depth = 0.;
168  double fhot = 0.;
169  double sigmaz = 0.;
170  CastorTowerRefVector usedTowers;
171  double zmean = 0.;
172  double z2mean = 0.;
173 
174  std::vector<CandidatePtr> ccp = bj->getJetConstituents();
175  std::vector<CandidatePtr>::const_iterator itParticle;
176  for (itParticle = ccp.begin(); itParticle != ccp.end(); ++itParticle) {
177  const CastorTower* castorcand = dynamic_cast<const CastorTower*>(itParticle->get());
178  //cout << " castortowercandidate reference energy = " << castorcand->castorTower()->energy() << endl;
179  //cout << " castortowercandidate reference eta = " << castorcand->castorTower()->eta() << endl;
180  //cout << " castortowercandidate reference phi = " << castorcand->castorTower()->phi() << endl;
181  //cout << " castortowercandidate reference depth = " << castorcand->castorTower()->depth() << endl;
182 
183  //CastorTowerCollection *ctc = new CastorTowerCollection();
184  //ctc->push_back(*castorcand);
185  //CastorTowerRef towerref = CastorTowerRef(ctc,0);
186 
187  size_t thisone = 0;
188  for (size_t l = 0; l < ctCollection->size(); l++) {
189  const CastorTower ct = (*ctCollection)[l];
190  if (std::abs(ct.phi() - castorcand->phi()) < 0.0001) {
191  thisone = l;
192  }
193  }
194 
195  CastorTowerRef towerref(ctCollection, thisone);
196  usedTowers.push_back(towerref);
197  emEnergy += castorcand->emEnergy();
198  hadEnergy += castorcand->hadEnergy();
199  depth += castorcand->depth() * castorcand->energy();
200  width += pow(phiangle(castorcand->phi() - bj->phi()), 2) * castorcand->energy();
201  fhot += castorcand->fhot() * castorcand->energy();
202 
203  // loop over rechits
204  for (edm::RefVector<edm::SortedCollection<CastorRecHit> >::iterator it = castorcand->rechitsBegin();
205  it != castorcand->rechitsEnd();
206  it++) {
208  double Erechit = rechit_p->energy();
209  HcalCastorDetId id = rechit_p->id();
210  int module = id.module();
211  double zrechit = 0;
212  if (module < 3)
213  zrechit = -14390 - 24.75 - 49.5 * (module - 1);
214  if (module > 2)
215  zrechit = -14390 - 99 - 49.5 - 99 * (module - 3);
216  zmean += Erechit * zrechit;
217  z2mean += Erechit * zrechit * zrechit;
218  } // end loop over rechits
219  }
220  //cout << "" << endl;
221 
222  depth = depth / energy;
223  width = sqrt(width / energy);
224  fhot = fhot / energy;
225 
226  zmean = zmean / energy;
227  z2mean = z2mean / energy;
228  double sigmaz2 = z2mean - zmean * zmean;
229  if (sigmaz2 > 0)
230  sigmaz = sqrt(sigmaz2);
231 
233  energy, position, emEnergy, hadEnergy, emEnergy / energy, width, depth, fhot, sigmaz, usedTowers);
234  OutputClustersfromBasicJets->push_back(cc);
235  }
236 
237  iEvent.put(std::move(OutputClustersfromBasicJets));
238  }
239 }
edm::EDGetTokenT< CastorTowerCollection > tok_input_
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
static constexpr int nTowers
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::EDGetTokenT< CastorTowerCollection > tok_tower_
CastorRecHitRefs::iterator rechitsBegin() const
fist iterator over CastorRecHit constituents
Definition: CastorTower.h:78
double depth() const
tower depth in z
Definition: CastorTower.h:69
edm::Ref< CastorTowerCollection > CastorTowerRef
Definition: CastorTower.h:140
Jets made from CaloTowers.
Definition: BasicJet.h:19
virtual Constituents getJetConstituents() const
list of constituents
double emEnergy() const
tower em energy
Definition: CastorTower.h:60
double hadEnergy() const
tower had energy
Definition: CastorTower.h:63
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< reco::BasicJetCollection > tok_jets_
ROOT::Math::RhoEtaPhiPoint TowerPoint
double fhot() const
tower hotcell/tot ratio
Definition: CastorTower.h:72
double phiangle(double testphi) const
fixed size matrix
HLT enums.
CastorRecHitRefs::iterator rechitsEnd() const
last iterator over CastorRecHit constituents
Definition: CastorTower.h:81
Structure Point Contains parameters of Gaussian fits to DMRs.
static int position[264][3]
Definition: ReadPGInfo.cc:289
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
double phi() const final
momentum azimuthal angle
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)
double energy() const final
energy
double eta() const final
momentum pseudorapidity

Member Data Documentation

◆ basicjets_

std::string CastorClusterProducer::basicjets_
private

Definition at line 65 of file CastorClusterProducer.cc.

Referenced by CastorClusterProducer(), and produce().

◆ clusteralgo_

bool CastorClusterProducer::clusteralgo_
private

Definition at line 69 of file CastorClusterProducer.cc.

Referenced by produce().

◆ input_

std::string CastorClusterProducer::input_
private

Definition at line 65 of file CastorClusterProducer.cc.

Referenced by CastorClusterProducer(), and produce().

◆ tok_input_

edm::EDGetTokenT<CastorTowerCollection> CastorClusterProducer::tok_input_
private

Definition at line 66 of file CastorClusterProducer.cc.

Referenced by CastorClusterProducer(), and produce().

◆ tok_jets_

edm::EDGetTokenT<reco::BasicJetCollection> CastorClusterProducer::tok_jets_
private

Definition at line 67 of file CastorClusterProducer.cc.

Referenced by CastorClusterProducer(), and produce().

◆ tok_tower_

edm::EDGetTokenT<CastorTowerCollection> CastorClusterProducer::tok_tower_
private

Definition at line 68 of file CastorClusterProducer.cc.

Referenced by CastorClusterProducer(), and produce().