15 #include "TLorentzVector.h"
21 #include <calobase/RawClusterContainer.h>
22 #include <calobase/RawCluster.h>
23 #include <calobase/RawClusterv1.h>
24 #include <calobase/RawTowerv2.h>
25 #include <calobase/RawTowerGeom.h>
26 #include <calobase/RawTowerContainer.h>
27 #include <calobase/TowerInfov1.h>
28 #include <calobase/TowerInfoContainerv1.h>
29 #include <calobase/RawTowerGeomContainer_Cylinderv1.h>
30 #include <calobase/RawTowerGeomContainer.h>
39 #include <gsl/gsl_rng.h>
61 std::cout <<
"sPHAnalysis_calo::Init started..." << endl;
63 std::cout <<
"sPHAnalysis_calo::Init: output file " <<
OutputFileName.c_str() <<
" opened." << endl;
65 ntp_notracking =
new TNtuple(
"ntp_notracking",
"",
"mass:pt:e1:e2:hoe1:hoe2");
66 h_mult =
new TH1D(
"h_mult",
"",1000,0.,10000.);
67 h_ecore =
new TH1D(
"h_ecore",
"",200,0.,20.);
70 for(
int i=0;
i<256*96;
i++) {
71 sprintf(hname,
"h_pedestal_%d",
i);
72 h_pedestal[
i] =
new TH1F(hname,hname,10000,-0.5,9999.5);
75 _rng =
new TRandom2();
78 cout <<
"sPHAnalysis_calo::Init ended." << endl;
86 cout <<
"sPHAnalysis_calo::InitRun started..." << endl;
87 cout <<
"sPHAnalysis_calo::InitRun ended." << endl;
110 cout<<
"--------------------------- EventNumber = " <<
EventNumber-1 << endl;
113 TowerInfoContainer* _towersCEMC = findNode::getClass<TowerInfoContainerv1>(topNode,
"TOWERS_CEMC");
115 unsigned int ntowers = _towersCEMC->
size();
116 cout <<
" # of towers = " << ntowers << endl;
121 float raw_amplitude = cemcinfo_raw->
get_energy();
122 float raw_time = cemcinfo_raw->
get_time();
127 if(
channel>0 &&
channel<20) cout <<
channel <<
" " << iphi <<
" " << ieta <<
" " << raw_amplitude <<
" " << raw_time << endl;
130 cout <<
"sPHAnalysis_calo::procedss_event_data() ended." << endl;
140 cout<<
"--------------------------- EventNumber = " <<
EventNumber-1 << endl;
144 GlobalVertexMap *global_vtxmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
153 cout <<
"Global vertex Z = " << Zvtx << endl;
156 RawClusterContainer* cemc_clusters = findNode::getClass<RawClusterContainer>(topNode,
"CLUSTER_CEMC");
158 cerr <<
PHWHERE <<
" ERROR: Can not find CLUSTER_CEMC node." << endl;
161 cout <<
" Number of CEMC clusters = " << cemc_clusters->
size() << endl;
165 RawTowerGeomContainer* _geomEM = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_CEMC");
166 if(!_geomEM) std::cerr<<
"No TOWERGEOM_CEMC"<<std::endl;
167 RawTowerGeomContainer* _geomIH = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALIN");
168 if(!_geomIH) std::cerr<<
"No TOWERGEOM_HCALIN"<<std::endl;
169 RawTowerGeomContainer* _geomOH = findNode::getClass<RawTowerGeomContainer>(topNode,
"TOWERGEOM_HCALOUT");
170 if(!_geomIH) std::cerr<<
"No TOWERGEOM_HCALIN"<<std::endl;
172 RawTowerContainer* _towersRawEM = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_CEMC");
173 if (!_towersRawEM) std::cerr<<
"No TOWER_CALIB_CEMC Node"<<std::endl;
174 RawTowerContainer* _towersRawIH = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALIN");
175 if (!_towersRawIH) std::cerr<<
"No TOWER_CALIB_HCALIN Node"<<std::endl;
176 RawTowerContainer* _towersRawOH = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_CALIB_HCALOUT");
177 if (!_towersRawOH) std::cerr<<
"No TOWER_CALIB_HCALOUT Node"<<std::endl;
179 vector<TLorentzVector> electrons;
185 for (iter = begin_end.first; iter != begin_end.second; ++iter)
188 if(!cluster) { cout <<
"ERROR: bad cluster pointer = " << cluster << endl;
continue; }
190 double cemc_ecore = cluster->
get_ecore();
192 if(cemc_ecore<2.0)
continue;
193 double cemc_x = cluster->
get_x();
194 double cemc_y = cluster->
get_y();
195 double cemc_z = cluster->
get_z() - Zvtx;
197 double cemc_r = sqrt(pow(cemc_x,2)+pow(cemc_y,2));
198 double cemc_rr = sqrt(pow(cemc_r,2)+pow(cemc_z,2));
199 double cemc_eta = asinh( cemc_z / cemc_r );
200 double cemc_phi = atan2( cemc_y, cemc_x );
201 double cemc_px = cemc_ecore * (cemc_x/cemc_rr);
202 double cemc_py = cemc_ecore * (cemc_y/cemc_rr);
203 double cemc_pz = cemc_ecore * (cemc_z/cemc_rr);
207 double distem = 99999.;
213 double cemc_tower_phi = tower_geom->
get_phi();
216 double cemc_tower_z = tower_geom->
get_center_z() - Zvtx;
217 double cemc_tower_r = sqrt(pow(cemc_tower_x,2)+pow(cemc_tower_y,2));
218 double cemc_tower_eta = asinh( cemc_tower_z / cemc_tower_r );
219 double tmpdist = sqrt(pow(cemc_eta-cemc_tower_eta,2)+pow(cemc_phi-cemc_tower_phi,2));
220 if(tmpdist<distem) { distem = tmpdist; thetowerem = tower; }
223 unsigned int ietaem = thetower_geom_em->
get_bineta();
224 unsigned int jphiem = thetower_geom_em->
get_binphi();
227 double distin = 99999.;
233 double hcalin_tower_phi = tower_geom->
get_phi();
236 double hcalin_tower_z = tower_geom->
get_center_z() - Zvtx;
237 double hcalin_tower_r = sqrt(pow(hcalin_tower_x,2)+pow(hcalin_tower_y,2));
238 double hcalin_tower_eta = asinh( hcalin_tower_z / hcalin_tower_r );
239 double tmpdist = sqrt(pow(cemc_eta-hcalin_tower_eta,2)+pow(cemc_phi-hcalin_tower_phi,2));
240 if(tmpdist<distin) { distin = tmpdist; thetowerin = tower; }
243 unsigned int ieta = thetower_geom->
get_bineta();
244 unsigned int jphi = thetower_geom->
get_binphi();
248 if(ieta<1 || ieta>22)
continue;
249 for(
unsigned int i=0;
i<=2;
i++) {
250 for(
unsigned int j=0;
j<=2;
j++) {
251 unsigned int itmp = ieta-1+
i;
252 unsigned int jtmp = 0;
253 if(jphi==0 &&
j==0) { jtmp = 63; }
254 else if(jphi==63 &&
j==2) { jtmp = 0; }
255 else { jtmp = jphi-1+
j; }
257 if(tmptower) { e3x3in += tmptower->
get_energy(); }
263 double distout = 99999.;
269 double hcalout_tower_phi = tower_geom->
get_phi();
272 double hcalout_tower_z = tower_geom->
get_center_z() - Zvtx;
273 double hcalout_tower_r = sqrt(pow(hcalout_tower_x,2)+pow(hcalout_tower_y,2));
274 double hcalout_tower_eta = asinh( hcalout_tower_z / hcalout_tower_r );
275 double tmpdist = sqrt(pow(cemc_eta-hcalout_tower_eta,2)+pow(cemc_phi-hcalout_tower_phi,2));
276 if(tmpdist<distout) { distout = tmpdist; thetowerout = tower; }
279 unsigned int ietaout = thetower_geomout->
get_bineta();
280 unsigned int jphiout = thetower_geomout->
get_binphi();
284 if(ietaout<1 || ietaout>22)
continue;
285 for(
unsigned int i=0;
i<=2;
i++) {
286 for(
unsigned int j=0;
j<=2;
j++) {
287 unsigned int itmp = ietaout-1+
i;
288 unsigned int jtmp = 0;
289 if(jphiout==0 &&
j==0) { jtmp = 63; }
290 else if(jphiout==63 &&
j==2) { jtmp = 0; }
291 else { jtmp = jphiout-1+
j; }
293 if(tmptower) { e3x3out += tmptower->
get_energy(); }
297 if(e3x3in/cemc_ecore>0.06)
continue;
299 TLorentzVector
tmp = TLorentzVector(cemc_px,cemc_py,cemc_pz,cemc_ecore);
300 electrons.push_back(tmp);
301 vhoe.push_back(e3x3in/cemc_ecore);
305 cout <<
"number of selected electrons = " << electrons.size() <<
" " << vhoe.size() << endl;
309 if(electrons.size()>=2) {
310 for(
long unsigned int i=0;
i<electrons.size()-1;
i++) {
311 for(
long unsigned int j=
i+1;
j<electrons.size();
j++) {
312 TLorentzVector pair = electrons[
i]+electrons[
j];
313 cout <<
i <<
" " <<
j << endl;
316 cout << pair.M() <<
" " << pair.Pt() << endl;
317 tmp1[2] = (electrons[
i]).
Pt();
318 tmp1[3] = (electrons[
j]).
Pt();
319 cout << vhoe[
i] <<
" " << vhoe[
j] << endl;
322 cout <<
"filling..." << endl;
324 cout <<
"done." << endl;
329 cout <<
"sPHAnalysis_calo::procedss_event_test() ended." << endl;
337 std::cout <<
"sPHAnalysis_calo::End() started, Number of processed events = " <<
EventNumber << endl;