1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/PropertyMgr.h"
8#include "EventModel/EventModel.h"
9#include "EventModel/Event.h"
11#include "EvtRecEvent/EvtRecEvent.h"
12#include "EvtRecEvent/EvtRecTrack.h"
13#include "DstEvent/TofHitStatus.h"
14#include "EventModel/EventHeader.h"
15#include "McTruth/McParticle.h"
16#include "HltEvent/HltInf.h"
17#include "HltEvent/DstHltInf.h"
20#include "GaudiKernel/INTupleSvc.h"
21#include "GaudiKernel/NTuple.h"
22#include "GaudiKernel/Bootstrap.h"
23#include "GaudiKernel/IHistogramSvc.h"
24#include "CLHEP/Vector/ThreeVector.h"
25#include "CLHEP/Vector/LorentzVector.h"
26#include "CLHEP/Vector/TwoVector.h"
27#include "VertexFit/IVertexDbSvc.h"
28#include "GaudiKernel/Bootstrap.h"
29#include "GaudiKernel/ISvcLocator.h"
32using CLHEP::Hep3Vector;
33using CLHEP::Hep2Vector;
34using CLHEP::HepLorentzVector;
35#include "CLHEP/Geometry/Point3D.h"
36#ifndef ENABLE_BACKWARDS_COMPATIBILITY
39#include "Gam4pikpAlg/Gam4pikp.h"
41#include "VertexFit/KalmanKinematicFit.h"
42#include "VertexFit/VertexFit.h"
43#include "VertexFit/SecondVertexFit.h"
44#include "VertexFit/Helix.h"
45#include "ParticleID/ParticleID.h"
47const double mpi = 0.13957;
48const double mk = 0.493677;
49const double mpro = 0.938272;
50const double xmass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
51const double velc = 299.792458;
52typedef std::vector<int>
Vint;
53typedef std::vector<HepLorentzVector>
Vp4;
55typedef std::vector<WTrackParameter>
Vw;
56typedef std::vector<VertexParameter>
Vv;
57static int Ncut[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
58static int Mcut[10]={0,0,0,0,0,0,0,0,0,0};
62 Algorithm(name, pSvcLocator) {
65 declareProperty(
"skim4pi", m_skim4pi=
false);
66 declareProperty(
"skim4k", m_skim4k=
false);
67 declareProperty(
"skim2pi2pr", m_skim2pi2pr=
false);
68 declareProperty(
"rootput", m_rootput=
false);
69 declareProperty(
"Ecms", m_ecms=3.6862);
70 declareProperty(
"Vr0cut", m_vr0cut=1.0);
71 declareProperty(
"Vz0cut", m_vz0cut=5.0);
72 declareProperty(
"EnergyThreshold", m_energyThreshold=0.05);
73 declareProperty(
"GammaPhiCut", m_gammaPhiCut=20.0);
74 declareProperty(
"GammaThetaCut", m_gammaThetaCut=20.0);
75 declareProperty(
"GammaDangCut", m_gammadangcut=20.0);
84 MsgStream log(
msgSvc(), name());
86 log << MSG::INFO <<
"in initialize()" << endmsg;
92 NTuplePtr nt1(
ntupleSvc(),
"FILE1/total4c");
93 if ( nt1 ) m_tuple1 = nt1;
95 m_tuple1 =
ntupleSvc()->book (
"FILE1/total4c", CLID_ColumnWiseTuple,
"ks N-Tuple example");
98 status = m_tuple1->addItem (
"run", m_run );
99 status = m_tuple1->addItem (
"rec", m_rec );
100 status = m_tuple1->addItem (
"mpprecall", m_mpprecall );
101 status = m_tuple1->addItem (
"meeall", m_meeall );
102 status = m_tuple1->addItem (
"ncgjs", m_ncgjs );
103 status = m_tuple1->addItem (
"cla2kpi", m_cla2kpi );
104 status = m_tuple1->addItem(
"indexmc", m_idxmc, 0, 100);
105 status = m_tuple1->addIndexedItem(
"pdgid", m_idxmc, m_pdgid);
107 status = m_tuple1->addIndexedItem(
"motheridx", m_idxmc, m_motheridx);
108 status = m_tuple1->addItem(
"indexmdc", m_idxmdc, 0, 5000);
109 status = m_tuple1->addIndexedItem (
"x0js", m_idxmdc, m_x0js);
110 status = m_tuple1->addIndexedItem (
"y0js", m_idxmdc, m_y0js);
111 status = m_tuple1->addIndexedItem (
"z0js",m_idxmdc, m_z0js);
112 status = m_tuple1->addIndexedItem (
"r0js",m_idxmdc, m_r0js);
113 status = m_tuple1->addIndexedItem (
"Rxyjs",m_idxmdc, m_Rxyjs);
114 status = m_tuple1->addIndexedItem (
"Rzjs",m_idxmdc, m_Rzjs);
115 status = m_tuple1->addIndexedItem (
"Rnxyjs",m_idxmdc, m_Rnxyjs);
116 status = m_tuple1->addIndexedItem (
"phinjs",m_idxmdc, m_phinjs);
117 status = m_tuple1->addIndexedItem (
"Rnzjs",m_idxmdc, m_Rnzjs);
118 status = m_tuple1->addItem (
"ncy20", m_ncy20);
119 status = m_tuple1->addItem (
"ncy30", m_ncy30);
120 status = m_tuple1->addIndexedItem(
"angjs5", m_idxmdc, m_angjs5);
121 status = m_tuple1->addIndexedItem(
"nearjs5", m_idxmdc, m_nearjs5);
122 status = m_tuple1->addIndexedItem(
"angjs6", m_idxmdc, m_angjs6);
123 status = m_tuple1->addIndexedItem(
"nearjs6", m_idxmdc, m_nearjs6);
124 status = m_tuple1->addIndexedItem(
"ang4pi5", m_idxmdc, m_ang4pi5);
125 status = m_tuple1->addIndexedItem(
"near4pi5", m_idxmdc, m_near4pi5);
126 status = m_tuple1->addIndexedItem(
"ang4pi6", m_idxmdc, m_ang4pi6);
127 status = m_tuple1->addIndexedItem(
"near4pi6", m_idxmdc, m_near4pi6);
128 status = m_tuple1->addIndexedItem(
"ppmdcjs", m_idxmdc, m_ppmdcjs);
129 status = m_tuple1->addIndexedItem(
"pxmdcjs", m_idxmdc, m_pxmdcjs);
130 status = m_tuple1->addIndexedItem(
"pymdcjs", m_idxmdc, m_pymdcjs);
131 status = m_tuple1->addIndexedItem(
"pzmdcjs", m_idxmdc, m_pzmdcjs);
132 status = m_tuple1->addIndexedItem(
"ppkaljs", m_idxmdc, m_ppkaljs);
133 status = m_tuple1->addIndexedItem(
"ptmdcjs", m_idxmdc, m_ptmdcjs);
134 status = m_tuple1->addIndexedItem(
"ptkaljs", m_idxmdc, m_ptkaljs);
135 status = m_tuple1->addIndexedItem(
"ppmdc2kpi", m_idxmdc, m_ppmdc2kpi);
136 status = m_tuple1->addIndexedItem(
"pxmdc2kpi", m_idxmdc, m_pxmdc2kpi);
137 status = m_tuple1->addIndexedItem(
"pymdc2kpi", m_idxmdc, m_pymdc2kpi);
138 status = m_tuple1->addIndexedItem(
"pzmdc2kpi", m_idxmdc, m_pzmdc2kpi);
139 status = m_tuple1->addIndexedItem(
"ppkal2kpi", m_idxmdc, m_ppkal2kpi);
140 status = m_tuple1->addIndexedItem(
"ptmdc2kpi", m_idxmdc, m_ptmdc2kpi);
141 status = m_tuple1->addIndexedItem(
"charge2kpi", m_idxmdc, m_charge2kpi);
142 status = m_tuple1->addIndexedItem(
"ptkal2kpi", m_idxmdc, m_ptkal2kpi);
143 status = m_tuple1->addItem (
"cy2pi", m_cy2kpi, 0, 100 );
144 status = m_tuple1->addIndexedItem(
"comcs2kpi", m_cy2kpi, m_comcs2kpi);
145 status = m_tuple1->addItem (
"chiejs", m_idxmdc, m_chiejs);
146 status = m_tuple1->addItem (
"chimujs", m_idxmdc, m_chimujs);
147 status = m_tuple1->addItem (
"chipijs", m_idxmdc, m_chipijs);
148 status = m_tuple1->addItem (
"chikjs", m_idxmdc, m_chikjs);
149 status = m_tuple1->addItem (
"chipjs", m_idxmdc, m_chipjs);
150 status = m_tuple1->addItem (
"ghitjs", m_idxmdc, m_ghitjs);
151 status = m_tuple1->addItem (
"thitjs", m_idxmdc, m_thitjs);
152 status = m_tuple1->addIndexedItem(
"probphjs", m_idxmdc, m_probphjs);
153 status = m_tuple1->addIndexedItem(
"normphjs", m_idxmdc, m_normphjs);
154 status = m_tuple1->addItem (
"pdg", m_idxmdc, m_pdg);
155 status = m_tuple1->addItem (
"cbmc", m_idxmdc, m_cbmc);
156 status = m_tuple1->addIndexedItem(
"sigmaetof2kpi", m_idxmdc, m_sigmaetof2kpi);
157 status = m_tuple1->addIndexedItem(
"sigmamutof2kpi", m_idxmdc, m_sigmamutof2kpi);
158 status = m_tuple1->addIndexedItem(
"sigmapitof2kpi", m_idxmdc, m_sigmapitof2kpi);
159 status = m_tuple1->addIndexedItem(
"sigmaktof2kpi", m_idxmdc, m_sigmaktof2kpi);
160 status = m_tuple1->addIndexedItem(
"sigmaprtof2kpi", m_idxmdc, m_sigmaprtof2kpi);
161 status = m_tuple1->addIndexedItem(
"t0tof2kpi", m_idxmdc, m_t0tof2kpi);
162 status = m_tuple1->addIndexedItem(
"errt0tof2kpi", m_idxmdc, m_errt0tof2kpi);
164 status = m_tuple1->addItem (
"chie2kpi", m_idxmdc, m_chie2kpi);
165 status = m_tuple1->addItem (
"chimu2kpi", m_idxmdc, m_chimu2kpi);
166 status = m_tuple1->addItem (
"chipi2kpi", m_idxmdc, m_chipi2kpi);
167 status = m_tuple1->addItem (
"chik2kpi", m_idxmdc, m_chik2kpi);
168 status = m_tuple1->addItem (
"chip2kpi", m_idxmdc, m_chip2kpi);
169 status = m_tuple1->addItem (
"ghit2kpi", m_idxmdc, m_ghit2kpi);
170 status = m_tuple1->addItem (
"thit2kpi", m_idxmdc, m_thit2kpi);
171 status = m_tuple1->addIndexedItem(
"probph2kpi", m_idxmdc, m_probph2kpi);
172 status = m_tuple1->addIndexedItem(
"normph2kpi", m_idxmdc, m_normph2kpi);
173 status = m_tuple1->addIndexedItem(
"pidnum2kpi", m_idxmdc, m_pidnum2kpi);
174 status = m_tuple1->addIndexedItem(
"bjmucjs", m_idxmdc, m_bjmucjs);
175 status = m_tuple1->addIndexedItem(
"bjmuc2kpi", m_idxmdc, m_bjmuc2kpi);
176 status = m_tuple1->addIndexedItem(
"bjemcjs", m_idxmdc, m_bjemcjs);
177 status = m_tuple1->addIndexedItem(
"bjemc2kpi", m_idxmdc, m_bjemc2kpi);
178 status = m_tuple1->addIndexedItem(
"bjtofjs", m_idxmdc, m_bjtofjs);
179 status = m_tuple1->addIndexedItem(
"bjtof2kpi", m_idxmdc, m_bjtof2kpi);
180 status = m_tuple1->addIndexedItem(
"bjtofvaljs", m_idxmdc, m_bjtofvaljs);
181 status = m_tuple1->addIndexedItem(
"bjtofval2kpi", m_idxmdc, m_bjtofval2kpi);
183 status = m_tuple1->addIndexedItem(
"emcjs", m_idxmdc, m_emcjs);
184 status = m_tuple1->addIndexedItem(
"evpjs", m_idxmdc, m_evpjs);
185 status = m_tuple1->addIndexedItem(
"timecgjs", m_idxmdc, m_timecgjs);
186 status = m_tuple1->addIndexedItem(
"depthjs", m_idxmdc, m_depthmucjs);
187 status = m_tuple1->addIndexedItem(
"layermucjs", m_idxmdc, m_layermucjs);
189 status = m_tuple1->addIndexedItem(
"emc2kpi", m_idxmdc, m_emc2kpi);
190 status = m_tuple1->addIndexedItem(
"evp2kpi", m_idxmdc, m_evp2kpi);
191 status = m_tuple1->addIndexedItem(
"timecg2kpi", m_idxmdc, m_timecg2kpi);
192 status = m_tuple1->addIndexedItem(
"depth2kpi", m_idxmdc, m_depthmuc2kpi);
193 status = m_tuple1->addIndexedItem(
"layermuc2kpi", m_idxmdc, m_layermuc2kpi);
195 status = m_tuple1->addIndexedItem(
"cotof1js", m_idxmdc, m_cotof1js);
196 status = m_tuple1->addIndexedItem(
"cotof2js", m_idxmdc, m_cotof2js);
197 status = m_tuple1->addIndexedItem(
"counterjs", m_idxmdc, m_counterjs);
198 status = m_tuple1->addIndexedItem(
"barreljs", m_idxmdc, m_barreljs);
199 status = m_tuple1->addIndexedItem(
"layertofjs", m_idxmdc, m_layertofjs);
200 status = m_tuple1->addIndexedItem(
"readoutjs", m_idxmdc, m_readoutjs);
201 status = m_tuple1->addIndexedItem(
"clusterjs", m_idxmdc, m_clusterjs);
202 status = m_tuple1->addIndexedItem(
"betajs", m_idxmdc, m_betajs);
203 status = m_tuple1->addIndexedItem(
"tofjs", m_idxmdc, m_tofjs);
204 status = m_tuple1->addIndexedItem(
"tofpathjs", m_idxmdc, m_tofpathjs);
205 status = m_tuple1->addIndexedItem(
"zhitjs", m_idxmdc, m_zhitjs);
206 status = m_tuple1->addIndexedItem(
"tofIDjs", m_idxmdc, m_tofIDjs);
207 status = m_tuple1->addIndexedItem(
"clusterIDjs", m_idxmdc, m_clusterIDjs);
208 status = m_tuple1->addIndexedItem(
"texejs", m_idxmdc, m_texejs);
209 status = m_tuple1->addIndexedItem(
"texmujs", m_idxmdc, m_texmujs);
210 status = m_tuple1->addIndexedItem(
"texpijs", m_idxmdc, m_texpijs);
211 status = m_tuple1->addIndexedItem(
"texkjs", m_idxmdc, m_texkjs);
212 status = m_tuple1->addIndexedItem(
"texprjs", m_idxmdc, m_texprjs);
213 status = m_tuple1->addIndexedItem(
"dtejs", m_idxmdc, m_dtejs);
214 status = m_tuple1->addIndexedItem(
"dtmujs", m_idxmdc, m_dtmujs);
215 status = m_tuple1->addIndexedItem(
"dtpijs", m_idxmdc, m_dtpijs);
216 status = m_tuple1->addIndexedItem(
"dtkjs", m_idxmdc, m_dtkjs);
217 status = m_tuple1->addIndexedItem(
"dtprjs", m_idxmdc, m_dtprjs);
218 status = m_tuple1->addIndexedItem(
"sigmaetofjs", m_idxmdc, m_sigmaetofjs);
219 status = m_tuple1->addIndexedItem(
"sigmamutofjs", m_idxmdc, m_sigmamutofjs);
220 status = m_tuple1->addIndexedItem(
"sigmapitofjs", m_idxmdc, m_sigmapitofjs);
221 status = m_tuple1->addIndexedItem(
"sigmaktofjs", m_idxmdc, m_sigmaktofjs);
222 status = m_tuple1->addIndexedItem(
"sigmaprtofjs", m_idxmdc, m_sigmaprtofjs);
223 status = m_tuple1->addIndexedItem(
"t0tofjs", m_idxmdc,m_t0tofjs);
224 status = m_tuple1->addIndexedItem(
"errt0tofjs", m_idxmdc,m_errt0tofjs);
225 status = m_tuple1->addIndexedItem(
"cotof12kpi", m_idxmdc, m_cotof12kpi);
226 status = m_tuple1->addIndexedItem(
"cotof22kpi", m_idxmdc, m_cotof22kpi);
227 status = m_tuple1->addIndexedItem(
"counter2kpi", m_idxmdc, m_counter2kpi);
228 status = m_tuple1->addIndexedItem(
"barrel2kpi", m_idxmdc, m_barrel2kpi);
229 status = m_tuple1->addIndexedItem(
"layertof2kpi", m_idxmdc, m_layertof2kpi);
230 status = m_tuple1->addIndexedItem(
"readout2kpi", m_idxmdc, m_readout2kpi);
231 status = m_tuple1->addIndexedItem(
"cluster2kpi", m_idxmdc, m_cluster2kpi);
232 status = m_tuple1->addIndexedItem(
"beta2kpi", m_idxmdc, m_beta2kpi);
233 status = m_tuple1->addIndexedItem(
"tof2kpi", m_idxmdc, m_tof2kpi);
234 status = m_tuple1->addIndexedItem(
"tofpath2kpi", m_idxmdc, m_tofpath2kpi);
235 status = m_tuple1->addIndexedItem(
"zhit2kpi", m_idxmdc, m_zhit2kpi);
236 status = m_tuple1->addIndexedItem(
"tofID2kpi", m_idxmdc, m_tofID2kpi);
237 status = m_tuple1->addIndexedItem(
"clusterID2kpi", m_idxmdc, m_clusterID2kpi);
238 status = m_tuple1->addIndexedItem(
"texe2kpi", m_idxmdc, m_texe2kpi);
239 status = m_tuple1->addIndexedItem(
"texmu2kpi", m_idxmdc, m_texmu2kpi);
240 status = m_tuple1->addIndexedItem(
"texpi2kpi", m_idxmdc, m_texpi2kpi);
241 status = m_tuple1->addIndexedItem(
"texk2kpi", m_idxmdc, m_texk2kpi);
242 status = m_tuple1->addIndexedItem(
"texpr2kpi", m_idxmdc, m_texpr2kpi);
243 status = m_tuple1->addIndexedItem(
"dte2kpi", m_idxmdc, m_dte2kpi);
244 status = m_tuple1->addIndexedItem(
"dtmu2kpi", m_idxmdc, m_dtmu2kpi);
245 status = m_tuple1->addIndexedItem(
"dtpi2kpi", m_idxmdc, m_dtpi2kpi);
246 status = m_tuple1->addIndexedItem(
"dtk2kpi", m_idxmdc, m_dtk2kpi);
247 status = m_tuple1->addIndexedItem(
"dtpr2kpi", m_idxmdc, m_dtpr2kpi);
248 status = m_tuple1->addIndexedItem(
"costpid2kpi", m_idxmdc, m_costpid2kpi);
249 status = m_tuple1->addIndexedItem(
"dedxpid2kpi", m_idxmdc, m_dedxpid2kpi);
250 status = m_tuple1->addIndexedItem(
"tof1pid2kpi", m_idxmdc, m_tof1pid2kpi);
251 status = m_tuple1->addIndexedItem(
"tof2pid2kpi", m_idxmdc, m_tof2pid2kpi);
252 status = m_tuple1->addIndexedItem(
"probe2kpi", m_idxmdc, m_probe2kpi);
253 status = m_tuple1->addIndexedItem(
"probmu2kpi", m_idxmdc, m_probmu2kpi);
254 status = m_tuple1->addIndexedItem(
"probpi2kpi", m_idxmdc, m_probpi2kpi);
255 status = m_tuple1->addIndexedItem(
"probk2kpi", m_idxmdc, m_probk2kpi);
256 status = m_tuple1->addIndexedItem(
"probpr2kpi", m_idxmdc, m_probpr2kpi);
258 status = m_tuple1->addIndexedItem(
"chipidxpid2kpi", m_idxmdc, m_chipidxpid2kpi);
259 status = m_tuple1->addIndexedItem(
"chipitof1pid2kpi", m_idxmdc, m_chipitof1pid2kpi);
260 status = m_tuple1->addIndexedItem(
"chipitof2pid2kpi", m_idxmdc, m_chipitof2pid2kpi);
261 status = m_tuple1->addIndexedItem(
"chipitofpid2kpi", m_idxmdc, m_chipitofpid2kpi);
262 status = m_tuple1->addIndexedItem(
"chipitofepid2kpi", m_idxmdc, m_chipitofepid2kpi);
263 status = m_tuple1->addIndexedItem(
"chipitofqpid2kpi", m_idxmdc, m_chipitofqpid2kpi);
264 status = m_tuple1->addIndexedItem(
"probpidxpid2kpi", m_idxmdc, m_probpidxpid2kpi);
265 status = m_tuple1->addIndexedItem(
"probpitofpid2kpi", m_idxmdc, m_probpitofpid2kpi);
266 status = m_tuple1->addIndexedItem(
"chikdxpid2kpi", m_idxmdc, m_chikdxpid2kpi);
267 status = m_tuple1->addIndexedItem(
"chiktof1pid2kpi", m_idxmdc, m_chiktof1pid2kpi);
268 status = m_tuple1->addIndexedItem(
"chiktof2pid2kpi", m_idxmdc, m_chiktof2pid2kpi);
269 status = m_tuple1->addIndexedItem(
"chiktofpid2kpi", m_idxmdc, m_chiktofpid2kpi);
270 status = m_tuple1->addIndexedItem(
"chiktofepid2kpi", m_idxmdc, m_chiktofepid2kpi);
271 status = m_tuple1->addIndexedItem(
"chiktofqpid2kpi", m_idxmdc, m_chiktofqpid2kpi);
272 status = m_tuple1->addIndexedItem(
"probkdxpid2kpi", m_idxmdc, m_probkdxpid2kpi);
273 status = m_tuple1->addIndexedItem(
"probktofpid2kpi", m_idxmdc, m_probktofpid2kpi);
275 status = m_tuple1->addIndexedItem(
"chiprdxpid2kpi", m_idxmdc, m_chiprdxpid2kpi);
276 status = m_tuple1->addIndexedItem(
"chiprtof1pid2kpi", m_idxmdc, m_chiprtof1pid2kpi);
277 status = m_tuple1->addIndexedItem(
"chiprtof2pid2kpi", m_idxmdc, m_chiprtof2pid2kpi);
278 status = m_tuple1->addIndexedItem(
"chiprtofpid2kpi", m_idxmdc, m_chiprtofpid2kpi);
279 status = m_tuple1->addIndexedItem(
"chiprtofepid2kpi", m_idxmdc, m_chiprtofepid2kpi);
280 status = m_tuple1->addIndexedItem(
"chiprtofqpid2kpi", m_idxmdc, m_chiprtofqpid2kpi);
281 status = m_tuple1->addIndexedItem(
"probprdxpid2kpi", m_idxmdc, m_probprdxpid2kpi);
282 status = m_tuple1->addIndexedItem(
"probprtofpid2kpi", m_idxmdc, m_probprtofpid2kpi);
284 status = m_tuple1->addIndexedItem(
"cosmdcjs", m_idxmdc, m_cosmdcjs);
285 status = m_tuple1->addIndexedItem(
"phimdcjs", m_idxmdc, m_phimdcjs);
286 status = m_tuple1->addIndexedItem(
"cosmdc2kpi", m_idxmdc, m_cosmdc2kpi);
287 status = m_tuple1->addIndexedItem(
"phimdc2kpi", m_idxmdc, m_phimdc2kpi);
289 status = m_tuple1->addIndexedItem(
"dedxpidjs", m_idxmdc, m_dedxpidjs);
290 status = m_tuple1->addIndexedItem(
"tof1pidjs", m_idxmdc, m_tof1pidjs);
291 status = m_tuple1->addIndexedItem(
"tof2pidjs", m_idxmdc, m_tof2pidjs);
292 status = m_tuple1->addIndexedItem(
"probejs", m_idxmdc, m_probejs);
293 status = m_tuple1->addIndexedItem(
"probmujs", m_idxmdc, m_probmujs);
294 status = m_tuple1->addIndexedItem(
"probpijs", m_idxmdc, m_probpijs);
295 status = m_tuple1->addIndexedItem(
"probkjs", m_idxmdc, m_probkjs);
296 status = m_tuple1->addIndexedItem(
"probprjs", m_idxmdc, m_probprjs);
297 status = m_tuple1->addItem (
"mchic2kpi", m_mchic2kpi);
298 status = m_tuple1->addItem (
"mpsip2kpi", m_mpsip2kpi);
299 status = m_tuple1->addItem (
"chis2kpi", m_chis2kpi);
300 status = m_tuple1->addItem (
"mchic4c2kpi", m_mchic4c2kpi);
301 status = m_tuple1->addItem (
"mpsip4c2kpi", m_mpsip4c2kpi);
302 status = m_tuple1->addItem (
"chis4c2kpi", m_chis4c2kpi);
304 status = m_tuple1->addItem(
"indexemc", m_idxemc, 0, 5000);
305 status = m_tuple1->addIndexedItem(
"numHits", m_idxemc, m_numHits);
306 status = m_tuple1->addIndexedItem(
"secmom", m_idxemc, m_secondmoment);
307 status = m_tuple1->addIndexedItem(
"latmom", m_idxemc, m_latmoment);
308 status = m_tuple1->addIndexedItem(
"timegm", m_idxemc, m_timegm);
309 status = m_tuple1->addIndexedItem(
"cellId", m_idxemc, m_cellId);
310 status = m_tuple1->addIndexedItem(
"module", m_idxemc, m_module);
311 status = m_tuple1->addIndexedItem(
"a20Moment", m_idxemc, m_a20Moment);
312 status = m_tuple1->addIndexedItem(
"a42Moment", m_idxemc, m_a42Moment);
313 status = m_tuple1->addIndexedItem(
"getEAll", m_idxemc, m_getEAll);
314 status = m_tuple1->addIndexedItem(
"getShowerId", m_idxemc, m_getShowerId);
315 status = m_tuple1->addIndexedItem(
"getClusterId", m_idxemc, m_getClusterId);
316 status = m_tuple1->addIndexedItem(
"x", m_idxemc, m_x);
317 status = m_tuple1->addIndexedItem(
"y", m_idxemc, m_y);
318 status = m_tuple1->addIndexedItem(
"z", m_idxemc, m_z);
319 status = m_tuple1->addIndexedItem(
"cosemc", m_idxemc, m_cosemc);
320 status = m_tuple1->addIndexedItem(
"phiemc", m_idxemc, m_phiemc);
321 status = m_tuple1->addIndexedItem(
"energy", m_idxemc, m_energy);
322 status = m_tuple1->addIndexedItem(
"e1", m_idxemc, m_eSeed);
323 status = m_tuple1->addIndexedItem(
"e9", m_idxemc, m_e3x3);
324 status = m_tuple1->addIndexedItem(
"e25", m_idxemc, m_e5x5);
325 status = m_tuple1->addIndexedItem(
"dang4c", m_idxemc, m_dang4c);
326 status = m_tuple1->addIndexedItem(
"dthe4c", m_idxemc, m_dthe4c);
327 status = m_tuple1->addIndexedItem(
"dphi4c", m_idxemc, m_dphi4c);
328 status = m_tuple1->addIndexedItem(
"dang4crt", m_idxemc, m_dang4crt);
329 status = m_tuple1->addIndexedItem(
"dthe4crt", m_idxemc, m_dthe4crt);
330 status = m_tuple1->addIndexedItem(
"dphi4crt", m_idxemc, m_dphi4crt);
331 status = m_tuple1->addIndexedItem(
"phtof", m_idxemc, 3, m_phgmtof,0.0,10000.0);
332 status = m_tuple1->addIndexedItem(
"phgmtof0", m_idxemc, m_phgmtof0);
333 status = m_tuple1->addIndexedItem(
"phgmtof1", m_idxemc, m_phgmtof1);
334 status = m_tuple1->addIndexedItem(
"phgmtof2", m_idxemc, m_phgmtof2);
338 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple1) << endmsg;
339 return StatusCode::FAILURE;
348 sc = createSubAlgorithm(
"EventWriter",
"Selectgam4pi", m_subalg1);
349 if( sc.isFailure() ) {
350 log << MSG::ERROR <<
"Error creating Sub-Algorithm Selectgam4pi" <<endreq;
353 log << MSG::INFO <<
"Success creating Sub-Algorithm Selectgam4pi" <<endreq;
360 sc = createSubAlgorithm(
"EventWriter",
"Selectgam4k", m_subalg2);
361 if( sc.isFailure() ) {
362 log << MSG::ERROR <<
"Error creating Sub-Algorithm Selectgam4k" <<endreq;
365 log << MSG::INFO <<
"Success creating Sub-Algorithm Selectgam4k" <<endreq;
371 sc = createSubAlgorithm(
"EventWriter",
"Selectgam2pi2pr", m_subalg3);
372 if( sc.isFailure() ) {
373 log << MSG::ERROR <<
"Error creating Sub-Algorithm Selectgam2pi2pr" <<endreq;
376 log << MSG::INFO <<
"Success creating Sub-Algorithm Selectgam2pi2pr" <<endreq;
387 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
388 return StatusCode::SUCCESS;
396 setFilterPassed(
false);
399 MsgStream log(
msgSvc(), name());
400 log << MSG::INFO <<
"in execute()" << endreq;
402 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
403 int run=eventHeader->runNumber();
404 int event=eventHeader->eventNumber();
405 log << MSG::DEBUG <<
"run, evtnum = "
417 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
418 << evtRecEvent->totalCharged() <<
" , "
419 << evtRecEvent->totalNeutral() <<
" , "
420 << evtRecEvent->totalTracks() <<endreq;
432 if (eventHeader->runNumber()<0)
434 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
435 int m_numParticle = 0;
439 return StatusCode::FAILURE;
443 bool psipDecay =
false;
445 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
446 for (; iter_mc != mcParticleCol->end(); iter_mc++)
448 if ((*iter_mc)->primaryParticle())
continue;
449 if (!(*iter_mc)->decayFromGenerator())
continue;
450 if ((*iter_mc)->particleProperty()==100443)
453 rootIndex = (*iter_mc)->trackIndex();
455 if (!psipDecay)
continue;
456 int mcidx = ((*iter_mc)->mother()).trackIndex() - rootIndex;
457 int pdgid = (*iter_mc)->particleProperty();
458 m_pdgid[m_numParticle] = pdgid;
459 m_motheridx[m_numParticle] = mcidx;
463 m_idxmc = m_numParticle;
467 Vint iGood, ipip, ipim;
480 Hep3Vector vv(0,0,0);
483 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
491 vv.setX(vertexsigma[0]);
492 vv.setY(vertexsigma[1]);
493 vv.setZ(vertexsigma[2]);
509 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
510 if(i>=evtRecTrkCol->size())
break;
513 if(!(*itTrk)->isMdcTrackValid())
continue;
514 if (!(*itTrk)->isMdcKalTrackValid())
continue;
518 HepVector a = mdcTrk->
helix();
519 HepSymMatrix Ea = mdcTrk->
err();
524 HepVector
vec = helixp.
a();
525 pTrkCh.push_back(mdcTrk->
p()*mdcTrk->
charge());
526 iGood.push_back((*itTrk)->trackId());
527 nCharge += mdcTrk->
charge();
531 int nGood = iGood.size();
532 log << MSG::DEBUG <<
"ngood, totcharge = " << nGood <<
" , " << nCharge << endreq;
535 return StatusCode::SUCCESS;
545 for(
int i = evtRecEvent->totalCharged(); i< evtRecEvent->totalTracks(); i++) {
547 if(i>=evtRecTrkCol->size())
break;
549 if(!(*itTrk)->isEmcShowerValid())
continue;
551 Hep3Vector emcpos(emcTrk->
x(), emcTrk->
y(), emcTrk->
z());
561 for(
int j = 0; j < evtRecEvent->totalCharged(); j++) {
562 if(j>=evtRecTrkCol->size())
break;
564 if(!(*jtTrk)->isExtTrackValid())
continue;
569 double angd = extpos.angle(emcpos);
570 double thed = extpos.theta() - emcpos.theta();
571 double phid = extpos.deltaPhi(emcpos);
572 thed = fmod(thed+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
573 phid = fmod(phid+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
579 if(angd < dang){ dang=angd;
586 double eraw = emcTrk->
energy();
587 dthe = dthe * 180 / (CLHEP::pi);
588 dphi = dphi * 180 / (CLHEP::pi);
589 dang = dang * 180 / (CLHEP::pi);
594 iGam.push_back((*itTrk)->trackId());
595 if(eraw < m_energyThreshold)
continue;
596 if(dang < 20.0)
continue;
597 iGamnofit.push_back((*itTrk)->trackId());
602 int nGam = iGam.size();
603 int nGamnofit = iGamnofit.size();
605 log << MSG::DEBUG <<
"num Good Photon " << nGam <<
" , " <<evtRecEvent->totalNeutral()<<endreq;
607 return StatusCode::SUCCESS;
611 if(nGood>20||nGam>30)
return StatusCode::SUCCESS;
621 for(
int i = 0; i < nGam; i++) {
624 double eraw = emcTrk->
energy();
625 double phi = emcTrk->
phi();
626 double the = emcTrk->
theta();
627 HepLorentzVector ptrk;
628 ptrk.setPx(eraw*
sin(the)*
cos(phi));
629 ptrk.setPy(eraw*
sin(the)*
sin(phi));
630 ptrk.setPz(eraw*
cos(the));
635 pGam.push_back(ptrk);
643 for(
int i = 0; i < nGood; i++) {
650 if(mdcKalTrk->
charge() >0) {
651 ipip.push_back(iGood[i]);
652 HepLorentzVector ptrk;
653 ptrk.setPx(mdcKalTrk->
px());
654 ptrk.setPy(mdcKalTrk->
py());
655 ptrk.setPz(mdcKalTrk->
pz());
656 double p3 = ptrk.mag();
657 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
660 ppip.push_back(ptrk);
662 ipim.push_back(iGood[i]);
663 HepLorentzVector ptrk;
664 ptrk.setPx(mdcKalTrk->
px());
665 ptrk.setPy(mdcKalTrk->
py());
666 ptrk.setPz(mdcKalTrk->
pz());
667 double p3 = ptrk.mag();
668 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
672 ppim.push_back(ptrk);
675 int npip = ipip.size();
676 int npim = ipim.size();
678 if((npip < 2)||(npim < 2))
return SUCCESS;
691 double chisqtrk = 9999.;
700 double mcompall=9999;
701 double mppreclst=9999;
703 double mchic2kpilst=9999;
704 double chis4c2kpilst=9999;
706 double dtpr2kpilst[4]={9999,9999,9999,9999};
710 HepLorentzVector pgam=(0,0,0,0);
715 HepSymMatrix xem(3,0);
719 HepLorentzVector p4psipjs(0.011*m_ecms, 0.0, 0.0, m_ecms);
720 double psipBetajs = (p4psipjs.vect()).mag()/(p4psipjs.e());
721 HepLorentzVector p4psip(0.011*m_ecms, 0.0, 0.0, m_ecms);
722 double psipBeta = (p4psip.vect()).mag()/(p4psip.e());
724 for(
int ii = 0; ii < npip-1; ii++) {
725 RecMdcKalTrack *pip1Trk = (*(evtRecTrkCol->begin()+ipip[ii]))->mdcKalTrack();
726 for(
int ij = ii+1; ij < npip; ij++) {
727 RecMdcKalTrack *pip2Trk = (*(evtRecTrkCol->begin()+ipip[ij]))->mdcKalTrack();
728 for(
int ik = 0; ik < npim-1; ik++) {
729 RecMdcKalTrack *pim1Trk = (*(evtRecTrkCol->begin()+ipim[ik]))->mdcKalTrack();
730 for(
int il = ik+1; il < npim; il++) {
731 RecMdcKalTrack *pim2Trk = (*(evtRecTrkCol->begin()+ipim[il]))->mdcKalTrack();
732 double squar[3]={9999.,9999.,9999.};
733 double squarkpi[6]={9999.,9999.,9999.,9999.,9999.,9999.};
743 pTrkjs.push_back(pip1Trk->
p()*pip1Trk->
charge());
744 pTrkjs.push_back(pip2Trk->
p()*pip2Trk->
charge());
745 pTrkjs.push_back(pim1Trk->
p()*pim1Trk->
charge());
746 pTrkjs.push_back(pim2Trk->
p()*pim2Trk->
charge());
747 iGoodjs.push_back(ipip[ii]);
748 iGoodjs.push_back(ipip[ij]);
749 iGoodjs.push_back(ipim[ik]);
750 iGoodjs.push_back(ipim[il]);
752 Gam4pikp::BubbleSort(pTrkjs, iGoodjs);
757 Vint i4cpip1js, i4cpip2js, i4cpim1js, i4cpim2js;
762 i4cpip1js.push_back(iGoodjs[2]);
763 i4cpip2js.push_back(iGoodjs[3]);
764 i4cpim1js.push_back(iGoodjs[1]);
765 i4cpim2js.push_back(iGoodjs[0]);
766 jGoodjs.push_back(i4cpip1js[0]);
767 jGoodjs.push_back(i4cpim1js[0]);
768 jGoodjs.push_back(i4cpip2js[0]);
769 jGoodjs.push_back(i4cpim2js[0]);
771 for (
int i = 0; i < 4; i++)
774 if (!(*itTrk)->isMdcTrackValid())
continue;
776 if (!(*itTrk)->isMdcKalTrackValid())
continue;
779 HepLorentzVector p4trk;
783 ptrk = mdcKalTrk->
p();
784 p4trk.setPx(mdcKalTrk->
px());
785 p4trk.setPy(mdcKalTrk->
py());
786 p4trk.setPz(mdcKalTrk->
pz());
787 p4trk.setE(sqrt(ptrk*ptrk+
mpi*
mpi));
791 ptrk = mdcKalTrk->
p();
792 p4trk.setPx(mdcKalTrk->
px());
793 p4trk.setPy(mdcKalTrk->
py());
794 p4trk.setPz(mdcKalTrk->
pz());
795 p4trk.setE(sqrt(ptrk*ptrk+
xmass[0]*
xmass[0]));
797 p4trk.boost(-1.0*psipBetajs, 0.0, 0.0);
798 p4chTrkjs.push_back(p4trk);
800 p4psipjs.boost(-1.0*psipBetajs, 0.0, 0.0);
802 HepLorentzVector p4pipijs = p4chTrkjs[0] + p4chTrkjs[1];
803 HepLorentzVector p4eejs = p4chTrkjs[2] + p4chTrkjs[3];
804 HepLorentzVector p4pipirecjs = p4psipjs - p4pipijs;
805 double mpprecjs=p4pipirecjs.m();
806 double mpipijs=p4pipijs.m();
807 double meejs=p4eejs.m();
808 double mcomp=sqrt((mpprecjs-3.097)*(mpprecjs-3.097)+(meejs-3.097)*(meejs-3.097));
812 ipip1js=i4cpip1js[0];
813 ipim1js=i4cpim1js[0];
814 ipip2js=i4cpip2js[0];
815 ipim2js=i4cpim2js[0];
822 m_mpprecall=mppreclst;
844 return StatusCode::SUCCESS;
846 jsGood.push_back(ipip1js);
847 jsGood.push_back(ipim1js);
848 jsGood.push_back(ipip2js);
849 jsGood.push_back(ipim2js);
851 for(
int i = 0; i < evtRecEvent->totalCharged(); i++)
853 if(i>=evtRecTrkCol->size())
break;
855 if(!(*itTrk)->isMdcTrackValid())
continue;
856 if (!(*itTrk)->isMdcKalTrackValid())
continue;
858 if((i!=ipip1js)&&(i!=ipim1js)&&(i!=ipip2js)&&(i!=ipim2js))
864 int njsGood=jsGood.size();
868 for (
int i = 0; i < njsGood; i++)
871 if (!(*itTrk)->isMdcTrackValid())
continue;
873 if (!(*itTrk)->isMdcKalTrackValid())
continue;
876 ptrk = mdcKalTrk->
p();
877 m_x0js[i] = mdcTrk->
x();
878 m_y0js[i] = mdcTrk->
y();
879 m_z0js[i] = mdcTrk->
z();
880 m_r0js[i] = mdcTrk->
r();
881 m_ppmdcjs[i] = mdcTrk->
p();
882 m_pxmdcjs[i] = mdcTrk->
px();
883 m_pymdcjs[i] = mdcTrk->
py();
884 m_pzmdcjs[i] = mdcTrk->
pz();
885 m_ppkaljs[i] = mdcKalTrk->
p();
886 Hep3Vector p3jsi(mdcTrk->
px(),mdcTrk->
py(),mdcTrk->
pz());
890 Hep3Vector p3js5(mdcTrk5->
px(),mdcTrk5->
py(),mdcTrk5->
pz());
891 m_angjs5[i]=p3jsi.angle(p3js5);
892 m_nearjs5[i]=p3jsi.howNear(p3js5);
897 Hep3Vector p3js6(mdcTrk6->
px(),mdcTrk6->
py(),mdcTrk6->
pz());
898 m_angjs6[i]=p3jsi.angle(p3js6);
899 m_nearjs6[i]=p3jsi.howNear(p3js6);
903 m_ptmdcjs[i] = mdcTrk->
pxy();
904 m_ptkaljs[i] = mdcKalTrk->
pxy();
905 double x0=mdcTrk->
x();
906 double y0=mdcTrk->
y();
907 double z0=mdcTrk->
z();
908 double phi0=mdcTrk->
helix(1);
912 double Rxy=(x0-xv)*
cos(phi0)+(y0-yv)*
sin(phi0);
916 HepVector a = mdcTrk->
helix();
917 HepSymMatrix Ea = mdcTrk->
err();
922 HepVector
vec = helixp.
a();
927 if ((*itTrk)->isTofTrackValid())
930 SmartRefVector<RecTofTrack> tofTrkCol = (*itTrk)->tofTrack();
931 SmartRefVector<RecTofTrack>::iterator iter_tof=tofTrkCol.begin();
932 for (;iter_tof != tofTrkCol.end(); iter_tof++ ){
934 status->
setStatus((*iter_tof)->status());
939 m_layertofjs[i] = status->
layer();
943 m_betajs[i]= (*iter_tof)->beta();
944 m_tofjs[i] = (*iter_tof)->tof();
945 m_tofpathjs[i] = (*iter_tof)->path();
946 m_zhitjs[i]= (*iter_tof)->zrhit();
947 m_texejs[i] = (*iter_tof)->texpElectron();
948 m_texmujs[i] = (*iter_tof)->texpMuon();
949 m_texpijs[i] = (*iter_tof)->texpPion();
950 m_texkjs[i] = (*iter_tof)->texpKaon();
951 m_texprjs[i] = (*iter_tof)->texpProton();
952 m_dtejs[i] = m_tofjs[i] - m_texejs[i];
953 m_dtmujs[i] = m_tofjs[i] - m_texmujs[i];
954 m_dtpijs[i] = m_tofjs[i] - m_texpijs[i];
955 m_dtkjs[i] = m_tofjs[i] - m_texkjs[i];
956 m_dtprjs[i] = m_tofjs[i] - m_texprjs[i];
958 m_sigmaetofjs[i]=(*iter_tof)->sigma(0);
959 m_sigmamutofjs[i]=(*iter_tof)->sigma(1);
960 m_sigmapitofjs[i]=(*iter_tof)->sigma(2);
961 m_sigmaktofjs[i]=(*iter_tof)->sigma(3);
962 m_sigmaprtofjs[i]=(*iter_tof)->sigma(4);
963 m_t0tofjs[i]=(*iter_tof)->t0();
964 m_errt0tofjs[i]=(*iter_tof)->errt0();
966 m_tofIDjs[i]=(*iter_tof)->tofID();
967 m_clusterIDjs[i]=(*iter_tof)->tofTrackID();
973 if ((*itTrk)->isMdcDedxValid())
977 m_chiejs[i] = dedxTrk->
chiE();
978 m_chimujs[i] = dedxTrk->
chiMu();
979 m_chipijs[i] = dedxTrk->
chiPi();
980 m_chikjs[i] = dedxTrk->
chiK();
981 m_chipjs[i] = dedxTrk->
chiP();
984 m_probphjs[i] = dedxTrk->
probPH();
985 m_normphjs[i] = dedxTrk->
normPH();
991 if ( (*itTrk)->isEmcShowerValid() )
995 m_emcjs[i] = emcTrk->
energy();
996 m_evpjs[i] = emcTrk->
energy()/ptrk;
997 m_timecgjs[i] = emcTrk->
time();
1002 if ( (*itTrk)->isMucTrackValid() )
1005 double dpthp = mucTrk->
depth()/25.0;
1008 m_depthmucjs[i]=mucTrk->
depth();
1012 m_cosmdcjs[i] =
cos(mdcTrk->
theta());
1013 m_phimdcjs[i] = mdcTrk->
phi();
1025 m_dedxpidjs[i] = pid->
chiDedx(2);
1026 m_tof1pidjs[i] = pid->
chiTof1(2);
1027 m_tof2pidjs[i] = pid->
chiTof2(2);
1043 Vint iGood2kpi, ipip2kpi, ipim2kpi;
1047 Vp4 ppip2kpi, ppim2kpi;
1051 Vint ipipnofit, ipimnofit, ikpnofit, ikmnofit, ipropnofit, ipromnofit;
1058 Vp4 ppipnofit, ppimnofit, pkpnofit, pkmnofit, ppropnofit, ppromnofit;
1074 double chis2kpi=9999.;
1075 double m4piall=9999.;
1076 double m4kall=9999.;
1077 double mgam4piall=9999.;
1078 double mgam4kall=9999.;
1079 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
1080 if(i>=evtRecTrkCol->size())
break;
1082 if(!(*itTrk)->isMdcTrackValid())
continue;
1083 if (!(*itTrk)->isMdcKalTrackValid())
continue;
1085 double z02kpi = mdcTrk->
z();
1086 double r02kpi = mdcTrk->
r();
1087 HepVector a = mdcTrk->
helix();
1088 HepSymMatrix Ea = mdcTrk->
err();
1093 HepVector
vec = helixp.
a();
1094 double Rnxy02kpi=
vec[0];
1095 double Rnz02kpi=
vec[3];
1098 iGood2kpi.push_back((*itTrk)->trackId());
1100 int nGood2kpi = iGood2kpi.size();
1103 for(
int i = 0; i < nGood2kpi; i++) {
1107 if(mdcKalTrk->
charge() >0) {
1108 ipip2kpi.push_back(iGood2kpi[i]);
1109 p3pip2kpi.push_back(mdcKalTrk->
p());
1110 HepLorentzVector ptrk;
1112 ptrk.setPy(mdcKalTrk->
py());
1113 ptrk.setPz(mdcKalTrk->
pz());
1114 double p3 = ptrk.mag();
1115 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
1116 ppip2kpi.push_back(ptrk);
1118 ipim2kpi.push_back(iGood2kpi[i]);
1119 p3pim2kpi.push_back(mdcKalTrk->
p());
1120 HepLorentzVector ptrk;
1121 ptrk.setPx(mdcKalTrk->
px());
1122 ptrk.setPy(mdcKalTrk->
py());
1123 ptrk.setPz(mdcKalTrk->
pz());
1124 double p3 = ptrk.mag();
1125 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
1126 ppim2kpi.push_back(ptrk);
1129 int npip2kpi = ipip2kpi.size();
1130 int npim2kpi = ipim2kpi.size();
1141 if((npip2kpi == 2)&&(npim2kpi == 2))
1149 xorigin2kpi[0]=9999.;
1150 xorigin2kpi[1]=9999.;
1151 xorigin2kpi[2]=9999.;
1152 HepSymMatrix xem2kpi(3,0);
1154 Gam4pikp::BubbleSort(p3pip2kpi, ipip2kpi);
1155 Gam4pikp::BubbleSort(p3pim2kpi, ipim2kpi);
1158 RecMdcKalTrack *pip12kpiTrk = (*(evtRecTrkCol->begin()+ipip2kpi[0]))->mdcKalTrack();
1159 RecMdcKalTrack *pip22kpiTrk = (*(evtRecTrkCol->begin()+ipip2kpi[1]))->mdcKalTrack();
1160 RecMdcKalTrack *pim12kpiTrk = (*(evtRecTrkCol->begin()+ipim2kpi[0]))->mdcKalTrack();
1161 RecMdcKalTrack *pim22kpiTrk = (*(evtRecTrkCol->begin()+ipim2kpi[1]))->mdcKalTrack();
1162 double squar2kpi[10]={9999.,9999.,9999.,9999.,9999.,9999.,9999.,9999.,9999.,9999.};
1163 double mc12kpi,mc22kpi,mc32kpi,mc42kpi;
1178 WTrackParameter wvpip12kpiTrk, wvpim12kpiTrk, wvpip22kpiTrk, wvpim22kpiTrk;
1179 for(
int k=0;k<6;k++)
1181 if(k==0){mc12kpi=
mpi;mc22kpi=
mpi;mc32kpi=
mpi;mc42kpi=
mpi;}
1182 if(k==1){mc12kpi=
mk;mc22kpi=
mk;mc32kpi=
mk;mc42kpi=
mk;}
1195 HepSymMatrix Evx(3, 0);
1207 vtxfit->
AddTrack(0, wvpip12kpiTrk);
1208 vtxfit->
AddTrack(1, wvpim12kpiTrk);
1209 vtxfit->
AddTrack(2, wvpip22kpiTrk);
1210 vtxfit->
AddTrack(3, wvpim22kpiTrk);
1212 if(!vtxfit->
Fit(0))
continue;
1222 xorigin2kpi = vtxfit->
vx(0);
1223 xem2kpi = vtxfit->
Evx(0);
1226 HepLorentzVector
ecms(0.040547,0,0,3.68632);
1228 double chisq = 9999.;
1230 for(
int i = 0; i < nGam; i++) {
1231 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[i]))->emcShower();
1242 bool oksq = kmfit->
Fit();
1244 double chi2 = kmfit->
chisq();
1253 if(squar2kpi[k]<200&&squar2kpi[k]<chis2kpi)
1256 chis2kpi=squar2kpi[k];
1257 if(squar2kpi[k]<20) n20=n20+1;
1258 if(squar2kpi[k]<30) n30=n30+1;
1260 icgp12kpi=ipip2kpi[0];
1261 icgp22kpi=ipip2kpi[1];
1262 icgm12kpi=ipim2kpi[0];
1263 icgm22kpi=ipim2kpi[1];
1265 wcgp12kpi=wpip12kpiys;
1266 wcgp22kpi=wpip22kpiys;
1267 wcgm12kpi=wpim12kpiys;
1268 wcgm22kpi=wpim22kpiys;
1272 itrak2kpi.push_back(ipip2kpi[0]); itrak2kpi.push_back(ipim2kpi[0]);
1273 itrak2kpi.push_back(ipip2kpi[1]); itrak2kpi.push_back(ipim2kpi[1]);
1277 itrak2kpi.push_back(ipip2kpi[0]); itrak2kpi.push_back(ipim2kpi[0]);
1278 itrak2kpi.push_back(ipip2kpi[1]); itrak2kpi.push_back(ipim2kpi[1]);
1283 itrak2kpi.push_back(ipip2kpi[0]); itrak2kpi.push_back(ipim2kpi[0]);
1284 itrak2kpi.push_back(ipip2kpi[1]); itrak2kpi.push_back(ipim2kpi[1]);
1288 itrak2kpi.push_back(ipip2kpi[1]); itrak2kpi.push_back(ipim2kpi[1]);
1289 itrak2kpi.push_back(ipip2kpi[0]); itrak2kpi.push_back(ipim2kpi[0]);
1293 itrak2kpi.push_back(ipip2kpi[0]); itrak2kpi.push_back(ipim2kpi[1]);
1294 itrak2kpi.push_back(ipip2kpi[1]); itrak2kpi.push_back(ipim2kpi[0]);
1298 itrak2kpi.push_back(ipip2kpi[1]); itrak2kpi.push_back(ipim2kpi[0]);
1299 itrak2kpi.push_back(ipip2kpi[0]); itrak2kpi.push_back(ipim2kpi[1]);
1306 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+igam2kpi))->emcShower();
1316 bool oksq = kmfit->
Fit();
1318 HepLorentzVector pchic2kpi = kmfit->
pfit(0) + kmfit->
pfit(1)+kmfit->
pfit(2) + kmfit->
pfit(3);
1319 HepLorentzVector ppsip2kpi = kmfit->
pfit(0) + kmfit->
pfit(1)+kmfit->
pfit(2) + kmfit->
pfit(3) + kmfit->
pfit(4);
1320 mchic2kpilst=pchic2kpi.m();
1321 chis4c2kpilst=kmfit->
chisq();
1324 m_mchic2kpi = pchic2kpi.m();
1325 m_chis2kpi = kmfit->
chisq();
1326 m_mpsip2kpi=ppsip2kpi.m();
1347 type2kpilst=cls2kpi;
1352 for (
int i = 0; i < 4; i++)
1355 if (!(*itTrk)->isMdcTrackValid())
continue;
1357 if (!(*itTrk)->isMdcKalTrackValid())
continue;
1360 HepLorentzVector p4trk2kpi;
1364 ptrk2kpi = mdcKalTrk->
p();
1365 p4trk2kpi.setPx(mdcKalTrk->
px());
1366 p4trk2kpi.setPy(mdcKalTrk->
py());
1367 p4trk2kpi.setPz(mdcKalTrk->
pz());
1368 p4trk2kpi.setE(sqrt(ptrk2kpi*ptrk2kpi+
mk*
mk));
1369 p2kpi.push_back(p4trk2kpi);
1377 ptrk2kpi = mdcKalTrk->
p();
1378 p4trk2kpi.setPx(mdcKalTrk->
px());
1379 p4trk2kpi.setPy(mdcKalTrk->
py());
1380 p4trk2kpi.setPz(mdcKalTrk->
pz());
1381 p4trk2kpi.setE(sqrt(ptrk2kpi*ptrk2kpi+
mpi*
mpi));
1382 p2kpi.push_back(p4trk2kpi);
1387 ptrk2kpi = mdcKalTrk->
p();
1388 p4trk2kpi.setPx(mdcKalTrk->
px());
1389 p4trk2kpi.setPy(mdcKalTrk->
py());
1390 p4trk2kpi.setPz(mdcKalTrk->
pz());
1391 p4trk2kpi.setE(sqrt(ptrk2kpi*ptrk2kpi+
mpro*
mpro));
1392 p2kpi.push_back(p4trk2kpi);
1397 if(cls2kpi!=1&&cls2kpi!=2)
1400 ptrk2kpi = mdcKalTrk->
p();
1401 p4trk2kpi.setPx(mdcKalTrk->
px());
1402 p4trk2kpi.setPy(mdcKalTrk->
py());
1403 p4trk2kpi.setPz(mdcKalTrk->
pz());
1404 p4trk2kpi.setE(sqrt(ptrk2kpi*ptrk2kpi+
mpi*
mpi));
1405 p2kpi.push_back(p4trk2kpi);
1413 for (
int i = 0; i < 4; i++)
1416 if (!(*itTrk)->isMdcTrackValid())
continue;
1418 if (!(*itTrk)->isMdcKalTrackValid())
continue;
1420 if ((*itTrk)->isTofTrackValid())
1422 SmartRefVector<RecTofTrack> tofTrkCol = (*itTrk)->tofTrack();
1423 SmartRefVector<RecTofTrack>::iterator iter_tof=tofTrkCol.begin();
1424 for (;iter_tof != tofTrkCol.end(); iter_tof++ ){
1426 status->
setStatus((*iter_tof)->status());
1427 if(status->
is_cluster()){ dtpr2kpilst[i]=((*iter_tof)->tof()-(*iter_tof)->texpProton());
1469 for (
int i = 0; i < 4; i++)
1472 if (!(*itTrk)->isMdcTrackValid())
continue;
1474 if (!(*itTrk)->isMdcKalTrackValid())
continue;
1476 m_ppmdc2kpi[i]=mdcTrk->
p();
1477 m_pxmdc2kpi[i]=mdcTrk->
px();
1478 m_pymdc2kpi[i]=mdcTrk->
py();
1479 m_pzmdc2kpi[i]=mdcTrk->
pz();
1480 m_ppkal2kpi[i]=mdcKalTrk->
p();
1481 m_charge2kpi[i]=mdcKalTrk->
charge();
1483 ptrk=mdcKalTrk->
p();
1485 if (eventHeader->runNumber()<0)
1487 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
1488 int m_numParticle = 0;
1492 return StatusCode::FAILURE;
1496 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
1497 for (; iter_mc != mcParticleCol->end(); iter_mc++)
1499 int pdgcode = (*iter_mc)->particleProperty();
1501 px=(*iter_mc)->initialFourMomentum().x();
1502 py=(*iter_mc)->initialFourMomentum().y();
1503 pz=(*iter_mc)->initialFourMomentum().z();
1505 commc=ptrk*ptrk-px*px-py*py-pz*pz;
1506 if(fabs(commc)<fabs(mcall))
1519 if ((*itTrk)->isTofTrackValid())
1520 { m_bjtofval2kpi[i]=1;
1522 SmartRefVector<RecTofTrack> tofTrkCol = (*itTrk)->tofTrack();
1523 SmartRefVector<RecTofTrack>::iterator iter_tof=tofTrkCol.begin();
1524 for (;iter_tof != tofTrkCol.end(); iter_tof++ ){
1526 status->
setStatus((*iter_tof)->status());
1534 m_layertof2kpi[i] = status->
layer();
1538 m_beta2kpi[i]= (*iter_tof)->beta();
1539 m_tof2kpi[i] = (*iter_tof)->tof();
1540 m_tofpath2kpi[i] = (*iter_tof)->path();
1541 m_zhit2kpi[i]= (*iter_tof)->zrhit();
1542 m_texe2kpi[i] = (*iter_tof)->texpElectron();
1543 m_texmu2kpi[i] = (*iter_tof)->texpMuon();
1544 m_texpi2kpi[i] = (*iter_tof)->texpPion();
1545 m_texk2kpi[i] = (*iter_tof)->texpKaon();
1546 m_texpr2kpi[i] = (*iter_tof)->texpProton();
1547 m_dte2kpi[i] = m_tof2kpi[i] - m_texe2kpi[i];
1548 m_dtmu2kpi[i] = m_tof2kpi[i] - m_texmu2kpi[i];
1549 m_dtpi2kpi[i] = m_tof2kpi[i] - m_texpi2kpi[i];
1550 m_dtk2kpi[i] = m_tof2kpi[i] - m_texk2kpi[i];
1551 m_dtpr2kpi[i] = m_tof2kpi[i] - m_texpr2kpi[i];
1552 m_tofID2kpi[i]=(*iter_tof)->tofID();
1553 m_clusterID2kpi[i]=(*iter_tof)->tofTrackID();
1554 m_sigmaetof2kpi[i]=(*iter_tof)->sigma(0);
1555 m_sigmamutof2kpi[i]=(*iter_tof)->sigma(1);
1556 m_sigmapitof2kpi[i]=(*iter_tof)->sigma(2);
1557 m_sigmaktof2kpi[i]=(*iter_tof)->sigma(3);
1558 m_sigmaprtof2kpi[i]=(*iter_tof)->sigma(4);
1559 m_t0tof2kpi[i]=(*iter_tof)->t0();
1560 m_errt0tof2kpi[i]=(*iter_tof)->errt0();
1572 if ((*itTrk)->isMdcDedxValid())
1575 m_chie2kpi[i] = dedxTrk->
chiE();
1576 m_chimu2kpi[i] = dedxTrk->
chiMu();
1577 m_chipi2kpi[i] = dedxTrk->
chiPi();
1578 m_chik2kpi[i] = dedxTrk->
chiK();
1579 m_chip2kpi[i] = dedxTrk->
chiP();
1582 m_probph2kpi[i] = dedxTrk->
probPH();
1583 m_normph2kpi[i] = dedxTrk->
normPH();
1587 if ( (*itTrk)->isEmcShowerValid() )
1591 m_emc2kpi[i] = emcTrk->
energy();
1592 m_evp2kpi[i] = emcTrk->
energy()/ptrk;
1593 m_timecg2kpi[i] = emcTrk->
time();
1598 if ( (*itTrk)->isMucTrackValid() )
1601 double dpthp = mucTrk->
depth()/25.0;
1603 m_depthmuc2kpi[i]=mucTrk->
depth();
1604 m_layermuc2kpi[i] = mucTrk->
numLayers();
1607 m_cosmdc2kpi[i] =
cos(mdcTrk->
theta());
1608 m_phimdc2kpi[i] = mdcTrk->
phi();
1610 m_pidnum2kpi[i]=(*itTrk)->partId();
1614 if(mppreclst<3.06&&chis4c2kpilst<20&&((mchic2kpilst>3.39&&mchic2kpilst<3.44)||(mchic2kpilst>3.5&&mchic2kpilst<3.57))&&type2kpilst==0)
1616 if(i<4) (*itTrk)->setPartId(3);
1619if(mppreclst<3.06&&chis4c2kpilst<20&&((mchic2kpilst>3.39&&mchic2kpilst<3.44)||(mchic2kpilst>3.5&&mchic2kpilst<3.57))&&type2kpilst==1&&dtpr2kpilst[0]<-0.4&&dtpr2kpilst[1]<-0.4&&dtpr2kpilst[2]<-0.4&&dtpr2kpilst[3]<-0.4)
1621 if(i<4) (*itTrk)->setPartId(4);
1625if(mppreclst<3.06&&chis4c2kpilst<20&&((mchic2kpilst>3.39&&mchic2kpilst<3.44)||(mchic2kpilst>3.5&&mchic2kpilst<3.57))&&type2kpilst==2)
1627 if(i==0||i==1) (*itTrk)->setPartId(3);
1628 if(i==2||i==3) (*itTrk)->setPartId(5);
1643 m_costpid2kpi[i] =
cos(mdcTrk->
theta());
1663if(mppreclst<3.06&&chis4c2kpilst<20&&((mchic2kpilst>3.39&&mchic2kpilst<3.44)||(mchic2kpilst>3.5&&mchic2kpilst<3.57))&&type2kpilst==0)
1665 jGam2kpi.push_back(igam2kpi);
1668 for(
int i = evtRecEvent->totalCharged(); i< evtRecEvent->totalTracks(); i++) {
1669 if(i>=evtRecTrkCol->size())
break;
1671 if(!(*itTrk)->isEmcShowerValid())
continue;
1672if(mppreclst<3.06&&chis4c2kpilst<20&&((mchic2kpilst>3.39&&mchic2kpilst<3.44)||(mchic2kpilst>3.5&&mchic2kpilst<3.57))&&type2kpilst==0)
1674 if(i!=igam2kpi) jGam2kpi.push_back((*itTrk)->trackId());
1677 jGam2kpi.push_back((*itTrk)->trackId());
1682int ngam2kpi=jGam2kpi.size();
1686for(
int i = 0; i< ngam2kpi; i++) {
1687 if(i>=evtRecTrkCol->size())
break;
1689 if(!(*itTrk)->isEmcShowerValid())
continue;
1690 RecEmcShower *emcTrk = (*(evtRecTrkCol->begin()+jGam2kpi[i]))->emcShower();
1691 Hep3Vector emcpos(emcTrk->
x(), emcTrk->
y(), emcTrk->
z());
1698 for(
int j = 0; j < evtRecEvent->totalCharged(); j++) {
1699 if(j>=evtRecTrkCol->size())
break;
1701 if(!(*jtTrk)->isExtTrackValid())
continue;
1705 double angd = extpos.angle(emcpos);
1706 double thed = extpos.theta() - emcpos.theta();
1707 double phid = extpos.deltaPhi(emcpos);
1708 thed = fmod(thed+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
1709 phid = fmod(phid+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
1713 if(angd < dang) { dang = angd;
1719 if(dang>=200)
continue;
1720 double eraw = emcTrk->
energy();
1721 dthe = dthe * 180 / (CLHEP::pi);
1722 dphi = dphi * 180 / (CLHEP::pi);
1723 dang = dang * 180 / (CLHEP::pi);
1727 m_numHits[i]= emcTrk->
numHits();
1730 m_timegm[i] = emcTrk->
time();
1731 m_cellId[i]=emcTrk->
cellId();
1732 m_module[i]=emcTrk->
module();
1737 m_getEAll[i]=emcTrk->
getEAll();
1738 m_x[i]= emcTrk->
x();
1739 m_y[i]= emcTrk->
y();
1740 m_z[i]= emcTrk->
z();
1741 m_cosemc[i] =
cos(emcTrk->
theta());
1742 m_phiemc[i] = emcTrk->
phi();
1743 m_energy[i] = emcTrk->
energy();
1744 m_eSeed[i] = emcTrk->
eSeed();
1745 m_e3x3[i] = emcTrk->
e3x3();
1746 m_e5x5[i] = emcTrk->
e5x5();
1768if(mppreclst<3.06&&chis4c2kpilst<20&&((mchic2kpilst>3.39&&mchic2kpilst<3.44)||(mchic2kpilst>3.5&&mchic2kpilst<3.57))&&type2kpilst==0)
1769 {m_subalg1->execute();
1778if(mppreclst<3.06&&chis4c2kpilst<20&&((mchic2kpilst>3.39&&mchic2kpilst<3.44)||(mchic2kpilst>3.5&&mchic2kpilst<3.57))&&type2kpilst==1&&dtpr2kpilst[0]<-0.4&&dtpr2kpilst[1]<-0.4&&dtpr2kpilst[2]<-0.4&&dtpr2kpilst[3]<-0.4)
1779 {m_subalg2->execute();
1786if(mppreclst<3.06&&chis4c2kpilst<20&&((mchic2kpilst>3.39&&mchic2kpilst<3.44)||(mchic2kpilst>3.5&&mchic2kpilst<3.57))&&type2kpilst==2)
1787 {m_subalg3->execute();
1799if((mppreclst<3.06&&chis4c2kpilst<40)||((meelst>3.06&&meelst<3.12)&&(fabs(mppreclst-3.097)<0.01)))
1806 return StatusCode::SUCCESS;
1822 MsgStream log(
msgSvc(), name());
1823 log << MSG::INFO <<
"in finalize()" << endmsg;
1824 return StatusCode::SUCCESS;
1827 void Gam4pikp::InitVar()
1838 for (
int i=0; i<100; i++)
1868 m_charge2kpi[i]=9999;
1871 m_probphjs[i] = 99999;
1872 m_normphjs[i] = 99999;
1874 m_ghit2kpi[i] = 9999;
1875 m_thit2kpi[i] = 9999;
1876 m_probph2kpi[i] = 99999;
1877 m_normph2kpi[i] = 99999;
1881 m_counterjs[i] = 9999;
1882 m_barreljs[i] = 9999;
1883 m_layertofjs[i] = 9999;
1884 m_readoutjs[i] = 9999;
1885 m_clusterjs[i] = 9999;
1887 m_counter2kpi[i] = 9999;
1888 m_barrel2kpi[i] = 9999;
1889 m_layertof2kpi[i] = 9999;
1890 m_readout2kpi[i] = 9999;
1891 m_cluster2kpi[i] = 9999;
1893 m_comcs2kpi[i]=9999;
1899 m_sigmaetof2kpi[i]=9999;
1900 m_sigmamutof2kpi[i]=9999;
1901 m_sigmapitof2kpi[i]=9999;
1902 m_sigmaktof2kpi[i]=9999;
1903 m_sigmaprtof2kpi[i]=9999;
1904 m_t0tof2kpi[i]=9999;
1905 m_errt0tof2kpi[i]=9999;
1907 m_sigmaetofjs[i]=9999;
1908 m_sigmamutofjs[i]=9999;
1909 m_sigmapitofjs[i]=9999;
1910 m_sigmaktofjs[i]=9999;
1911 m_sigmaprtofjs[i]=9999;
1913 m_errt0tofjs[i]=9999;
1922 m_chimu2kpi[i]=9999;
1923 m_chipi2kpi[i]=9999;
1926 m_pidnum2kpi[i]=9999;
1941 void Gam4pikp::BubbleSort(std::vector<double> &p, std::vector<int> &trkid)
1943 if ( (
int) p.size() != (
int) trkid.size() )
1945 std::cout <<
"the two vector have different length!" << std::endl;
1946 std::cout <<
"the size of p is " << (int) p.size() << std::endl;
1947 std::cout <<
"the size of trkid is " << (int) trkid.size() << std::endl;
1948 std::cout <<
"Please check your code!" << std::endl;
1951 unsigned int vsize = p.size();
1954 for (
unsigned int i=0; i<vsize-1; i++ )
1956 for (
unsigned int j=i+1; j<vsize; j++ )
1960 ptemp = p[i]; idtemp = trkid[i];
1961 p[i] = p[j]; trkid[i] = trkid[j];
1962 p[j] = ptemp; trkid[j] = idtemp;
EvtRecTrackCol::iterator EvtRecTrackIterator
HepGeom::Point3D< double > HepPoint3D
std::vector< VertexParameter > Vv
std::vector< HepLorentzVector > Vp4
std::vector< WTrackParameter > Vw
std::vector< double > Vdouble
double sin(const BesAngle a)
double cos(const BesAngle a)
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
double secondMoment() const
const Hep3Vector emcPosition() const
const int emcVolumeNumber() const
void setPx(const double px, const int pid)
static void setPidType(PidType pidType)
const double theta() const
const HepSymMatrix err() const
const HepVector helix() const
......
Gam4pikp(const std::string &name, ISvcLocator *pSvcLocator)
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
void AddFourMomentum(int number, HepLorentzVector p4)
HepLorentzVector pfit(int n) const
static KalmanKinematicFit * instance()
int methodProbability() const
void setChiMinCut(const double chi=4)
void setRecTrack(EvtRecTrack *trk)
void setMethod(const int method)
double chiTof2(int n) const
void identify(const int pidcase)
double probElectron() const
void usePidSys(const int pidsys)
static ParticleID * instance()
bool IsPidInfoValid() const
double chiTof1(int n) const
double probProton() const
double chiDedx(int n) const
RecEmcID getClusterId() const
RecEmcID getShowerId() const
RecEmcEnergy getEAll() const
const HepVector & getZHelix() const
const HepSymMatrix & getZError() const
unsigned int layer() const
void setStatus(unsigned int status)
void setVBeamPosition(const HepSymMatrix VBeamPosition)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
void setBeamPosition(const HepPoint3D BeamPosition)
const HepPoint3D & pivot(void) const
returns pivot position.
const HepVector & a(void) const
returns helix parameters.
WTrackParameter wtrk(int n) const
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
HepSymMatrix Evx(int n) const
HepPoint3D vx(int n) const
static VertexFit * instance()
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol