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 hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () 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::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 50 of file CastorTowerProducer.cc.

Member Typedef Documentation

◆ CastorRecHitCollection

Definition at line 65 of file CastorTowerProducer.cc.

◆ CastorRecHitRefVector

Definition at line 67 of file CastorTowerProducer.cc.

◆ CastorTowerCollection

Definition at line 66 of file CastorTowerProducer.cc.

◆ CellPoint

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

Definition at line 64 of file CastorTowerProducer.cc.

◆ Point

Definition at line 62 of file CastorTowerProducer.cc.

◆ TowerPoint

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

Definition at line 63 of file CastorTowerProducer.cc.

Constructor & Destructor Documentation

◆ CastorTowerProducer()

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

Definition at line 86 of file CastorTowerProducer.cc.

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

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

◆ ~CastorTowerProducer()

CastorTowerProducer::~CastorTowerProducer ( )
override

Definition at line 96 of file CastorTowerProducer.cc.

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

Member Function Documentation

◆ ComputeTowerVariable()

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

Definition at line 281 of file CastorTowerProducer.cc.

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

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

Referenced by produce().

◆ produce()

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

Definition at line 106 of file CastorTowerProducer.cc.

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

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

Member Data Documentation

◆ maxtime_

double CastorTowerProducer::maxtime_
private

Definition at line 71 of file CastorTowerProducer.cc.

Referenced by produce().

◆ mintime_

double CastorTowerProducer::mintime_
private

Definition at line 70 of file CastorTowerProducer.cc.

Referenced by produce().

◆ tok_input_

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

Definition at line 68 of file CastorTowerProducer.cc.

Referenced by CastorTowerProducer(), and produce().

◆ towercut_

double CastorTowerProducer::towercut_
private

Definition at line 69 of file CastorTowerProducer.cc.

Referenced by produce().

CastorTowerProducer::CastorRecHitRefVector
edm::RefVector< CastorRecHitCollection > CastorRecHitRefVector
Definition: CastorTowerProducer.cc:67
CastorTowerProducer::ComputeTowerVariable
virtual void ComputeTowerVariable(const edm::RefVector< edm::SortedCollection< CastorRecHit > > &usedRecHits, double &Ehot, double &depth)
Definition: CastorTowerProducer.cc:281
mps_fire.i
i
Definition: mps_fire.py:355
module::module
module()
Definition: vlib.cc:913
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
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:68
CastorTowerProducer::maxtime_
double maxtime_
Definition: CastorTowerProducer.cc:71
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:69
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
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
Abs
T Abs(T a)
Definition: MathUtil.h:49
CastorTowerProducer::TowerPoint
ROOT::Math::RhoEtaPhiPoint TowerPoint
Definition: CastorTowerProducer.cc:63
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:670
CastorChannelQualityRcd
Definition: CastorChannelQualityRcd.h:24
CastorTowerProducer::mintime_
double mintime_
Definition: CastorTowerProducer.cc:70
iEvent
int iEvent
Definition: GenABIO.cc:224
module
Definition: vlib.h:198
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443