2#include "CgemClusterCreate/CgemClusterCreate.h"
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/AlgFactory.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/DataSvc.h"
7#include "GaudiKernel/SmartDataPtr.h"
8#include "GaudiKernel/IDataProviderSvc.h"
9#include "GaudiKernel/IDataManagerSvc.h"
10#include "GaudiKernel/PropertyMgr.h"
11#include "GaudiKernel/Bootstrap.h"
12#include "GaudiKernel/IService.h"
13#include "GaudiKernel/INTupleSvc.h"
14#include "GaudiKernel/NTuple.h"
15#include "GaudiKernel/RndmGenerators.h"
16#include "EventModel/EventHeader.h"
17#include "KalFitAlg/helix/Helix.h"
19#include "RawEvent/RawDataUtil.h"
20#include "RawDataProviderSvc/IRawDataProviderSvc.h"
21#include "Identifier/CgemID.h"
22#include "Identifier/Identifier.h"
23#include "CgemRawEvent/CgemDigi.h"
26#include "EvTimeEvent/RecEsTime.h"
28#include "McTruth/McParticle.h"
29#include "McTruth/CgemMcHit.h"
31#include "BesTimerSvc/IBesTimerSvc.h"
32#include "BesTimerSvc/BesTimerSvc.h"
33#include "BesTimerSvc/BesTimer.h"
35#include "ReconEvent/ReconEvent.h"
36#include "CgemRecEvent/RecCgemCluster.h"
38#include "CLHEP/Vector/ThreeVector.h"
43#include "TGraphErrors.h"
52const double a_stero[3] = {(45.94*3.14/180),(31.10*3.14/180),(32.99*3.14/180)};
53const double w_sheet[3] = {549.78,417.097,550.614};
54const double dw_sheet[3] = {549.78,416.26,549.78};
55const double r_layer[3] = {87.51,132.7661,175.2661};
56const double dr_layer[3] = {78.338,123.604,166.104};
74 Algorithm(name,pSvcLocator)
76 declareProperty(
"PrintFlag",myPrintFlag=0);
77 declareProperty(
"MotherParticleID",myMotherParticleID=443);
78 declareProperty(
"Method",myMethod=2);
79 declareProperty(
"ntuple",myNtuple=0);
80 declareProperty(
"effCluster",myClusterEff=1.0);
81 declareProperty(
"fillOpt",m_fillOption=-1);
82 declareProperty(
"selGoodDigi",m_selGoodDigi=1);
83 declareProperty(
"minDigiTime",m_minDigiTime=-8875);
84 declareProperty(
"maxDigiTime",m_maxDigiTime=-8562);
85 declareProperty(
"TPCFitMethod",m_selectTPC=1);
86 declareProperty(
"minQDigi",myQMin=0.0);
89 if(myMethod==0) reset();
90 else if(myMethod==1||myMethod==3) resetFiredStripMap();
101 MsgStream log(
msgSvc(), name());
102 log << MSG::INFO <<
"in initialize()" << endreq;
117 tsc = service(
"BesTimerSvc", m_timersvc);
118 if( tsc.isFailure() )
120 log << MSG::WARNING << name() <<
" Unable to locate BesTimerSvc" << endreq;
121 return StatusCode::FAILURE;
123 m_timer = m_timersvc->
addItem(
"Execution");
125 if(myNtuple) myNTupleHelper=
new NTupleHelper(
ntupleSvc()->book(
"RecCgem/CgemCluster",CLID_ColumnWiseTuple,
"CgemCluster"));
127 if(myMethod==0||myMethod==2) {
128 if(myNtuple) hist_def();
132 ISvcLocator* svcLocator = Gaudi::svcLocator();
134 StatusCode sc=svcLocator->service(
"CgemGeomSvc", ISvc);
137 if (!sc.isSuccess()) log<< MSG::INFO <<
"CgemClusterCreate::initialize(): Could not open CGEM geometry file" << endreq;
139 if(myPrintFlag) cout<<
"CgemClusterCreate::initialize() "<<myNCgemLayers<<
" Cgem layers"<<endl;
140 for(
int i=0; i<myNCgemLayers; i++)
151 if(myPrintFlag) cout<<
"layer "<<i<<
": "<<myNSheets[i]<<
" sheets"<<
", is reversed "<<IsReverse<<
", RX="<<myRXstrips[i]<<
", RY="<<myRVstrips[i]<<endl;
155 sc = service (
"CgemCalibFunSvc", myCgemCalibSvc);
156 if ( sc.isFailure() ){
157 cout<< name() <<
"Could not load MdcCalibFunSvc!" << endl;
162 return StatusCode::SUCCESS;
167 MsgStream log(
msgSvc(), name());
168 log << MSG::INFO <<
"in execute()" << endreq;
171 DataObject *aReconEvent;
172 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
173 if(aReconEvent==NULL) {
175 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon",aReconEvent);
176 if(sc!=StatusCode::SUCCESS) {
177 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
178 return( StatusCode::FAILURE);
183 if(myMethod==0) method0();
184 else if(myMethod==1) method1();
185 else if(myMethod==2) toyCluster();
186 else if(myMethod==3) method2();
189 return StatusCode::SUCCESS;
192StatusCode CgemClusterCreate::method0()
197 MsgStream log(
msgSvc(), name());
198 log << MSG::INFO <<
"in method0()" << endreq;
204 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
207 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
208 return StatusCode::FAILURE;
210 int run=evtHead->runNumber();
211 int evt=evtHead->eventNumber();
216 cout<<
"-----------------------------------------------"<<endl;
217 cout<<
"CgemClusterCreate::execute: run "<<run<<
", evt "<<evt<<endl;
221 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
224 log << MSG::WARNING <<
"Could not retrieve Cgem digi list" << endreq;
225 return StatusCode::FAILURE;
229 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
230 int layerid,sheetid,stripid,time_chnnel;
231 double energydeposit;
232 double nXStrips[3]={0,0,0};
233 double nVStrips[3]={0,0,0};
234 for( ; iter_digi != cgemDigiCol->end(); ++iter_digi)
239 energydeposit = (*iter_digi)->getChargeChannel();
240 time_chnnel = (*iter_digi)->getTimeChannel();
243 if(striptype ==
true)
246 nXStrips[layerid]+=1;
250 nVStrips[layerid]+=1;
254 if(iter_digi==cgemDigiCol->begin())
256 cout<<
"cgemDigiCol:"<<endl;
260 <<setw(10)<<
"XV(0/1)"
261 <<setw(10)<<
"strip_ID"
271 <<setw(15)<<setprecision(10)<<energydeposit
272 <<setw(15)<<setprecision(10)<<time_chnnel
275 m_strip[layerid][sheetid][flagxv][stripid] = 1;
276 m_edep[layerid][sheetid][flagxv][stripid] = energydeposit;
288 IDataProviderSvc* evtSvc = NULL;
289 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
291 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
293 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
294 return StatusCode::SUCCESS;
297 StatusCode clustersc;
298 IDataManagerSvc *dataManSvc;
299 dataManSvc=
dynamic_cast<IDataManagerSvc*
>(evtSvc);
300 DataObject *aClusterCol;
301 evtSvc->findObject(
"/Event/Recon/RecCgemClusterCol",aClusterCol);
302 if(aClusterCol != NULL) {
303 dataManSvc->clearSubTree(
"/Event/Recon/RecCgemClusterCol");
304 evtSvc->unregisterObject(
"/Event/Recon/RecCgemClusterCol");
307 clustersc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", clustercol);
308 if( clustersc.isFailure() ) {
309 log << MSG::FATAL <<
"Could not register RecCgemCluster" << endreq;
310 return StatusCode::SUCCESS;
312 log << MSG::INFO <<
"RecCgemClusterCol registered successfully!" <<endreq;
315 for(m_x_map_it = m_x_map.begin();m_x_map_it!=m_x_map.end();++m_x_map_it){
317 clustercol->push_back(reccluster);
319 for(m_v_map_it = m_v_map.begin();m_v_map_it!=m_v_map.end();++m_v_map_it){
321 clustercol->push_back(reccluster);
323 for(m_xv_map_it = m_xv_map.begin();m_xv_map_it!=m_xv_map.end();++m_xv_map_it){
325 clustercol->push_back(reccluster);
329 SmartDataPtr<RecCgemClusterCol> cgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
330 if (!cgemClusterCol){
331 log << MSG::WARNING <<
"Could not retrieve Cgem cluster list" << endreq;
332 return StatusCode::FAILURE;
335 m_evt = evtHead->eventNumber();
336 m_evt1 = evtHead->eventNumber();
339 RecCgemClusterCol::iterator iter_cluster = cgemClusterCol->begin();
341 for( ; iter_cluster != cgemClusterCol->end(); ++iter_cluster){
342 if((*iter_cluster)->getflag()==2){
344 m_layerid[ii] = (*iter_cluster)->getlayerid();
345 m_sheetid[ii] = (*iter_cluster)->getsheetid();
346 m_clusterid[ii]= (*iter_cluster)->getclusterid();
347 m_flag[ii] = (*iter_cluster)->getflag();
348 m_energy[ii] = (*iter_cluster)->getenergydeposit();
349 m_recphi[ii] = (*iter_cluster)->getrecphi();
350 m_recv[ii] = (*iter_cluster)->getrecv();
364 return StatusCode::SUCCESS;
367StatusCode CgemClusterCreate::method1()
372 MsgStream log(
msgSvc(), name());
373 log << MSG::INFO <<
"in method1()" << endreq;
376 resetFiredStripMap();
379 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
382 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
383 return StatusCode::FAILURE;
385 int run=evtHead->runNumber();
386 int evt=evtHead->eventNumber();
391 cout<<
"-----------------------------------------------"<<endl;
392 cout<<
"CgemClusterCreate::execute: run "<<run<<
", evt "<<evt<<endl;
395 if(run<0) fillMCTruth();
397 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
400 log << MSG::WARNING <<
"Could not retrieve Cgem digi list" << endreq;
401 return StatusCode::FAILURE;
405 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
406 int layerid,sheetid,stripid,time_chnnel;
407 double energydeposit;
409 double nXStrips[3]={0,0,0};
410 double nVStrips[3]={0,0,0};
411 bool printed =
false;
412 for( ; iter_digi != cgemDigiCol->end(); ++iter_digi)
416 if(!selDigi(iter_digi,m_selGoodDigi))
continue;
420 energydeposit = (*iter_digi)->getChargeChannel();
421 time_chnnel = (*iter_digi)->getTimeChannel();
422 Q_fC = (*iter_digi)->getCharge_fc();
423 T_ns = (*iter_digi)->getTime_ns();
426 if(striptype ==
true)
429 nXStrips[layerid]+=1;
433 nVStrips[layerid]+=1;
440 cout<<
"cgemDigiCol:"<<endl;
444 <<setw(10)<<
"XV(0/1)"
445 <<setw(10)<<
"strip_ID"
458 <<setw(15)<<setprecision(10)<<Q_fC
459 <<setw(15)<<setprecision(10)<<T_ns
462 myFiredStripMap[layerid][sheetid][flagxv][stripid]=iter_digi;
466 SmartDataPtr<RecCgemClusterCol> lastCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
467 IDataProviderSvc* evtSvc = NULL;
468 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
470 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
472 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
473 return StatusCode::SUCCESS;
475 if(lastCgemClusterCol) {
476 evtSvc->unregisterObject(
"/Event/Recon/RecCgemClusterCol");
481 sc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", aCgemClusterCol);
484 log << MSG::FATAL <<
"Could not register RecCgemClusterCol" << endreq;
485 return StatusCode::SUCCESS;
489 if(myPrintFlag) cout<<
"--------------------------------------------"<<endl;
491 double sumQ(0.0),sumQX(0.0);
493 int nCluster[3][3]={{0,0,0},{0,0,0},{0,0,0}};
494 double posX[3][100],posZ[3][100],posV[3][100],phi_XV[3][100];
495 double QX[3][100],QV[3][100],QX_XV[3][100],QV_XV[3][100];
496 int nStripsX[3][100],nStripsV[3][100];
498 vector<int> iStart_cluster[3][2][2];
499 vector<int> iEnd_cluster[3][2][2];
500 vector<double> E_cluster[3][2][2];
501 vector<int> id_cluster[3][2][3];
502 vector<double> vecPos_cluster[3][2][3];
503 vector<int> idxCluster[3][2][2];
504 vector<int> idxBoundaryXVcluster[3][2][2];
507 for(
int i=0; i<3; i++)
509 if(myPrintFlag) cout<<
"---- layer "<<i<<
" ----"<<endl;
510 for(
int j=0; j<myNSheets[i]; j++)
512 if(myPrintFlag) cout<<
"---- sheet "<<j<<
":: "<<endl;
514 for(
int k=0; k<2; k++)
516 if(myPrintFlag) cout<<
"---- XV "<<k<<
": "<<endl;
518 map<int,CgemDigiCol::iterator>::iterator
iter=myFiredStripMap[i][j][k].begin();
519 map<int,CgemDigiCol::iterator>::iterator iter_end=myFiredStripMap[i][j][k].end();
520 int i1(-1),i2(-1),idLast(-2);
523 if((
iter->first-idLast)>1)
527 double posCluster(9999.);
529 posCluster = sumQX/sumQ;
531 if(k==0) cout<<
"find X cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" rad"<<endl;
532 if(k==1) cout<<
"find V cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" mm"<<endl;
534 int clusterId=aCgemClusterCol->size();
535 iStart_cluster[i][j][k].push_back(i1);
536 iEnd_cluster[i][j][k].push_back(i2);
537 vecPos_cluster[i][j][k].push_back(posCluster);
538 E_cluster[i][j][k].push_back(sumQ);
539 id_cluster[i][j][k].push_back(clusterId);
548 if(k==0) pt_recCluster->
setrecphi(posCluster);
549 if(k==1) pt_recCluster->
setrecv(posCluster);
550 aCgemClusterCol->push_back(pt_recCluster);
552 if(k==0&&nCluster[i][k]<100)
554 posX[i][nCluster[i][k]]=posCluster;
555 QX[i][nCluster[i][k]]=sumQ;
556 nStripsX[i][nCluster[i][k]]=i2-i1+1;
561 if(nCluster[i][k]<100) {
562 nStripsV[i][nCluster[i][k]]=i2-i1+1;
563 posV[i][nCluster[i][k]]=posCluster;
564 QV[i][nCluster[i][k]]=sumQ;
566 int nXCluster=iStart_cluster[i][j][0].size();
567 for(
int iX=0; iX<nXCluster; iX++)
569 double Z_pos = readoutPlane->
getZFromPhiV(vecPos_cluster[i][j][0][iX],posCluster);
571 if(readoutPlane->
OnThePlane(vecPos_cluster[i][j][0][iX],Z_pos))
573 if(myPrintFlag) cout<<
"find a XV cluster, Z="<<Z_pos<<endl;
574 int iV=iStart_cluster[i][j][1].size()-1;
575 clusterId=aCgemClusterCol->size();
576 vecPos_cluster[i][j][2].push_back(Z_pos);
577 id_cluster[i][j][2].push_back(clusterId);
578 idxCluster[i][j][0].push_back(iX);
579 idxCluster[i][j][1].push_back(iV);
586 pt2_recCluster->
setclusterflag(id_cluster[i][j][0][iX],id_cluster[i][j][1][iV]);
587 pt2_recCluster->
setrecphi(vecPos_cluster[i][j][0][iX]);
588 pt2_recCluster->
setrecv(vecPos_cluster[i][j][1][iV]);
589 pt2_recCluster->
setRecZ(Z_pos);
591 aCgemClusterCol->push_back(pt2_recCluster);
593 if(nCluster[i][2]<100) {
594 posZ[i][nCluster[i][2]]=Z_pos;
595 phi_XV[i][nCluster[i][2]]=vecPos_cluster[i][j][0][iX];
597 if( (iEnd_cluster[i][j][0][iX]+1)==readoutPlane->
getNXstrips() )
598 idxBoundaryXVcluster[i][j][0].push_back(idxCluster[i][j][1].size()-1);
599 if(iStart_cluster[i][j][0][iX]==0)
600 idxBoundaryXVcluster[i][j][1].push_back(idxCluster[i][j][1].size()-1);
608 cout<<
"sumQ<=0!: sumQX,sumQ="<<sumQX<<
","<<sumQ<<endl;
620 if(myPrintFlag) cout<<
"fired strip "<<idLast<<endl;
622 double energy=(*(
iter->second))->getCharge_fc();
632 double posCluster(9999.);
634 posCluster = sumQX/sumQ;
636 if(k==0) cout<<
"find X cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" rad"<<endl;
637 if(k==1) cout<<
"find V cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" mm"<<endl;
639 int clusterId=aCgemClusterCol->size();
640 iStart_cluster[i][j][k].push_back(i1);
641 iEnd_cluster[i][j][k].push_back(i2);
642 vecPos_cluster[i][j][k].push_back(posCluster);
643 E_cluster[i][j][k].push_back(sumQ);
644 id_cluster[i][j][k].push_back(clusterId);
653 if(k==0) pt_recCluster->
setrecphi(posCluster);
654 if(k==1) pt_recCluster->
setrecv(posCluster);
655 aCgemClusterCol->push_back(pt_recCluster);
657 if(k==0&&nCluster[i][k]<100) {
658 posX[i][nCluster[i][k]]=posCluster;
659 QX[i][nCluster[i][k]]=sumQ;
660 nStripsX[i][nCluster[i][k]]=i2-i1+1;
665 if(nCluster[i][k]<100) {
666 nStripsV[i][nCluster[i][k]]=i2-i1+1;
667 posV[i][nCluster[i][k]]=posCluster;
668 QV[i][nCluster[i][k]]=sumQ;
670 int nXCluster=iStart_cluster[i][j][0].size();
671 for(
int iX=0; iX<nXCluster; iX++)
673 double Z_pos = readoutPlane->
getZFromPhiV(vecPos_cluster[i][j][0][iX],posCluster);
675 if(readoutPlane->
OnThePlane(vecPos_cluster[i][j][0][iX],Z_pos))
677 if(myPrintFlag) cout<<
"find a XV cluster, Z="<<Z_pos<<endl;
678 clusterId=aCgemClusterCol->size();
679 vecPos_cluster[i][j][2].push_back(Z_pos);
680 id_cluster[i][j][2].push_back(clusterId);
681 int iV=iStart_cluster[i][j][1].size()-1;
688 pt2_recCluster->
setclusterflag(id_cluster[i][j][0][iX],id_cluster[i][j][1][iV]);
689 pt2_recCluster->
setrecphi(vecPos_cluster[i][j][0][iX]);
690 pt2_recCluster->
setrecv(vecPos_cluster[i][j][1][iV]);
691 pt2_recCluster->
setRecZ(Z_pos);
692 aCgemClusterCol->push_back(pt2_recCluster);
694 if(nCluster[i][2]<100) {
695 posZ[i][nCluster[i][2]]=Z_pos;
696 phi_XV[i][nCluster[i][2]]=vecPos_cluster[i][j][0][iX];
698 idxCluster[i][j][0].push_back(iX);
699 idxCluster[i][j][1].push_back(iEnd_cluster[i][j][1].size()-1);
700 if( (iEnd_cluster[i][j][0][iX]+1)==readoutPlane->
getNXstrips() )
701 idxBoundaryXVcluster[i][j][0].push_back(idxCluster[i][j][1].size()-1);
702 if(iStart_cluster[i][j][0][iX]==0)
703 idxBoundaryXVcluster[i][j][1].push_back(idxCluster[i][j][1].size()-1);
710 else cout<<
"sumQ<=0!: sumQX,sumQ="<<sumQX<<
","<<sumQ<<endl;
717 if(nCluster[i][0]>100) nCluster[i][0]=100;
718 if(nCluster[i][1]>100) nCluster[i][1]=100;
719 if(nCluster[i][2]>100) nCluster[i][2]=100;
722 for(
int j=0; j<myNSheets[i]; j++)
726 if(j_next==myNSheets[i]) j_next=0;
730 double xmin_next = nextReadoutPlane->
getXmin();
732 int nXV_atXEnd=idxBoundaryXVcluster[i][j][0].size();
733 int nXV_atXStart=idxBoundaryXVcluster[i][j_next][1].size();
734 if(nXV_atXEnd==0||nXV_atXStart==0)
continue;
735 for(
int iXV_atXEnd=0; iXV_atXEnd<nXV_atXEnd; iXV_atXEnd++)
737 int iXVCluster = idxBoundaryXVcluster[i][j][0][iXV_atXEnd];
738 int iXCluster = idxCluster[i][j][0][iXVCluster];
739 int iVCluster = idxCluster[i][j][1][iXVCluster];
740 int VID1=iStart_cluster[i][j][1][iVCluster];
741 int VID2=iEnd_cluster[i][j][1][iVCluster];
744 for(
int iXV_atXStart=0; iXV_atXStart<nXV_atXStart; iXV_atXStart++)
746 int iXVCluster_next = idxBoundaryXVcluster[i][j_next][1][iXV_atXStart];
747 int iXCluster_next = idxCluster[i][j_next][0][iXVCluster_next];
748 int iVCluster_next = idxCluster[i][j_next][1][iXVCluster_next];
749 int VID1_next=iStart_cluster[i][j_next][1][iVCluster_next];
750 int VID2_next=iEnd_cluster[i][j_next][1][iVCluster_next];
751 if( !( (VID1_next-VID2_extend)>1 || (VID1_extend-VID2_next)>1 ) )
753 int XID1=iStart_cluster[i][j][0][iXCluster];
754 int XID2=iEnd_cluster[i][j][0][iXCluster];
755 int XID1_next=iStart_cluster[i][j_next][0][iXCluster_next];
756 int XID2_next=iEnd_cluster[i][j_next][0][iXCluster_next];
757 int clusterId=aCgemClusterCol->size();
764 int id1=id_cluster[i][j][2][iXVCluster];
765 int id2=id_cluster[i][j_next][2][iXVCluster_next];
768 double phi1=vecPos_cluster[i][j][0][iXCluster];
769 double phi2=vecPos_cluster[i][j_next][0][iXCluster_next];
775 double E1=E_cluster[i][j][0][iXCluster];
776 double E2=E_cluster[i][j_next][0][iXCluster_next];
777 double phiAverage=(E1*
phi1+E2*
phi2)/(E1+E2);
780 double v1=vecPos_cluster[i][j][1][iVCluster];
782 double v2=vecPos_cluster[i][j_next][1][iVCluster_next];
783 E1=E_cluster[i][j][1][iVCluster];
784 E2=E_cluster[i][j_next][1][iVCluster_next];
785 double V_average_next=(E1*v1+E2*v2)/(E1+E2);
786 pt_recCluster->
setrecv(V_average_next);
788 double z_average = nextReadoutPlane->
getZFromPhiV(phiAverage,V_average_next,0);
789 pt_recCluster->
setRecZ(z_average);
791 aCgemClusterCol->push_back(pt_recCluster);
794 cout<<
"one combinational cluster found: "<<endl;
795 cout<<
" sheet "<<j <<
" xID:"<<XID1 <<
"~"<<XID2 <<
", phi:"<<vecPos_cluster[i][j][0][iXCluster] <<
", vID:"<<VID1 <<
"~"<<VID2 <<
", v:"<<vecPos_cluster[i][j][1][iVCluster] <<
", z:"<<vecPos_cluster[i][j][2][iXVCluster] <<endl;
796 cout<<
" sheet "<<j_next<<
" xID:"<<XID1_next<<
"~"<<XID2_next<<
", phi:"<<vecPos_cluster[i][j_next][0][iXCluster_next]<<
", vID:"<<VID1_next<<
"~"<<VID2_next<<
", v:"<<vecPos_cluster[i][j_next][1][iVCluster_next]<<
", z:"<<vecPos_cluster[i][j_next][2][iXVCluster_next]<<endl;
797 cout<<
" averagePhi:"<<phiAverage<<
", v_average:"<<V_average_next<<
", z_average:"<<z_average<<endl;
809 double evttime=m_timer->
elapsed();
812 if(myPrintFlag) checkRecCgemClusterCol();
816 myNTupleHelper->
fillLong(
"run",(
long)run);
817 myNTupleHelper->
fillLong(
"evt",(
long)evt);
819 myNTupleHelper->
fillArray(
"nXstrips",
"nLayer",(
double*) nXStrips,3);
820 myNTupleHelper->
fillArray(
"nVstrips",
"nLayer",(
double*) nVStrips,3);
822 myNTupleHelper->
fillArray(
"phiClusterLay1",
"nXClusterLay1",(
double*) posX[0],nCluster[0][0]);
823 myNTupleHelper->
fillArrayInt(
"nXStripsLay1",
"nXClusterLay1",(
int*) nStripsX[0],nCluster[0][0]);
824 myNTupleHelper->
fillArray(
"QXLay1",
"nXClusterLay1",(
double*) QX[0],nCluster[0][0]);
826 myNTupleHelper->
fillArray(
"VClusterLay1",
"nVClusterLay1",(
double*) posV[0],nCluster[0][1]);
827 myNTupleHelper->
fillArrayInt(
"nVStripsLay1",
"nVClusterLay1",(
int*) nStripsV[0],nCluster[0][1]);
828 myNTupleHelper->
fillArray(
"QVLay1",
"nVClusterLay1",(
double*) QV[0],nCluster[0][1]);
830 myNTupleHelper->
fillArray(
"zClusterLay1",
"nXVClusterLay1",(
double*) posZ[0],nCluster[0][2]);
831 myNTupleHelper->
fillArray(
"phiXVClusterLay1",
"nXVClusterLay1",(
double*) phi_XV[0],nCluster[0][2]);
833 myNTupleHelper->
fillArray(
"phiClusterLay2",
"nXClusterLay2",(
double*) posX[1],nCluster[1][0]);
834 myNTupleHelper->
fillArrayInt(
"nXStripsLay2",
"nXClusterLay2",(
int*) nStripsX[1],nCluster[1][0]);
835 myNTupleHelper->
fillArray(
"QXLay2",
"nXClusterLay2",(
double*) QX[1],nCluster[1][0]);
837 myNTupleHelper->
fillArray(
"VClusterLay2",
"nVClusterLay2",(
double*) posV[1],nCluster[1][1]);
838 myNTupleHelper->
fillArrayInt(
"nVStripsLay2",
"nVClusterLay2",(
int*) nStripsV[1],nCluster[1][1]);
839 myNTupleHelper->
fillArray(
"QVLay2",
"nVClusterLay2",(
double*) QV[1],nCluster[1][1]);
841 myNTupleHelper->
fillArray(
"zClusterLay2",
"nXVClusterLay2",(
double*) posZ[1],nCluster[1][2]);
842 myNTupleHelper->
fillArray(
"phiXVClusterLay2",
"nXVClusterLay2",(
double*) phi_XV[1],nCluster[1][2]);
844 myNTupleHelper->
fillArray(
"phiClusterLay3",
"nXClusterLay3",(
double*) posX[2],nCluster[2][0]);
845 myNTupleHelper->
fillArrayInt(
"nXStripsLay3",
"nXClusterLay3",(
int*) nStripsX[2],nCluster[2][0]);
846 myNTupleHelper->
fillArray(
"QXLay3",
"nXClusterLay3",(
double*) QX[2],nCluster[2][0]);
848 myNTupleHelper->
fillArray(
"VClusterLay3",
"nVClusterLay3",(
double*) posV[2],nCluster[2][1]);
849 myNTupleHelper->
fillArrayInt(
"nVStripsLay3",
"nVClusterLay3",(
int*) nStripsV[2],nCluster[2][1]);
850 myNTupleHelper->
fillArray(
"QVLay3",
"nVClusterLay3",(
double*) QV[2],nCluster[2][1]);
852 myNTupleHelper->
fillArray(
"zClusterLay3",
"nXVClusterLay3",(
double*) posZ[2],nCluster[2][2]);
853 myNTupleHelper->
fillArray(
"phiXVClusterLay3",
"nXVClusterLay3",(
double*) phi_XV[2],nCluster[2][2]);
855 myNTupleHelper->
fillDouble(
"evtTime",evttime);
857 myNTupleHelper->
write();
859 if(myPrintFlag) cout<<
"End of CgemClusterCreate::method1()"<<endl;
861 return StatusCode::SUCCESS;
864StatusCode CgemClusterCreate::method2()
869 MsgStream log(
msgSvc(), name());
870 log << MSG::INFO <<
"in method1()" << endreq;
873 resetFiredStripMap();
877 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
880 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
881 return StatusCode::FAILURE;
883 int run=evtHead->runNumber();
884 int evt=evtHead->eventNumber();
890 cout<<
"-----------------------------------------------"<<endl;
891 cout<<
"CgemClusterCreate::execute: run "<<run<<
", evt "<<evt<<endl;
894 if(run<0) fillMCTruth();
896 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
899 log << MSG::WARNING <<
"Could not retrieve Cgem digi list" << endreq;
900 return StatusCode::FAILURE;
904 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
905 int layerid,sheetid,stripid,time_chnnel;
906 double energydeposit;
908 double nXStrips[3]={0,0,0};
909 double nVStrips[3]={0,0,0};
910 bool printed =
false;
911 for( ; iter_digi != cgemDigiCol->end(); ++iter_digi)
915 if(!selDigi(iter_digi,m_selGoodDigi))
continue;
919 energydeposit = (*iter_digi)->getChargeChannel();
920 time_chnnel = (*iter_digi)->getTimeChannel();
921 Q_fC = (*iter_digi)->getCharge_fc();
922 T_ns = (*iter_digi)->getTime_ns();
925 if(striptype ==
true)
928 nXStrips[layerid]+=1;
932 nVStrips[layerid]+=1;
939 cout<<
"cgemDigiCol:"<<endl;
943 <<setw(10)<<
"XV(0/1)"
944 <<setw(10)<<
"strip_ID"
957 <<setw(15)<<setprecision(10)<<Q_fC
958 <<setw(15)<<setprecision(10)<<T_ns
961 myFiredStripMap[layerid][sheetid][flagxv][stripid]=iter_digi;
965 SmartDataPtr<RecCgemClusterCol> lastCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
966 IDataProviderSvc* evtSvc = NULL;
967 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
969 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
971 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
972 return StatusCode::SUCCESS;
974 if(lastCgemClusterCol) {
975 evtSvc->unregisterObject(
"/Event/Recon/RecCgemClusterCol");
980 sc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", aCgemClusterCol);
983 log << MSG::FATAL <<
"Could not register RecCgemClusterCol" << endreq;
984 return StatusCode::SUCCESS;
988 if(myPrintFlag) cout<<
"--------------------------------------------"<<endl;
991 double sumQ(0.0),sumQX(0.0);
994 vector<double> pos_strips;
995 vector<double> drift_strips;
996 vector<double> q_strips;
997 double tposX[3][100],tposZ[3][100],tposV[3][100];
998 vector<double> vecTPos_cluster[3][2][3];
1002 double pos_tpc(9999.0), a_tpc(0.0), b_tpc(0.0);
1003 double sum_x_tpc(0.), sum_y_tpc(0.), sum_xx_tpc(0.), sum_yy_tpc(0.), sum_xy_tpc(0.);
1005 double a_tpc_cluster_X[3][100];
1006 double b_tpc_cluster_X[3][100];
1007 double pos_tpc_cluster_X[3][100];
1008 double a_tpc_cluster_V[3][100];
1009 double b_tpc_cluster_V[3][100];
1010 double pos_tpc_cluster_V[3][100];
1013 int nCluster[3][3]={{0,0,0},{0,0,0},{0,0,0}};
1014 double posX[3][100],posZ[3][100],posV[3][100],phi_XV[3][100];
1015 double QX[3][100],QV[3][100],QX_XV[3][100],QV_XV[3][100];
1016 int nStripsX[3][100],nStripsV[3][100];
1017 vector<int> iStart_cluster[3][2][2];
1018 vector<int> iEnd_cluster[3][2][2];
1019 vector<double> E_cluster[3][2][2];
1020 vector<int> id_cluster[3][2][3];
1021 vector<double> vecPos_cluster[3][2][3];
1022 vector<int> idxCluster[3][2][2];
1023 vector<int> idxBoundaryXVcluster[3][2][2];
1026 for(
int i=0; i<3; i++)
1028 if(myPrintFlag) cout<<
"---- layer "<<i<<
" ----"<<endl;
1029 for(
int j=0; j<myNSheets[i]; j++)
1031 if(myPrintFlag) cout<<
"---- sheet "<<j<<
":: "<<endl;
1033 for(
int k=0; k<2; k++)
1035 if(myPrintFlag) cout<<
"---- XV "<<k<<
": "<<endl;
1037 map<int,CgemDigiCol::iterator>::iterator
iter=myFiredStripMap[i][j][k].begin();
1038 map<int,CgemDigiCol::iterator>::iterator iter_end=myFiredStripMap[i][j][k].end();
1039 map<int,CgemDigiCol::iterator>::iterator iter_next=
iter;
1040 int i1(-1),i2(-1),idLast(-2);
1041 bool clusterFound=
true;
1044 if(myPrintFlag) cout<<
"fired strip "<<
iter->first<<endl;
1047 double energy=(*(
iter->second))->getCharge_fc();
1049 double time=(*(
iter->second))->getTime_ns();
1059 pos_strips.push_back(pos);
1063 double time_gap = time_falling-time_rising;
1064 double drift_velocity =
drift_gap/time_gap;
1065 double time_ns =
time-time_rising;
1066 if(myPrintFlag) cout<<
"T_r, T_f = "<<time_rising<<
", "<<time_falling<<
", time_ns="<<
time<<endl;
1067 drift_strips.push_back(time_ns*drift_velocity);
1068 q_strips.push_back(
energy);
1072 double drift = time_ns*drift_velocity;
1075 sum_xx_tpc+=pos*pos;
1076 sum_yy_tpc+=drift*drift;
1077 sum_xy_tpc+=pos*drift;
1088 if(iter_next==iter_end||(iter_next->first-
iter->first)>1)
1091 double posCluster_CC(9999.);
1093 cout<<
"sumQ<=0!: sumQX,sumQ="<<sumQX<<
","<<sumQ<<endl;
1096 posCluster_CC = sumQX/sumQ;
1100 double tposCluster(9999.);
1101 double slope(-9999);
1102 int n_Strips=pos_strips.size();
1105 double *
x =
new double[n_Strips];
1106 double *tx =
new double[n_Strips];
1107 double *ex =
new double[n_Strips];
1108 double *etx =
new double[n_Strips];
1109 for(
int ix=0; ix<n_Strips; ix++)
1111 x[ix] = pos_strips[ix];
1112 tx[ix] = drift_strips[ix];
1116 cout<<
"t = "<<tx[ix]<<
", q = "<<q_strips[ix]<<
", x= "<<
x[ix]<<endl;
1118 TGraphErrors xline(n_Strips, x, tx, ex, etx);
1119 TF1
f1(
"f1",
"[0]*x + [1]", -10000, 10000);
1120 xline.Fit(&
f1,
"Q");
1121 TF1* f2 = xline.GetFunction(
"f1");
1123 f2->GetParameters(xpar);
1124 double *expar=f2->GetParErrors();
1129 tposCluster=(
drift_gap/2.-xpar[1])/xpar[0];
1130 if(fabs(tposCluster)>9999) tposCluster=9999.0;
1140 double slope2(-9999);
1142 a_tpc = ((sum_y_tpc*sum_xx_tpc)-(sum_x_tpc*sum_xy_tpc))/(n_tpc*sum_xx_tpc-sum_x_tpc*sum_x_tpc);
1143 b_tpc = (n_tpc*sum_xy_tpc-sum_x_tpc*sum_y_tpc)/(n_tpc*sum_xx_tpc-sum_x_tpc*sum_x_tpc);
1154 if(k==0) cout<<
"find X cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", CC position = "<<posCluster_CC<<
" rad"<<
", mTPC1 position = "<<tposCluster<<
", mTPC2 position = "<<pos_tpc<<endl;
1155 if(k==1) cout<<
"find V cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", CC position = "<<posCluster_CC<<
" mm"<<
", mTPC1 position = "<<tposCluster<<
", mTPC2 position = "<<pos_tpc<<endl;
1160 int clusterId=aCgemClusterCol->size();
1161 iStart_cluster[i][j][k].push_back(i1);
1162 iEnd_cluster[i][j][k].push_back(i2);
1163 vecPos_cluster[i][j][k].push_back(posCluster_CC);
1164 if(m_selectTPC==1) {
1165 vecTPos_cluster[i][j][k].push_back(tposCluster);
1167 else if(m_selectTPC==2) {
1168 vecTPos_cluster[i][j][k].push_back(pos_tpc);
1171 E_cluster[i][j][k].push_back(sumQ);
1172 id_cluster[i][j][k].push_back(clusterId);
1184 pt_recCluster->
setrecphi(posCluster_CC);
1186 if(m_selectTPC==1) {
1190 else if(m_selectTPC==2) {
1196 pt_recCluster->
setrecv(posCluster_CC);
1198 if(m_selectTPC==1) {
1202 else if(m_selectTPC==2){
1207 aCgemClusterCol->push_back(pt_recCluster);
1210 if(k==0&&nCluster[i][k]<100)
1213 nStripsX[i][nCluster[i][k]]=i2-i1+1;
1214 posX[i][nCluster[i][k]]=posCluster_CC;
1215 QX[i][nCluster[i][k]]=sumQ;
1218 tposX[i][nCluster[i][k]]=tposCluster;
1221 a_tpc_cluster_X[i][nCluster[i][k]]=a_tpc;
1222 b_tpc_cluster_X[i][nCluster[i][k]]=b_tpc;
1223 pos_tpc_cluster_X[i][nCluster[i][k]]=pos_tpc;
1230 if(nCluster[i][k]<100) {
1232 nStripsV[i][nCluster[i][k]]=i2-i1+1;
1233 posV[i][nCluster[i][k]]=posCluster_CC;
1234 QV[i][nCluster[i][k]]=sumQ;
1237 tposV[i][nCluster[i][k]]=tposCluster;
1241 int nXCluster=iStart_cluster[i][j][0].size();
1242 for(
int iX=0; iX<nXCluster; iX++)
1244 double Z_pos = readoutPlane->
getZFromPhiV(vecPos_cluster[i][j][0][iX],posCluster_CC);
1245 double tZ_pos =9999.0;
1246 if(vecTPos_cluster[i][j][0][iX]!=9999.0&&tposCluster!=9999.0)
1247 tZ_pos = readoutPlane->
getZFromPhiV(vecTPos_cluster[i][j][0][iX],tposCluster);
1249 if(readoutPlane->
OnThePlane(vecPos_cluster[i][j][0][iX],Z_pos))
1251 if(myPrintFlag) cout<<
"find a XV cluster, Z="<<Z_pos<<endl;
1252 int iV=iStart_cluster[i][j][1].size()-1;
1253 clusterId=aCgemClusterCol->size();
1254 vecPos_cluster[i][j][2].push_back(Z_pos);
1255 id_cluster[i][j][2].push_back(clusterId);
1256 idxCluster[i][j][0].push_back(iX);
1257 idxCluster[i][j][1].push_back(iV);
1265 pt2_recCluster->
setclusterflag(id_cluster[i][j][0][iX],id_cluster[i][j][1][iV]);
1266 pt2_recCluster->
setrecphi(vecPos_cluster[i][j][0][iX]);
1267 pt2_recCluster->
setrecphi_CC(vecPos_cluster[i][j][0][iX]);
1269 pt2_recCluster->
setrecv(vecPos_cluster[i][j][1][iV]);
1270 pt2_recCluster->
setrecv_CC(vecPos_cluster[i][j][1][iV]);
1271 pt2_recCluster->
setrecv_mTPC(vecTPos_cluster[i][j][1][iV]);
1272 pt2_recCluster->
setRecZ(Z_pos);
1275 aCgemClusterCol->push_back(pt2_recCluster);
1278 if(nCluster[i][2]<100) {
1279 posZ[i][nCluster[i][2]]=Z_pos;
1280 tposZ[i][nCluster[i][2]]=tZ_pos;
1281 phi_XV[i][nCluster[i][2]]=vecPos_cluster[i][j][0][iX];
1283 if( (iEnd_cluster[i][j][0][iX]+1)==readoutPlane->
getNXstrips() )
1284 idxBoundaryXVcluster[i][j][0].push_back(idxCluster[i][j][1].size()-1);
1285 if(iStart_cluster[i][j][0][iX]==0)
1286 idxBoundaryXVcluster[i][j][1].push_back(idxCluster[i][j][1].size()-1);
1301 drift_strips.clear();
1320 for(
int j=0; j<myNSheets[i]; j++)
1324 if(j_next==myNSheets[i]) j_next=0;
1328 double xmin_next = nextReadoutPlane->
getXmin();
1330 int nXV_atXEnd=idxBoundaryXVcluster[i][j][0].size();
1331 int nXV_atXStart=idxBoundaryXVcluster[i][j_next][1].size();
1332 if(nXV_atXEnd==0||nXV_atXStart==0)
continue;
1333 for(
int iXV_atXEnd=0; iXV_atXEnd<nXV_atXEnd; iXV_atXEnd++)
1335 int iXVCluster = idxBoundaryXVcluster[i][j][0][iXV_atXEnd];
1336 int iXCluster = idxCluster[i][j][0][iXVCluster];
1337 int iVCluster = idxCluster[i][j][1][iXVCluster];
1338 int VID1=iStart_cluster[i][j][1][iVCluster];
1339 int VID2=iEnd_cluster[i][j][1][iVCluster];
1342 for(
int iXV_atXStart=0; iXV_atXStart<nXV_atXStart; iXV_atXStart++)
1344 int iXVCluster_next = idxBoundaryXVcluster[i][j_next][1][iXV_atXStart];
1345 int iXCluster_next = idxCluster[i][j_next][0][iXVCluster_next];
1346 int iVCluster_next = idxCluster[i][j_next][1][iXVCluster_next];
1347 int VID1_next=iStart_cluster[i][j_next][1][iVCluster_next];
1348 int VID2_next=iEnd_cluster[i][j_next][1][iVCluster_next];
1349 if( !( (VID1_next-VID2_extend)>1 || (VID1_extend-VID2_next)>1 ) )
1351 int XID1=iStart_cluster[i][j][0][iXCluster];
1352 int XID2=iEnd_cluster[i][j][0][iXCluster];
1353 int XID1_next=iStart_cluster[i][j_next][0][iXCluster_next];
1354 int XID2_next=iEnd_cluster[i][j_next][0][iXCluster_next];
1355 int clusterId=aCgemClusterCol->size();
1362 int id1=id_cluster[i][j][2][iXVCluster];
1363 int id2=id_cluster[i][j_next][2][iXVCluster_next];
1366 double phi1=vecPos_cluster[i][j][0][iXCluster];
1367 double phi2=vecPos_cluster[i][j_next][0][iXCluster_next];
1373 double E1=E_cluster[i][j][0][iXCluster];
1374 double E2=E_cluster[i][j_next][0][iXCluster_next];
1375 double phiAverage=(E1*
phi1+E2*
phi2)/(E1+E2);
1378 double v1=vecPos_cluster[i][j][1][iVCluster];
1380 double v2=vecPos_cluster[i][j_next][1][iVCluster_next];
1381 E1=E_cluster[i][j][1][iVCluster];
1382 E2=E_cluster[i][j_next][1][iVCluster_next];
1383 double V_average_next=(E1*v1+E2*v2)/(E1+E2);
1384 pt_recCluster->
setrecv(V_average_next);
1386 double z_average = nextReadoutPlane->
getZFromPhiV(phiAverage,V_average_next,0);
1387 pt_recCluster->
setRecZ(z_average);
1389 aCgemClusterCol->push_back(pt_recCluster);
1392 cout<<
"one combinational cluster found: "<<endl;
1393 cout<<
" sheet "<<j <<
" xID:"<<XID1 <<
"~"<<XID2 <<
", phi:"<<vecPos_cluster[i][j][0][iXCluster] <<
", vID:"<<VID1 <<
"~"<<VID2 <<
", v:"<<vecPos_cluster[i][j][1][iVCluster] <<
", z:"<<vecPos_cluster[i][j][2][iXVCluster] <<endl;
1394 cout<<
" sheet "<<j_next<<
" xID:"<<XID1_next<<
"~"<<XID2_next<<
", phi:"<<vecPos_cluster[i][j_next][0][iXCluster_next]<<
", vID:"<<VID1_next<<
"~"<<VID2_next<<
", v:"<<vecPos_cluster[i][j_next][1][iVCluster_next]<<
", z:"<<vecPos_cluster[i][j_next][2][iXVCluster_next]<<endl;
1395 cout<<
" averagePhi:"<<phiAverage<<
", v_average:"<<V_average_next<<
", z_average:"<<z_average<<endl;
1402 if(nCluster[i][0]>100) nCluster[i][0]=100;
1403 if(nCluster[i][1]>100) nCluster[i][1]=100;
1404 if(nCluster[i][2]>100) nCluster[i][2]=100;
1409 double evttime=m_timer->
elapsed();
1412 if(myPrintFlag) checkRecCgemClusterCol();
1417 myNTupleHelper->
fillLong(
"run",(
long)run);
1418 myNTupleHelper->
fillLong(
"evt",(
long)evt);
1420 myNTupleHelper->
fillArray(
"nXstrips",
"nLayer",(
double*) nXStrips,3);
1421 myNTupleHelper->
fillArray(
"nVstrips",
"nLayer",(
double*) nVStrips,3);
1423 myNTupleHelper->
fillArray(
"phiClusterLay1",
"nXClusterLay1",(
double*) posX[0],nCluster[0][0]);
1424 myNTupleHelper->
fillArray(
"tphiClusterLay1",
"nXClusterLay1",(
double*) tposX[0],nCluster[0][0]);
1425 myNTupleHelper->
fillArrayInt(
"nXStripsLay1",
"nXClusterLay1",(
int*) nStripsX[0],nCluster[0][0]);
1426 myNTupleHelper->
fillArray(
"QXLay1",
"nXClusterLay1",(
double*) QX[0],nCluster[0][0]);
1427 myNTupleHelper->
fillArray(
"a_tpc_XLay1" ,
"nXClusterLay1",(
double*) a_tpc_cluster_X[0] ,nCluster[0][0]);
1428 myNTupleHelper->
fillArray(
"b_tpc_XLay1" ,
"nXClusterLay1",(
double*) b_tpc_cluster_X[0] ,nCluster[0][0]);
1429 myNTupleHelper->
fillArray(
"pos_tpc_XLay1" ,
"nXClusterLay1",(
double*) pos_tpc_cluster_X[0],nCluster[0][0]);
1431 myNTupleHelper->
fillArray(
"VClusterLay1",
"nVClusterLay1",(
double*) posV[0],nCluster[0][1]);
1432 myNTupleHelper->
fillArray(
"tVClusterLay1",
"nVClusterLay1",(
double*) tposV[0],nCluster[0][1]);
1433 myNTupleHelper->
fillArrayInt(
"nVStripsLay1",
"nVClusterLay1",(
int*) nStripsV[0],nCluster[0][1]);
1434 myNTupleHelper->
fillArray(
"QVLay1",
"nVClusterLay1",(
double*) QV[0],nCluster[0][1]);
1436 myNTupleHelper->
fillArray(
"zClusterLay1",
"nXVClusterLay1",(
double*) posZ[0],nCluster[0][2]);
1437 myNTupleHelper->
fillArray(
"tzClusterLay1",
"nXVClusterLay1",(
double*) tposZ[0],nCluster[0][2]);
1438 myNTupleHelper->
fillArray(
"phiXVClusterLay1",
"nXVClusterLay1",(
double*) phi_XV[0],nCluster[0][2]);
1440 myNTupleHelper->
fillArray(
"phiClusterLay2",
"nXClusterLay2",(
double*) posX[1],nCluster[1][0]);
1441 myNTupleHelper->
fillArray(
"tphiClusterLay2",
"nXClusterLay2",(
double*) tposX[1],nCluster[1][0]);
1442 myNTupleHelper->
fillArrayInt(
"nXStripsLay2",
"nXClusterLay2",(
int*) nStripsX[1],nCluster[1][0]);
1443 myNTupleHelper->
fillArray(
"QXLay2",
"nXClusterLay2",(
double*) QX[1],nCluster[1][0]);
1444 myNTupleHelper->
fillArray(
"a_tpc_XLay2" ,
"nXClusterLay2",(
double*) a_tpc_cluster_X[1] ,nCluster[1][0]);
1445 myNTupleHelper->
fillArray(
"b_tpc_XLay2" ,
"nXClusterLay2",(
double*) b_tpc_cluster_X[1] ,nCluster[1][0]);
1446 myNTupleHelper->
fillArray(
"pos_tpc_XLay2" ,
"nXClusterLay2",(
double*) pos_tpc_cluster_X[1],nCluster[1][0]);
1448 myNTupleHelper->
fillArray(
"VClusterLay2",
"nVClusterLay2",(
double*) posV[1],nCluster[1][1]);
1449 myNTupleHelper->
fillArray(
"tVClusterLay2",
"nVClusterLay2",(
double*) tposV[1],nCluster[1][1]);
1450 myNTupleHelper->
fillArrayInt(
"nVStripsLay2",
"nVClusterLay2",(
int*) nStripsV[1],nCluster[1][1]);
1451 myNTupleHelper->
fillArray(
"QVLay2",
"nVClusterLay2",(
double*) QV[1],nCluster[1][1]);
1453 myNTupleHelper->
fillArray(
"zClusterLay2",
"nXVClusterLay2",(
double*) posZ[1],nCluster[1][2]);
1454 myNTupleHelper->
fillArray(
"tzClusterLay2",
"nXVClusterLay2",(
double*) tposZ[1],nCluster[1][2]);
1455 myNTupleHelper->
fillArray(
"phiXVClusterLay2",
"nXVClusterLay2",(
double*) phi_XV[1],nCluster[1][2]);
1457 myNTupleHelper->
fillArray(
"phiClusterLay3",
"nXClusterLay3",(
double*) posX[2],nCluster[2][0]);
1458 myNTupleHelper->
fillArray(
"tphiClusterLay3",
"nXClusterLay3",(
double*) tposX[2],nCluster[2][0]);
1459 myNTupleHelper->
fillArrayInt(
"nXStripsLay3",
"nXClusterLay3",(
int*) nStripsX[2],nCluster[2][0]);
1460 myNTupleHelper->
fillArray(
"QXLay3",
"nXClusterLay3",(
double*) QX[2],nCluster[2][0]);
1461 myNTupleHelper->
fillArray(
"a_tpc_XLay3" ,
"nXClusterLay3",(
double*) a_tpc_cluster_X[2] ,nCluster[2][0]);
1462 myNTupleHelper->
fillArray(
"b_tpc_XLay3" ,
"nXClusterLay3",(
double*) b_tpc_cluster_X[2] ,nCluster[2][0]);
1463 myNTupleHelper->
fillArray(
"pos_tpc_XLay3" ,
"nXClusterLay3",(
double*) pos_tpc_cluster_X[2],nCluster[2][0]);
1465 myNTupleHelper->
fillArray(
"VClusterLay3",
"nVClusterLay3",(
double*) posV[2],nCluster[2][1]);
1466 myNTupleHelper->
fillArray(
"tVClusterLay3",
"nVClusterLay3",(
double*) tposV[2],nCluster[2][1]);
1467 myNTupleHelper->
fillArrayInt(
"nVStripsLay3",
"nVClusterLay3",(
int*) nStripsV[2],nCluster[2][1]);
1468 myNTupleHelper->
fillArray(
"QVLay3",
"nVClusterLay3",(
double*) QV[2],nCluster[2][1]);
1470 myNTupleHelper->
fillArray(
"zClusterLay3",
"nXVClusterLay3",(
double*) posZ[2],nCluster[2][2]);
1471 myNTupleHelper->
fillArray(
"tzClusterLay3",
"nXVClusterLay3",(
double*) tposZ[2],nCluster[2][2]);
1472 myNTupleHelper->
fillArray(
"phiXVClusterLay3",
"nXVClusterLay3",(
double*) phi_XV[2],nCluster[2][2]);
1474 myNTupleHelper->
fillDouble(
"evtProcessTime",evttime);
1476 myNTupleHelper->
write();
1478 if(myPrintFlag) cout<<
"End of CgemClusterCreate::method2()"<<endl;
1480 return StatusCode::SUCCESS;
1483StatusCode CgemClusterCreate::toyCluster()
1485 MsgStream log(
msgSvc(),name());
1488 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
1491 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
1492 return StatusCode::FAILURE;
1494 int run=evtHead->runNumber();
1495 int evt=evtHead->eventNumber();
1496 if(myPrintFlag) cout<<
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "<<evt<<endl;
1499 IDataProviderSvc* evtSvc = NULL;
1500 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
1502 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
1504 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
1505 return StatusCode::SUCCESS;
1509 sc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", aCgemClusterCol);
1512 log << MSG::FATAL <<
"Could not register RecCgemClusterCol" << endreq;
1513 return StatusCode::SUCCESS;
1517 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
1520 log << MSG::WARNING <<
"Could not retrieve CgemMcHitCol list" << endreq;
1521 return StatusCode::FAILURE;
1526 double phi_truth[100], z_truth[100], r_truth[100], x_truth[100], v_truth[100], cosTh_truth[100], z_check[100];
1527 double phi_gen[100], z_gen[100], x_gen[100], v_gen[100];
1529 int nCgemMcHit = cgemMcHitCol->size();
if(myPrintFlag) cout<<
"nCgemMcHit = "<<nCgemMcHit<<endl;
1530 vector<int> idxXClusters[4][2], idxVClusters[4][2];
1531 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
1533 for(; iter_truth!=cgemMcHitCol->end(); iter_truth++ )
1535 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster(): creator process = "<<(*iter_truth)->GetCreatorProcess()<<endl;
1536 string creatorProcess = (*iter_truth)->GetCreatorProcess();
1537 if(creatorProcess==
"Generator"||creatorProcess==
"Decay")
1540 if(myClusterEff>0.&&myClusterEff<1.0) {
1541 Rndm::Numbers flat(randSvc(), Rndm::Flat(0,1));
1542 if(flat()>myClusterEff) {
1543 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() skip one cluster! "<<endl;
1548 int iLayer = (*iter_truth)->GetLayerID();
1549 double x_pre = (*iter_truth)->GetPositionXOfPrePoint();
1550 double y_pre = (*iter_truth)->GetPositionYOfPrePoint();
1551 double z_pre = (*iter_truth)->GetPositionZOfPrePoint();
1552 double x_post = (*iter_truth)->GetPositionXOfPostPoint();
1553 double y_post = (*iter_truth)->GetPositionYOfPostPoint();
1554 double z_post = (*iter_truth)->GetPositionZOfPostPoint();
1555 double x_mid = 0.5*(x_pre+x_post);
1556 double y_mid = 0.5*(y_pre+y_post);
1557 double z_mid = 0.5*(z_pre+z_post);
1558 double r_pre = sqrt(x_pre*x_pre+y_pre*y_pre+z_pre*z_pre);
1559 double r_post = sqrt(x_post*x_post+y_post*y_post+z_post*z_post);
1560 double v_x = x_post-x_pre;
1561 double v_y = y_post-y_pre;
1562 double v_z = z_post-z_pre;
1563 double cth_v = v_z/sqrt(v_x*v_x+v_y*v_y+v_z*v_z);
1569 double v_tot = sqrt(v_x*v_x+v_y*v_y+v_z*v_z);
1570 double theta_v = acos(v_z/v_tot);
1571 double phi_v = atan2(v_y, v_x);
1573 double r_middle = sqrt(x_mid*x_mid+y_mid*y_mid);
1574 if(myPrintFlag) cout<<
"iLayer, r_middle = "<<iLayer<<
", "<<r_middle<<endl;
1575 Hep3Vector pos_mid(x_mid, y_mid, z_mid);
1576 double phi_mid = pos_mid.phi();
1577 while(phi_mid>CLHEP::twopi) phi_mid-=CLHEP::twopi;
1578 while(phi_mid<0.) phi_mid+=CLHEP::twopi;
1580 double dPhi = phi_v-phi_mid;
1581 while(dPhi>CLHEP::pi) dPhi-=CLHEP::twopi;
1582 while(dPhi<-CLHEP::pi) dPhi+=CLHEP::twopi;
1586 for(
int i=0; i<myNSheets[iLayer]; i++)
1596 if(readoutPlane==NULL)
continue;
1598 double v_loc = readoutPlane->
getVFromPhiZ(phi_mid, z_mid);
1599 if(iCgemMcHit<100) {
1600 phi_truth[iCgemMcHit]=phi_mid;
1601 z_truth[iCgemMcHit]=z_mid;
1602 r_truth[iCgemMcHit]=r_middle;
1603 x_truth[iCgemMcHit]=phi_mid*myRXstrips[iLayer];
1604 v_truth[iCgemMcHit]=v_loc;
1605 cosTh_truth[iCgemMcHit]=cth_v;
1606 z_check[iCgemMcHit] = readoutPlane->
getZFromPhiV(phi_mid, v_loc);
1608 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() iLayer "<<iLayer<<
", MC hit: phi, z, V = "<<phi_mid<<
", "<<z_mid<<
", "<<v_loc<<endl;
1612 int iView(0), mode(2);
1613 double Q(100), T(100);
1614 double sigma_X = myCgemCalibSvc->
getSigma(iLayer,iView,mode,dPhi,Q,T);
1615 Rndm::Numbers gauss(randSvc(), Rndm::Gauss(0,1));
1616 double phi_mid_gen = phi_mid+gauss()*sigma_X/myRXstrips[iLayer];
1618 while(!(readoutPlane->
OnThePlane(phi_mid_gen,z_mid))) {
1619 phi_mid_gen = phi_mid+gauss()*sigma_X/myRXstrips[iLayer];
1621 if(iGenTried>=10)
break;
1624 if(myPrintFlag) cout<<
"Generation of phi with 10 times!"<<endl;
1627 if(myPrintFlag) cout<<
"generated phi: "<<phi_mid_gen<<endl;
1630 double sigma_V = myCgemCalibSvc->
getSigma(iLayer,iView,mode,dPhi,Q,T);
1632 double v_loc_gen = v_loc+gauss()*sigma_V;
1633 double z_mid_gen = readoutPlane->
getZFromPhiV(phi_mid_gen, v_loc_gen);
1635 while(!(readoutPlane->
OnThePlane(phi_mid_gen,z_mid_gen)))
1637 v_loc_gen = v_loc+gauss()*sigma_V;
1638 z_mid_gen = readoutPlane->
getZFromPhiV(phi_mid_gen, v_loc_gen);
1639 if(myPrintFlag) cout<<
"try generated V, z: "<<v_loc_gen<<
", "<<z_mid_gen<<endl;
1641 if(iGenTried>=10)
break;
1644 if(myPrintFlag) cout<<
"Generation of V with 10 times!"<<endl;
1648 if(iCgemMcHit<100) {
1649 phi_gen[iCgemMcHit]=phi_mid_gen;
1650 z_gen[iCgemMcHit]=z_mid_gen;
1651 x_gen[iCgemMcHit]=phi_mid_gen*myRXstrips[iLayer];
1652 v_gen[iCgemMcHit]=v_loc_gen;
1658 int clusterId=aCgemClusterCol->size();
1669 aCgemClusterCol->push_back(pt_recCluster);
1670 idxXClusters[iLayer][iSheet].push_back(clusterId);
1672 clusterId=aCgemClusterCol->size();
1679 pt_recCluster->
setrecv(v_loc_gen);
1680 aCgemClusterCol->push_back(pt_recCluster);
1681 idxVClusters[iLayer][iSheet].push_back(clusterId);
1684 int pdg = (*iter_truth)->GetPDGCode();
1685 double px = (*iter_truth)->GetMomentumXOfPrePoint();
1686 double py = (*iter_truth)->GetMomentumYOfPrePoint();
1687 double pz = (*iter_truth)->GetMomentumZOfPrePoint();
1688 Hep3Vector truth_p(px/1000.,py/1000.,pz/1000.);
1690 HepPoint3D truth_position(x_pre/10.,y_pre/10.,z_pre/10.);
1691 if(myPrintFlag&&fabs(pdg)==13)
1693 int charge = -1*pdg/fabs(pdg);
1696 tmp_helix->
pivot(tmp_pivot);
1698 cout<<
"pdg="<<pdg<<setw(10)<<
" Helix of MC truth: "<<setw(10)<<tmp_helix->
dr()<<setw(10)<<tmp_helix->
phi0()<<setw(10)<<tmp_helix->
kappa()<<setw(10)<<tmp_helix->
dz()<<setw(10)<<tmp_helix->
tanl()<<endl;
1710 RecCgemClusterCol::iterator it_cluster0 = aCgemClusterCol->begin();
1711 RecCgemClusterCol::iterator it_cluster;
1712 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() start searching XV clusters: "<<endl;
1713 for(
int i=0; i<myNCgemLayers; i++)
1715 for(
int j=0; j<myNSheets[i]; j++)
1717 if(myPrintFlag) cout<<
"iLayer, iSheet = "<<i<<
", "<<j<<endl;
1719 for(
int iV=0; iV<idxVClusters[i][j].size(); iV++)
1721 if(myPrintFlag) cout<<
"iV: "<<iV;
1722 it_cluster = it_cluster0+idxVClusters[i][j][iV];
1724 double V_loc = (*it_cluster)->getrecv();
1726 for(
int iX=0; iX<idxXClusters[i][j].size(); iX++)
1728 if(myPrintFlag) cout<<
" iX: "<<iX<<endl;
1729 it_cluster = it_cluster0+idxXClusters[i][j][iX];
1730 double phi = (*it_cluster)->getrecphi();
1732 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() check phi, z, V = "<<phi<<
", "<<z<<
", "<<V_loc<<
", layer "<<i<<
", sheet "<<j<<endl;
1735 int clusterId=aCgemClusterCol->size();
1742 pt_recCluster->
setclusterflag(idxXClusters[i][j][iX], idxVClusters[i][j][iV]);
1744 pt_recCluster->
setrecv(V_loc);
1746 aCgemClusterCol->push_back(pt_recCluster);
1747 it_cluster0 = aCgemClusterCol->begin();
1748 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() finds a XV cluster"<<endl;
1756 if(myPrintFlag) cout<<
"nCgemCluster = "<<aCgemClusterCol->size()<<endl;
1758 if(myPrintFlag) checkRecCgemClusterCol();
1759 if(run<0) fillMCTruth();
1762 if(iCgemMcHit>100) iCgemMcHit=100;
1763 myNTupleHelper->
fillArray(
"phi_mc",
"nCgemMcHit",(
double*)phi_truth,iCgemMcHit);
1764 myNTupleHelper->
fillArray(
"z_mc",
"nCgemMcHit",(
double*)z_truth,iCgemMcHit);
1765 myNTupleHelper->
fillArray(
"z_mc_check",
"nCgemMcHit",(
double*)z_check,iCgemMcHit);
1766 myNTupleHelper->
fillArray(
"r_mc",
"nCgemMcHit",(
double*)r_truth,iCgemMcHit);
1767 myNTupleHelper->
fillArray(
"x_mc",
"nCgemMcHit",(
double*)x_truth,iCgemMcHit);
1768 myNTupleHelper->
fillArray(
"v_mc",
"nCgemMcHit",(
double*)v_truth,iCgemMcHit);
1769 myNTupleHelper->
fillArray(
"cth_mc",
"nCgemMcHit",(
double*)cosTh_truth,iCgemMcHit);
1770 myNTupleHelper->
fillArray(
"phi",
"nCgemMcHit",(
double*)phi_gen,iCgemMcHit);
1771 myNTupleHelper->
fillArray(
"z",
"nCgemMcHit",(
double*)z_gen,iCgemMcHit);
1772 myNTupleHelper->
fillArray(
"x",
"nCgemMcHit",(
double*)x_gen,iCgemMcHit);
1773 myNTupleHelper->
fillArray(
"v",
"nCgemMcHit",(
double*)v_gen,iCgemMcHit);
1774 myNTupleHelper->
write();
1784 return StatusCode::SUCCESS;
1787void CgemClusterCreate::fillMCTruth(
int run,
int evt)
1791 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
1794 std::cout <<
"Could not retrieve cgemMcHitCol" << std::endl;
1797 m_mc_nhit = cgemMcHitCol->size();
1799 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
1800 for(
int iHit=0; iter_truth!= cgemMcHitCol->end(); iter_truth++,iHit++)
1802 m_mc_trackID[iHit] = (*iter_truth)->GetTrackID();
1803 m_mc_layerID[iHit] = (*iter_truth)->GetLayerID();
1804 m_mc_pdg[iHit] = (*iter_truth)->GetPDGCode();
1805 m_mc_parentID[iHit] = (*iter_truth)->GetParentID();
1806 m_mc_E_deposit[iHit] = (*iter_truth)->GetTotalEnergyDeposit();
1807 m_mc_XYZ_pre_x[iHit] = (*iter_truth)->GetPositionXOfPrePoint();
1808 m_mc_XYZ_pre_y[iHit] = (*iter_truth)->GetPositionYOfPrePoint();
1809 m_mc_XYZ_pre_z[iHit] = (*iter_truth)->GetPositionZOfPrePoint();
1810 m_mc_XYZ_post_x[iHit] = (*iter_truth)->GetPositionXOfPostPoint();
1811 m_mc_XYZ_post_y[iHit] = (*iter_truth)->GetPositionYOfPostPoint();
1812 m_mc_XYZ_post_z[iHit] = (*iter_truth)->GetPositionZOfPostPoint();
1813 m_mc_P_pre_x[iHit] = (*iter_truth)->GetMomentumXOfPrePoint();
1814 m_mc_P_pre_y[iHit] = (*iter_truth)->GetMomentumYOfPrePoint();
1815 m_mc_P_pre_z[iHit] = (*iter_truth)->GetMomentumZOfPrePoint();
1816 m_mc_P_post_x[iHit] = (*iter_truth)->GetMomentumXOfPostPoint();
1817 m_mc_P_post_y[iHit] = (*iter_truth)->GetMomentumYOfPostPoint();
1818 m_mc_P_post_z[iHit] = (*iter_truth)->GetMomentumZOfPostPoint();
1825void CgemClusterCreate::fillRecData(
int run,
int evt)
1831 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
1832 if(!recCgemClusterCol)
1834 cout <<
"Could not retrieve RecCgemClusterCol" << endl;
1836 m_rec_ncluster = recCgemClusterCol->size();
1838 RecCgemClusterCol::iterator iter_cluster=recCgemClusterCol->begin();
1839 for(; iter_cluster!=recCgemClusterCol->end(); iter_cluster++)
1841 if(m_fillOption == -1){
1842 m_rec_clusterid[iCluster] = (*iter_cluster)->getclusterid();
1843 m_rec_layerid[iCluster] = (*iter_cluster)->getlayerid();
1844 m_rec_sheetid[iCluster] = (*iter_cluster)->getsheetid();
1845 m_rec_flag[iCluster] = (*iter_cluster)->getflag();
1846 m_rec_energydeposit[iCluster] = (*iter_cluster)->getenergydeposit();
1847 m_rec_recphi[iCluster] = (*iter_cluster)->getrecphi();
1848 m_rec_recv[iCluster] = (*iter_cluster)->getrecv();
1849 m_rec_recZ[iCluster] = (*iter_cluster)->getRecZ();
1850 m_rec_clusterflagb[iCluster] = (*iter_cluster)->getclusterflagb();
1851 m_rec_clusterflage[iCluster] = (*iter_cluster)->getclusterflage();
1853 }
else if(m_fillOption==(*iter_cluster)->getflag()){
1854 m_rec_clusterid[iCluster] = (*iter_cluster)->getclusterid();
1855 m_rec_layerid[iCluster] = (*iter_cluster)->getlayerid();
1856 m_rec_sheetid[iCluster] = (*iter_cluster)->getsheetid();
1857 m_rec_flag[iCluster] = (*iter_cluster)->getflag();
1858 m_rec_energydeposit[iCluster] = (*iter_cluster)->getenergydeposit();
1859 m_rec_recphi[iCluster] = (*iter_cluster)->getrecphi();
1860 m_rec_recv[iCluster] = (*iter_cluster)->getrecv();
1861 m_rec_recZ[iCluster] = (*iter_cluster)->getRecZ();
1862 m_rec_clusterflagb[iCluster] = (*iter_cluster)->getclusterflagb();
1863 m_rec_clusterflage[iCluster] = (*iter_cluster)->getclusterflage();
1866 if(iCluster>1000)
break;
1869 m_rec_ncluster = iCluster;
1874void CgemClusterCreate::hist_def(){
1876 NTuplePtr nt_rec(
ntupleSvc(),
"RecCgem/RecCluster");
1877 if( nt_rec ) m_rec_nt = nt_rec;
1879 m_rec_nt=
ntupleSvc()->book(
"RecCgem/RecCluster",CLID_ColumnWiseTuple,
"RecCluster");
1881 status = m_rec_nt->addItem(
"rec_run" ,m_rec_run);
1882 status = m_rec_nt->addItem(
"rec_evt" ,m_rec_evt);
1883 status = m_rec_nt->addItem(
"rec_ncluster" ,m_rec_ncluster,0,1000);
1884 status = m_rec_nt->addItem(
"rec_clusterid" ,m_rec_ncluster,m_rec_clusterid);
1885 status = m_rec_nt->addItem(
"rec_layerid" ,m_rec_ncluster,m_rec_layerid);
1886 status = m_rec_nt->addItem(
"rec_sheetid" ,m_rec_ncluster,m_rec_sheetid);
1887 status = m_rec_nt->addItem(
"rec_flag" ,m_rec_ncluster,m_rec_flag);
1888 status = m_rec_nt->addItem(
"rec_energydeposit" ,m_rec_ncluster,m_rec_energydeposit);
1889 status = m_rec_nt->addItem(
"rec_recphi" ,m_rec_ncluster,m_rec_recphi);
1890 status = m_rec_nt->addItem(
"rec_recv" ,m_rec_ncluster,m_rec_recv);
1891 status = m_rec_nt->addItem(
"rec_recZ" ,m_rec_ncluster,m_rec_recZ);
1892 status = m_rec_nt->addItem(
"rec_clusterflagb" ,m_rec_ncluster,m_rec_clusterflagb);
1893 status = m_rec_nt->addItem(
"rec_clusterflage" ,m_rec_ncluster,m_rec_clusterflage);
1897 NTuplePtr nt_mc(
ntupleSvc(),
"RecCgem/McHit");
1898 if( nt_mc ) m_mc_nt = nt_mc;
1900 m_mc_nt =
ntupleSvc()->book(
"RecCgem/McHit",CLID_ColumnWiseTuple,
"McHit");
1902 status = m_mc_nt->addItem(
"mc_run" ,m_mc_run);
1903 status = m_mc_nt->addItem(
"mc_evt" ,m_mc_evt);
1904 status = m_mc_nt->addItem(
"mc_nhit" ,m_mc_nhit,0,1000);
1905 status = m_mc_nt->addItem(
"mc_trackID" ,m_mc_nhit,m_mc_trackID);
1906 status = m_mc_nt->addItem(
"mc_layerID" ,m_mc_nhit,m_mc_layerID);
1907 status = m_mc_nt->addItem(
"mc_pdg" ,m_mc_nhit,m_mc_pdg);
1908 status = m_mc_nt->addItem(
"mc_parentID" ,m_mc_nhit,m_mc_parentID);
1909 status = m_mc_nt->addItem(
"mc_E_deposit" ,m_mc_nhit,m_mc_E_deposit);
1910 status = m_mc_nt->addItem(
"mc_XYZ_pre_x" ,m_mc_nhit,m_mc_XYZ_pre_x);
1911 status = m_mc_nt->addItem(
"mc_XYZ_pre_y" ,m_mc_nhit,m_mc_XYZ_pre_y);
1912 status = m_mc_nt->addItem(
"mc_XYZ_pre_z" ,m_mc_nhit,m_mc_XYZ_pre_z);
1913 status = m_mc_nt->addItem(
"mc_XYZ_post_x" ,m_mc_nhit,m_mc_XYZ_post_x);
1914 status = m_mc_nt->addItem(
"mc_XYZ_post_y" ,m_mc_nhit,m_mc_XYZ_post_y);
1915 status = m_mc_nt->addItem(
"mc_XYZ_post_z" ,m_mc_nhit,m_mc_XYZ_post_z);
1916 status = m_mc_nt->addItem(
"mc_P_pre_x" ,m_mc_nhit,m_mc_P_pre_x);
1917 status = m_mc_nt->addItem(
"mc_P_pre_y" ,m_mc_nhit,m_mc_P_pre_y);
1918 status = m_mc_nt->addItem(
"mc_P_pre_z" ,m_mc_nhit,m_mc_P_pre_z);
1919 status = m_mc_nt->addItem(
"mc_P_post_x" ,m_mc_nhit,m_mc_P_post_x);
1920 status = m_mc_nt->addItem(
"mc_P_post_y" ,m_mc_nhit,m_mc_P_post_y);
1921 status = m_mc_nt->addItem(
"mc_P_post_z" ,m_mc_nhit,m_mc_P_post_z);
1928 MsgStream log(
msgSvc(),name());
1929 log << MSG::INFO <<
"in finalize(): Number of events in CgemClusterCreate" << m_totEvt << endreq;
1932 return StatusCode::SUCCESS;
1935void CgemClusterCreate::reset() {
1936 for (
int i=0; i<3; i++)
1938 for (
int j=0; j<2; j++)
1940 for (
int k=0; k<2; k++)
1942 for (
int l=0; l<1500; l++)
1944 m_strip[i][j][k][l] = -1;
1945 m_edep[i][j][k][l] = 0;
1955 m_trans_map.clear();
1956 m_driftrec_map.clear();
1958 m_strip_map.clear();
1962void CgemClusterCreate::resetFiredStripMap()
1964 for (
int i=0; i<3; i++)
1966 for (
int j=0; j<2; j++)
1968 for (
int k=0; k<2; k++)
1970 myFiredStripMap[i][j][k].clear();
1985void CgemClusterCreate:: processstrips(
int k){
1987 for(
int i=0;i<3;i++){
1988 for(
int j=0;j<2;j++){
1993 static int N_cluster;
1995 for(
int l=1;l<1500;l++){
1997 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]>0){
2001 if(m_strip[i][j][k][l]<0&&m_strip[i][j][k][l-1]>0){
2003 N_cluster= N_cluster + 1;
2005 m_x_group.push_back(cluster);
2026 posxfind(reccluster);
2028 m_x_map[
key] = reccluster;
2032 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]<0){
2040 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]>0){
2046 if(m_strip[i][j][k][l]<0&&m_strip[i][j][k][l-1]>0){
2050 m_v_group.push_back(cluster);
2070 posvfind(reccluster);
2072 m_v_map[
key] = reccluster;
2076 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]<0){
2090void CgemClusterCreate:: transcluster(){
2092 for(
int i=0;i<3;i++){
2093 for(
int j=0;j<2;j++){
2094 for(
int l=0;l<1500;l++){
2096 keytype
key((10*i+j),l);
2097 m_v_map_it = m_v_map.find(
key);
2098 if(m_v_map_it != m_v_map.end()){
2118 transflag.first = vcluster;
2119 transflag.second = cluster;
2120 m_trans_map[
key]= transflag;
2128void CgemClusterCreate::mixcluster(){
2130 for(
int i=0;i<3;i++){
2131 for(
int j=0;j<2;j++){
2132 for(
int l=0;l<1500;l++){
2134 keytype
key((10*i+j),l);
2135 m_x_map_it = m_x_map.find(
key);
2136 if(m_x_map_it != m_x_map.end()){
2144 for(
int ll=0;ll<1500;ll++){
2145 keytype mkey((10*i+j),ll);
2146 m_trans_map_it = m_trans_map.find(mkey);
2147 if(m_trans_map_it == m_trans_map.end()){
continue;}
2150 flagxv transflag = (*m_trans_map_it).second;
2159 v.end = cluster.
end;
2163 m_xv_group.push_back(XV);
2164 m_mid_group.push_back(vcluster);
2170 posxvfind(reccluster);
2172 m_xv_map[
key] = reccluster;
2173 posindrift(reccluster);
2188 m_mid_group.clear();
2199 for(
int k=begin;k<=end;k++){
2200 phi = phi + m_edep[layerid][sheetid][0][k]*k*
W_pitch;
2211 for(
int k=begin;k<=end;k++){
2212 v =
v + m_edep[layerid][sheetid][1][k]*k*
W_pitch;
2229 double xenergy = 0.0;
2230 double venergy = 0.0;
2233 for(
int ii=
x.begin;ii<=
x.end;ii++){
2234 for(
int jj=
v.begin;jj<=
v.end;jj++){
2237 xenergy = xenergy + m_edep[layerid][sheetid][0][ii];
2238 phi = phi + m_edep[layerid][sheetid][0][ii]*ii*
W_pitch;
2240 m_sameID.push_back(ii);
2248 for(
int kk=mid.
begin;kk<=mid.
end;kk++){
2254 for(
int ll=0;ll<(int)m_sameID.size();ll++){
2255 if(pa<=m_sameID[ll]&&pb>=m_sameID[ll]){
2257 venergy = venergy + m_edep[layerid][sheetid][1][kk];
2258 recv = recv + m_edep[layerid][sheetid][1][kk]*kk*
W_pitch;
2270 int nxstrip = m_sameID.size();
2274 keytype
key((10*layerid+sheetid),clusterid);
2275 pphi = pphi/nxstrip;
2277 keytype strip(nxstrip,nvstrip);
2278 postype pos(pphi,pv);
2281 m_strip_map[
key]=strip;
2288 reccluster->
setrecv(recv/venergy);
2297 double posphi =
dr_layer[layerid]*dphi;
2298 for(
int vv =0;vv<
n_sheet[layerid];vv++){
2300 posphi = posphi-vv*
dw_sheet[layerid];
2308 postype positiond(posphi,posv);
2309 keytype
key((10*layerid+sheetid),clusterid);
2310 m_driftrec_map[
key] = positiond;
2313void CgemClusterCreate::fillMCTruth()
2315 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
2318 std::cout <<
"Could not retrieve McParticelCol" << std::endl;
2326 double Pmc[100],costhmc[100],phimc[100];
2327 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
2328 for (; iter_mc != mcParticleCol->end(); iter_mc++)
2330 int idx = (*iter_mc)->trackIndex();
2331 int pdgid = (*iter_mc)->particleProperty();
2332 int mother_pdg = ((*iter_mc)->mother()).particleProperty();
2333 int mother_idx = (*iter_mc)->mother().trackIndex();
2334 int primaryParticle = (*iter_mc)->primaryParticle();
2335 int fromGenerator = (*iter_mc)->decayFromGenerator();
2336 if(primaryParticle==1)
continue;
2337 if(fromGenerator==0)
continue;
2338 if(pdgid==myMotherParticleID) {
2342 if(foundMom==0)
continue;
2343 if(mother_pdg==myMotherParticleID) {
2347 if(pdgid!=myMotherParticleID&&foundMom>0&&startDecay==0)
2352 mother_idx=mother_idx-foundMom-itmp;
2354 if(myPrintFlag==1) {
2356 cout<<
"****** MC particles ****** "<<endl;
2357 cout <<setw(10)<<
"index"
2359 <<setw(16)<<
"primaryParticle"
2360 <<setw(15)<<
"fromGenerator"
2361 <<setw(15)<<
"from_trk"
2364 cout <<setw(10)<<i_mc
2366 <<setw(16)<<primaryParticle
2367 <<setw(15)<<fromGenerator
2368 <<setw(15)<<mother_idx
2374 HepLorentzVector p4_mc = (*iter_mc)->initialFourMomentum();
2375 Pmc[i_mc]=p4_mc.rho();
2376 costhmc[i_mc]=p4_mc.cosTheta();
2377 phimc[i_mc]=p4_mc.phi();
2381 if(i_mc>=100) i_mc=100;
2383 int nTruth[3]={0,0,0};
2384 int trkID_Layer1[100], trkID_Layer2[100], trkID_Layer3[100];
2385 int pdg_Layer1[100], pdg_Layer2[100], pdg_Layer3[100];
2386 double x_pre_Layer1[100], x_pre_Layer2[100], x_pre_Layer3[100];
2387 double y_pre_Layer1[100], y_pre_Layer2[100], y_pre_Layer3[100];
2388 double z_pre_Layer1[100], z_pre_Layer2[100], z_pre_Layer3[100];
2389 double x_post_Layer1[100], x_post_Layer2[100], x_post_Layer3[100];
2390 double y_post_Layer1[100], y_post_Layer2[100], y_post_Layer3[100];
2391 double z_post_Layer1[100], z_post_Layer2[100], z_post_Layer3[100];
2392 double phi_Layer1[100], phi_Layer2[100], phi_Layer3[100];
2393 double z_Layer1[100], z_Layer2[100], z_Layer3[100];
2394 double V_Layer1[100], V_Layer2[100], V_Layer3[100];
2395 double px_pre_Layer1[100], px_pre_Layer2[100], px_pre_Layer3[100];
2396 double py_pre_Layer1[100], py_pre_Layer2[100], py_pre_Layer3[100];
2397 double pz_pre_Layer1[100], pz_pre_Layer2[100], pz_pre_Layer3[100];
2398 double en_Layer1[100], en_Layer2[100], en_Layer3[100];
2399 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
2402 std::cout <<
"Could not retrieve cgemMcHitCol" << std::endl;
2405 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
2406 for (; iter_truth!= cgemMcHitCol->end(); iter_truth++)
2408 int iLayer = (*iter_truth)->GetLayerID();
2409 int trkID = (*iter_truth)->GetTrackID();
2410 int pdg = (*iter_truth)->GetPDGCode();
2411 double x_pre = (*iter_truth)->GetPositionXOfPrePoint();
2412 double y_pre = (*iter_truth)->GetPositionYOfPrePoint();
2413 double z_pre = (*iter_truth)->GetPositionZOfPrePoint();
2414 double x_post = (*iter_truth)->GetPositionXOfPostPoint();
2415 double y_post = (*iter_truth)->GetPositionYOfPostPoint();
2416 double z_post = (*iter_truth)->GetPositionZOfPostPoint();
2417 double x_middle = 0.5*(x_pre+x_post);
2418 double y_middle = 0.5*(y_pre+y_post);
2419 double z_middle = 0.5*(z_pre+z_post);
2420 double r_middle = sqrt(x_middle*x_middle+y_middle*y_middle);
2421 double phi_middle = atan2(y_middle, x_middle);
2422 double px_pre = (*iter_truth)->GetMomentumXOfPrePoint();
2423 double py_pre = (*iter_truth)->GetMomentumYOfPrePoint();
2424 double pz_pre = (*iter_truth)->GetMomentumZOfPrePoint();
2425 double en = (*iter_truth)->GetTotalEnergyDeposit();
2429 for(
int j=0; j<myNSheets[iLayer]; j++)
2434 if(readoutPlane->
OnThePlane(phi_middle,z_middle))
break;
2437 double V_mid = 9999;
2438 if(readoutPlane==NULL) {
2439 if(myPrintFlag) cout<<
"CgemClusterCreate::fillMCTruth() readoutPlane not found with phi_middle = "<<phi_middle<<
", layer = "<<iLayer<<endl;
2444 V_mid = readoutPlane->
getVFromPhiZ(phi_middle,z_middle);
2452 if(nTruth[0]>=100)
break;
2453 trkID_Layer1[nTruth[0]]=trkID;
2454 pdg_Layer1[nTruth[0]]=pdg;
2455 x_pre_Layer1[nTruth[0]]=x_pre;
2456 y_pre_Layer1[nTruth[0]]=y_pre;
2457 z_pre_Layer1[nTruth[0]]=z_pre;
2458 x_post_Layer1[nTruth[0]]=x_post;
2459 y_post_Layer1[nTruth[0]]=y_post;
2460 z_post_Layer1[nTruth[0]]=z_post;
2461 phi_Layer1[nTruth[0]]=atan2(y_post+y_pre,x_post+x_pre);
2462 z_Layer1[nTruth[0]]=z_middle;
2463 V_Layer1[nTruth[0]]=V_mid;
2464 px_pre_Layer1[nTruth[0]]=px_pre;
2465 py_pre_Layer1[nTruth[0]]=py_pre;
2466 pz_pre_Layer1[nTruth[0]]=pz_pre;
2467 en_Layer1[nTruth[0]]=en;
2470 if(nTruth[1]>=100)
break;
2471 trkID_Layer2[nTruth[1]]=trkID;
2472 pdg_Layer2[nTruth[1]]=pdg;
2473 x_pre_Layer2[nTruth[1]]=x_pre;
2474 y_pre_Layer2[nTruth[1]]=y_pre;
2475 z_pre_Layer2[nTruth[1]]=z_pre;
2476 x_post_Layer2[nTruth[1]]=x_post;
2477 y_post_Layer2[nTruth[1]]=y_post;
2478 z_post_Layer2[nTruth[1]]=z_post;
2479 phi_Layer2[nTruth[1]]=atan2(y_post+y_pre,x_post+x_pre);
2480 z_Layer2[nTruth[1]]=z_middle;
2481 V_Layer2[nTruth[1]]=V_mid;
2482 px_pre_Layer2[nTruth[1]]=px_pre;
2483 py_pre_Layer2[nTruth[1]]=py_pre;
2484 pz_pre_Layer2[nTruth[1]]=pz_pre;
2485 en_Layer2[nTruth[1]]=en;
2488 if(nTruth[2]>=100)
break;
2489 trkID_Layer3[nTruth[2]]=trkID;
2490 pdg_Layer3[nTruth[2]]=pdg;
2491 x_pre_Layer3[nTruth[2]]=x_pre;
2492 y_pre_Layer3[nTruth[2]]=y_pre;
2493 z_pre_Layer3[nTruth[2]]=z_pre;
2494 x_post_Layer3[nTruth[2]]=x_post;
2495 y_post_Layer3[nTruth[2]]=y_post;
2496 z_post_Layer3[nTruth[2]]=z_post;
2497 phi_Layer3[nTruth[2]]=atan2(y_post+y_pre,x_post+x_pre);
2498 z_Layer3[nTruth[2]]=z_middle;
2499 V_Layer3[nTruth[2]]=V_mid;
2500 px_pre_Layer3[nTruth[2]]=px_pre;
2501 py_pre_Layer3[nTruth[2]]=py_pre;
2502 pz_pre_Layer3[nTruth[2]]=pz_pre;
2503 en_Layer3[nTruth[2]]=en;
2506 cout<<
"wrong layer ID for CGEM: "<<iLayer<<endl;
2510 for(
int i=0; i<3; i++)
if(nTruth[i]>100) nTruth[i]=100;
2514 myNTupleHelper->
fillArrayInt(
"pdgmc",
"nmc",(
int*)mcPDG,i_mc);
2515 myNTupleHelper->
fillArray(
"pmc",
"nmc",(
double*)Pmc,i_mc);
2516 myNTupleHelper->
fillArray(
"costhmc",
"nmc",(
double*)costhmc,i_mc);
2517 myNTupleHelper->
fillArray(
"phimc",
"nmc",(
double*)phimc,i_mc);
2519 myNTupleHelper->
fillArrayInt(
"trkID_Layer1",
"nTruthLay1",(
int*) trkID_Layer1, nTruth[0]);
2520 myNTupleHelper->
fillArrayInt(
"pdg_Layer1",
"nTruthLay1",(
int*) pdg_Layer1, nTruth[0]);
2521 myNTupleHelper->
fillArray(
"x_pre_Layer1",
"nTruthLay1",(
double*) x_pre_Layer1, nTruth[0]);
2522 myNTupleHelper->
fillArray(
"y_pre_Layer1",
"nTruthLay1",(
double*) y_pre_Layer1, nTruth[0]);
2523 myNTupleHelper->
fillArray(
"z_pre_Layer1",
"nTruthLay1",(
double*) z_pre_Layer1, nTruth[0]);
2524 myNTupleHelper->
fillArray(
"x_post_Layer1",
"nTruthLay1",(
double*) x_post_Layer1, nTruth[0]);
2525 myNTupleHelper->
fillArray(
"y_post_Layer1",
"nTruthLay1",(
double*) y_post_Layer1, nTruth[0]);
2526 myNTupleHelper->
fillArray(
"z_post_Layer1",
"nTruthLay1",(
double*) z_post_Layer1, nTruth[0]);
2527 myNTupleHelper->
fillArray(
"px_pre_Layer1",
"nTruthLay1",(
double*) px_pre_Layer1, nTruth[0]);
2528 myNTupleHelper->
fillArray(
"py_pre_Layer1",
"nTruthLay1",(
double*) py_pre_Layer1, nTruth[0]);
2529 myNTupleHelper->
fillArray(
"pz_pre_Layer1",
"nTruthLay1",(
double*) pz_pre_Layer1, nTruth[0]);
2530 myNTupleHelper->
fillArray(
"en_Layer1",
"nTruthLay1",(
double*) en_Layer1, nTruth[0]);
2531 myNTupleHelper->
fillArray(
"phi_Layer1",
"nTruthLay1",(
double*) phi_Layer1, nTruth[0]);
2532 myNTupleHelper->
fillArray(
"V_Layer1",
"nTruthLay1",(
double*) V_Layer1, nTruth[0]);
2534 myNTupleHelper->
fillArrayInt(
"trkID_Layer2",
"nTruthLay2",(
int*) trkID_Layer2, nTruth[1]);
2535 myNTupleHelper->
fillArrayInt(
"pdg_Layer2",
"nTruthLay2",(
int*) pdg_Layer2, nTruth[1]);
2536 myNTupleHelper->
fillArray(
"x_pre_Layer2",
"nTruthLay2",(
double*) x_pre_Layer2, nTruth[1]);
2537 myNTupleHelper->
fillArray(
"y_pre_Layer2",
"nTruthLay2",(
double*) y_pre_Layer2, nTruth[1]);
2538 myNTupleHelper->
fillArray(
"z_pre_Layer2",
"nTruthLay2",(
double*) z_pre_Layer2, nTruth[1]);
2539 myNTupleHelper->
fillArray(
"x_post_Layer2",
"nTruthLay2",(
double*) x_post_Layer2, nTruth[1]);
2540 myNTupleHelper->
fillArray(
"y_post_Layer2",
"nTruthLay2",(
double*) y_post_Layer2, nTruth[1]);
2541 myNTupleHelper->
fillArray(
"z_post_Layer2",
"nTruthLay2",(
double*) z_post_Layer2, nTruth[1]);
2542 myNTupleHelper->
fillArray(
"px_pre_Layer2",
"nTruthLay2",(
double*) px_pre_Layer2, nTruth[1]);
2543 myNTupleHelper->
fillArray(
"py_pre_Layer2",
"nTruthLay2",(
double*) py_pre_Layer2, nTruth[1]);
2544 myNTupleHelper->
fillArray(
"pz_pre_Layer2",
"nTruthLay2",(
double*) pz_pre_Layer2, nTruth[1]);
2545 myNTupleHelper->
fillArray(
"en_Layer2",
"nTruthLay2",(
double*) en_Layer2, nTruth[1]);
2546 myNTupleHelper->
fillArray(
"phi_Layer2",
"nTruthLay2",(
double*) phi_Layer2, nTruth[1]);
2547 myNTupleHelper->
fillArray(
"V_Layer2",
"nTruthLay2",(
double*) V_Layer2, nTruth[1]);
2549 myNTupleHelper->
fillArrayInt(
"trkID_Layer3",
"nTruthLay3",(
int*) trkID_Layer3, nTruth[2]);
2550 myNTupleHelper->
fillArrayInt(
"pdg_Layer3",
"nTruthLay3",(
int*) pdg_Layer3, nTruth[2]);
2551 myNTupleHelper->
fillArray(
"x_pre_Layer3",
"nTruthLay3",(
double*) x_pre_Layer3, nTruth[2]);
2552 myNTupleHelper->
fillArray(
"y_pre_Layer3",
"nTruthLay3",(
double*) y_pre_Layer3, nTruth[2]);
2553 myNTupleHelper->
fillArray(
"z_pre_Layer3",
"nTruthLay3",(
double*) z_pre_Layer3, nTruth[2]);
2554 myNTupleHelper->
fillArray(
"x_post_Layer3",
"nTruthLay3",(
double*) x_post_Layer3, nTruth[2]);
2555 myNTupleHelper->
fillArray(
"y_post_Layer3",
"nTruthLay3",(
double*) y_post_Layer3, nTruth[2]);
2556 myNTupleHelper->
fillArray(
"z_post_Layer3",
"nTruthLay3",(
double*) z_post_Layer3, nTruth[2]);
2557 myNTupleHelper->
fillArray(
"px_pre_Layer3",
"nTruthLay3",(
double*) px_pre_Layer3, nTruth[2]);
2558 myNTupleHelper->
fillArray(
"py_pre_Layer3",
"nTruthLay3",(
double*) py_pre_Layer3, nTruth[2]);
2559 myNTupleHelper->
fillArray(
"pz_pre_Layer3",
"nTruthLay3",(
double*) pz_pre_Layer3, nTruth[2]);
2560 myNTupleHelper->
fillArray(
"en_Layer3",
"nTruthLay3",(
double*) en_Layer3, nTruth[2]);
2561 myNTupleHelper->
fillArray(
"phi_Layer3",
"nTruthLay3",(
double*) phi_Layer3, nTruth[2]);
2562 myNTupleHelper->
fillArray(
"V_Layer3",
"nTruthLay3",(
double*) V_Layer3, nTruth[2]);
2567void CgemClusterCreate::checkRecCgemClusterCol()
2569 SmartDataPtr<RecCgemClusterCol> aCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
2572 RecCgemClusterCol::iterator iter_cluster=aCgemClusterCol->begin();
2573 int nCluster = aCgemClusterCol->size();
2574 cout<<
"~~~~~~~~~~~~~~~~~~~~~~~~ check RecCgemClusterCol:"<<endl;
2575 cout <<setw(10)<<
"idx"
2578 <<setw(10)<<
"XVFlag"
2585 for(; iter_cluster!=aCgemClusterCol->end(); iter_cluster++)
2587 cout <<setw(10)<<(*iter_cluster)->getclusterid()
2588 <<setw(10)<<(*iter_cluster)->getlayerid()
2589 <<setw(10)<<(*iter_cluster)->getsheetid()
2590 <<setw(10)<<(*iter_cluster)->getflag()
2591 <<setw(10)<<(*iter_cluster)->getclusterflagb()
2592 <<setw(10)<<(*iter_cluster)->getclusterflage()
2593 <<setw(15)<<setprecision(10)<<(*iter_cluster)->getrecphi()
2594 <<setw(15)<<setprecision(10)<<(*iter_cluster)->getrecv()
2595 <<setw(15)<<setprecision(10)<<(*iter_cluster)->getRecZ()
2598 cout<<
"~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
2600 else cout<<
"CgemClusterCreate::checkRecCgemClusterCol(): RecCgemClusterCol not accessible!"<<endl;
2603bool CgemClusterCreate::isGoodDigi(CgemDigiCol::iterator
iter)
2605 double time = (*iter)->getTime_ns();
2607 if(time<-180.||time>100.)
return false;
2608 double Q = (*iter)->getCharge_fc();
2609 if(Q<0.)
return false;
2614bool CgemClusterCreate::selDigi(CgemDigiCol::iterator
iter,
int sel)
2616 if(sel==0)
return true;
2618 double time = (*iter)->getTime_ns();
2619 bool timeIsGood=
true;
2620 if(time<m_minDigiTime||time>m_maxDigiTime) timeIsGood=
false;
2622 double Q = (*iter)->getCharge_fc();
2623 bool chargeIsGood=
true;
2624 if(Q<myQMin) chargeIsGood=
false;
2626 if(sel==1)
return timeIsGood&&chargeIsGood;
2627 if(sel==-1)
return !timeIsGood&&chargeIsGood;
ObjectVector< RecCgemCluster > RecCgemClusterCol
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
************Class m_ypar INTEGER m_KeyWgt INTEGER m_nphot INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
**********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 PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
float elapsed(void) const
CgemClusterCreate(const std::string &name, ISvcLocator *pSvcLocator)
double getOuterROfAnodeCu1() const
double getInnerROfAnodeCu1() const
int getNumberOfSheet() const
bool getOrientation() const
double getOuterROfAnodeCu2() const
double getInnerROfAnodeCu2() const
int getVIDInNextSheetFromVID(int vID, double phimin_next) const
double getZFromPhiV(double phi, double V, int checkXRange=1) const
double getCentralVFromVID(int V_ID) const
double getPhiFromXID(int X_ID) const
bool OnThePlane(double phi, double z) const
double getVFromPhiZ(double phi, double z) const
double getVInNextSheetFromV(double v, double phiminNext) const
CgemGeoLayer * getCgemLayer(int i) const
double getNumberOfCgemLayer() const
CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const
static int strip(const Identifier &id)
static int sheet(const Identifier &id)
static int layer(const Identifier &id)
static bool is_xstrip(const Identifier &id)
virtual BesTimer * addItem(const std::string &name)=0
virtual double getSigma(int layer, int xvFlag, int readoutMode, double angle, double Q, double T) const =0
virtual double getTimeRising(int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const =0
virtual double getTimeFalling(int layer, int xvFlag, int sheet, int stripID, double Q=100., double z=0.) const =0
double dr(void) const
returns an element of parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
void fillLong(string name, long value)
void fillDouble(string name, double value)
void fillArrayInt(string name, string index_name, int *value, int size)
void fillArray(string name, string index_name, double *value, int size)
void setsheetid(int sheetid)
void setlayerid(int layerid)
void setRecZ_mTPC(double recZ)
void setSlope_mTPC(double s)
void setrecv_CC(double recv)
double getenergydeposit(void) const
void setrecphi_CC(double recphi)
void setclusterid(int clusterid)
void setenergydeposit(double energydeposit)
int getclusterid(void) const
void setrecv(double recv)
void setRecZ(double recZ)
int getlayerid(void) const
int getclusterflagb(void) const
void setrecphi_mTPC(double recphi)
void setRecZ_CC(double recZ)
double getrecphi(void) const
double getrecv(void) const
int getsheetid(void) const
void setclusterflag(int begin, int end)
void setrecv_mTPC(double recv)
void setrecphi(double recphi)
int getclusterflage(void) const