CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
EcalTrigPrimAnalyzer Class Reference

#include <EcalTrigPrimAnalyzer.h>

Inheritance diagram for EcalTrigPrimAnalyzer:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 EcalTrigPrimAnalyzer (const edm::ParameterSet &)
 
void endJob () override
 
 ~EcalTrigPrimAnalyzer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

TH1I * ecal_et_ [2]
 
TH1I * ecal_fgvb_ [2]
 
std::vector< std::string > ecal_parts_
 
TH1I * ecal_tt_ [2]
 
float eRec_
 
int fg_
 
TH1I * histBar
 
TH1I * histEndc
 
TFile * histfile_
 
TH1F * hTPoverRechit_
 
TH2F * hTPvsRechit_
 
int ieta_
 
int iphi_
 
edm::InputTag label_
 
bool recHits_
 
edm::InputTag rechits_labelEB_
 
edm::InputTag rechits_labelEE_
 
int tpgADC_
 
float tpgGeV_
 
TTree * tree_
 
int ttf_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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: test of the output of EcalTrigPrimProducer

Description: rereads the result of the EcalTrigPrimProducer

Definition at line 37 of file EcalTrigPrimAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 50 of file EcalTrigPrimAnalyzer.cc.

References edm::ParameterSet::getParameter(), mps_fire::i, and overlapproblemtsosanalyzer_cfi::title.

52 {
53  ecal_parts_.push_back("Barrel");
54  ecal_parts_.push_back("Endcap");
55 
56  histfile_ = new TFile("histos.root", "RECREATE");
57  tree_ = new TTree("TPGtree", "TPGtree");
58  tree_->Branch("iphi", &iphi_, "iphi/I");
59  tree_->Branch("ieta", &ieta_, "ieta/I");
60  tree_->Branch("eRec", &eRec_, "eRec/F");
61  tree_->Branch("tpgADC", &tpgADC_, "tpgADC/I");
62  tree_->Branch("tpgGeV", &tpgGeV_, "tpgGeV/F");
63  tree_->Branch("ttf", &ttf_, "ttf/I");
64  tree_->Branch("fg", &fg_, "fg/I");
65  for (unsigned int i = 0; i < 2; ++i) {
66  ecal_et_[i] = new TH1I(ecal_parts_[i].c_str(), "Et", 255, 0, 255);
67  char title[30];
68  sprintf(title, "%s_ttf", ecal_parts_[i].c_str());
69  ecal_tt_[i] = new TH1I(title, "TTF", 10, 0, 10);
70  sprintf(title, "%s_fgvb", ecal_parts_[i].c_str());
71  ecal_fgvb_[i] = new TH1I(title, "FGVB", 10, 0, 10);
72  }
73 
74  recHits_ = iConfig.getParameter<bool>("AnalyzeRecHits");
75  label_ = iConfig.getParameter<edm::InputTag>("inputTP");
76  if (recHits_) {
77  hTPvsRechit_ = new TH2F("TP_vs_RecHit", "TP vs rechit", 256, -1, 255, 255, 0, 255);
78  hTPoverRechit_ = new TH1F("TP_over_RecHit", "TP over rechit", 500, 0, 4);
79  rechits_labelEB_ = iConfig.getParameter<edm::InputTag>("inputRecHitsEB");
80  rechits_labelEE_ = iConfig.getParameter<edm::InputTag>("inputRecHitsEE");
81  }
82 }
T getParameter(std::string const &) const
std::vector< std::string > ecal_parts_
edm::InputTag rechits_labelEE_
edm::InputTag rechits_labelEB_
EcalTrigPrimAnalyzer::~EcalTrigPrimAnalyzer ( )
override

Definition at line 84 of file EcalTrigPrimAnalyzer.cc.

84  {
85  // do anything here that needs to be done at desctruction time
86  // (e.g. close files, deallocate resources etc.)
87 
88  histfile_->Write();
89  histfile_->Close();
90 }

Member Function Documentation

void EcalTrigPrimAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 97 of file EcalTrigPrimAnalyzer.cc.

References EcalTriggerPrimitiveDigi::compressedEt(), KineDebug3::count(), ztail::d, HCALHighEnergyHPDFilter_cfi::energy, EcalTriggerPrimitiveDigi::fineGrain(), edm::EventSetup::get(), edm::Event::getByLabel(), CaloSubdetectorGeometry::getGeometry(), EcalTPGScale::getTPGInGeV(), mps_fire::i, EcalTriggerPrimitiveDigi::id(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::ietaAbs(), EcalTrigTowerDetId::iphi(), dqmiolumiharvest::j, edm::Handle< T >::product(), edm::ESHandle< T >::product(), EcalTPGScale::setEventSetup(), funct::sin(), edm::SortedCollection< T, SORT >::size(), EcalTrigTowerDetId::subDet(), theta(), EBDetId::tower(), and EcalTriggerPrimitiveDigi::ttFlag().

97  {
98  using namespace edm;
99  using namespace std;
100 
101  // Get input
103  iEvent.getByLabel(label_, tp);
104  for (unsigned int i = 0; i < tp.product()->size(); i++) {
105  EcalTriggerPrimitiveDigi d = (*(tp.product()))[i];
106  int subdet = d.id().subDet() - 1;
107  if (subdet == 0) {
108  ecal_et_[subdet]->Fill(d.compressedEt());
109  } else {
110  if (d.id().ietaAbs() == 27 || d.id().ietaAbs() == 28) {
111  if (i % 2)
112  ecal_et_[subdet]->Fill(d.compressedEt() * 2.);
113  } else
114  ecal_et_[subdet]->Fill(d.compressedEt());
115  }
116  ecal_tt_[subdet]->Fill(d.ttFlag());
117  ecal_fgvb_[subdet]->Fill(d.fineGrain());
118  }
119  if (!recHits_)
120  return;
121 
122  // comparison with RecHits
123  edm::Handle<EcalRecHitCollection> rechit_EB_col;
124  iEvent.getByLabel(rechits_labelEB_, rechit_EB_col);
125 
126  edm::Handle<EcalRecHitCollection> rechit_EE_col;
127  iEvent.getByLabel(rechits_labelEE_, rechit_EE_col);
128 
129  edm::ESHandle<CaloGeometry> theGeometry;
130  edm::ESHandle<CaloSubdetectorGeometry> theBarrelGeometry_handle;
131  edm::ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle;
132  iSetup.get<CaloGeometryRecord>().get(theGeometry);
133  iSetup.get<EcalEndcapGeometryRecord>().get("EcalEndcap", theEndcapGeometry_handle);
134  iSetup.get<EcalBarrelGeometryRecord>().get("EcalBarrel", theBarrelGeometry_handle);
135 
136  const CaloSubdetectorGeometry *theEndcapGeometry = theEndcapGeometry_handle.product();
137  const CaloSubdetectorGeometry *theBarrelGeometry = theBarrelGeometry_handle.product();
139  iSetup.get<IdealGeometryRecord>().get(eTTmap_);
140 
141  map<EcalTrigTowerDetId, float> mapTow_Et;
142 
143  for (unsigned int i = 0; i < rechit_EB_col.product()->size(); i++) {
144  const EBDetId &myid1 = (*rechit_EB_col.product())[i].id();
145  EcalTrigTowerDetId towid1 = myid1.tower();
146  float theta = theBarrelGeometry->getGeometry(myid1)->getPosition().theta();
147  float Etsum = ((*rechit_EB_col.product())[i].energy()) * sin(theta);
148  bool test_alreadyin = false;
149  map<EcalTrigTowerDetId, float>::iterator ittest = mapTow_Et.find(towid1);
150  if (ittest != mapTow_Et.end())
151  test_alreadyin = true;
152  if (test_alreadyin)
153  continue;
154  unsigned int j = i + 1;
155  bool loopend = false;
156  unsigned int count = 0;
157  while (j < rechit_EB_col.product()->size() && !loopend) {
158  count++;
159  const EBDetId &myid2 = (*rechit_EB_col.product())[j].id();
160  EcalTrigTowerDetId towid2 = myid2.tower();
161  if (towid1 == towid2) {
162  float theta = theBarrelGeometry->getGeometry(myid2)->getPosition().theta();
163  Etsum += (*rechit_EB_col.product())[j].energy() * sin(theta);
164  }
165  j++;
166  if (count > 1800)
167  loopend = true;
168  }
169  mapTow_Et.insert(pair<EcalTrigTowerDetId, float>(towid1, Etsum));
170  }
171 
172  for (unsigned int i = 0; i < rechit_EE_col.product()->size(); i++) {
173  const EEDetId &myid1 = (*rechit_EE_col.product())[i].id();
174  EcalTrigTowerDetId towid1 = (*eTTmap_).towerOf(myid1);
175  float theta = theEndcapGeometry->getGeometry(myid1)->getPosition().theta();
176  float Etsum = (*rechit_EE_col.product())[i].energy() * sin(theta);
177  bool test_alreadyin = false;
178  map<EcalTrigTowerDetId, float>::iterator ittest = mapTow_Et.find(towid1);
179  if (ittest != mapTow_Et.end())
180  test_alreadyin = true;
181  if (test_alreadyin)
182  continue;
183  unsigned int j = i + 1;
184  bool loopend = false;
185  unsigned int count = 0;
186  while (j < rechit_EE_col.product()->size() && !loopend) {
187  const EEDetId &myid2 = (*rechit_EE_col.product())[j].id();
188  EcalTrigTowerDetId towid2 = (*eTTmap_).towerOf(myid2);
189  if (towid1 == towid2) {
190  float theta = theEndcapGeometry->getGeometry(myid2)->getPosition().theta();
191  Etsum += (*rechit_EE_col.product())[j].energy() * sin(theta);
192  }
193  // else loopend=true;
194  j++;
195  if (count > 500)
196  loopend = true;
197  }
198  // alreadyin_EE.push_back(towid1);
199  mapTow_Et.insert(pair<EcalTrigTowerDetId, float>(towid1, Etsum));
200  }
201 
202  EcalTPGScale ecalScale;
203  ecalScale.setEventSetup(iSetup);
204  for (unsigned int i = 0; i < tp.product()->size(); i++) {
205  EcalTriggerPrimitiveDigi d = (*(tp.product()))[i];
206  const EcalTrigTowerDetId TPtowid = d.id();
207  map<EcalTrigTowerDetId, float>::iterator it = mapTow_Et.find(TPtowid);
208  float Et = ecalScale.getTPGInGeV(d.compressedEt(), TPtowid);
209  if (d.id().ietaAbs() == 27 || d.id().ietaAbs() == 28)
210  Et *= 2;
211  iphi_ = TPtowid.iphi();
212  ieta_ = TPtowid.ieta();
213  tpgADC_ = d.compressedEt();
214  tpgGeV_ = Et;
215  ttf_ = d.ttFlag();
216  fg_ = d.fineGrain();
217  if (it != mapTow_Et.end()) {
218  hTPvsRechit_->Fill(it->second, Et);
219  hTPoverRechit_->Fill(Et / it->second);
220  eRec_ = it->second;
221  }
222  tree_->Fill();
223  }
224 }
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:16
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:18
int ieta() const
get the tower ieta
int compressedEt() const
get the encoded/compressed Et of interesting sample
int ietaAbs() const
get the absolute value of the tower ieta
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
d
Definition: ztail.py:151
int iphi() const
get the tower iphi
const EcalTrigTowerDetId & id() const
T const * product() const
Definition: Handle.h:69
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
edm::InputTag rechits_labelEE_
edm::InputTag rechits_labelEB_
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
HLT enums.
size_type size() const
T get() const
Definition: EventSetup.h:73
bool fineGrain() const
get the fine-grain bit of interesting sample
int ttFlag() const
get the Trigger tower Flag of interesting sample
T const * product() const
Definition: ESHandle.h:86
void EcalTrigPrimAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 226 of file EcalTrigPrimAnalyzer.cc.

References mps_fire::i.

226  {
227  for (unsigned int i = 0; i < 2; ++i) {
228  ecal_et_[i]->Write();
229  ecal_tt_[i]->Write();
230  ecal_fgvb_[i]->Write();
231  }
232  if (recHits_) {
233  hTPvsRechit_->Write();
234  hTPoverRechit_->Write();
235  }
236 }

Member Data Documentation

TH1I* EcalTrigPrimAnalyzer::ecal_et_[2]
private

Definition at line 48 of file EcalTrigPrimAnalyzer.h.

TH1I* EcalTrigPrimAnalyzer::ecal_fgvb_[2]
private

Definition at line 50 of file EcalTrigPrimAnalyzer.h.

std::vector<std::string> EcalTrigPrimAnalyzer::ecal_parts_
private

Definition at line 47 of file EcalTrigPrimAnalyzer.h.

TH1I* EcalTrigPrimAnalyzer::ecal_tt_[2]
private

Definition at line 49 of file EcalTrigPrimAnalyzer.h.

float EcalTrigPrimAnalyzer::eRec_
private

Definition at line 58 of file EcalTrigPrimAnalyzer.h.

int EcalTrigPrimAnalyzer::fg_
private

Definition at line 57 of file EcalTrigPrimAnalyzer.h.

TH1I * EcalTrigPrimAnalyzer::histBar
private

Definition at line 51 of file EcalTrigPrimAnalyzer.h.

TH1I* EcalTrigPrimAnalyzer::histEndc
private

Definition at line 51 of file EcalTrigPrimAnalyzer.h.

TFile* EcalTrigPrimAnalyzer::histfile_
private

Definition at line 52 of file EcalTrigPrimAnalyzer.h.

TH1F* EcalTrigPrimAnalyzer::hTPoverRechit_
private

Definition at line 54 of file EcalTrigPrimAnalyzer.h.

TH2F* EcalTrigPrimAnalyzer::hTPvsRechit_
private

Definition at line 53 of file EcalTrigPrimAnalyzer.h.

int EcalTrigPrimAnalyzer::ieta_
private

Definition at line 57 of file EcalTrigPrimAnalyzer.h.

int EcalTrigPrimAnalyzer::iphi_
private

Definition at line 57 of file EcalTrigPrimAnalyzer.h.

edm::InputTag EcalTrigPrimAnalyzer::label_
private
bool EcalTrigPrimAnalyzer::recHits_
private

Definition at line 65 of file EcalTrigPrimAnalyzer.h.

edm::InputTag EcalTrigPrimAnalyzer::rechits_labelEB_
private

Definition at line 62 of file EcalTrigPrimAnalyzer.h.

edm::InputTag EcalTrigPrimAnalyzer::rechits_labelEE_
private

Definition at line 63 of file EcalTrigPrimAnalyzer.h.

int EcalTrigPrimAnalyzer::tpgADC_
private

Definition at line 57 of file EcalTrigPrimAnalyzer.h.

float EcalTrigPrimAnalyzer::tpgGeV_
private

Definition at line 58 of file EcalTrigPrimAnalyzer.h.

TTree* EcalTrigPrimAnalyzer::tree_
private

Definition at line 55 of file EcalTrigPrimAnalyzer.h.

int EcalTrigPrimAnalyzer::ttf_
private

Definition at line 57 of file EcalTrigPrimAnalyzer.h.