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<>

Public Member Functions

 CastorTowerProducer (const edm::ParameterSet &)
 
 ~CastorTowerProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double maxtime_
 
double mintime_
 
edm::ESGetToken< CastorChannelQuality, CastorChannelQualityRcdtok_channelQuality_
 
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
 

Detailed Description

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

Definition at line 51 of file CastorTowerProducer.cc.

Member Typedef Documentation

◆ CastorRecHitCollection

Definition at line 66 of file CastorTowerProducer.cc.

◆ CastorRecHitRefVector

Definition at line 68 of file CastorTowerProducer.cc.

◆ CastorTowerCollection

Definition at line 67 of file CastorTowerProducer.cc.

◆ CellPoint

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

Definition at line 65 of file CastorTowerProducer.cc.

◆ Point

Definition at line 63 of file CastorTowerProducer.cc.

◆ TowerPoint

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

Definition at line 64 of file CastorTowerProducer.cc.

Constructor & Destructor Documentation

◆ CastorTowerProducer()

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

Definition at line 88 of file CastorTowerProducer.cc.

89  : towercut_(iConfig.getParameter<double>("towercut")),
90  mintime_(iConfig.getParameter<double>("mintime")),
91  maxtime_(iConfig.getParameter<double>("maxtime")) {
92  tok_input_ = consumes<CastorRecHitCollection>(iConfig.getParameter<std::string>("inputprocess"));
93  tok_channelQuality_ = esConsumes<CastorChannelQuality, CastorChannelQualityRcd>();
94  //register your products
95  produces<CastorTowerCollection>();
96  //now do what ever other initialization is needed
97 }

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

◆ ~CastorTowerProducer()

CastorTowerProducer::~CastorTowerProducer ( )
override

Definition at line 99 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

◆ ComputeTowerVariable()

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

Definition at line 283 of file CastorTowerProducer.cc.

285  {
286  using namespace reco;
287 
288  double Etot = 0;
289 
290  // loop over the cells used in the tower k
291  for (CastorRecHitRefVector::iterator it = usedRecHits.begin(); it != usedRecHits.end(); it++) {
292  edm::Ref<CastorRecHitCollection> rechit_p = *it;
293 
294  double Erechit = rechit_p->energy();
295  HcalCastorDetId id = rechit_p->id();
296  int module = id.module();
297  double zrechit = 0;
298  if (module < 3)
299  zrechit = -14390 - 24.75 - 49.5 * (module - 1);
300  if (module > 2)
301  zrechit = -14390 - 99 - 49.5 - 99 * (module - 3);
302 
303  if (Erechit > Ehot)
304  Ehot = Erechit;
305  depth += Erechit * zrechit;
306  Etot += Erechit;
307  }
308 
309  depth /= Etot;
310  Ehot /= Etot;
311 }

References LEDCalibrationChannels::depth, and edm::Ref< C, T, F >::id().

Referenced by produce().

◆ produce()

void CastorTowerProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 109 of file CastorTowerProducer.cc.

109  {
110  using namespace edm;
111  using namespace reco;
112  using namespace TMath;
113 
114  // Produce CastorTowers from CastorCells
115 
117  iEvent.getByToken(tok_input_, InputRecHits);
118 
119  auto OutputTowers = std::make_unique<CastorTowerCollection>();
120 
121  // get and check input size
122  int nRecHits = InputRecHits->size();
123 
124  LogDebug("CastorTowerProducer") << "2. entering CastorTowerProducer" << std::endl;
125 
126  if (nRecHits == 0)
127  LogDebug("CastorTowerProducer") << "Warning: You are trying to run the Tower algorithm with 0 input rechits.";
128 
129  // declare castor array
130  // (0,x): Energies - (1,x): emEnergies - (2,x): hadEnergies - (3,x): phi position
131 
132  double poscastortowerarray[4][16];
133  double negcastortowerarray[4][16];
134 
135  CastorRecHitRefVector poscastorusedrechits[16];
136  CastorRecHitRefVector negcastorusedrechits[16];
137 
138  // set phi values and everything else to zero
139  for (int j = 0; j < 16; j++) {
140  poscastortowerarray[3][j] = -2.94524 + j * 0.3927;
141  poscastortowerarray[0][j] = 0.;
142  poscastortowerarray[1][j] = 0.;
143  poscastortowerarray[2][j] = 0.;
144 
145  negcastortowerarray[3][j] = -2.94524 + j * 0.3927;
146  negcastortowerarray[0][j] = 0.;
147  negcastortowerarray[1][j] = 0.;
148  negcastortowerarray[2][j] = 0.;
149  }
150 
151  // retrieve the channel quality lists from database
153  std::vector<DetId> channels = p->getAllChannels();
154 
155  // loop over rechits to build castortowerarray[4][16] and castorusedrechits[16]
156  for (unsigned int i = 0; i < InputRecHits->size(); i++) {
158 
159  HcalCastorDetId id = rechit_p->id();
160  DetId genericID = (DetId)id;
161 
162  // first check if the rechit is in the BAD channel list
163  bool bad = false;
164  for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); channel++) {
165  if (channel->rawId() == genericID.rawId()) {
166  // if the rechit is found in the list, set it bad
167  bad = true;
168  break;
169  }
170  }
171  // if bad, continue the loop to the next rechit
172  if (bad)
173  continue;
174 
175  double Erechit = rechit_p->energy();
176  int module = id.module();
177  int sector = id.sector();
178  double zrechit = 0;
179  if (module < 3)
180  zrechit = -14390 - 24.75 - 49.5 * (module - 1);
181  if (module > 2)
182  zrechit = -14390 - 99 - 49.5 - 99 * (module - 3);
183  double phirechit = -100;
184  if (sector < 9)
185  phirechit = 0.19635 + (sector - 1) * 0.3927;
186  if (sector > 8)
187  phirechit = -2.94524 + (sector - 9) * 0.3927;
188 
189  // add time conditions for the rechit
190  if (rechit_p->time() > mintime_ && rechit_p->time() < maxtime_) {
191  // loop over the 16 towers possibilities
192  for (int j = 0; j < 16; j++) {
193  // phi matching condition
194  if (TMath::Abs(phirechit - poscastortowerarray[3][j]) < 0.0001) {
195  // condition over rechit z value
196  if (zrechit > 0.) {
197  poscastortowerarray[0][j] += Erechit;
198  if (module < 3) {
199  poscastortowerarray[1][j] += Erechit;
200  } else {
201  poscastortowerarray[2][j] += Erechit;
202  }
203  poscastorusedrechits[j].push_back(rechit_p);
204  } else {
205  negcastortowerarray[0][j] += Erechit;
206  if (module < 3) {
207  negcastortowerarray[1][j] += Erechit;
208  } else {
209  negcastortowerarray[2][j] += Erechit;
210  }
211  negcastorusedrechits[j].push_back(rechit_p);
212  } // end condition over rechit z value
213  } // end phi matching condition
214  } // end loop over the 16 towers possibilities
215  } // end time conditions
216 
217  } // end loop over rechits to build castortowerarray[4][16] and castorusedrechits[16]
218 
219  // make towers of the arrays
220 
221  double fem, Ehot, depth;
222  double rhoTower = 88.5;
223 
224  // loop over the 16 towers possibilities
225  for (int k = 0; k < 16; k++) {
226  fem = 0;
227  Ehot = 0;
228  depth = 0;
229 
230  // select the positive towers with E > sqrt(Nusedrechits)*Ecut
231  if (poscastortowerarray[0][k] > sqrt(poscastorusedrechits[k].size()) * towercut_) {
232  fem = poscastortowerarray[1][k] / poscastortowerarray[0][k];
233  CastorRecHitRefVector usedRecHits = poscastorusedrechits[k];
234  ComputeTowerVariable(usedRecHits, Ehot, depth);
235 
236  LogDebug("CastorTowerProducer") << "tower " << k + 1 << ": fem = " << fem << " ,depth = " << depth
237  << " ,Ehot = " << Ehot << std::endl;
238 
239  TowerPoint temptowerposition(rhoTower, 5.9, poscastortowerarray[3][k]);
240  Point towerposition(temptowerposition);
241 
242  CastorTower newtower(poscastortowerarray[0][k],
243  towerposition,
244  poscastortowerarray[1][k],
245  poscastortowerarray[2][k],
246  fem,
247  depth,
248  Ehot,
249  poscastorusedrechits[k]);
250  OutputTowers->push_back(newtower);
251  } // end select the positive towers with E > Ecut
252 
253  // select the negative towers with E > sqrt(Nusedrechits)*Ecut
254  if (negcastortowerarray[0][k] > sqrt(negcastorusedrechits[k].size()) * towercut_) {
255  fem = negcastortowerarray[1][k] / negcastortowerarray[0][k];
256  CastorRecHitRefVector usedRecHits = negcastorusedrechits[k];
257  ComputeTowerVariable(usedRecHits, Ehot, depth);
258 
259  LogDebug("CastorTowerProducer") << "tower " << k + 1 << " energy = " << negcastortowerarray[0][k]
260  << "EM = " << negcastortowerarray[1][k] << "HAD = " << negcastortowerarray[2][k]
261  << "phi = " << negcastortowerarray[3][k] << ": fem = " << fem
262  << " ,depth = " << depth << " ,Ehot = " << Ehot << std::endl;
263 
264  TowerPoint temptowerposition(rhoTower, -5.9, negcastortowerarray[3][k]);
265  Point towerposition(temptowerposition);
266 
267  CastorTower newtower(negcastortowerarray[0][k],
268  towerposition,
269  negcastortowerarray[1][k],
270  negcastortowerarray[2][k],
271  fem,
272  depth,
273  Ehot,
274  negcastorusedrechits[k]);
275  OutputTowers->push_back(newtower);
276  } // end select the negative towers with E > Ecut
277 
278  } // end loop over the 16 towers possibilities
279 
280  iEvent.put(std::move(OutputTowers));
281 }

References Abs(), ewkTauDQM_cfi::channels, ComputeTowerVariable(), LEDCalibrationChannels::depth, edm::EventSetup::getHandle(), mps_fire::i, edm::Ref< C, T, F >::id(), iEvent, dqmiolumiharvest::j, dqmdumpme::k, LogDebug, maxtime_, mintime_, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, edm::RefVector< C, T, F >::push_back(), DetId::rawId(), edm::SortedCollection< T, SORT >::size(), findQualityFiles::size, mathSSE::sqrt(), tok_channelQuality_, tok_input_, and towercut_.

Member Data Documentation

◆ maxtime_

double CastorTowerProducer::maxtime_
private

Definition at line 73 of file CastorTowerProducer.cc.

Referenced by produce().

◆ mintime_

double CastorTowerProducer::mintime_
private

Definition at line 72 of file CastorTowerProducer.cc.

Referenced by produce().

◆ tok_channelQuality_

edm::ESGetToken<CastorChannelQuality, CastorChannelQualityRcd> CastorTowerProducer::tok_channelQuality_
private

Definition at line 70 of file CastorTowerProducer.cc.

Referenced by CastorTowerProducer(), and produce().

◆ tok_input_

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

Definition at line 69 of file CastorTowerProducer.cc.

Referenced by CastorTowerProducer(), and produce().

◆ towercut_

double CastorTowerProducer::towercut_
private

Definition at line 71 of file CastorTowerProducer.cc.

Referenced by produce().

CastorTowerProducer::CastorRecHitRefVector
edm::RefVector< CastorRecHitCollection > CastorRecHitRefVector
Definition: CastorTowerProducer.cc:68
CastorTowerProducer::ComputeTowerVariable
virtual void ComputeTowerVariable(const edm::RefVector< edm::SortedCollection< CastorRecHit > > &usedRecHits, double &Ehot, double &depth)
Definition: CastorTowerProducer.cc:283
mps_fire.i
i
Definition: mps_fire.py:428
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CastorTowerProducer::tok_channelQuality_
edm::ESGetToken< CastorChannelQuality, CastorChannelQualityRcd > tok_channelQuality_
Definition: CastorTowerProducer.cc:70
edm::RefVector< CastorRecHitCollection >::iterator
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
edm::RefVector::begin
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
CastorTowerProducer::tok_input_
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
Definition: CastorTowerProducer.cc:69
CastorTowerProducer::maxtime_
double maxtime_
Definition: CastorTowerProducer.cc:73
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
CastorTowerProducer::towercut_
double towercut_
Definition: CastorTowerProducer.cc:71
edm::Ref
Definition: AssociativeIterator.h:58
DetId
Definition: DetId.h:17
edm::RefVector::end
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
Abs
T Abs(T a)
Definition: MathUtil.h:49
CastorTowerProducer::TowerPoint
ROOT::Math::RhoEtaPhiPoint TowerPoint
Definition: CastorTowerProducer.cc:64
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle
Definition: DTSurvey.h:22
dqmdumpme.k
k
Definition: dqmdumpme.py:60
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalCastorDetId
Definition: HcalCastorDetId.h:23
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
CastorTowerProducer::mintime_
double mintime_
Definition: CastorTowerProducer.cc:72
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
edm::Ref::id
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
ewkTauDQM_cfi.channels
channels
Definition: ewkTauDQM_cfi.py:14
reco::CastorTower
Definition: CastorTower.h:26
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443