55 ecal_parts_.push_back(
"Barrel");
56 ecal_parts_.push_back(
"Endcap");
58 histfile_=
new TFile(
"histos.root",
"RECREATE");
59 tree_ =
new TTree(
"TPGtree",
"TPGtree");
60 tree_->Branch(
"iphi",&iphi_,
"iphi/I");
61 tree_->Branch(
"ieta",&ieta_,
"ieta/I");
62 tree_->Branch(
"eRec",&eRec_,
"eRec/F");
63 tree_->Branch(
"tpgADC",&tpgADC_,
"tpgADC/I");
64 tree_->Branch(
"tpgGeV",&tpgGeV_,
"tpgGeV/F");
65 tree_->Branch(
"ttf",&ttf_,
"ttf/I");
66 tree_->Branch(
"fg",&fg_,
"fg/I");
67 for (
unsigned int i=0;
i<2;++
i) {
68 ecal_et_[
i]=
new TH1I(ecal_parts_[
i].c_str(),
"Et",255,0,255);
70 sprintf(title,
"%s_ttf",ecal_parts_[
i].c_str());
71 ecal_tt_[
i]=
new TH1I(title,
"TTF",10,0,10);
72 sprintf(title,
"%s_fgvb",ecal_parts_[
i].c_str());
73 ecal_fgvb_[
i]=
new TH1I(title,
"FGVB",10,0,10);
79 hTPvsRechit_=
new TH2F(
"TP_vs_RecHit",
"TP vs rechit",256,-1,255,255,0,255);
80 hTPoverRechit_=
new TH1F(
"TP_over_RecHit",
"TP over rechit",500,0,4);
113 for (
unsigned int i=0;
i<tp.product()->size();
i++) {
125 ecal_tt_[subdet]->Fill(d.
ttFlag());
129 if (!recHits_)
return;
133 iEvent.
getByLabel(rechits_labelEB_,rechit_EB_col);
136 iEvent.
getByLabel(rechits_labelEE_,rechit_EE_col);
147 theEndcapGeometry = &(*theEndcapGeometry_handle);
148 theBarrelGeometry = &(*theBarrelGeometry_handle);
152 map<EcalTrigTowerDetId, float> mapTow_Et;
155 for (
unsigned int i=0;
i<rechit_EB_col.product()->size();
i++) {
156 const EBDetId & myid1=(*rechit_EB_col.product())[
i].
id();
158 float theta = theBarrelGeometry->getGeometry(myid1)->getPosition().theta();
159 float Etsum=((*rechit_EB_col.product())[
i].
energy())*
sin(theta);
160 bool test_alreadyin=
false;
161 map<EcalTrigTowerDetId, float>::iterator ittest= mapTow_Et.find(towid1);
162 if (ittest!= mapTow_Et.end()) test_alreadyin=
true;
163 if (test_alreadyin)
continue;
166 unsigned int count=0;
167 while( j<rechit_EB_col.product()->size() && !loopend){
169 const EBDetId & myid2=(*rechit_EB_col.product())[j].
id();
171 if( towid1==towid2 ) {
172 float theta=theBarrelGeometry->getGeometry(myid2)->getPosition().theta();
173 Etsum += (*rechit_EB_col.product())[j].
energy()*
sin(theta);
176 if (count>1800) loopend=
true;
178 mapTow_Et.insert(pair<EcalTrigTowerDetId,float>(towid1, Etsum));
182 for (
unsigned int i=0;
i<rechit_EE_col.product()->size();
i++) {
183 const EEDetId & myid1=(*rechit_EE_col.product())[
i].
id();
185 float theta=theEndcapGeometry->getGeometry(myid1)->getPosition().theta();
186 float Etsum=(*rechit_EE_col.product())[
i].
energy()*
sin(theta);
187 bool test_alreadyin=
false;
188 map<EcalTrigTowerDetId, float>::iterator ittest= mapTow_Et.find(towid1);
189 if (ittest!= mapTow_Et.end()) test_alreadyin=
true;
190 if (test_alreadyin)
continue;
193 unsigned int count=0;
194 while( j<rechit_EE_col.product()->size() && !loopend){
195 const EEDetId & myid2=(*rechit_EE_col.product())[j].
id();
197 if( towid1==towid2 ) {
198 float theta=theEndcapGeometry->getGeometry(myid2)->getPosition().theta();
199 Etsum += (*rechit_EE_col.product())[j].
energy()*
sin(theta);
203 if (count>500) loopend=
true;
206 mapTow_Et.insert(pair<EcalTrigTowerDetId,float>(towid1, Etsum));
212 for (
unsigned int i=0;
i<tp.product()->size();
i++) {
215 map<EcalTrigTowerDetId, float>::iterator it= mapTow_Et.find(TPtowid);
216 float Et = ecalScale.getTPGInGeV(d.
compressedEt(), TPtowid) ;
218 iphi_ = TPtowid.
iphi() ;
219 ieta_ = TPtowid.
ieta() ;
224 if (it!= mapTow_Et.end()) {
225 hTPvsRechit_->Fill(it->second,Et);
226 hTPoverRechit_->Fill(Et/it->second);
236 for (
unsigned int i=0;
i<2;++
i) {
237 ecal_et_[
i]->Write();
238 ecal_tt_[
i]->Write();
239 ecal_fgvb_[
i]->Write();
242 hTPvsRechit_->Write();
243 hTPoverRechit_->Write();
T getParameter(std::string const &) const
void setEventSetup(const edm::EventSetup &evtSetup)
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
int ieta() const
get the tower ieta
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
EcalTrigPrimAnalyzer(const edm::ParameterSet &)
int iphi() const
get the tower iphi
const EcalTrigTowerDetId & id() const
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