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)
 
- 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 34 of file EcalTrigPrimProducer.h.

Constructor & Destructor Documentation

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

Definition at line 61 of file EcalTrigPrimProducer.cc.

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

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

Definition at line 194 of file EcalTrigPrimProducer.cc.

195 {}

Member Function Documentation

void EcalTrigPrimProducer::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 89 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.

89  {
90 
91  // get binOfMax
92  // try first in cfg, then in ProductRegistry
93  // =6 is default (1-10 possible values)
94  binOfMaximum_=0; //starts at 1!
95  bool found=false;
96  std::vector<std::string> names = ps_.getParameterNames();
97  if (find(names.begin(), names.end(), std::string("binOfMaximum"))
98  != names.end()) {
99  binOfMaximum_=ps_.getParameter<int>("binOfMaximum");
100  edm::LogInfo("EcalTPG") <<"EcalTrigPrimProducer is using binOfMaximum found in cfg file : "<<binOfMaximum_;
101  found = true;
102  }
103 
105  // Loop over provenance of products in registry.
106  for (edm::ProductRegistry::ProductList::const_iterator it = reg->productList().begin();
107  it != reg->productList().end(); ++it) {
108  edm::BranchDescription desc = it->second;
109  if (desc.friendlyClassName().find("EBDigiCollection")==0 &&
110  desc.moduleLabel()=="ecalUnsuppressedDigis") {
112  if (found ) {
113  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")<<")!!!";
114  }else {
115  binOfMaximum_=result.getParameter<int>("binOfMaximum");
116  edm::LogInfo("EcalTPG") <<"EcalTrigPrimProducer is using binOfMaximum found in ProductRegistry : "<<binOfMaximum_;
117  break;
118  }
119  }
120  }
121 
122 
123  if (binOfMaximum_==0) {
124  binOfMaximum_=6;
125  edm::LogWarning("EcalTPG")<<"Could not find product registry of EBDigiCollection (label ecalUnsuppressedDigis), had to set the following parameters by Hand: binOfMaximum="<<binOfMaximum_;
126  }
127 }
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 76 of file EcalTrigPrimProducer.cc.

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

76  {
77  bool famos = ps_.getParameter<bool>("Famos");
78 
80 
81  // get a first version of the records
82  cacheID_=this->getRecords(setup);
83 }
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 85 of file EcalTrigPrimProducer.cc.

References algo_.

85  {
86  delete algo_;
87 }
EcalTrigPrimFunctionalAlgo * algo_
unsigned long long EcalTrigPrimProducer::getRecords ( edm::EventSetup const &  setup)
private

Definition at line 129 of file EcalTrigPrimProducer.cc.

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

Referenced by beginRun(), and produce().

129  {
130  // get Eventsetup records
131 
132  // for EcalFenixStrip...
133  // get parameter records for xtals
134  edm::ESHandle<EcalTPGLinearizationConst> theEcalTPGLinearization_handle;
135  setup.get<EcalTPGLinearizationConstRcd>().get(theEcalTPGLinearization_handle);
136  const EcalTPGLinearizationConst * ecaltpLin = theEcalTPGLinearization_handle.product();
137  edm::ESHandle<EcalTPGPedestals> theEcalTPGPedestals_handle;
138  setup.get<EcalTPGPedestalsRcd>().get(theEcalTPGPedestals_handle);
139  const EcalTPGPedestals * ecaltpPed = theEcalTPGPedestals_handle.product();
140  edm::ESHandle<EcalTPGCrystalStatus> theEcalTPGCrystalStatus_handle;
141  setup.get<EcalTPGCrystalStatusRcd>().get(theEcalTPGCrystalStatus_handle);
142  const EcalTPGCrystalStatus * ecaltpgBadX = theEcalTPGCrystalStatus_handle.product();
143 
144 
145  //for strips
146  edm::ESHandle<EcalTPGSlidingWindow> theEcalTPGSlidingWindow_handle;
147  setup.get<EcalTPGSlidingWindowRcd>().get(theEcalTPGSlidingWindow_handle);
148  const EcalTPGSlidingWindow * ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product();
149  edm::ESHandle<EcalTPGWeightIdMap> theEcalTPGWEightIdMap_handle;
150  setup.get<EcalTPGWeightIdMapRcd>().get(theEcalTPGWEightIdMap_handle);
151  const EcalTPGWeightIdMap * ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product();
152  edm::ESHandle<EcalTPGWeightGroup> theEcalTPGWEightGroup_handle;
153  setup.get<EcalTPGWeightGroupRcd>().get(theEcalTPGWEightGroup_handle);
154  const EcalTPGWeightGroup * ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product();
155  edm::ESHandle<EcalTPGFineGrainStripEE> theEcalTPGFineGrainStripEE_handle;
156  setup.get<EcalTPGFineGrainStripEERcd>().get(theEcalTPGFineGrainStripEE_handle);
157  const EcalTPGFineGrainStripEE * ecaltpgFgStripEE = theEcalTPGFineGrainStripEE_handle.product();
158 
159  algo_->setPointers(ecaltpLin,ecaltpPed,ecaltpgSlidW,ecaltpgWeightMap,ecaltpgWeightGroup,ecaltpgFgStripEE,ecaltpgBadX);
160 
161  // .. and for EcalFenixTcp
162  // get parameter records for towers
163  edm::ESHandle<EcalTPGFineGrainEBGroup> theEcalTPGFineGrainEBGroup_handle;
164  setup.get<EcalTPGFineGrainEBGroupRcd>().get(theEcalTPGFineGrainEBGroup_handle);
165  const EcalTPGFineGrainEBGroup * ecaltpgFgEBGroup = theEcalTPGFineGrainEBGroup_handle.product();
166 
167  edm::ESHandle<EcalTPGLutGroup> theEcalTPGLutGroup_handle;
168  setup.get<EcalTPGLutGroupRcd>().get(theEcalTPGLutGroup_handle);
169  const EcalTPGLutGroup * ecaltpgLutGroup = theEcalTPGLutGroup_handle.product();
170 
171  edm::ESHandle<EcalTPGLutIdMap> theEcalTPGLutIdMap_handle;
172  setup.get<EcalTPGLutIdMapRcd>().get(theEcalTPGLutIdMap_handle);
173  const EcalTPGLutIdMap * ecaltpgLut = theEcalTPGLutIdMap_handle.product();
174 
175  edm::ESHandle<EcalTPGFineGrainEBIdMap> theEcalTPGFineGrainEBIdMap_handle;
176  setup.get<EcalTPGFineGrainEBIdMapRcd>().get(theEcalTPGFineGrainEBIdMap_handle);
177  const EcalTPGFineGrainEBIdMap * ecaltpgFineGrainEB = theEcalTPGFineGrainEBIdMap_handle.product();
178 
179  edm::ESHandle<EcalTPGFineGrainTowerEE> theEcalTPGFineGrainTowerEE_handle;
180  setup.get<EcalTPGFineGrainTowerEERcd>().get(theEcalTPGFineGrainTowerEE_handle);
181  const EcalTPGFineGrainTowerEE * ecaltpgFineGrainTowerEE = theEcalTPGFineGrainTowerEE_handle.product();
182 
183  edm::ESHandle<EcalTPGTowerStatus> theEcalTPGTowerStatus_handle;
184  setup.get<EcalTPGTowerStatusRcd>().get(theEcalTPGTowerStatus_handle);
185  const EcalTPGTowerStatus * ecaltpgBadTT = theEcalTPGTowerStatus_handle.product();
186 
187 
188  algo_->setPointers2(ecaltpgFgEBGroup,ecaltpgLutGroup,ecaltpgLut,ecaltpgFineGrainEB,ecaltpgFineGrainTowerEE,ecaltpgBadTT);
189 
190  // we will suppose that everything is to be updated if the EcalTPGLinearizationConstRcd has changed
191  return setup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
192 }
EcalTrigPrimFunctionalAlgo * algo_
void setPointers(const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGPedestals *ecaltpPed, const EcalTPGSlidingWindow *ecaltpgSlidW, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup, const EcalTPGFineGrainStripEE *ecaltpgFgStripEE, const EcalTPGCrystalStatus *ecaltpgBadX)
void setPointers2(const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB, const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE, const EcalTPGTowerStatus *ecaltpgBadTT)
T const * product() const
Definition: ESHandle.h:62
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 200 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_.

201 {
202 
203  // update constants if necessary
204  if (iSetup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier()!=cacheID_) cacheID_=this->getRecords(iSetup);
205 
206  // get input collections
207 
210  bool barrel=true;
211  bool endcap=true;
212  if (barrelOnly_) endcap=false;
213 
214  if (!e.getByLabel(label_,instanceNameEB_,ebDigis)) {
215  barrel=false;
216  edm::LogWarning("EcalTPG") <<" Couldnt find Barrel dataframes with producer "<<label_<<" and label "<<instanceNameEB_<<"!!!";
217  }
218  if (!barrelOnly_) {
219  if (!e.getByLabel(label_,instanceNameEE_,eeDigis)) {
220  endcap=false;
221  edm::LogWarning("EcalTPG") <<" Couldnt find Endcap dataframes with producer "<<label_<<" and label "<<instanceNameEE_<<"!!!";
222  }
223  }
224  if (!barrel && !endcap) {
225  throw cms::Exception(" ProductNotFound") <<"No EBDataFrames(EEDataFrames) with producer "<<label_<<" and label "<<instanceNameEB_<<" found in input!!\n";
226  }
227 
228  if (!barrelOnly_) LogDebug("EcalTPG") <<" =================> Treating event "<<e.id()<<", Number of EBDataFrames "<<ebDigis.product()->size()<<", Number of EEDataFrames "<<eeDigis.product()->size() ;
229  else LogDebug("EcalTPG") <<" =================> Treating event "<<e.id()<<", Number of EBDataFrames "<<ebDigis.product()->size();
230 
231  std::auto_ptr<EcalTrigPrimDigiCollection> pOut(new EcalTrigPrimDigiCollection);
232  std::auto_ptr<EcalTrigPrimDigiCollection> pOutTcp(new EcalTrigPrimDigiCollection);
233 
234 
235  // invoke algorithm
236 
237  const EBDigiCollection *ebdc=NULL;
238  const EEDigiCollection *eedc=NULL;
239  if (barrel) {
240  ebdc=ebDigis.product();
241  algo_->run(iSetup,ebdc,*pOut,*pOutTcp);
242  }
243 
244  if (endcap) {
245  eedc=eeDigis.product();
246  algo_->run(iSetup,eedc,*pOut,*pOutTcp);
247  }
248 
249  edm::LogInfo("produce") <<"For Barrel + Endcap, "<<pOut->size()<<" TP Digis were produced";
250 
251  // debug prints if TP >0
252 
253  for (unsigned int i=0;i<pOut->size();++i) {
254  bool print=false;
255  for (int isam=0;isam<(*pOut)[i].size();++isam) {
256  if ((*pOut)[i][isam].raw()) print=true;
257  }
258  if (print) LogDebug("EcalTPG") <<" For tower "<<(((*pOut)[i])).id()<<", TP is "<<(*pOut)[i];
259  }
260  if (barrelOnly_) LogDebug("EcalTPG") <<"\n =================> For Barrel , "<<pOut->size()<<" TP Digis were produced (including zero ones)";
261  else LogDebug("EcalTPG") <<"\n =================> For Barrel + Endcap, "<<pOut->size()<<" TP Digis were produced (including zero ones)";
262 
263  // put result into the Event
264 
265  e.put(pOut);
266  if (tcpFormat_) e.put(pOutTcp,"formatTCP");
267 }
#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:84
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:355
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 48 of file EcalTrigPrimProducer.h.

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

bool EcalTrigPrimProducer::barrelOnly_
private

Definition at line 50 of file EcalTrigPrimProducer.h.

Referenced by beginRun(), and produce().

int EcalTrigPrimProducer::binOfMaximum_
private

Definition at line 57 of file EcalTrigPrimProducer.h.

Referenced by beginJob(), and beginRun().

unsigned long long EcalTrigPrimProducer::cacheID_
private

Definition at line 63 of file EcalTrigPrimProducer.h.

Referenced by beginRun(), and produce().

bool EcalTrigPrimProducer::debug_
private

Definition at line 52 of file EcalTrigPrimProducer.h.

Referenced by beginRun().

TFile* EcalTrigPrimProducer::histfile_
private

Definition at line 49 of file EcalTrigPrimProducer.h.

std::string EcalTrigPrimProducer::instanceNameEB_
private

Definition at line 54 of file EcalTrigPrimProducer.h.

Referenced by EcalTrigPrimProducer(), and produce().

std::string EcalTrigPrimProducer::instanceNameEE_
private

Definition at line 55 of file EcalTrigPrimProducer.h.

Referenced by EcalTrigPrimProducer(), and produce().

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

Definition at line 59 of file EcalTrigPrimProducer.h.

Referenced by beginJob(), and beginRun().

bool EcalTrigPrimProducer::tcpFormat_
private

Definition at line 51 of file EcalTrigPrimProducer.h.

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