2#include "GaudiKernel/IDataManagerSvc.h"
3#include "GaudiKernel/SmartDataPtr.h"
4#include "GaudiKernel/IDataProviderSvc.h"
5#include "GaudiKernel/IPartPropSvc.h"
6#include "GaudiKernel/MsgStream.h"
7#include "GaudiKernel/AlgFactory.h"
8#include "GaudiKernel/ISvcLocator.h"
9#include "GaudiKernel/DataSvc.h"
10#include "GaudiKernel/PropertyMgr.h"
11#include "GaudiKernel/Bootstrap.h"
12#include "GaudiKernel/INTupleSvc.h"
16#include "CLHEP/Units/PhysicalConstants.h"
18#include "HepPDT/ParticleDataTable.hh"
19#include "HepPDT/ParticleData.hh"
26#include "CLHEP/Vector/ThreeVector.h"
56 Algorithm(name, pSvcLocator)
58 declareProperty(
"Debug", m_debug =0);
59 declareProperty(
"version", m_ver =2);
60 declareProperty(
"CheckMCSoleTrk", m_checkSingleTrkMC=0);
61 declareProperty(
"HistFile", m_fname);
62 declareProperty(
"HistFileMode", m_fmode =
"recreate");
63 declareProperty(
"PostFix", m_postfix =
"");
64 declareProperty(
"ParticleType", m_pid);
65 declareProperty(
"isDst", m_dst =
true );
66 declareProperty(
"UseCut", m_UseCut );
67 declareProperty(
"z_slope", m_z_slope );
68 declareProperty(
"z_Par1", m_z_Par1 );
69 declareProperty(
"z_Par2", m_z_Par2 );
70 declareProperty(
"z_Par3", m_z_Par3 );
71 declareProperty(
"z_nSigma",m_z_nSigma );
72 declareProperty(
"z_bound", m_z_bound );
73 declareProperty(
"phi_slope", m_phi_slope );
74 declareProperty(
"phi_3Par", m_phi_3Par );
75 declareProperty(
"phi_4Par", m_phi_4Par );
76 declareProperty(
"phi_nSigma", m_phi_nSigma );
77 declareProperty(
"phi_bound", m_phi_bound );
78 declareProperty(
"UseTesterSim", m_UseTesterSim );
84 MsgStream log(
msgSvc(), name());
85 log << MSG::INFO <<
"in initialize()" << endreq;
90 N_cluster = 0;N_strip = 0;N_XV_cluster = 0; N_hit = 0;N_flag3 = 0; N_sim_strip = 0; N_trk = 0;N_N21 = 0; N_N23 = 0; N_sim_N21 =0; N_sim_N23 =0;N_OutRange = 0;
91 N_PiL2 = 0;N_PiE0 = 0;N_PiM7 = 0;N_Match=0;N_Event=0;N_4cluster = 0;
92 N_nonPi = 0; N_ErrMat = 0; N_CrossMat = 0; N_OtherPar4 = 0;N_OtherPar3 = 0; N_OtherPar = 0; N_3cluster = 0; N_inTrk3 = 0; N_InTrk = 0; N_outTrk = 0;
93 N_Match_hit = 0;N_Match_all_hit = 0;OutDetecter = 0;
94 if(m_checkSingleTrkMC>0)
99 int postfixlen = m_postfix.length();
101 char *foldername = (
char *)malloc((postfixlen + 15) *
sizeof(char));
102 sprintf(foldername,
"FILE145/CgemRec%s", m_postfix.c_str());
104 if ( mt ) cgem_ntuple = mt;
106 cgem_ntuple =
ntupleSvc->book(foldername, CLID_ColumnWiseTuple,
"CgemSegment");
110 status = cgem_ntuple->addItem(
"run", cgem_run);
111 status = cgem_ntuple->addItem(
"evt", cgem_evt);
112 status = cgem_ntuple->addItem(
"ncluster",cgem_ncluster,0,1000);
113 status = cgem_ntuple->addIndexedItem(
"clusterid", cgem_ncluster , cgem_clusterid);
114 status = cgem_ntuple->addIndexedItem(
"layerid", cgem_ncluster , cgem_layerid);
115 status = cgem_ntuple->addIndexedItem(
"sheetid", cgem_ncluster , cgem_sheetid);
116 status = cgem_ntuple->addIndexedItem(
"flag", cgem_ncluster , cgem_flag);
117 status = cgem_ntuple->addIndexedItem(
"energydeposit", cgem_ncluster , cgem_energydeposit);
118 status = cgem_ntuple->addIndexedItem(
"recphi", cgem_ncluster , cgem_recphi);
119 status = cgem_ntuple->addIndexedItem(
"recv", cgem_ncluster , cgem_recv);
120 status = cgem_ntuple->addIndexedItem(
"recZ", cgem_ncluster , cgem_recZ);
121 status = cgem_ntuple->addIndexedItem(
"clusterflag_first", cgem_ncluster , cgem_clusterflag_first);
122 status = cgem_ntuple->addIndexedItem(
"clusterflag_second", cgem_ncluster , cgem_clusterflag_second);
124 status = cgem_ntuple->addItem(
"rec_nStrip_PerE",cgem_test_nStrip,0,3000);
125 status = cgem_ntuple->addIndexedItem(
"rec_ident_ID", cgem_test_nStrip , cgem_ident_ID);
126 status = cgem_ntuple->addIndexedItem(
"rec_strip_type", cgem_test_nStrip , cgem_strip_type);
127 status = cgem_ntuple->addIndexedItem(
"rec_strip_ID", cgem_test_nStrip , cgem_strip_ID);
128 status = cgem_ntuple->addIndexedItem(
"rec_sheet_ID", cgem_test_nStrip , cgem_sheet_ID);
129 status = cgem_ntuple->addIndexedItem(
"rec_layer_ID", cgem_test_nStrip , cgem_layer_ID);
130 status = cgem_ntuple->addItem(
"XV_ncluster",cgem_XV_ncluster,0,2000);
131 status = cgem_ntuple->addIndexedItem(
"rec_nStrip", cgem_XV_ncluster , cgem_nStrip);
132 status = cgem_ntuple->addIndexedItem(
"rec_nStrip_flagb", cgem_XV_ncluster , cgem_nStrip_flagb);
133 status = cgem_ntuple->addIndexedItem(
"XV_clusterid", cgem_XV_ncluster , cgem_XV_clusterid);
134 status = cgem_ntuple->addIndexedItem(
"XV_flag", cgem_XV_ncluster , cgem_XV_flag);
135 status = cgem_ntuple->addIndexedItem(
"XV_layerID", cgem_XV_ncluster , cgem_XV_layerID);
136 status = cgem_ntuple->addItem(
"rec_Num21",cgem_Num21,0,10000);
137 status = cgem_ntuple->addIndexedItem(
"rec_IsTruth21", cgem_Num21, cgem_IsTruth21);
138 status = cgem_ntuple->addIndexedItem(
"rec_pdg21", cgem_Num21, cgem_pdg21);
139 status = cgem_ntuple->addIndexedItem(
"rec_deltaZ21", cgem_Num21, cgem_deltaZ21);
140 status = cgem_ntuple->addIndexedItem(
"rec_deltaPhi21", cgem_Num21, cgem_deltaPhi21);
141 status = cgem_ntuple->addItem(
"rec_Num23",cgem_Num23,0,10000);
142 status = cgem_ntuple->addIndexedItem(
"rec_IsTruth23", cgem_Num23, cgem_IsTruth23);
143 status = cgem_ntuple->addIndexedItem(
"rec_pdg23", cgem_Num23, cgem_pdg23);
144 status = cgem_ntuple->addIndexedItem(
"rec_deltaZ23", cgem_Num23, cgem_deltaZ23);
145 status = cgem_ntuple->addIndexedItem(
"rec_deltaPhi23", cgem_Num23, cgem_deltaPhi23);
147 status = cgem_ntuple->addItem(
"MC_nhit", m_mc_nHit, 0, 1000);
148 status = cgem_ntuple->addIndexedItem(
"sim_nStrip",m_mc_nHit,m_mc_nStrip);
149 status = cgem_ntuple->addIndexedItem(
"sim_nStripB",m_mc_nHit,m_mc_nStripB);
150 status = cgem_ntuple->addIndexedItem(
"hittrackID",m_mc_nHit, m_mc_ID_track);
151 status = cgem_ntuple->addIndexedItem(
"CgemlayerID",m_mc_nHit, m_mc_ID_layer);
152 status = cgem_ntuple->addIndexedItem(
"pdg_code", m_mc_nHit,m_mc_pdg_code);
153 status = cgem_ntuple->addIndexedItem(
"ParentID", m_mc_nHit,m_mc_ID_parent);
154 status = cgem_ntuple->addIndexedItem(
"Deposit_Energy", m_mc_nHit,m_mc_E_deposit);
155 status = cgem_ntuple->addIndexedItem(
"X_pre_point", m_mc_nHit, m_mc_XYZ_pre_X );
156 status = cgem_ntuple->addIndexedItem(
"Y_pre_point", m_mc_nHit, m_mc_XYZ_pre_Y );
157 status = cgem_ntuple->addIndexedItem(
"Z_pre_point", m_mc_nHit, m_mc_XYZ_pre_Z );
158 status = cgem_ntuple->addIndexedItem(
"X_post_point", m_mc_nHit, m_mc_XYZ_post_X );
159 status = cgem_ntuple->addIndexedItem(
"Y_post_point", m_mc_nHit, m_mc_XYZ_post_Y );
160 status = cgem_ntuple->addIndexedItem(
"Z_post_point", m_mc_nHit, m_mc_XYZ_post_Z );
161 status = cgem_ntuple->addIndexedItem(
"P_X_pre_point", m_mc_nHit, m_mc_P_pre_X);
162 status = cgem_ntuple->addIndexedItem(
"P_Y_pre_point", m_mc_nHit, m_mc_P_pre_Y);
163 status = cgem_ntuple->addIndexedItem(
"P_Z_pre_point", m_mc_nHit, m_mc_P_pre_Z);
164 status = cgem_ntuple->addIndexedItem(
"P_X_post_point",m_mc_nHit, m_mc_P_post_X);
165 status = cgem_ntuple->addIndexedItem(
"P_Y_post_point",m_mc_nHit, m_mc_P_post_Y);
166 status = cgem_ntuple->addIndexedItem(
"P_Z_post_point",m_mc_nHit, m_mc_P_post_Z);
167 status = cgem_ntuple->addIndexedItem(
"rec_truth_phi", m_mc_nHit, m_mc_rec_phi);
168 status = cgem_ntuple->addIndexedItem(
"rec_truth_v", m_mc_nHit, m_mc_rec_v);
169 status = cgem_ntuple->addIndexedItem(
"rec_truth_z", m_mc_nHit, m_mc_rec_z);
170 status = cgem_ntuple->addItem(
"sim_nStrip_PerE",mc_test_nStrip,0,3000);
171 status = cgem_ntuple->addIndexedItem(
"sim_ident_ID", mc_test_nStrip , m_mc_ident_ID);
172 status = cgem_ntuple->addIndexedItem(
"sim_strip_type", mc_test_nStrip , m_mc_strip_type);
173 status = cgem_ntuple->addIndexedItem(
"sim_strip_ID" , mc_test_nStrip , m_mc_strip_ID);
174 status = cgem_ntuple->addIndexedItem(
"sim_sheet_ID" , mc_test_nStrip , m_mc_sheet_ID);
175 status = cgem_ntuple->addIndexedItem(
"sim_layer_ID" , mc_test_nStrip , m_mc_layer_ID);
176 status = cgem_ntuple->addItem(
"sim_Num1",m_mc_Num1,0,10000);
177 status = cgem_ntuple->addItem(
"sim_Num3",m_mc_Num3,0,10000);
178 status = cgem_ntuple->addItem(
"sim_Num21",m_mc_Num21,0,10000);
179 status = cgem_ntuple->addIndexedItem(
"sim_Track21", m_mc_Num21, m_mc_Track21);
180 status = cgem_ntuple->addIndexedItem(
"sim_PDG21", m_mc_Num21, m_mc_PDG21);
181 status = cgem_ntuple->addIndexedItem(
"sim_hit_PDG21", m_mc_Num21, m_mc_hit_PDG21);
182 status = cgem_ntuple->addIndexedItem(
"sim_deltaZ21", m_mc_Num21, m_mc_deltaZ21);
183 status = cgem_ntuple->addIndexedItem(
"sim_deltaPhi21", m_mc_Num21, m_mc_deltaPhi21);
184 status = cgem_ntuple->addIndexedItem(
"sim_hit_ID1", m_mc_Num21, m_mc_hit_ID1);
185 status = cgem_ntuple->addItem(
"sim_Num23",m_mc_Num23,0,10000);
186 status = cgem_ntuple->addIndexedItem(
"sim_Track23", m_mc_Num23, m_mc_Track23);
187 status = cgem_ntuple->addIndexedItem(
"sim_PDG23", m_mc_Num23, m_mc_PDG23);
188 status = cgem_ntuple->addIndexedItem(
"sim_hit_PDG23", m_mc_Num23, m_mc_hit_PDG23);
189 status = cgem_ntuple->addIndexedItem(
"sim_deltaZ23", m_mc_Num23, m_mc_deltaZ23);
190 status = cgem_ntuple->addIndexedItem(
"sim_deltaPhi23", m_mc_Num23, m_mc_deltaPhi23);
191 status = cgem_ntuple->addIndexedItem(
"sim_hit_ID2", m_mc_Num23, m_mc_hit_ID2);
192 status = cgem_ntuple->addIndexedItem(
"sim_hit_ID3", m_mc_Num23, m_mc_hit_ID3);
194 status = cgem_ntuple->addItem(
"MC_nTrk", m_mc_nTrk, 0, 100);
195 status = cgem_ntuple->addIndexedItem(
"pidTruth", m_mc_nTrk, m_mc_pidTruth);
196 status = cgem_ntuple->addIndexedItem(
"motheridx", m_mc_nTrk, m_mc_motheridx);
197 status = cgem_ntuple->addIndexedItem(
"costaTruth",m_mc_nTrk, m_mc_costaTruth);
198 status = cgem_ntuple->addIndexedItem(
"phiTruth", m_mc_nTrk, m_mc_phiTruth);
199 status = cgem_ntuple->addIndexedItem(
"Final_vrTruth", m_mc_nTrk, m_mc_Final_vrTruth);
200 status = cgem_ntuple->addIndexedItem(
"Final_vzTruth", m_mc_nTrk, m_mc_Final_vzTruth);
201 status = cgem_ntuple->addIndexedItem(
"vrTruth", m_mc_nTrk, m_mc_vrTruth);
202 status = cgem_ntuple->addIndexedItem(
"vzTruth", m_mc_nTrk, m_mc_vzTruth);
203 status = cgem_ntuple->addIndexedItem(
"pxTruth", m_mc_nTrk, m_mc_pxTruth);
204 status = cgem_ntuple->addIndexedItem(
"pyTruth", m_mc_nTrk, m_mc_pyTruth);
205 status = cgem_ntuple->addIndexedItem(
"pzTruth", m_mc_nTrk, m_mc_pzTruth);
206 status = cgem_ntuple->addIndexedItem(
"ptTruth", m_mc_nTrk, m_mc_ptTruth);
207 status = cgem_ntuple->addIndexedItem(
"pTruth", m_mc_nTrk, m_mc_pTruth);
208 status = cgem_ntuple->addIndexedItem(
"qTruth", m_mc_nTrk, m_mc_qTruth);
209 status = cgem_ntuple->addIndexedItem(
"rateTrk", m_mc_nTrk, m_mc_rateTrk);
210 status = cgem_ntuple->addIndexedItem(
"rateTruth", m_mc_nTrk, m_mc_rateTruth);
215 INTupleSvc* cut_ntupleSvc;
216 StatusCode src = service(
"NTupleSvc", cut_ntupleSvc);
218 foldername = (
char *)malloc((postfixlen + 16) *
sizeof(char));
219 sprintf(foldername,
"FILE145/CutResult%s", m_postfix.c_str());
221 if ( nt ) cut_ntuple = nt;
223 cut_ntuple =
ntupleSvc->book(foldername, CLID_ColumnWiseTuple,
"CgemSegment");
227 status = cut_ntuple->addItem(
"cut_Num",cut_Num,0,10000);
228 status = cut_ntuple->addIndexedItem(
"cut_IsTruth21", cut_Num, cut_IsTruth21);
229 status = cut_ntuple->addIndexedItem(
"cut_pdg21", cut_Num, cut_pdg21);
230 status = cut_ntuple->addIndexedItem(
"cut_deltaZ21", cut_Num, cut_deltaZ21);
231 status = cut_ntuple->addIndexedItem(
"cut_deltaPhi21", cut_Num, cut_deltaPhi21);
232 status = cut_ntuple->addIndexedItem(
"cut_IsTruth23", cut_Num, cut_IsTruth23);
233 status = cut_ntuple->addIndexedItem(
"cut_pdg23", cut_Num, cut_pdg23);
234 status = cut_ntuple->addIndexedItem(
"cut_deltaZ23", cut_Num, cut_deltaZ23);
235 status = cut_ntuple->addIndexedItem(
"cut_deltaPhi23", cut_Num, cut_deltaPhi23);
241 sc = service(
"CgemGeomSvc",m_ICgemGeomSvc);
242 if( sc != StatusCode::SUCCESS ){
243 log << MSG::ERROR <<
"can not use CgemGeomSvc" << endreq;
244 return StatusCode::FAILURE;
248 return StatusCode::SUCCESS;
255 else if(m_ver==2)
exe_v2();
257 return StatusCode::SUCCESS;
262 MsgStream log(
msgSvc(), name());
263 log << MSG::INFO <<
"in excute()" << endreq;
267 if(0 == (cgem_totevt % 10000) || m_debug>0) cout <<
"Event " << cgem_totevt << endl;
270 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
272 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
273 return( StatusCode::FAILURE);
275 int iEvt = eventHeader->eventNumber();
276 int iRun = eventHeader->runNumber();
284 double r[3] = {79.838 ,125.104 ,167.604};
285 double pi=acos(-1.0);
286 vector<double>sim_phi[3];
287 vector<double>sim_Z[3];
288 vector<int>sim_pdg[3];
289 vector<int>sim_track[3];
290 vector<int>sim_hit[3];
292 vector<double>phi[3];
295 vector<int>rec_pdg[3];
297 vector<int>clusterid[3];
298 vector<int>hit_id[1000];
299 vector<int>track_id[3];
300 vector<int>trkID_S3L6;
304 vector<int>pdg_track;
305 map<int,int>pdg_track_size;
310 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
311 if (!recCgemClusterCol){
312 log << MSG::WARNING <<
"Could not retrieve Cgem cluster list" << endreq;
313 return StatusCode::FAILURE;
316 int count(0);
int ss = 0;
318 RecCgemClusterCol::iterator itTrk=recCgemClusterCol->begin();
319 for( cgem_test_nStrip = 0, cgem_XV_ncluster = 0; itTrk != recCgemClusterCol->end(); ++itTrk)
321 if(ss>=999){N_cluster++;
continue;}
322 if(cgem_test_nStrip >= 2999) {N_strip++;
continue;}
323 if(cgem_XV_ncluster >= 1999) {N_XV_cluster++;
continue;}
324 if((*itTrk)->getflag() == 3) N_flag3++;
327 if((*itTrk)->getflag() == 0 || (*itTrk)->getflag() == 1)
329 int cgem_Num_Strip = (*itTrk)->getclusterflage() - (*itTrk)->getclusterflagb() + 1;
330 cgem_nStrip_flagb[cgem_XV_ncluster]=cgem_test_nStrip;
331 cgem_nStrip[cgem_XV_ncluster]=cgem_Num_Strip;
332 for(
int ll = 0 ; ll < cgem_Num_Strip ; ll++){
333 cgem_ident_ID[cgem_test_nStrip] =
CgemID::getIntID((*itTrk)->getlayerid(),(*itTrk)->getsheetid(),(*itTrk)->getflag(),ll + (*itTrk)->getclusterflagb());
334 cgem_layer_ID[cgem_test_nStrip] = (*itTrk)->getlayerid();
335 cgem_sheet_ID[cgem_test_nStrip] = (*itTrk)->getsheetid();
336 cgem_strip_ID[cgem_test_nStrip] = ll + (*itTrk)->getclusterflagb();
337 cgem_strip_type[cgem_test_nStrip] = (*itTrk)->getflag();
340 cgem_XV_clusterid[cgem_XV_ncluster] = (*itTrk)->getclusterid();
341 cgem_XV_flag[cgem_XV_ncluster] = (*itTrk)->getflag();
342 cgem_XV_layerID[cgem_XV_ncluster] = (*itTrk)->getlayerid();
345 if((*itTrk)->getflag() == 2)
350 cgem_clusterid[ss] = (*itTrk)->getclusterid();
351 cgem_layerid[ss] = (*itTrk)->getlayerid();
352 cgem_sheetid[ss] = (*itTrk)->getsheetid();
353 cgem_flag[ss] = (*itTrk)->getflag();
354 cgem_energydeposit[ss] = (*itTrk)->getenergydeposit();
355 cgem_recphi[ss] = (*itTrk)->getrecphi();
356 cgem_recv[ss] = (*itTrk)->getrecv();
357 cgem_recZ[ss] = (*itTrk)->getRecZ();
358 cgem_clusterflag_first[ss] = (*itTrk)->getclusterflagb();
359 cgem_clusterflag_second[ss] = (*itTrk)->getclusterflage();
363 if((*itTrk)->getflag() == 2)
365 phi[(*itTrk)->getlayerid()].push_back((*itTrk)->getrecphi());
366 Z[(*itTrk)->getlayerid()].push_back((*itTrk)->getRecZ());
370 if(cgem_ntuple) cgem_ncluster = ss;
373 cgem_Num21 = 0; cgem_Num23 = 0;
374 for(
int ii = 0; ii < Z[1].size(); ii++){
375 for(
int jj = 0; jj < Z[0].size(); jj++){
377 if(cgem_Num21 == 999)
continue;
378 cgem_deltaZ21[cgem_Num21] = Z[0][jj] - Z[1][ii];
379 cgem_deltaPhi21[cgem_Num21] = phi[0][jj] - phi[1][ii];
380 if(cgem_deltaPhi21[cgem_Num21]>-2*
pi && cgem_deltaPhi21[cgem_Num21]<-
pi)cgem_deltaPhi21[cgem_Num21] = cgem_deltaPhi21[cgem_Num21] + 2*
pi;
381 if(cgem_deltaPhi21[cgem_Num21]<2*
pi && cgem_deltaPhi21[cgem_Num21]>
pi) cgem_deltaPhi21[cgem_Num21] = cgem_deltaPhi21[cgem_Num21] - 2*
pi;
384 for(
int ll = 0; ll < Z[2].size(); ll++){
386 if(cgem_Num23 == 999)
continue;
387 cgem_deltaZ23[cgem_Num23] = Z[2][ll] - Z[1][ii];
388 cgem_deltaPhi23[cgem_Num23] = phi[2][ll] - phi[1][ii];
389 if(cgem_deltaPhi23[cgem_Num23]>-2*
pi && cgem_deltaPhi23[cgem_Num23]<-
pi)cgem_deltaPhi23[cgem_Num23] = cgem_deltaPhi23[cgem_Num23] + 2*
pi;
390 if(cgem_deltaPhi23[cgem_Num23]<2*
pi && cgem_deltaPhi23[cgem_Num23]>
pi) cgem_deltaPhi23[cgem_Num23] = cgem_deltaPhi23[cgem_Num23] - 2*
pi;
397 MsgStream log(
msgSvc(), name());
398 log << MSG::INFO <<
"in TruthExecute()" << endreq;
400 SmartDataPtr<Event::CgemMcHitCol> lv_CgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
401 if (!lv_CgemMcHitCol)
403 log << MSG::WARNING <<
"Could not find event" << endreq;
404 return StatusCode::FAILURE;
408 vector<int> Track_ID;
410 Event::CgemMcHitCol::iterator iter_truth = lv_CgemMcHitCol->begin();
412 for( mc_test_nStrip= 0; iter_truth != lv_CgemMcHitCol->end(); ++iter_truth)
414 if(i>=1000){N_hit++;
continue;}
416 m_mc_ID_track[i]=(*iter_truth)->GetTrackID();
417 m_mc_ID_layer[i]=(*iter_truth)->GetLayerID();
418 m_mc_pdg_code[i]=(*iter_truth)->GetPDGCode();
419 m_mc_ID_parent[i]=(*iter_truth)->GetParentID();
420 m_mc_E_deposit[i]=(*iter_truth)->GetTotalEnergyDeposit();
421 m_mc_XYZ_pre_X[i] =(*iter_truth)->GetPositionXOfPrePoint() ;
422 m_mc_XYZ_pre_Y[i] =(*iter_truth)->GetPositionYOfPrePoint() ;
423 m_mc_XYZ_pre_Z[i] =(*iter_truth)->GetPositionZOfPrePoint() ;
424 m_mc_XYZ_post_X[i]=(*iter_truth)->GetPositionXOfPostPoint();
425 m_mc_XYZ_post_Y[i]=(*iter_truth)->GetPositionYOfPostPoint();
426 m_mc_XYZ_post_Z[i]=(*iter_truth)->GetPositionZOfPostPoint();
427 m_mc_P_pre_X[i]=(*iter_truth)->GetMomentumXOfPrePoint() ;
428 m_mc_P_pre_Y[i]=(*iter_truth)->GetMomentumYOfPrePoint() ;
429 m_mc_P_pre_Z[i]=(*iter_truth)->GetMomentumZOfPrePoint() ;
430 m_mc_P_post_X[i]=(*iter_truth)->GetMomentumXOfPostPoint();
431 m_mc_P_post_Y[i]=(*iter_truth)->GetMomentumYOfPostPoint();
432 m_mc_P_post_Z[i]=(*iter_truth)->GetMomentumZOfPostPoint();
433 m_mc_rec_z[i]=(m_mc_XYZ_pre_Z[i]+m_mc_XYZ_post_Z[i])/2;
434 m_mc_rec_phi[i]=(m_mc_XYZ_pre_X[i]+m_mc_XYZ_post_X[i])/2/r[m_mc_ID_layer[i]];
436 sim_phi[m_mc_ID_layer[i]].push_back(m_mc_rec_phi[i]);
437 sim_Z[m_mc_ID_layer[i]].push_back(m_mc_rec_z[i]);
438 sim_pdg[m_mc_ID_layer[i]].push_back(m_mc_pdg_code[i]);
439 sim_track[m_mc_ID_layer[i]].push_back(m_mc_ID_track[i]);
440 sim_hit[m_mc_ID_layer[i]].push_back(i);
443 for(
int Pp =0; Pp<m_pid.size(); Pp++)
446 if(m_mc_pdg_code[i] == m_pid[Pp] ){
448 if(m_mc_ID_parent[i] == 0){
449 pdg_track.push_back(m_mc_ID_track[i]);
450 pdg_track_size.insert(pair<int,int> (m_mc_ID_track[i],i));
454 pdg_track.push_back(m_mc_ID_track[i]);
455 pdg_track_size.insert(pair<int,int> (m_mc_ID_track[i],i));
460 m_mc_nStripB[i] = mc_test_nStrip;
461 TArrayI ident = (*iter_truth)->GetIdentifier();
462 for(
int j= 0;j<ident.GetSize();j++){
463 if(mc_test_nStrip >= 2999){N_sim_strip++;
continue;}
464 m_mc_ident_ID[mc_test_nStrip] = ident.GetAt(j);
466 Track_ID.push_back(m_mc_ID_track[i]);
469 m_mc_nStrip[i] = ident.GetSize();
475 for(m_mc_nTrk = 0; m_mc_nTrk < t_nTrkMC; m_mc_nTrk++){
476 if(m_mc_nTrk>=100){N_trk++;
continue;}
477 m_mc_pidTruth[m_mc_nTrk] = t_pidTruth[m_mc_nTrk] ;
478 m_mc_motheridx[m_mc_nTrk] = t_motheridx[m_mc_nTrk] ;
479 m_mc_costaTruth[m_mc_nTrk] = t_costhetaMC[m_mc_nTrk];
480 m_mc_phiTruth[m_mc_nTrk] = t_phiMC[m_mc_nTrk] ;
481 m_mc_Final_vrTruth[m_mc_nTrk]= t_FvrMC[m_mc_nTrk] ;
482 m_mc_Final_vzTruth[m_mc_nTrk]= t_FvzMC[m_mc_nTrk] ;
483 m_mc_vrTruth[m_mc_nTrk] = t_vrMC[m_mc_nTrk] ;
484 m_mc_vzTruth[m_mc_nTrk] = t_vzMC[m_mc_nTrk] ;
485 m_mc_pxTruth[m_mc_nTrk] = t_pxMC[m_mc_nTrk] ;
486 m_mc_pyTruth[m_mc_nTrk] = t_pyMC[m_mc_nTrk] ;
487 m_mc_pzTruth[m_mc_nTrk] = t_pzMC[m_mc_nTrk] ;
488 m_mc_ptTruth[m_mc_nTrk] = t_ptMC[m_mc_nTrk] ;
489 m_mc_pTruth[m_mc_nTrk] = t_pMC[m_mc_nTrk] ;
490 m_mc_qTruth[m_mc_nTrk] = t_qMC[m_mc_nTrk] ;
492 for(
int Pp =0; Pp<m_pid.size(); Pp++){
493 if(m_mc_pidTruth[m_mc_nTrk] == m_pid[Pp]&&fabs(m_mc_costaTruth[m_mc_nTrk])>0.93&&m_mc_ptTruth[m_mc_nTrk]<0.05)
498 m_mc_Num21 = 0;m_mc_Num23 = 0;
bool sim_IsOut21 =
false;
bool sim_IsOut23 =
false;m_mc_Num1 = sim_Z[0].size();m_mc_Num3 = sim_Z[2].size();
499 for(
int Xx = 0; Xx != sim_Z[1].size(); Xx++){
500 for(
int Yy = 0; Yy != sim_Z[0].size(); Yy++){
501 if(Yy == 999){sim_IsOut21 =
true;
continue;}
502 m_mc_deltaZ21[m_mc_Num21] = sim_Z[0][Yy] - sim_Z[1][Xx];
503 m_mc_deltaPhi21[m_mc_Num21] = sim_phi[0][Yy] - sim_phi[1][Xx];
504 if(m_mc_deltaPhi21[m_mc_Num21]>-2*
pi && m_mc_deltaPhi21[m_mc_Num21]<-
pi)m_mc_deltaPhi21[m_mc_Num21] = m_mc_deltaPhi21[m_mc_Num21] + 2*
pi;
505 if(m_mc_deltaPhi21[m_mc_Num21]<2*
pi && m_mc_deltaPhi21[m_mc_Num21]>
pi) m_mc_deltaPhi21[m_mc_Num21] = m_mc_deltaPhi21[m_mc_Num21] - 2*
pi;
507 m_mc_hit_ID1[m_mc_Num21] = sim_hit[0][Yy];
508 m_mc_hit_ID2[m_mc_Num21] = sim_hit[1][Xx];
509 if(m_mc_pdg_code[sim_hit[1][Xx]] == m_mc_pdg_code[sim_hit[0][Yy]]) m_mc_hit_PDG21[m_mc_Num21] = m_mc_pdg_code[sim_hit[1][Xx]];
510 else m_mc_hit_PDG21[m_mc_Num21] = -999;
511 if(sim_pdg[1][Xx] == sim_pdg[0][Yy]) m_mc_PDG21[m_mc_Num21] = sim_pdg[1][Xx];
512 else m_mc_PDG21[m_mc_Num21] = -999;
513 if(sim_track[1][Xx] == sim_track[0][Yy]) m_mc_Track21[m_mc_Num21] = sim_track[1][Xx];
514 else m_mc_Track21[m_mc_Num21] = -999;
517 for(
int Zz = 0; Zz != sim_Z[2].size(); Zz++){
518 if(Zz == 999){sim_IsOut23 =
true;
continue;}
519 m_mc_deltaZ23[m_mc_Num23] = sim_Z[2][Zz] - sim_Z[1][Xx];
520 m_mc_deltaPhi23[m_mc_Num23] = sim_phi[2][Zz] - sim_phi[1][Xx];
521 if(m_mc_deltaPhi23[m_mc_Num23]>-2*
pi && m_mc_deltaPhi23[m_mc_Num23]<-
pi)m_mc_deltaPhi23[m_mc_Num23] = m_mc_deltaPhi23[m_mc_Num23] + 2*
pi;
522 if(m_mc_deltaPhi23[m_mc_Num23]<2*
pi && m_mc_deltaPhi23[m_mc_Num23]>
pi) m_mc_deltaPhi23[m_mc_Num23] = m_mc_deltaPhi23[m_mc_Num23] - 2*
pi;
524 m_mc_hit_ID3[m_mc_Num23] = sim_hit[2][Zz];
525 if(m_mc_pdg_code[sim_hit[1][Xx]] == m_mc_pdg_code[sim_hit[2][Zz]]) m_mc_hit_PDG23[m_mc_Num23] = m_mc_pdg_code[sim_hit[1][Xx]];
526 else m_mc_hit_PDG23[m_mc_Num23] = -999;
527 if(sim_pdg[1][Xx] == sim_pdg[2][Zz]) m_mc_PDG23[m_mc_Num23] = sim_pdg[1][Xx];
528 else m_mc_PDG23[m_mc_Num23] = -999;
529 if(sim_track[1][Xx] == sim_track[2][Zz]) m_mc_Track23[m_mc_Num23] = sim_track[1][Xx];
530 else m_mc_Track23[m_mc_Num23] = -999;
534 if(sim_IsOut21) N_sim_N21++;
535 if(sim_IsOut23) N_sim_N23++;
537 for(
int m = 0; m < ss; m++){
540 vector<int> tmp_hit_ID[1000];
546 for(
int rr=0;rr<cgem_XV_ncluster;rr++){
547 if(cgem_XV_clusterid[rr] == cgem_clusterflag_first[m] || cgem_XV_clusterid[rr] == cgem_clusterflag_second[m]){
549 for(
int id = cgem_nStrip_flagb[rr];
id < cgem_nStrip_flagb[rr] + cgem_nStrip[rr];
id++){
550 for(
int sim = 0; sim<mc_test_nStrip; sim++){
551 if(cgem_ident_ID[
id]==m_mc_ident_ID[sim]){
552 tmp_hit_ID[hit_ID[sim]].push_back(Track_ID[sim]);
556 tmp += cgem_nStrip[rr];
559 for(
int Mm = 0; Mm < 1000; Mm++){
560 if(tmp_hit_ID[Mm].size() == 0)
continue;
561 IsEq.insert(pair<int,int> (Mm,tmp_hit_ID[Mm][0]));
563 if(tmp_hit_ID[Mm].size() >= tmp) tmp_sim++;
566 bool IsPid ;
int pid(0);
int tmp_track_ID = 0;
567 for(map<int,int>::iterator Mm = IsEq.begin(); Mm != IsEq.end(); Mm++){
569 for(
int Pp =0; Pp<m_pid.size(); Pp++){
571 if(m_mc_pdg_code[Mm->first] == m_pid[Pp] && m_mc_ID_parent[Mm->first] == 0){
573 pid = m_mc_pdg_code[Mm->first];
577 if(m_mc_pdg_code[Mm->first] == m_pid[Pp]){
579 pid = m_mc_pdg_code[Mm->first];
583 hit_id[m].push_back(Mm->first);
584 tmp_track_ID = Mm->second;
586 track_id[cgem_layerid[m]].push_back(tmp_track_ID);
587 clusterid[cgem_layerid[m]].push_back(m);
588 if(IsPid) rec_pdg[cgem_layerid[m]].push_back(pid);
589 else rec_pdg[cgem_layerid[m]].push_back(-999);
590 if(IsPid && tmp_sim == 1 )IsTruth =1;
591 if(IsTruth == 1)N_Match_all_hit++;
592 if(IsTruth == 1 && hit_num > 1)N_Match_hit++;
593 Truth[cgem_layerid[m]].push_back(IsTruth);
596 cgem_Num21 = 0;cgem_Num23 = 0;
bool IsOut21 =
false;
bool IsOut23 =
false;
597 for(
int tt = 0; tt < Truth[1].size(); tt++){
598 for(
int hh = 0; hh < Truth[0].size(); hh++){
599 if(cgem_Num21 == 999){IsOut21 =
true;
continue;}
600 if(rec_pdg[1][tt] != rec_pdg[0][hh] ) cgem_pdg21[cgem_Num21] = -9999;
601 else cgem_pdg21[cgem_Num21] = rec_pdg[1][tt];
602 if(Truth[1][tt] == 0 || Truth[0][hh] == 0)cgem_IsTruth21[cgem_Num21] = 0;
603 if(Truth[1][tt] == 1 && Truth[0][hh] == 1){
604 if(track_id[1][tt] == track_id[0][hh])cgem_IsTruth21[cgem_Num21] = 1;
605 else cgem_IsTruth21[cgem_Num21] = 0;
610 for(
int pp = 0; pp < Truth[2].size(); pp++){
611 if(cgem_Num23 == 999){IsOut23 =
true;
continue;}
612 if(rec_pdg[1][tt] != rec_pdg[2][pp] ) cgem_pdg23[cgem_Num23] = -9999;
613 else cgem_pdg23[cgem_Num23] = rec_pdg[1][tt];
614 if(Truth[1][tt] == 0 || Truth[2][pp] == 0)cgem_IsTruth23[cgem_Num23] = 0;
615 if(Truth[1][tt] == 1 && Truth[2][pp] == 1){
616 if(track_id[1][tt] == track_id[2][pp])cgem_IsTruth23[cgem_Num23] = 1;
617 else cgem_IsTruth23[cgem_Num23] = 0;
626 int tmp_pdg[100] = {0};
627 if(pdg_track_size.size() == 0)N_PiE0++;
628 for(
int Nn = 0; Nn < pdg_track.size(); Nn++){
630 for(map<int,int>::iterator Mm = pdg_track_size.begin(); Mm != pdg_track_size.end(); Mm++){
631 if(pdg_track[Nn] == Mm->first) tmp_pdg[Ii]+=1;
637 for( map<int,int>::iterator Mm = pdg_track_size.begin(); Mm != pdg_track_size.end(); Mm++){
638 if(tmp_pdg[II] < 3){N_PiL2++;trkID_S3L6.push_back(Mm->first);}
639 if(tmp_pdg[II] > 6){N_PiM7++;trkID_S3L6.push_back(Mm->first);}
647 int cgem_Num1= phi[0].size();
int cgem_Num3 = phi[2].size();
649 for(
int Ii = 0; Ii < cgem_Num21; Ii++){
650 int tmp_2 = Ii/cgem_Num1;
651 int tmp_1 = Ii%cgem_Num1;
652 for(
int Jj = 0; Jj < cgem_Num23; Jj++){
653 int tmp2 = Jj/cgem_Num3;
654 int tmp_3 = Jj%cgem_Num3;
655 if(tmp_2 != tmp2)
continue;
656 if(!
InZAr(cgem_deltaZ21[Ii],cgem_deltaZ23[Jj]) || !
InPhiAr(cgem_deltaPhi21[Ii],cgem_deltaPhi23[Jj])){N_OutRange++;
continue;}
665 int IsTruth = cgem_IsTruth21[Ii]*cgem_IsTruth23[Jj];
667 m_seg_map.insert(pair<int,RecCgemSegment*>(N_Seg,recsegment));
670 cut_deltaZ21[cut_Num] = cgem_deltaZ21[Ii];
671 cut_deltaZ23[cut_Num] = cgem_deltaZ23[Jj];
672 cut_deltaPhi21[cut_Num] = cgem_deltaPhi21[Ii];
673 cut_deltaPhi23[cut_Num] = cgem_deltaPhi23[Jj];
674 cut_IsTruth21[cut_Num] = cgem_IsTruth21[Ii];
675 cut_IsTruth23[cut_Num] = cgem_IsTruth23[Jj];
676 cut_pdg21[cut_Num] = cgem_pdg21[Ii];
677 cut_pdg23[cut_Num] = cgem_pdg23[Jj];
681 bool UnFit_Hits =
false;
682 for(
int Mm = 0; Mm <= 1000; Mm++){
683 if(Mm != clusterid[0][tmp_1] && Mm != clusterid[1][tmp_2] && Mm != clusterid[2][tmp_3])
continue;
684 for(
int mm = 0; mm < hit_id[Mm].size(); mm++){
685 for(
int Pp =0; Pp<trkID_S3L6.size(); Pp++){
686 if(m_mc_ID_track[hit_id[Mm][mm]] == trkID_S3L6[Pp])UnFit_Hits =
true;
690 if(UnFit_Hits)
continue;
692 if(cgem_IsTruth21[Ii]*cgem_IsTruth23[Jj] != 1){
693 int num = 0;
int N_hit_size = 0;
694 for(
int Mm = 0; Mm <= 1000; Mm++){
695 if(Mm != clusterid[0][tmp_1] && Mm != clusterid[1][tmp_2] && Mm != clusterid[2][tmp_3])
continue;
696 N_hit_size += hit_id[Mm].size();
697 for(
int mm = 0; mm < hit_id[Mm].size(); mm++){
698 for(
int Pp =0; Pp<m_pid.size(); Pp++){
699 if(m_mc_pdg_code[hit_id[Mm][mm]] == m_pid[Pp]){
701 if(sqrt(pow(m_mc_XYZ_pre_X[hit_id[Mm][mm]],2)+pow(m_mc_XYZ_pre_Y[hit_id[Mm][mm]],2))>=sqrt(pow(m_mc_XYZ_post_X[hit_id[Mm][mm]],2)+pow(m_mc_XYZ_post_Y[hit_id[Mm][mm]],2)))Un_InTrk++;
706 if(
num == 0) N_nonPi++;
708 if(
num == N_hit_size){
709 if(Un_InTrk == 0 ||
num == Un_InTrk) N_ErrMat++;
713 if(
num>3)N_OtherPar4++;
714 if(
num==3)N_OtherPar3++;
715 if(
num<3)N_OtherPar++;
717 if(
num>3) N_4cluster++;
718 if(
num==3) N_3cluster++;
724 for(
int Mm = 0; Mm <= 1000; Mm++){
725 if(Mm != clusterid[0][tmp_1] && Mm != clusterid[1][tmp_2] && Mm != clusterid[2][tmp_3])
continue;
726 for(
int mm = 0; mm < hit_id[Mm].size(); mm++){
727 if(sqrt(pow(m_mc_XYZ_pre_X[hit_id[Mm][mm]],2)+pow(m_mc_XYZ_pre_Y[hit_id[Mm][mm]],2))>=sqrt(pow(m_mc_XYZ_post_X[hit_id[Mm][mm]],2)+pow(m_mc_XYZ_post_Y[hit_id[Mm][mm]],2)))InTrk++;
730 if(InTrk == 3)N_inTrk3++;
731 else if(InTrk < 3&& InTrk > 0)N_InTrk++;
739 IDataProviderSvc* evtSvc = NULL;
740 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
742 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
744 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
745 return StatusCode::SUCCESS;
748 StatusCode segmentsc;
749 IDataManagerSvc *dataManSvc;
750 dataManSvc=
dynamic_cast<IDataManagerSvc*
>(evtSvc);
751 DataObject *aSegmentCol;
752 evtSvc->findObject(
"/Event/Recon/RecCgemSegmentCol",aSegmentCol);
753 if(aSegmentCol != NULL) {
754 dataManSvc->clearSubTree(
"/Event/Recon/RecCgemSegmentCol");
755 evtSvc->unregisterObject(
"/Event/Recon/RecCgemSegmentCol");
758 segmentsc = evtSvc->registerObject(
"/Event/Recon/RecCgemSegmentCol", segmentcol);
759 if( segmentsc.isFailure() ) {
760 log << MSG::FATAL <<
"Could not register RecCgemSegment" << endreq;
761 return StatusCode::SUCCESS;
763 log << MSG::INFO <<
"RecCgemSegmentCol registered successfully!" <<endreq;
766 for(m_seg_map_it = m_seg_map.begin();m_seg_map_it!=m_seg_map.end();++m_seg_map_it){
768 segmentcol->push_back(recsegment);
772 if(m_checkSingleTrkMC>0) cut_ntuple->write();
775 if(m_checkSingleTrkMC>0) cgem_ntuple->write();
792 return StatusCode::SUCCESS;
797 MsgStream log(
msgSvc(), name());
799 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
801 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
802 return( StatusCode::FAILURE);
804 m_run = eventHeader->runNumber();
805 m_evt = eventHeader->eventNumber();
811 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
812 if (!recCgemClusterCol){
813 log << MSG::WARNING <<
"Could not retrieve Cgem cluster list" << endreq;
814 return StatusCode::FAILURE;
819 cout<<
"get "<<recCgemClusterCol->size()<<
" Cgem clusters:"<<endl;
820 cout<<setw(15)<<
"idClu"<<setw(20)<<
"phi"<<setw(20)<<
"Z"<<endl;
822 RecCgemClusterCol::iterator itCluster=recCgemClusterCol->begin();
823 for( ; itCluster != recCgemClusterCol->end(); ++itCluster)
825 int CluFlag = (*itCluster)->getflag();
828 int idClu = (*itCluster)->getclusterid();
829 int iLayer = (*itCluster)->getlayerid();
830 int iSheet = (*itCluster)->getsheetid();
831 int id_XClu = (*itCluster)->getclusterflagb();
832 int id_VClu = (*itCluster)->getclusterflage();
833 double recPhi = (*itCluster)->getrecphi();
834 double recV = (*itCluster)->getrecv();
835 double recZ = (*itCluster)->getRecZ();
836 mVec_idXVClu[iLayer].push_back(idClu);
837 mVec_phiClu[iLayer].push_back(recPhi);
838 mVec_idXClu[iLayer].push_back(id_XClu);
839 mVec_ZClu[iLayer].push_back(recZ);
840 mVec_idVClu[iLayer].push_back(id_VClu);
841 if(m_debug) cout<<setw(15)<<idClu<<setw(20)<<recPhi<<setw(20)<<recZ<<endl;
845 for(
int i=0; i<3; i++) n_XVCluster[i] = mVec_phiClu[i].size();
851 IDataProviderSvc* evtSvc = NULL;
852 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
854 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
856 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
857 return StatusCode::SUCCESS;
860 StatusCode segmentsc;
861 IDataManagerSvc *dataManSvc;
862 dataManSvc=
dynamic_cast<IDataManagerSvc*
>(evtSvc);
863 DataObject *aSegmentCol;
864 evtSvc->findObject(
"/Event/Recon/RecCgemSegmentCol",aSegmentCol);
865 if(aSegmentCol != NULL) {
866 dataManSvc->clearSubTree(
"/Event/Recon/RecCgemSegmentCol");
867 evtSvc->unregisterObject(
"/Event/Recon/RecCgemSegmentCol");
870 segmentsc = evtSvc->registerObject(
"/Event/Recon/RecCgemSegmentCol", segmentcol);
871 if( segmentsc.isFailure() ) {
872 log << MSG::FATAL <<
"Could not register RecCgemSegment" << endreq;
873 return StatusCode::SUCCESS;
875 log << MSG::INFO <<
"RecCgemSegmentCol registered successfully!" <<endreq;
880 for(
int i=0; i<n_XVCluster[1]; i++)
883 double phi2 = mVec_phiClu[1][i];
884 double Z2 = mVec_ZClu[1][i];
885 int id_lay2 = mVec_idXVClu[1][i];
886 vector<double> vec_dPhi21;
887 vector<double> vec_dPhi23;
888 vector<double> vec_dZ21;
889 vector<double> vec_dZ23;
890 for(
int j=0; j<n_XVCluster[0]; j++)
892 double phi1 = mVec_phiClu[0][j];
893 double Z1 = mVec_ZClu[0][j];
895 while(dPhi21<-(CLHEP::pi)) dPhi21+=CLHEP::twopi;
896 while(dPhi21> (CLHEP::pi)) dPhi21-=CLHEP::twopi;
898 vec_dPhi21.push_back(dPhi21);
899 vec_dZ21.push_back(dZ21);
901 for(
int k=0; k<n_XVCluster[2]; k++)
903 int id_lay3 = mVec_idXVClu[2][k];
904 double phi3 = mVec_phiClu[2][k];
905 double Z3 = mVec_ZClu[2][k];
906 double dPhi23 = phi3-
phi2;
907 while(dPhi23<-(CLHEP::pi)) dPhi23+=CLHEP::twopi;
908 while(dPhi23> (CLHEP::pi)) dPhi23-=CLHEP::twopi;
910 vec_dPhi23.push_back(dPhi23);
911 vec_dZ23.push_back(dZ23);
912 for(
int j=0; j<n_XVCluster[0]; j++)
914 int id_lay1 = mVec_idXVClu[0][j];
915 double dPhi21 = vec_dPhi21[j];
916 double dZ21 = vec_dZ21[j];
917 bool isGoodDPhi =
InPhiAr(dPhi21,dPhi23);
918 bool isGoodDZ =
InZAr(dZ21,dZ23);
919 if(isGoodDPhi && isGoodDZ) {
929 segmentcol->push_back(recsegment);
931 cout<<
"id_lay1, id_lay2, id_lay3 = "<<id_lay1<<
", "<<id_lay2<<
", "<<id_lay3<<endl;
939 if(m_debug) cout<<
"nGoodSegCandi="<<nGoodSegCandi<<
" for XV cluster "<<i<<
" in layer 2"<<endl;
945 return StatusCode::SUCCESS;
950 for(
int i=0; i<3; i++)
952 mVec_idXVClu[i].clear();
953 mVec_phiClu[i].clear();
954 mVec_idXClu[i].clear();
955 mVec_ZClu[i].clear();
956 mVec_idVClu[i].clear();
966 cout<<
"CgemSegmentRecAlg printInfo(): "<<endl;
969 for(
int i=0; i<3; i++)
971 int nXV = mVec_phiClu[i].size();
972 cout<<
"Layer "<<i<<endl;
973 cout<<setw(txtWidth)<<
"phi"<<setw(txtWidth)<<
"Z"<<setw(txtWidth)<<
"id_X"<<setw(txtWidth)<<
"id_V"<<endl;
974 for(
int j=0; j<nXV; j++)
976 cout<<setw(txtWidth)<<mVec_phiClu[i][j]<<setw(txtWidth)<<mVec_ZClu[i][j]<<setw(txtWidth)<<mVec_idXClu[i][j]<<setw(txtWidth)<<mVec_idVClu[i][j]<<endl;
980 SmartDataPtr<RecCgemSegmentCol> recCgemSegmentCol(eventSvc(),
"/Event/Recon/RecCgemSegmentCol");
981 if(recCgemSegmentCol)
983 int n_seg = recCgemSegmentCol->size();
984 RecCgemSegmentCol::iterator it_seg = recCgemSegmentCol->begin();
985 cout<<
"RecCgemSegmentCol contains "<<n_seg<<
" CgemSegments: "<<endl;
986 cout<<setw(txtWidth)<<
"seg_id"<<setw(txtWidth)<<
"clu_id1"<<setw(txtWidth)<<
"clu_id2"<<setw(txtWidth)<<
"clu_id3"<<endl;
987 for(; it_seg!=recCgemSegmentCol->end(); it_seg++)
991 cout <<setw(txtWidth)<<(*it_seg)->getsegmentid()
992 <<setw(txtWidth)<<(*it_seg)->getclusterid_1()
993 <<setw(txtWidth)<<(*it_seg)->getclusterid_2()
994 <<setw(txtWidth)<<(*it_seg)->getclusterid_3()
1005 MsgStream log(
msgSvc(), name());
1008 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
1009 if (!mcParticleCol) {
1010 log << MSG::ERROR<<
"Could not find McParticle" << endreq;
1015 bool findJpsi=
false;
1016 if(m_debug>0) cout<<
"size_mcParticleCol "<<mcParticleCol->size()<< endl;
1017 McParticleCol::iterator iter_mc = mcParticleCol->begin();
1018 for (;iter_mc != mcParticleCol->end(); iter_mc++ ) {
1020 int pdg=(*iter_mc)->particleProperty();
1023 rootIndex = (*iter_mc)->trackIndex();
1027 t_pidTruth[itk] = (*iter_mc)->particleProperty();
1028 if(m_debug>0) cout<<
"tk "<<itk<<
" pid="<< t_pidTruth[itk]<< endl;
1030 int mcidx = ((*iter_mc)->mother()).trackIndex() - rootIndex;
1031 if (mcidx > 0) t_motheridx[itk] = mcidx-1;
1032 else t_motheridx[itk] = mcidx;
1037 t_t0Truth=(*iter_mc)->initialPosition().t();
1041 int pid = t_pidTruth[itk];
1043 log << MSG::WARNING <<
"Wrong particle id" <<endreq;
1046 IPartPropSvc* p_PartPropSvc;
1047 static const bool CREATEIFNOTTHERE(
true);
1048 StatusCode PartPropStatus = service(
"PartPropSvc", p_PartPropSvc, CREATEIFNOTTHERE);
1049 if (!PartPropStatus.isSuccess() || 0 == p_PartPropSvc) {
1050 cout<<
"CgemSegmentRecAlg::getMcTruth() Could not initialize Particle Properties Service" << endl;
1052 HepPDT::ParticleDataTable* p_particleTable = p_PartPropSvc->PDT();
1054 if( p_particleTable->particle(pid) ){
1055 name = p_particleTable->particle(pid)->name();
1056 t_qMC[itk] = p_particleTable->particle(pid)->charge();
1057 }
else if( p_particleTable->particle(-pid) ){
1058 name =
"anti " + p_particleTable->particle(-pid)->name();
1059 t_qMC[itk] = (-1.)*p_particleTable->particle(-pid)->charge();
1063 t_vrMC[itk] = sqrt((*iter_mc)->initialPosition().x()*(*iter_mc)->initialPosition().x() + (*iter_mc)->initialPosition().y()*(*iter_mc)->initialPosition().y()) ;
1064 t_vzMC[itk] = (*iter_mc)->initialPosition().z();
1065 t_pxMC[itk] = (*iter_mc)->initialFourMomentum().px();
1066 t_pyMC[itk] = (*iter_mc)->initialFourMomentum().py();
1067 t_pzMC[itk] = (*iter_mc)->initialFourMomentum().pz();
1068 t_ptMC[itk] = sqrt(t_pxMC[itk]*t_pxMC[itk] + t_pyMC[itk]*t_pyMC[itk]);
1069 t_pMC[itk] = sqrt(t_ptMC[itk]*t_ptMC[itk] + t_pzMC[itk]*t_pzMC[itk]);
1070 t_FvrMC[itk]= sqrt((*iter_mc)->finalPosition().x()*(*iter_mc)->finalPosition().x() + (*iter_mc)->finalPosition().y()*(*iter_mc)->finalPosition().y()) ;
1071 t_FvzMC[itk] = (*iter_mc)->initialPosition().z();
1074 Hep3Vector p3(t_pxMC[itk],t_pyMC[itk],t_pzMC[itk]);
1076 t_costhetaMC[itk] = t_pzMC[itk]/t_pMC[itk];
1078 t_phiMC[itk] = p3.phi();
1136 if(fabs(
x)>m_z_bound||fabs(y)>m_z_bound)
return false;
1138 double distance,ZCut,deltaL;
1141 for(
int z = 0; z < m_z_slope.size(); z++){
1142 distance = (y - m_z_slope[z]*
x)/sqrt(1 + pow(m_z_slope[z],2));
1143 deltaL = (
x + m_z_slope[z]*y)/sqrt(1 + pow(m_z_slope[z],2));
1144 ZCut = m_z_nSigma*(m_z_Par1[z]*pow(deltaL,2) + m_z_Par2[z]*deltaL + m_z_Par3[z]);
1145 if(fabs(distance) < ZCut) IsIn =
true;
1151 if(fabs(
x)>m_phi_bound||fabs(y)>m_phi_bound)
return false;
1154 double distance = (y - m_phi_slope*
x)/sqrt(1 + pow(m_phi_slope,2));
1155 double deltaL = (
x + m_phi_slope*y)/sqrt(1 + pow(m_phi_slope,2));
1156 double mean = m_phi_3Par[0]*pow(deltaL,3) + m_phi_3Par[1]*pow(deltaL,2) + m_phi_3Par[2]*deltaL + m_phi_3Par[3];
1157 double PhiCut = m_phi_nSigma*(m_phi_4Par[0]*pow(deltaL,4) + m_phi_4Par[1]*pow(deltaL,3) + m_phi_4Par[2]*pow(deltaL,2) + m_phi_4Par[3]*deltaL + m_phi_4Par[4]);
1158 if(fabs(distance - mean) < PhiCut) IsIn =
true;
1166 MsgStream log(
msgSvc(), name());
1167 log << MSG::INFO <<
"in finalize()" << endreq;
1174 cout <<
"Cgem total event: " << cgem_totevt << endl;
1176 cout <<
"Out of Detector track: " << OutDetecter << endl;
1177 cout <<
"Number of hits which IsTruth equare to 1: " << N_Match_all_hit << endl;
1178 cout <<
"Number of hits which IsTruth equare to 1 and matched hits more than 2: " << N_Match_hit << endl;
1180 cout <<
"Cgem events of ncluster more than 1000 : "<<N_cluster<<endl;
1181 cout <<
"Cgem events of XV_ncluster more than 2000 : "<<N_XV_cluster<<endl;
1182 cout <<
"Cgem events of reconstruction strips more than 3000 : "<<N_strip<<endl;
1183 cout <<
"Cgem events of cluster with falg = 3 : "<<N_flag3<<endl;
1184 cout <<
"Cgem events of hits more than 1000 : "<<N_hit<<endl;
1185 cout <<
"Cgem events of simulation strips more than 3000 : "<<N_sim_strip<<endl;
1186 cout <<
"Cgem events of tracks more than 100 : "<<N_trk<<endl;
1187 cout <<
"Cgem events of rec Num_21 more than 1000 : "<<N_N21<<endl;
1188 cout <<
"Cgem events of rec Num_23 more than 1000 : "<<N_N23<<endl;
1189 cout <<
"Cgem events of sim Num_21 more than 1000 : "<<N_sim_N21<<endl;
1190 cout <<
"Cgem events of sim Num_23 more than 1000 : "<<N_sim_N23<<endl;
1191 cout <<
"Cgem segments stay out of range : "<<N_OutRange<<endl;
1192 cout <<
"Cgem events of particles = 0 : "<<N_PiE0<<endl;
1193 cout <<
"Cgem tracks of particles between 0 to 3 : "<<N_PiL2<<endl;
1194 cout <<
"Cgem tracks of particles more than 6 : "<<N_PiM7<<endl;
1195 cout <<
"Cgem events' number : "<<N_Event<<endl;
1196 cout <<
"Cgem segments' number : "<<N_Seg<<endl;
1197 cout <<
"Matching Cgem segments' number : "<<N_Match<<endl;
1198 cout <<
"Matching Cgem segments' number which towards out of detector : "<<N_outTrk<<endl;
1199 cout <<
"Matching Cgem segments' number which towards in detector : "<<N_inTrk3<<endl;
1200 cout <<
"Matching Cgem segments' number which contains other particles towards in detector : "<<N_InTrk<<endl;
1201 cout <<
"Unmatched Cgem segments' number with equare to 3 pid clusters : "<<N_3cluster<<endl;
1202 cout <<
"Unmatched Cgem segments' number with more than 3 pid clusters : "<<N_4cluster<<endl;
1203 cout <<
"Unmatched Cgem segments' number without pid clusters : "<<N_nonPi<<endl;
1204 cout <<
"Unmatched Cgem segments' number which reconstructed error : "<<N_ErrMat<<endl;
1205 cout <<
"Unmatched Cgem segments' number which both contains toward in and out track : "<<N_CrossMat<<endl;
1206 cout <<
"Unmatched Cgem segments' number which contains more than 3 pid clusters effects by other particles : "<<N_OtherPar4<<endl;
1207 cout <<
"Unmatched Cgem segments' number which contains equare to 3 pid clusters effects by other particles : "<<N_OtherPar3<<endl;
1208 cout <<
"Unmatched Cgem segments' number which contains 1 or 2 pid clusters and effects by other particles : "<<N_OtherPar<<endl;
1211 cout<<endl<<
"******* CgemSegmentRecAlg *******"<<endl;
1212 cout<<
"* m_dst ="<<m_dst<<endl;
1213 cout<<
"* nEvent ="<<Ncut0<<endl;
1214 cout<<
"***************************"<<endl;
1215 cout<<
"******** continueHit ******"<<endl;
1226 return StatusCode::SUCCESS;
ObjectVector< RecCgemSegment > RecCgemSegmentCol
static value_type getIntID(unsigned int f_layer, unsigned int f_sheet, unsigned int f_strip_type, unsigned int f_strip)
CgemSegmentRecAlg(const std::string &name, ISvcLocator *pSvcLocator)
bool InZAr(double x, double y)
bool InPhiAr(double x, double y)
const int getclusterid_3() const
void setclusterid_2(const int clusterId_2)
void setmatch(const int match)
void setsegmentid(const int segmentId)
void setclusterid_1(const int clusterId_1)
void seteventid(const int eventId)
void setclusterid_3(const int clusterId_3)