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 Member Functions | Private Attributes
EcalTrigPrimProducer Class Reference

#include <EcalTrigPrimProducer.h>

Inheritance diagram for EcalTrigPrimProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

void beginJob ()
 
void beginRun (edm::Run &run, const edm::EventSetup &es)
 
 EcalTrigPrimProducer (const edm::ParameterSet &conf)
 
void endRun (edm::Run &, const edm::EventSetup &)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
virtual ~EcalTrigPrimProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

unsigned long long getRecords (edm::EventSetup const &setup)
 

Private Attributes

EcalTrigPrimFunctionalAlgoalgo_
 
bool barrelOnly_
 
int binOfMaximum_
 
unsigned long long cacheID_
 
bool debug_
 
TFile * histfile_
 
std::string instanceNameEB_
 
std::string instanceNameEE_
 
std::string label_
 
const edm::ParameterSet ps_
 
bool tcpFormat_
 

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
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

EcalTrigPrimProducer produces a EcalTrigPrimDigiCollection The barrel code does a detailed simulation The code for the endcap is simulated in a rough way, due to missing strip geometry

Author
Ursula Berthon, Stephanie Baffioni, LLR Palaiseau
Version
1st Version may 2006
2nd Version jul 2006

EcalTrigPrimProducer produces a EcalTrigPrimDigiCollection Simulation as close as possible to hardware Main algorithm is EcalTrigPrimFunctionalAlgo which is now templated to take EBdataFrames/EEDataFrames as input

Author
Ursula Berthon, Stephanie Baffioni, Pascal Paganini, LLR Palaiseau
Version
1st Version may 2006
2nd Version jul 2006
3rd Version nov 2006
4th Version apr 2007 full endcap

Definition at line 33 of file EcalTrigPrimProducer.h.

Constructor & Destructor Documentation

EcalTrigPrimProducer::EcalTrigPrimProducer ( const edm::ParameterSet conf)
explicit

Definition at line 65 of file EcalTrigPrimProducer.cc.

References algo_, edm::ParameterSet::getParameter(), instanceNameEB_, instanceNameEE_, label_, NULL, and tcpFormat_.

65  :
66  barrelOnly_(iConfig.getParameter<bool>("BarrelOnly")),
67  tcpFormat_(iConfig.getParameter<bool>("TcpOutput")),
68  debug_(iConfig.getParameter<bool>("Debug")),ps_(iConfig)
69 {
70  //register your products
71  produces <EcalTrigPrimDigiCollection >();
72  if (tcpFormat_) produces <EcalTrigPrimDigiCollection >("formatTCP");
73 
74  label_= iConfig.getParameter<std::string>("Label");
75  instanceNameEB_ = iConfig.getParameter<std::string>("InstanceEB");;
76  instanceNameEE_ = iConfig.getParameter<std::string>("InstanceEE");;
77  algo_=NULL;
78 }
EcalTrigPrimFunctionalAlgo * algo_
#define NULL
Definition: scimark2.h:8
const edm::ParameterSet ps_
EcalTrigPrimProducer::~EcalTrigPrimProducer ( )
virtual

Definition at line 204 of file EcalTrigPrimProducer.cc.

205 {}

Member Function Documentation

void EcalTrigPrimProducer::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 93 of file EcalTrigPrimProducer.cc.

References binOfMaximum_, spr::find(), newFWLiteAna::found, edm::BranchDescription::friendlyClassName(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::getParameterSet(), edm::BranchDescription::moduleLabel(), h::names, edm::ConstProductRegistry::productList(), ps_, edm::BranchDescription::psetID(), and query::result.

93  {
94 
95  // get binOfMax
96  // try first in cfg, then in ProductRegistry
97  // =6 is default (1-10 possible values)
98  binOfMaximum_=0; //starts at 1!
99  bool found=false;
100  std::vector<std::string> names = ps_.getParameterNames();
101  if (find(names.begin(), names.end(), std::string("binOfMaximum"))
102  != names.end()) {
103  binOfMaximum_=ps_.getParameter<int>("binOfMaximum");
104  edm::LogInfo("EcalTPG") <<"EcalTrigPrimProducer is using binOfMaximum found in cfg file : "<<binOfMaximum_;
105  found = true;
106  }
107 
109  // Loop over provenance of products in registry.
110  for (edm::ProductRegistry::ProductList::const_iterator it = reg->productList().begin();
111  it != reg->productList().end(); ++it) {
112  edm::BranchDescription desc = it->second;
113  if (desc.friendlyClassName().find("EBDigiCollection")==0 &&
114  desc.moduleLabel()=="ecalUnsuppressedDigis") {
116  if (found ) {
117  if ( result.getParameter<int>("binOfMaximum")!=binOfMaximum_)edm:: LogWarning("EcalTPG")<< "binofMaximum given in configuration (="<<binOfMaximum_<<") is different from the one found in ProductRegistration(="<<result.getParameter<int>("binOfMaximum")<<")!!!";
118  }else {
119  binOfMaximum_=result.getParameter<int>("binOfMaximum");
120  edm::LogInfo("EcalTPG") <<"EcalTrigPrimProducer is using binOfMaximum found in ProductRegistry : "<<binOfMaximum_;
121  break;
122  }
123  }
124  }
125 
126 
127  if (binOfMaximum_==0) {
128  binOfMaximum_=6;
129  edm::LogWarning("EcalTPG")<<"Could not find product registry of EBDigiCollection (label ecalUnsuppressedDigis), had to set the following parameters by Hand: binOfMaximum="<<binOfMaximum_;
130  }
131 }
T getParameter(std::string const &) const
ParameterSet const & getParameterSet(ParameterSetID const &id)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
ParameterSetID const & psetID() const
std::string const & moduleLabel() const
tuple result
Definition: query.py:137
std::string const & friendlyClassName() const
std::vector< std::string > getParameterNames() const
const edm::ParameterSet ps_
static const HistoName names[]
ProductList const & productList() const
void EcalTrigPrimProducer::beginRun ( edm::Run run,
const edm::EventSetup es 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 80 of file EcalTrigPrimProducer.cc.

References algo_, barrelOnly_, binOfMaximum_, cacheID_, debug_, edm::ParameterSet::getParameter(), getRecords(), ps_, and tcpFormat_.

80  {
81  bool famos = ps_.getParameter<bool>("Famos");
82 
84 
85  // get a first version of the records
86  cacheID_=this->getRecords(setup);
87 }
T getParameter(std::string const &) const
EcalTrigPrimFunctionalAlgo * algo_
unsigned long long cacheID_
unsigned long long getRecords(edm::EventSetup const &setup)
const edm::ParameterSet ps_
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void EcalTrigPrimProducer::endRun ( edm::Run run,
const edm::EventSetup setup 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 89 of file EcalTrigPrimProducer.cc.

References algo_.

89  {
90  delete algo_;
91 }
EcalTrigPrimFunctionalAlgo * algo_
unsigned long long EcalTrigPrimProducer::getRecords ( edm::EventSetup const &  setup)
private

Definition at line 133 of file EcalTrigPrimProducer.cc.

References algo_, edm::EventSetup::get(), edm::ESHandle< class >::product(), EcalTrigPrimFunctionalAlgo::setPointers(), and EcalTrigPrimFunctionalAlgo::setPointers2().

Referenced by beginRun(), and produce().

133  {
134  // get Eventsetup records
135 
136  // for EcalFenixStrip...
137  // get parameter records for xtals
138  edm::ESHandle<EcalTPGLinearizationConst> theEcalTPGLinearization_handle;
139  setup.get<EcalTPGLinearizationConstRcd>().get(theEcalTPGLinearization_handle);
140  const EcalTPGLinearizationConst * ecaltpLin = theEcalTPGLinearization_handle.product();
141  edm::ESHandle<EcalTPGPedestals> theEcalTPGPedestals_handle;
142  setup.get<EcalTPGPedestalsRcd>().get(theEcalTPGPedestals_handle);
143  const EcalTPGPedestals * ecaltpPed = theEcalTPGPedestals_handle.product();
144  edm::ESHandle<EcalTPGCrystalStatus> theEcalTPGCrystalStatus_handle;
145  setup.get<EcalTPGCrystalStatusRcd>().get(theEcalTPGCrystalStatus_handle);
146  const EcalTPGCrystalStatus * ecaltpgBadX = theEcalTPGCrystalStatus_handle.product();
147 
148 
149  //for strips
150  edm::ESHandle<EcalTPGSlidingWindow> theEcalTPGSlidingWindow_handle;
151  setup.get<EcalTPGSlidingWindowRcd>().get(theEcalTPGSlidingWindow_handle);
152  const EcalTPGSlidingWindow * ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product();
153  edm::ESHandle<EcalTPGWeightIdMap> theEcalTPGWEightIdMap_handle;
154  setup.get<EcalTPGWeightIdMapRcd>().get(theEcalTPGWEightIdMap_handle);
155  const EcalTPGWeightIdMap * ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product();
156  edm::ESHandle<EcalTPGWeightGroup> theEcalTPGWEightGroup_handle;
157  setup.get<EcalTPGWeightGroupRcd>().get(theEcalTPGWEightGroup_handle);
158  const EcalTPGWeightGroup * ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product();
159  edm::ESHandle<EcalTPGFineGrainStripEE> theEcalTPGFineGrainStripEE_handle;
160  setup.get<EcalTPGFineGrainStripEERcd>().get(theEcalTPGFineGrainStripEE_handle);
161  const EcalTPGFineGrainStripEE * ecaltpgFgStripEE = theEcalTPGFineGrainStripEE_handle.product();
162  edm::ESHandle<EcalTPGStripStatus> theEcalTPGStripStatus_handle;
163  setup.get<EcalTPGStripStatusRcd>().get(theEcalTPGStripStatus_handle);
164  const EcalTPGStripStatus * ecaltpgStripStatus = theEcalTPGStripStatus_handle.product();
165 
166  algo_->setPointers(ecaltpLin,ecaltpPed,ecaltpgSlidW,ecaltpgWeightMap,ecaltpgWeightGroup,ecaltpgFgStripEE,ecaltpgBadX,ecaltpgStripStatus);
167 
168  // .. and for EcalFenixTcp
169  // get parameter records for towers
170  edm::ESHandle<EcalTPGFineGrainEBGroup> theEcalTPGFineGrainEBGroup_handle;
171  setup.get<EcalTPGFineGrainEBGroupRcd>().get(theEcalTPGFineGrainEBGroup_handle);
172  const EcalTPGFineGrainEBGroup * ecaltpgFgEBGroup = theEcalTPGFineGrainEBGroup_handle.product();
173 
174  edm::ESHandle<EcalTPGLutGroup> theEcalTPGLutGroup_handle;
175  setup.get<EcalTPGLutGroupRcd>().get(theEcalTPGLutGroup_handle);
176  const EcalTPGLutGroup * ecaltpgLutGroup = theEcalTPGLutGroup_handle.product();
177 
178  edm::ESHandle<EcalTPGLutIdMap> theEcalTPGLutIdMap_handle;
179  setup.get<EcalTPGLutIdMapRcd>().get(theEcalTPGLutIdMap_handle);
180  const EcalTPGLutIdMap * ecaltpgLut = theEcalTPGLutIdMap_handle.product();
181 
182  edm::ESHandle<EcalTPGFineGrainEBIdMap> theEcalTPGFineGrainEBIdMap_handle;
183  setup.get<EcalTPGFineGrainEBIdMapRcd>().get(theEcalTPGFineGrainEBIdMap_handle);
184  const EcalTPGFineGrainEBIdMap * ecaltpgFineGrainEB = theEcalTPGFineGrainEBIdMap_handle.product();
185 
186  edm::ESHandle<EcalTPGFineGrainTowerEE> theEcalTPGFineGrainTowerEE_handle;
187  setup.get<EcalTPGFineGrainTowerEERcd>().get(theEcalTPGFineGrainTowerEE_handle);
188  const EcalTPGFineGrainTowerEE * ecaltpgFineGrainTowerEE = theEcalTPGFineGrainTowerEE_handle.product();
189 
190  edm::ESHandle<EcalTPGTowerStatus> theEcalTPGTowerStatus_handle;
191  setup.get<EcalTPGTowerStatusRcd>().get(theEcalTPGTowerStatus_handle);
192  const EcalTPGTowerStatus * ecaltpgBadTT = theEcalTPGTowerStatus_handle.product();
193 
194  edm::ESHandle<EcalTPGSpike> theEcalTPGSpike_handle;
195  setup.get<EcalTPGSpikeRcd>().get(theEcalTPGSpike_handle);
196  const EcalTPGSpike * ecaltpgSpike = theEcalTPGSpike_handle.product();
197 
198  algo_->setPointers2(ecaltpgFgEBGroup,ecaltpgLutGroup,ecaltpgLut,ecaltpgFineGrainEB,ecaltpgFineGrainTowerEE,ecaltpgBadTT,ecaltpgSpike);
199 
200  // we will suppose that everything is to be updated if the EcalTPGLinearizationConstRcd has changed
201  return setup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
202 }
void setPointers2(const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB, const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE, const EcalTPGTowerStatus *ecaltpgBadTT, const EcalTPGSpike *ecaltpgSpike)
EcalTrigPrimFunctionalAlgo * algo_
T const * product() const
Definition: ESHandle.h:62
void setPointers(const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGPedestals *ecaltpPed, const EcalTPGSlidingWindow *ecaltpgSlidW, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup, const EcalTPGFineGrainStripEE *ecaltpgFgStripEE, const EcalTPGCrystalStatus *ecaltpgBadX, const EcalTPGStripStatus *ecaltpgStripStatus)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void EcalTrigPrimProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDProducer.

Definition at line 210 of file EcalTrigPrimProducer.cc.

References algo_, Reference_intrackfit_cff::barrel, barrelOnly_, cacheID_, edm::eventsetup::EventSetupRecord::cacheIdentifier(), Reference_intrackfit_cff::endcap, edm::hlt::Exception, edm::EventSetup::get(), edm::Event::getByLabel(), getRecords(), i, edm::EventBase::id(), instanceNameEB_, instanceNameEE_, label_, LogDebug, NULL, reco::print(), edm::Handle< T >::product(), edm::Event::put(), EcalTrigPrimFunctionalAlgo::run(), and tcpFormat_.

211 {
212 
213  // update constants if necessary
214  if (iSetup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier()!=cacheID_) cacheID_=this->getRecords(iSetup);
215 
216  // get input collections
217 
220  bool barrel=true;
221  bool endcap=true;
222  if (barrelOnly_) endcap=false;
223 
224  if (!e.getByLabel(label_,instanceNameEB_,ebDigis)) {
225  barrel=false;
226  edm::LogWarning("EcalTPG") <<" Couldnt find Barrel dataframes with producer "<<label_<<" and label "<<instanceNameEB_<<"!!!";
227  }
228  if (!barrelOnly_) {
229  if (!e.getByLabel(label_,instanceNameEE_,eeDigis)) {
230  endcap=false;
231  edm::LogWarning("EcalTPG") <<" Couldnt find Endcap dataframes with producer "<<label_<<" and label "<<instanceNameEE_<<"!!!";
232  }
233  }
234  if (!barrel && !endcap) {
235  throw cms::Exception(" ProductNotFound") <<"No EBDataFrames(EEDataFrames) with producer "<<label_<<" and label "<<instanceNameEB_<<" found in input!!\n";
236  }
237 
238  if (!barrelOnly_) LogDebug("EcalTPG") <<" =================> Treating event "<<e.id()<<", Number of EBDataFrames "<<ebDigis.product()->size()<<", Number of EEDataFrames "<<eeDigis.product()->size() ;
239  else LogDebug("EcalTPG") <<" =================> Treating event "<<e.id()<<", Number of EBDataFrames "<<ebDigis.product()->size();
240 
241  std::auto_ptr<EcalTrigPrimDigiCollection> pOut(new EcalTrigPrimDigiCollection);
242  std::auto_ptr<EcalTrigPrimDigiCollection> pOutTcp(new EcalTrigPrimDigiCollection);
243 
244 
245  // invoke algorithm
246 
247  const EBDigiCollection *ebdc=NULL;
248  const EEDigiCollection *eedc=NULL;
249  if (barrel) {
250  ebdc=ebDigis.product();
251  algo_->run(iSetup,ebdc,*pOut,*pOutTcp);
252  }
253 
254  if (endcap) {
255  eedc=eeDigis.product();
256  algo_->run(iSetup,eedc,*pOut,*pOutTcp);
257  }
258 
259  edm::LogInfo("produce") <<"For Barrel + Endcap, "<<pOut->size()<<" TP Digis were produced";
260 
261  // debug prints if TP >0
262 
263  for (unsigned int i=0;i<pOut->size();++i) {
264  bool print=false;
265  for (int isam=0;isam<(*pOut)[i].size();++isam) {
266  if ((*pOut)[i][isam].raw()) print=true;
267  }
268  if (print) LogDebug("EcalTPG") <<" For tower "<<(((*pOut)[i])).id()<<", TP is "<<(*pOut)[i];
269  }
270  if (barrelOnly_) LogDebug("EcalTPG") <<"\n =================> For Barrel , "<<pOut->size()<<" TP Digis were produced (including zero ones)";
271  else LogDebug("EcalTPG") <<"\n =================> For Barrel + Endcap, "<<pOut->size()<<" TP Digis were produced (including zero ones)";
272 
273  // put result into the Event
274 
275  e.put(pOut);
276  if (tcpFormat_) e.put(pOutTcp,"formatTCP");
277 }
#define LogDebug(id)
unsigned long long cacheIdentifier() const
int i
Definition: DBlmapReader.cc:9
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:8
EcalTrigPrimFunctionalAlgo * algo_
#define NULL
Definition: scimark2.h:8
unsigned long long cacheID_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void run(const edm::EventSetup &, const EBDigiCollection *col, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp)
unsigned long long getRecords(edm::EventSetup const &setup)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
T const * product() const
Definition: Handle.h:74
edm::EventID id() const
Definition: EventBase.h:56

Member Data Documentation

EcalTrigPrimFunctionalAlgo* EcalTrigPrimProducer::algo_
private

Definition at line 47 of file EcalTrigPrimProducer.h.

Referenced by beginRun(), EcalTrigPrimProducer(), endRun(), getRecords(), and produce().

bool EcalTrigPrimProducer::barrelOnly_
private

Definition at line 49 of file EcalTrigPrimProducer.h.

Referenced by beginRun(), and produce().

int EcalTrigPrimProducer::binOfMaximum_
private

Definition at line 56 of file EcalTrigPrimProducer.h.

Referenced by beginJob(), and beginRun().

unsigned long long EcalTrigPrimProducer::cacheID_
private

Definition at line 62 of file EcalTrigPrimProducer.h.

Referenced by beginRun(), and produce().

bool EcalTrigPrimProducer::debug_
private

Definition at line 51 of file EcalTrigPrimProducer.h.

Referenced by beginRun().

TFile* EcalTrigPrimProducer::histfile_
private

Definition at line 48 of file EcalTrigPrimProducer.h.

std::string EcalTrigPrimProducer::instanceNameEB_
private

Definition at line 53 of file EcalTrigPrimProducer.h.

Referenced by EcalTrigPrimProducer(), and produce().

std::string EcalTrigPrimProducer::instanceNameEE_
private

Definition at line 54 of file EcalTrigPrimProducer.h.

Referenced by EcalTrigPrimProducer(), and produce().

std::string EcalTrigPrimProducer::label_
private
const edm::ParameterSet EcalTrigPrimProducer::ps_
private

Definition at line 58 of file EcalTrigPrimProducer.h.

Referenced by beginJob(), and beginRun().

bool EcalTrigPrimProducer::tcpFormat_
private

Definition at line 50 of file EcalTrigPrimProducer.h.

Referenced by beginRun(), EcalTrigPrimProducer(), and produce().