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 Attributes
EcalTrigPrimAnalyzer Class Reference

#include <EcalTrigPrimAnalyzer.h>

Inheritance diagram for EcalTrigPrimAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
 EcalTrigPrimAnalyzer (const edm::ParameterSet &)
 
virtual void endJob ()
 
 ~EcalTrigPrimAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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: test of the output of EcalTrigPrimProducer

Description: rereads the result of the EcalTrigPrimProducer

Definition at line 38 of file EcalTrigPrimAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 51 of file EcalTrigPrimAnalyzer.cc.

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

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

Definition at line 86 of file EcalTrigPrimAnalyzer.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 104 of file EcalTrigPrimAnalyzer.cc.

References EcalTriggerPrimitiveDigi::compressedEt(), prof2calltree::count, ztail::d, relval_parameters_module::energy, EcalTriggerPrimitiveDigi::fineGrain(), edm::EventSetup::get(), edm::Event::getByLabel(), i, EcalTriggerPrimitiveDigi::id(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::ietaAbs(), EcalTrigTowerDetId::iphi(), j, EcalTPGScale::setEventSetup(), funct::sin(), EcalTrigTowerDetId::subDet(), theta(), EBDetId::tower(), and EcalTriggerPrimitiveDigi::ttFlag().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 234 of file EcalTrigPrimAnalyzer.cc.

References i.

234  {
235  for (unsigned int i=0;i<2;++i) {
236  ecal_et_[i]->Write();
237  ecal_tt_[i]->Write();
238  ecal_fgvb_[i]->Write();
239  }
240  if (recHits_) {
241  hTPvsRechit_->Write();
242  hTPoverRechit_->Write();
243  }
244 }
int i
Definition: DBlmapReader.cc:9

Member Data Documentation

TH1I* EcalTrigPrimAnalyzer::ecal_et_[2]
private

Definition at line 50 of file EcalTrigPrimAnalyzer.h.

TH1I* EcalTrigPrimAnalyzer::ecal_fgvb_[2]
private

Definition at line 52 of file EcalTrigPrimAnalyzer.h.

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

Definition at line 49 of file EcalTrigPrimAnalyzer.h.

TH1I* EcalTrigPrimAnalyzer::ecal_tt_[2]
private

Definition at line 51 of file EcalTrigPrimAnalyzer.h.

float EcalTrigPrimAnalyzer::eRec_
private

Definition at line 60 of file EcalTrigPrimAnalyzer.h.

int EcalTrigPrimAnalyzer::fg_
private

Definition at line 59 of file EcalTrigPrimAnalyzer.h.

TH1I * EcalTrigPrimAnalyzer::histBar
private

Definition at line 53 of file EcalTrigPrimAnalyzer.h.

TH1I* EcalTrigPrimAnalyzer::histEndc
private

Definition at line 53 of file EcalTrigPrimAnalyzer.h.

TFile* EcalTrigPrimAnalyzer::histfile_
private

Definition at line 54 of file EcalTrigPrimAnalyzer.h.

TH1F* EcalTrigPrimAnalyzer::hTPoverRechit_
private

Definition at line 56 of file EcalTrigPrimAnalyzer.h.

TH2F* EcalTrigPrimAnalyzer::hTPvsRechit_
private

Definition at line 55 of file EcalTrigPrimAnalyzer.h.

int EcalTrigPrimAnalyzer::ieta_
private

Definition at line 59 of file EcalTrigPrimAnalyzer.h.

int EcalTrigPrimAnalyzer::iphi_
private

Definition at line 59 of file EcalTrigPrimAnalyzer.h.

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

Definition at line 67 of file EcalTrigPrimAnalyzer.h.

edm::InputTag EcalTrigPrimAnalyzer::rechits_labelEB_
private

Definition at line 64 of file EcalTrigPrimAnalyzer.h.

edm::InputTag EcalTrigPrimAnalyzer::rechits_labelEE_
private

Definition at line 65 of file EcalTrigPrimAnalyzer.h.

int EcalTrigPrimAnalyzer::tpgADC_
private

Definition at line 59 of file EcalTrigPrimAnalyzer.h.

float EcalTrigPrimAnalyzer::tpgGeV_
private

Definition at line 60 of file EcalTrigPrimAnalyzer.h.

TTree* EcalTrigPrimAnalyzer::tree_
private

Definition at line 57 of file EcalTrigPrimAnalyzer.h.

int EcalTrigPrimAnalyzer::ttf_
private

Definition at line 59 of file EcalTrigPrimAnalyzer.h.