CMS 3D CMS Logo

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

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

Inheritance diagram for CastorTowerProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CastorTowerProducer (const edm::ParameterSet &)
 
 ~CastorTowerProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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 & itemsToGetFromEvent () 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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef edm::SortedCollection< CastorRecHitCastorRecHitCollection
 
typedef edm::RefVector< CastorRecHitCollectionCastorRecHitRefVector
 
typedef std::vector< reco::CastorTowerCastorTowerCollection
 
typedef ROOT::Math::RhoZPhiPoint CellPoint
 
typedef math::XYZPointD Point
 
typedef ROOT::Math::RhoEtaPhiPoint TowerPoint
 

Private Member Functions

virtual void ComputeTowerVariable (const edm::RefVector< edm::SortedCollection< CastorRecHit > > &usedRecHits, double &Ehot, double &depth)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double maxtime_
 
double mintime_
 
edm::EDGetTokenT< CastorRecHitCollectiontok_input_
 
double towercut_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

Description: CastorTower Reconstruction Producer. Produce CastorTowers from CastorCells. Implementation:

Definition at line 51 of file CastorTowerProducer.cc.

Member Typedef Documentation

Definition at line 64 of file CastorTowerProducer.cc.

Definition at line 66 of file CastorTowerProducer.cc.

Definition at line 65 of file CastorTowerProducer.cc.

typedef ROOT::Math::RhoZPhiPoint CastorTowerProducer::CellPoint
private

Definition at line 63 of file CastorTowerProducer.cc.

Definition at line 61 of file CastorTowerProducer.cc.

typedef ROOT::Math::RhoEtaPhiPoint CastorTowerProducer::TowerPoint
private

Definition at line 62 of file CastorTowerProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 86 of file CastorTowerProducer.cc.

References edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, and tok_input_.

86  :
87  towercut_(iConfig.getParameter<double>("towercut")),
88  mintime_(iConfig.getParameter<double>("mintime")),
89  maxtime_(iConfig.getParameter<double>("maxtime"))
90 {
91  tok_input_ = consumes<CastorRecHitCollection>(iConfig.getParameter<std::string>("inputprocess"));
92  //register your products
93  produces<CastorTowerCollection>();
94  //now do what ever other initialization is needed
95 }
T getParameter(std::string const &) const
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
CastorTowerProducer::~CastorTowerProducer ( )

Definition at line 98 of file CastorTowerProducer.cc.

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

Member Function Documentation

void CastorTowerProducer::ComputeTowerVariable ( const edm::RefVector< edm::SortedCollection< CastorRecHit > > &  usedRecHits,
double &  Ehot,
double &  depth 
)
privatevirtual

Definition at line 267 of file CastorTowerProducer.cc.

References DEFINE_FWK_MODULE, edm::Ref< C, T, F >::id(), and module::module().

Referenced by produce().

267  {
268 
269  using namespace reco;
270 
271  double Etot = 0;
272 
273  // loop over the cells used in the tower k
274  for (CastorRecHitRefVector::iterator it = usedRecHits.begin(); it != usedRecHits.end(); it++) {
275  edm::Ref<CastorRecHitCollection> rechit_p = *it;
276 
277  double Erechit = rechit_p->energy();
278  HcalCastorDetId id = rechit_p->id();
279  int module = id.module();
280  double zrechit = 0;
281  if (module < 3) zrechit = -14390 - 24.75 - 49.5*(module-1);
282  if (module > 2) zrechit = -14390 - 99 - 49.5 - 99*(module-3);
283 
284  if(Erechit > Ehot) Ehot = Erechit;
285  depth+=Erechit*zrechit;
286  Etot+=Erechit;
287  }
288 
289  depth/=Etot;
290  Ehot/=Etot;
291 }
module()
Definition: vlib.cc:994
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:253
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:248
refhelper::RefVectorTrait< CastorRecHitCollection, typename refhelper::ValueTrait< CastorRecHitCollection >::value, typename refhelper::FindTrait< CastorRecHitCollection, typename refhelper::ValueTrait< CastorRecHitCollection >::value >::value >::iterator_type iterator
Definition: RefVector.h:37
fixed size matrix
Definition: vlib.h:208
void CastorTowerProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Definition at line 110 of file CastorTowerProducer.cc.

References Abs(), ComputeTowerVariable(), particleFlowClusterECALTimeSelected_cfi::depth, edm::EventSetup::get(), CastorCondObjectContainer< Item >::getAllChannels(), edm::Event::getByToken(), mps_fire::i, edm::Ref< C, T, F >::id(), gen::k, LogDebug, maxtime_, mintime_, module::module(), eostools::move(), AlCaHLTBitMon_ParallelJobs::p, edm::RefVector< C, T, F >::push_back(), edm::Event::put(), DetId::rawId(), edm::SortedCollection< T, SORT >::size(), findQualityFiles::size, mathSSE::sqrt(), tok_input_, and towercut_.

110  {
111 
112  using namespace edm;
113  using namespace reco;
114  using namespace TMath;
115 
116  // Produce CastorTowers from CastorCells
117 
119  iEvent.getByToken(tok_input_,InputRecHits);
120 
121  auto OutputTowers = std::make_unique<CastorTowerCollection>();
122 
123  // get and check input size
124  int nRecHits = InputRecHits->size();
125 
126  LogDebug("CastorTowerProducer")
127  <<"2. entering CastorTowerProducer"<<std::endl;
128 
129  if (nRecHits==0)
130  LogDebug("CastorTowerProducer") <<"Warning: You are trying to run the Tower algorithm with 0 input rechits.";
131 
132  // declare castor array
133  // (0,x): Energies - (1,x): emEnergies - (2,x): hadEnergies - (3,x): phi position
134 
135  double poscastortowerarray[4][16];
136  double negcastortowerarray[4][16];
137 
138  CastorRecHitRefVector poscastorusedrechits[16];
139  CastorRecHitRefVector negcastorusedrechits[16];
140 
141  // set phi values and everything else to zero
142  for (int j = 0; j < 16; j++) {
143  poscastortowerarray[3][j] = -2.94524 + j*0.3927;
144  poscastortowerarray[0][j] = 0.;
145  poscastortowerarray[1][j] = 0.;
146  poscastortowerarray[2][j] = 0.;
147 
148  negcastortowerarray[3][j] = -2.94524 + j*0.3927;
149  negcastortowerarray[0][j] = 0.;
150  negcastortowerarray[1][j] = 0.;
151  negcastortowerarray[2][j] = 0.;
152  }
153 
154  // retrieve the channel quality lists from database
156  iSetup.get<CastorChannelQualityRcd>().get(p);
157  std::vector<DetId> channels = p->getAllChannels();
158 
159  // loop over rechits to build castortowerarray[4][16] and castorusedrechits[16]
160  for (unsigned int i = 0; i < InputRecHits->size(); i++) {
161 
163 
164  HcalCastorDetId id = rechit_p->id();
165  DetId genericID=(DetId)id;
166 
167  // first check if the rechit is in the BAD channel list
168  bool bad = false;
169  for (std::vector<DetId>::iterator channel = channels.begin();channel != channels.end();channel++) {
170  if (channel->rawId() == genericID.rawId()) {
171  // if the rechit is found in the list, set it bad
172  bad = true; break;
173  }
174  }
175  // if bad, continue the loop to the next rechit
176  if (bad) continue;
177 
178  double Erechit = rechit_p->energy();
179  int module = id.module();
180  int sector = id.sector();
181  double zrechit = 0;
182  if (module < 3) zrechit = -14390 - 24.75 - 49.5*(module-1);
183  if (module > 2) zrechit = -14390 - 99 - 49.5 - 99*(module-3);
184  double phirechit = -100;
185  if (sector < 9) phirechit = 0.19635 + (sector-1)*0.3927;
186  if (sector > 8) phirechit = -2.94524 + (sector - 9)*0.3927;
187 
188  // add time conditions for the rechit
189  if (rechit_p->time() > mintime_ && rechit_p->time() < maxtime_) {
190 
191  // loop over the 16 towers possibilities
192  for ( int j=0;j<16;j++) {
193 
194  // phi matching condition
195  if (TMath::Abs(phirechit - poscastortowerarray[3][j]) < 0.0001) {
196 
197  // condition over rechit z value
198  if (zrechit > 0.) {
199  poscastortowerarray[0][j]+=Erechit;
200  if (module < 3) {poscastortowerarray[1][j]+=Erechit;} else {poscastortowerarray[2][j]+=Erechit;}
201  poscastorusedrechits[j].push_back(rechit_p);
202  } else {
203  negcastortowerarray[0][j]+=Erechit;
204  if (module < 3) {negcastortowerarray[1][j]+=Erechit;} else {negcastortowerarray[2][j]+=Erechit;}
205  negcastorusedrechits[j].push_back(rechit_p);
206  } // end condition over rechit z value
207  } // end phi matching condition
208  } // end loop over the 16 towers possibilities
209  } // end time conditions
210 
211  } // end loop over rechits to build castortowerarray[4][16] and castorusedrechits[16]
212 
213  // make towers of the arrays
214 
215  double fem, Ehot, depth;
216  double rhoTower = 88.5;
217 
218  // loop over the 16 towers possibilities
219  for (int k=0;k<16;k++) {
220 
221  fem = 0;
222  Ehot = 0;
223  depth = 0;
224 
225  // select the positive towers with E > sqrt(Nusedrechits)*Ecut
226  if (poscastortowerarray[0][k] > sqrt(poscastorusedrechits[k].size())*towercut_) {
227 
228  fem = poscastortowerarray[1][k]/poscastortowerarray[0][k];
229  CastorRecHitRefVector usedRecHits = poscastorusedrechits[k];
230  ComputeTowerVariable(usedRecHits,Ehot,depth);
231 
232  LogDebug("CastorTowerProducer")
233  <<"tower "<<k+1<<": fem = "<<fem<<" ,depth = "<<depth<<" ,Ehot = "<<Ehot<<std::endl;
234 
235  TowerPoint temptowerposition(rhoTower,5.9,poscastortowerarray[3][k]);
236  Point towerposition(temptowerposition);
237 
238  CastorTower newtower(poscastortowerarray[0][k],towerposition,poscastortowerarray[1][k],poscastortowerarray[2][k],fem,depth,Ehot,
239  poscastorusedrechits[k]);
240  OutputTowers->push_back(newtower);
241  } // end select the positive towers with E > Ecut
242 
243  // select the negative towers with E > sqrt(Nusedrechits)*Ecut
244  if (negcastortowerarray[0][k] > sqrt(negcastorusedrechits[k].size())*towercut_) {
245 
246  fem = negcastortowerarray[1][k]/negcastortowerarray[0][k];
247  CastorRecHitRefVector usedRecHits = negcastorusedrechits[k];
248  ComputeTowerVariable(usedRecHits,Ehot,depth);
249 
250  LogDebug("CastorTowerProducer")
251  <<"tower "<<k+1 << " energy = " << negcastortowerarray[0][k] << "EM = " << negcastortowerarray[1][k] << "HAD = " << negcastortowerarray[2][k] << "phi = " << negcastortowerarray[3][k] << ": fem = "<<fem<<" ,depth = "<<depth<<" ,Ehot = "<<Ehot<<std::endl;
252 
253  TowerPoint temptowerposition(rhoTower,-5.9,negcastortowerarray[3][k]);
254  Point towerposition(temptowerposition);
255 
256  CastorTower newtower(negcastortowerarray[0][k],towerposition,negcastortowerarray[1][k],negcastortowerarray[2][k],fem,depth,Ehot,
257  negcastorusedrechits[k]);
258  OutputTowers->push_back(newtower);
259  } // end select the negative towers with E > Ecut
260 
261  } // end loop over the 16 towers possibilities
262 
263  iEvent.put(std::move(OutputTowers));
264 }
#define LogDebug(id)
size
Write out results.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
module()
Definition: vlib.cc:994
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::vector< DetId > getAllChannels() const
ROOT::Math::RhoEtaPhiPoint TowerPoint
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
T sqrt(T t)
Definition: SSEVec.h:18
edm::RefVector< CastorRecHitCollection > CastorRecHitRefVector
math::XYZPoint Point
T Abs(T a)
Definition: MathUtil.h:49
int k[5][pyjets_maxn]
Definition: DetId.h:18
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
virtual void ComputeTowerVariable(const edm::RefVector< edm::SortedCollection< CastorRecHit > > &usedRecHits, double &Ehot, double &depth)
const T & get() const
Definition: EventSetup.h:56
fixed size matrix
HLT enums.
size_type size() const
Definition: vlib.h:208
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

double CastorTowerProducer::maxtime_
private

Definition at line 70 of file CastorTowerProducer.cc.

Referenced by produce().

double CastorTowerProducer::mintime_
private

Definition at line 69 of file CastorTowerProducer.cc.

Referenced by produce().

edm::EDGetTokenT<CastorRecHitCollection> CastorTowerProducer::tok_input_
private

Definition at line 67 of file CastorTowerProducer.cc.

Referenced by CastorTowerProducer(), and produce().

double CastorTowerProducer::towercut_
private

Definition at line 68 of file CastorTowerProducer.cc.

Referenced by produce().