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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CastorClusterProducer (const edm::ParameterSet &)
 
 ~CastorClusterProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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
 
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)
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices 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)
 
void produce (edm::Event &, const edm::EventSetup &) 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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

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

Definition at line 50 of file CastorClusterProducer.cc.

Member Typedef Documentation

Definition at line 66 of file CastorClusterProducer.cc.

Definition at line 65 of file CastorClusterProducer.cc.

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

Definition at line 64 of file CastorClusterProducer.cc.

Definition at line 62 of file CastorClusterProducer.cc.

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

Definition at line 63 of file CastorClusterProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 87 of file CastorClusterProducer.cc.

References basicjets_, input_, tok_input_, tok_jets_, and tok_tower_.

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

Definition at line 102 of file CastorClusterProducer.cc.

103 {
104  // do anything here that needs to be done at desctruction time
105  // (e.g. close files, deallocate resources etc.)
106 }

Member Function Documentation

void CastorClusterProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 251 of file CastorClusterProducer.cc.

References LogDebug.

251  {
252  LogDebug("CastorClusterProducer")
253  <<"Starting CastorClusterProducer";
254 }
#define LogDebug(id)
void CastorClusterProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 257 of file CastorClusterProducer.cc.

References DEFINE_FWK_MODULE, and LogDebug.

257  {
258  LogDebug("CastorClusterProducer")
259  <<"Ending CastorClusterProducer";
260 }
#define LogDebug(id)
double CastorClusterProducer::phiangle ( double  testphi)
private

Definition at line 243 of file CastorClusterProducer.cc.

References M_PI, and phi.

Referenced by produce().

243  {
244  double phi = testphi;
245  while (phi>M_PI) phi -= (2*M_PI);
246  while (phi<-M_PI) phi += (2*M_PI);
247  return phi;
248 }
#define M_PI
void CastorClusterProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 114 of file CastorClusterProducer.cc.

References funct::abs(), basicjets_, clusteralgo_, egammaForCoreTracking_cff::depth, reco::CastorTower::depth(), reco::CastorTower::emEnergy(), reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), reco::CastorTower::fhot(), edm::Event::getByToken(), reco::Jet::getJetConstituents(), reco::CastorTower::hadEnergy(), mps_fire::i, edm::Ref< C, T, F >::id(), input_, checklumidiff::l, LogDebug, module::module(), eostools::move(), ecaldqm::nTowers, reco::LeafCandidate::phi(), phiangle(), position, funct::pow(), edm::RefVector< C, T, F >::push_back(), edm::Event::put(), reco::CastorTower::rechitsBegin(), reco::CastorTower::rechitsEnd(), mathSSE::sqrt(), groupFilesInBlocks::temp, tok_input_, tok_jets_, tok_tower_, and ApeEstimator_cff::width.

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

Member Data Documentation

std::string CastorClusterProducer::basicjets_
private

Definition at line 67 of file CastorClusterProducer.cc.

Referenced by CastorClusterProducer(), and produce().

bool CastorClusterProducer::clusteralgo_
private

Definition at line 71 of file CastorClusterProducer.cc.

Referenced by produce().

std::string CastorClusterProducer::input_
private

Definition at line 67 of file CastorClusterProducer.cc.

Referenced by CastorClusterProducer(), and produce().

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

Definition at line 68 of file CastorClusterProducer.cc.

Referenced by CastorClusterProducer(), and produce().

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

Definition at line 69 of file CastorClusterProducer.cc.

Referenced by CastorClusterProducer(), and produce().

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

Definition at line 70 of file CastorClusterProducer.cc.

Referenced by CastorClusterProducer(), and produce().