CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CastorTowerProducer (const edm::ParameterSet &)
 
 ~CastorTowerProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef edm::SortedCollection
< CastorRecHit
CastorRecHitCollection
 
typedef edm::RefVector
< CastorRecHitCollection
CastorRecHitRefVector
 
typedef std::vector
< reco::CastorTower
CastorTowerCollection
 
typedef ROOT::Math::RhoZPhiPoint CellPoint
 
typedef math::XYZPointD Point
 
typedef ROOT::Math::RhoEtaPhiPoint TowerPoint
 

Private Member Functions

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

Private Attributes

std::string input_
 
double maxtime_
 
double mintime_
 
double towercut_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 52 of file CastorTowerProducer.cc.

Member Typedef Documentation

Definition at line 67 of file CastorTowerProducer.cc.

Definition at line 69 of file CastorTowerProducer.cc.

Definition at line 68 of file CastorTowerProducer.cc.

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

Definition at line 66 of file CastorTowerProducer.cc.

Definition at line 64 of file CastorTowerProducer.cc.

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

Definition at line 65 of file CastorTowerProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 90 of file CastorTowerProducer.cc.

90  :
91  input_(iConfig.getParameter<std::string>("inputprocess")),
92  towercut_(iConfig.getParameter<double>("towercut")),
93  mintime_(iConfig.getParameter<double>("mintime")),
94  maxtime_(iConfig.getParameter<double>("maxtime"))
95 {
96  //register your products
97  produces<CastorTowerCollection>();
98  //now do what ever other initialization is needed
99 }
T getParameter(std::string const &) const
CastorTowerProducer::~CastorTowerProducer ( )

Definition at line 102 of file CastorTowerProducer.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 CastorTowerProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 272 of file CastorTowerProducer.cc.

References LogDebug.

272  {
273  LogDebug("CastorTowerProducer")
274  <<"Starting CastorTowerProducer";
275 }
#define LogDebug(id)
void CastorTowerProducer::ComputeTowerVariable ( const edm::RefVector< edm::SortedCollection< CastorRecHit > > &  usedRecHits,
double &  Ehot,
double &  depth 
)
privatevirtual

Definition at line 283 of file CastorTowerProducer.cc.

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

Referenced by produce().

283  {
284 
285  using namespace reco;
286 
287  double Etot = 0;
288 
289  // loop over the cells used in the tower k
290  for (CastorRecHitRefVector::iterator it = usedRecHits.begin(); it != usedRecHits.end(); it++) {
291  edm::Ref<CastorRecHitCollection> rechit_p = *it;
292 
293  double Erechit = rechit_p->energy();
294  HcalCastorDetId id = rechit_p->id();
295  int module = id.module();
296  double zrechit = 0;
297  if (module < 3) zrechit = -14390 - 24.75 - 49.5*(module-1);
298  if (module > 2) zrechit = -14390 - 99 - 49.5 - 99*(module-3);
299 
300  if(Erechit > Ehot) Ehot = Erechit;
301  depth+=Erechit*zrechit;
302  Etot+=Erechit;
303  }
304 
305  depth/=Etot;
306  Ehot/=Etot;
307 }
module()
Definition: vlib.cc:994
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
refhelper::RefVectorTrait< CastorRecHitCollection, T, F >::iterator_type iterator
Definition: RefVector.h:40
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
Definition: vlib.h:209
void CastorTowerProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 278 of file CastorTowerProducer.cc.

References LogDebug.

278  {
279  LogDebug("CastorTowerProducer")
280  <<"Ending CastorTowerProducer";
281 }
#define LogDebug(id)
void CastorTowerProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 114 of file CastorTowerProducer.cc.

References cond::ecalcond::bad(), ComputeTowerVariable(), edm::EventSetup::get(), edm::Event::getByLabel(), i, edm::Ref< C, T, F >::id(), input_, j, gen::k, LogDebug, maxtime_, mintime_, module::module(), AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), DetId::rawId(), L1Trigger_dataformats::reco, findQualityFiles::size, mathSSE::sqrt(), and towercut_.

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

Member Data Documentation

std::string CastorTowerProducer::input_
private

Definition at line 70 of file CastorTowerProducer.cc.

Referenced by produce().

double CastorTowerProducer::maxtime_
private

Definition at line 73 of file CastorTowerProducer.cc.

Referenced by produce().

double CastorTowerProducer::mintime_
private

Definition at line 72 of file CastorTowerProducer.cc.

Referenced by produce().

double CastorTowerProducer::towercut_
private

Definition at line 71 of file CastorTowerProducer.cc.

Referenced by produce().