CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
EcalRawToRecHitProducer Class Reference

#include <EventFilter/EcalRawToRecHitProducer/src/EcalRawToRecHitProducer.cc>

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

Public Types

typedef edm::LazyGetter
< EcalRecHit
EcalRecHitLazyGetter
 
typedef edm::RefGetter
< EcalRecHit
EcalRecHitRefGetter
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

 EcalRawToRecHitProducer (const edm::ParameterSet &)
 
 ~EcalRawToRecHitProducer ()
 
- 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

virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

EcalCleaningAlgocleaningAlgo_
 
std::string EBrechitCollection_
 
std::string EErechitCollection_
 
edm::InputTag lsourceTag_
 
std::string rechitCollection_
 
edm::InputTag sourceTag_
 
bool splitOutput_
 

Additional Inherited Members

- 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

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 55 of file EcalRawToRecHitProducer.h.

Member Typedef Documentation

Definition at line 58 of file EcalRawToRecHitProducer.h.

Definition at line 59 of file EcalRawToRecHitProducer.h.

Constructor & Destructor Documentation

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

Definition at line 4 of file EcalRawToRecHitProducer.cc.

References cleaningAlgo_, EBrechitCollection_, EErechitCollection_, edm::ParameterSet::empty(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), LogDebug, lsourceTag_, rechitCollection_, sourceTag_, and splitOutput_.

5 {
6  lsourceTag_=iConfig.getParameter<edm::InputTag>("lazyGetterTag");
7  sourceTag_=iConfig.getParameter<edm::InputTag>("sourceTag");
8 
9  splitOutput_=iConfig.getParameter<bool>("splitOutput");
10  if (splitOutput_){
11  EBrechitCollection_=iConfig.getParameter<std::string>("EBrechitCollection");
12  EErechitCollection_=iConfig.getParameter<std::string>("EErechitCollection");
13  produces<EBRecHitCollection>(EBrechitCollection_);
14  produces<EERecHitCollection>(EErechitCollection_);
15  LogDebug("EcalRawToRecHit|Producer")<<"ready to create rechits from lazy getter: "<<lsourceTag_
16  <<"\n using region ref from: "<<sourceTag_
17  <<"\n splitting in two collections"
18  <<"\n EB instance: "<<EBrechitCollection_
19  <<"\n EE instance: "<<EErechitCollection_;
20  }
21  else{
22  rechitCollection_=iConfig.getParameter<std::string>("rechitCollection");
23  produces<EcalRecHitCollection>(rechitCollection_);
24  LogDebug("EcalRawToRecHit|Producer")<<"ready to create rechits from lazy getter: "<<lsourceTag_
25  <<"\n using region ref from: "<<sourceTag_
26  <<"\n not splitting the output collection.";
27  }
28 
29  cleaningAlgo_=0;
30  if (iConfig.exists("cleaningConfig")){
31  const edm::ParameterSet & cleaning=iConfig.getParameter<edm::ParameterSet>("cleaningConfig");
32  if (!cleaning.empty())
33  cleaningAlgo_ = new EcalCleaningAlgo(cleaning);
34  }
35 }
#define LogDebug(id)
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:213
bool exists(std::string const &parameterName) const
checks if a parameter exists
EcalCleaningAlgo * cleaningAlgo_
EcalRawToRecHitProducer::~EcalRawToRecHitProducer ( )

Definition at line 38 of file EcalRawToRecHitProducer.cc.

References cleaningAlgo_.

39 {
40  if (cleaningAlgo_) delete cleaningAlgo_;
41 }
EcalCleaningAlgo * cleaningAlgo_

Member Function Documentation

void EcalRawToRecHitProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 50 of file EcalRawToRecHitProducer.cc.

References cleaningAlgo_, cond::rpcobgas::detid, EBrechitCollection_, EErechitCollection_, edm::Event::getByLabel(), MyWatcher::lap(), LogDebug, lsourceTag_, edm::Event::put(), rechitCollection_, EcalCleaningAlgo::setFlags(), sourceTag_, splitOutput_, and DetId::subdetId().

Referenced by python.JSONExport.JsonExport::export(), and python.HTMLExport.HTMLExport::export().

51 {
52  using namespace edm;
53 
54  MyWatcher watcher("Producer");
55  LogDebug("EcalRawToRecHit|Producer")<<watcher.lap();
56 
57  //retrieve a lazygetter
59  iEvent.getByLabel(lsourceTag_, lgetter);
60  LogDebug("EcalRawToRecHit|Producer")<<"lazy getter retreived from: "<<lsourceTag_<<(lgetter.failedToGet()?" not valid ":"valid")
61  <<watcher.lap();
62 
63  //retrieve a refgetter
65  iEvent.getByLabel(sourceTag_ ,rgetter);
66  LogDebug("EcalRawToRecHit|Producer")<<"ref getter retreived from: "<<sourceTag_<<(rgetter.failedToGet()?" not valid ":"valid")
67  <<watcher.lap();
68 
69 
70  if (splitOutput_){
71  //prepare the output collection
72  std::auto_ptr<EBRecHitCollection> EBrechits( new EBRecHitCollection );
73  std::auto_ptr<EERecHitCollection> EErechits( new EERecHitCollection );
74  //loop the refgetter
75  unsigned int iR=0;
76  EcalRecHitRefGetter::const_iterator iRegion=rgetter->begin();
77  EcalRecHitRefGetter::const_iterator iRegionEnd=rgetter->end();
78  for (;iRegion!=iRegionEnd;++iRegion){
79  LogDebug("EcalRawToRecHit|Producer")<<"looping over refgetter region: "<<iR<<watcher.lap();
80  std::vector<EcalRecHit>::const_iterator iRecHit=lgetter->begin_record()+iRegion->start();
81  std::vector<EcalRecHit>::const_iterator iRecHitEnd =lgetter->begin_record()+iRegion->finish();
82  for (;iRecHit!=iRecHitEnd;iRecHit++){
83  DetId detid =iRecHit->id();
84  //split barrel and endcap
85  int EcalNum=detid.subdetId(); //1 stands for Barrel, 2 for endcaps
86  LogDebug("EcalRawToRecHit|Producer")<<"subdetId is: "<<EcalNum;
87  if (EcalNum==1) EBrechits->push_back(*iRecHit);
88  else if (EcalNum==2) EErechits->push_back(*iRecHit);
89  else {
90  edm::LogError("IncorrectRecHit")<<" a subdetid is not recognized. recHit on :"<< iRecHit->id().rawId()
91  <<" is lost.";
92  }//subdetid
93  }//loop over things in region
94  LogDebug("EcalRawToRecHit|Producer")<<"looping over refgetter region: "<<iR++<<" done"
95  <<watcher.lap();
96  }//loop over regions
97 
98  LogDebug("EcalRawToRecHit|Producer")<<EBrechits->size()<<" EB recHits to be put with instance: "<<EBrechitCollection_
99  <<"\n"<<EErechits->size()<<" EE recHits to be put with instance: "<<EErechitCollection_
100  << watcher.lap();
101 
102  // cleaning of anomalous signals, aka spikes
103  // only doable once we have a "global" collection of hits
104  if (cleaningAlgo_){
105  EBrechits->sort();
106  EErechits->sort();
107  cleaningAlgo_->setFlags(*EBrechits);
108  cleaningAlgo_->setFlags(*EErechits);
109  }
110 
111  iEvent.put(EBrechits, EBrechitCollection_);
112  iEvent.put(EErechits, EErechitCollection_);
113  LogDebug("EcalRawToRecHit|Producer")<<"collections uploaded."
114  << watcher.lap();
115  }
116  else{
117  //prepare the output collection
118  std::auto_ptr< EcalRecHitCollection > rechits( new EcalRecHitCollection);
119  //loop the refgetter
120  unsigned int iR=0;
121  EcalRecHitRefGetter::const_iterator iRegion=rgetter->begin();
122  EcalRecHitRefGetter::const_iterator iRegionEnd=rgetter->end();
123  for (;iRegion!=iRegionEnd;++iRegion){
124  LogDebug("EcalRawToRecHit|Producer")<<"looping over refgetter region: "<<iR<<watcher.lap();
125  std::vector<EcalRecHit>::const_iterator iRecHit=lgetter->begin_record()+iRegion->start();
126  std::vector<EcalRecHit>::const_iterator iRecHitEnd=lgetter->begin_record()+iRegion->finish();
127  for (;iRecHit!=iRecHitEnd;iRecHit++){
128  LogDebug("EcalRawToRecHit|Producer")<<"dereferencing rechit ref.";
129  DetId detid =iRecHit->id();
130  int EcalNum=detid.subdetId(); //1 stands for Barrel, 2 for endcaps
131  LogDebug("EcalRawToRecHit|Producer")<<"subdetId is: "<<EcalNum;
132  rechits->push_back(*iRecHit);
133  }//loop over things in region
134  LogDebug("EcalRawToRecHit|Producer")<<"looping over refgetter region: "<<iR++<<" done"<<watcher.lap();
135  }//loop over regions
136 
137  if (cleaningAlgo_){
138  rechits->sort();
139  cleaningAlgo_->setFlags(*rechits);
140  }
141  LogDebug("EcalRawToRecHit|Producer")<<rechits->size()<<" rechits to be put."<< watcher.lap();
142  iEvent.put(rechits,rechitCollection_);
143  LogDebug("EcalRawToRecHit|Producer")<<"collections uploaded."
144  << watcher.lap();
145  }
146 
147 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
EcalCleaningAlgo * cleaningAlgo_
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
Definition: DetId.h:20
boost::indirect_iterator< typename collection_type::const_iterator > const_iterator
Definition: RefGetter.h:25
void setFlags(EcalRecHitCollection &rhs)

Member Data Documentation

EcalCleaningAlgo* EcalRawToRecHitProducer::cleaningAlgo_
private
std::string EcalRawToRecHitProducer::EBrechitCollection_
private

Definition at line 72 of file EcalRawToRecHitProducer.h.

Referenced by EcalRawToRecHitProducer(), and produce().

std::string EcalRawToRecHitProducer::EErechitCollection_
private

Definition at line 73 of file EcalRawToRecHitProducer.h.

Referenced by EcalRawToRecHitProducer(), and produce().

edm::InputTag EcalRawToRecHitProducer::lsourceTag_
private

Definition at line 68 of file EcalRawToRecHitProducer.h.

Referenced by EcalRawToRecHitProducer(), and produce().

std::string EcalRawToRecHitProducer::rechitCollection_
private

Definition at line 74 of file EcalRawToRecHitProducer.h.

Referenced by EcalRawToRecHitProducer(), and produce().

edm::InputTag EcalRawToRecHitProducer::sourceTag_
private

Definition at line 69 of file EcalRawToRecHitProducer.h.

Referenced by EcalRawToRecHitProducer(), and produce().

bool EcalRawToRecHitProducer::splitOutput_
private

Definition at line 71 of file EcalRawToRecHitProducer.h.

Referenced by EcalRawToRecHitProducer(), and produce().