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"
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);
87 declareProperty(
"LUTfile", m_LUTfile =
"LUTfile.root");
88 declareProperty(
"clustering_gap", clustering_gap = 0);
89 declareProperty(
"dropHitRandomly", myDropHit = 0);
90 declareProperty(
"uTPC_correction", uTPC_correction =
true);
93 declareProperty(
"addRandomToyCluster", myRandomCluster=0);
94 declareProperty(
"NoiseRate_layer1", myNoiseRate[0]=0.0);
95 declareProperty(
"NoiseRate_layer2", myNoiseRate[1]=0.0);
96 declareProperty(
"NoiseRate_layer3", myNoiseRate[2]=0.0);
99 if(myMethod==0) reset();
100 else if(myMethod==1||myMethod==3) resetFiredStripMap();
114 MsgStream log(
msgSvc(), name());
115 log << MSG::INFO <<
"in initialize()" << endreq;
130 tsc = service(
"BesTimerSvc", m_timersvc);
131 if( tsc.isFailure() )
133 log << MSG::WARNING << name() <<
" Unable to locate BesTimerSvc" << endreq;
134 return StatusCode::FAILURE;
136 m_timer = m_timersvc->
addItem(
"Execution");
138 if(myNtuple) myNTupleHelper=
new NTupleHelper(
ntupleSvc()->book(
"RecCgem/CgemCluster",CLID_ColumnWiseTuple,
"CgemCluster"));
140 if(myMethod==0||myMethod==2) {
141 if(myNtuple) hist_def();
145 ISvcLocator* svcLocator = Gaudi::svcLocator();
147 StatusCode sc=svcLocator->service(
"CgemGeomSvc", ISvc);
150 if (!sc.isSuccess()) log<< MSG::INFO <<
"CgemClusterCreate::initialize(): Could not open CGEM geometry file" << endreq;
152 if(myPrintFlag) cout<<
"CgemClusterCreate::initialize() "<<myNCgemLayers<<
" Cgem layers"<<endl;
153 for(
int i=0; i<myNCgemLayers; i++)
164 if(myRandomCluster>0) {
166 cout<<
"going to add toy cluster as noise with noise rate "<<myNoiseRate[i]<<
" for CGEM layer "<<i<<endl;
168 if(myPrintFlag) cout<<
"layer "<<i<<
": "<<myNSheets[i]<<
" sheets"<<
", is reversed "<<IsReverse<<
", RX="<<myRXstrips[i]<<
", RY="<<myRVstrips[i]<<endl;
171 sc = service(
"CgemGeomSvc", m_SvcCgem);
172 if(sc != StatusCode::SUCCESS) {
173 log << MSG::ERROR <<
"can not use CgemGeomSvc" << endreq;
174 return StatusCode::FAILURE;
186 sc = service (
"CgemCalibFunSvc", myCgemCalibSvc);
187 if ( sc.isFailure() ){
188 cout<< name() <<
"Could not load MdcCalibFunSvc!" << endl;
198 return StatusCode::SUCCESS;
203 MsgStream log(
msgSvc(), name());
204 log << MSG::INFO <<
"in execute()" << endreq;
207 DataObject *aReconEvent;
208 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
209 if(aReconEvent==NULL) {
211 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon",aReconEvent);
212 if(sc!=StatusCode::SUCCESS) {
213 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
214 return( StatusCode::FAILURE);
219 if(myMethod==0) method0();
220 else if(myMethod==1) method1();
221 else if(myMethod==2) toyCluster();
222 else if(myMethod==3) method2();
225 return StatusCode::SUCCESS;
228StatusCode CgemClusterCreate::method0()
233 MsgStream log(
msgSvc(), name());
234 log << MSG::INFO <<
"in method0()" << endreq;
240 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
243 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
244 return StatusCode::FAILURE;
246 int run=evtHead->runNumber();
247 int evt=evtHead->eventNumber();
252 cout<<
"-----------------------------------------------"<<endl;
253 cout<<
"CgemClusterCreate::execute: run "<<run<<
", evt "<<evt<<endl;
257 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
260 log << MSG::WARNING <<
"Could not retrieve Cgem digi list" << endreq;
261 return StatusCode::FAILURE;
265 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
266 int layerid,sheetid,stripid,time_chnnel;
267 double energydeposit;
268 double nXStrips[3]={0,0,0};
269 double nVStrips[3]={0,0,0};
270 for( ; iter_digi != cgemDigiCol->end(); ++iter_digi)
275 energydeposit = (*iter_digi)->getChargeChannel();
276 time_chnnel = (*iter_digi)->getTimeChannel();
279 if(striptype ==
true)
282 nXStrips[layerid]+=1;
286 nVStrips[layerid]+=1;
290 if(iter_digi==cgemDigiCol->begin())
292 cout<<
"cgemDigiCol:"<<endl;
296 <<setw(10)<<
"XV(0/1)"
297 <<setw(10)<<
"strip_ID"
307 <<setw(15)<<setprecision(10)<<energydeposit
308 <<setw(15)<<setprecision(10)<<time_chnnel
311 m_strip[layerid][sheetid][flagxv][stripid] = 1;
312 m_edep[layerid][sheetid][flagxv][stripid] = energydeposit;
324 IDataProviderSvc* evtSvc = NULL;
325 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
327 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
329 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
330 return StatusCode::SUCCESS;
333 StatusCode clustersc;
334 IDataManagerSvc *dataManSvc;
335 dataManSvc=
dynamic_cast<IDataManagerSvc*
>(evtSvc);
336 DataObject *aClusterCol;
337 evtSvc->findObject(
"/Event/Recon/RecCgemClusterCol",aClusterCol);
338 if(aClusterCol != NULL) {
339 dataManSvc->clearSubTree(
"/Event/Recon/RecCgemClusterCol");
340 evtSvc->unregisterObject(
"/Event/Recon/RecCgemClusterCol");
343 clustersc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", clustercol);
344 if( clustersc.isFailure() ) {
345 log << MSG::FATAL <<
"Could not register RecCgemCluster" << endreq;
346 return StatusCode::SUCCESS;
348 log << MSG::INFO <<
"RecCgemClusterCol registered successfully!" <<endreq;
351 for(m_x_map_it = m_x_map.begin();m_x_map_it!=m_x_map.end();++m_x_map_it){
353 clustercol->push_back(reccluster);
355 for(m_v_map_it = m_v_map.begin();m_v_map_it!=m_v_map.end();++m_v_map_it){
357 clustercol->push_back(reccluster);
359 for(m_xv_map_it = m_xv_map.begin();m_xv_map_it!=m_xv_map.end();++m_xv_map_it){
361 clustercol->push_back(reccluster);
365 SmartDataPtr<RecCgemClusterCol> cgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
366 if (!cgemClusterCol){
367 log << MSG::WARNING <<
"Could not retrieve Cgem cluster list" << endreq;
368 return StatusCode::FAILURE;
371 m_evt = evtHead->eventNumber();
372 m_evt1 = evtHead->eventNumber();
375 RecCgemClusterCol::iterator iter_cluster = cgemClusterCol->begin();
377 for( ; iter_cluster != cgemClusterCol->end(); ++iter_cluster){
378 if((*iter_cluster)->getflag()==2){
380 m_layerid[ii] = (*iter_cluster)->getlayerid();
381 m_sheetid[ii] = (*iter_cluster)->getsheetid();
382 m_clusterid[ii]= (*iter_cluster)->getclusterid();
383 m_flag[ii] = (*iter_cluster)->getflag();
384 m_energy[ii] = (*iter_cluster)->getenergydeposit();
385 m_recphi[ii] = (*iter_cluster)->getrecphi();
386 m_recv[ii] = (*iter_cluster)->getrecv();
400 return StatusCode::SUCCESS;
403StatusCode CgemClusterCreate::method1()
408 MsgStream log(
msgSvc(), name());
409 log << MSG::INFO <<
"in method1()" << endreq;
412 resetFiredStripMap();
415 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
418 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
419 return StatusCode::FAILURE;
421 int run=evtHead->runNumber();
422 int evt=evtHead->eventNumber();
427 cout<<
"-----------------------------------------------"<<endl;
428 cout<<
"CgemClusterCreate::execute: run "<<run<<
", evt "<<evt<<endl;
431 if(run<0) fillMCTruth();
433 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
436 log << MSG::WARNING <<
"Could not retrieve Cgem digi list" << endreq;
437 return StatusCode::FAILURE;
441 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
442 int layerid,sheetid,stripid,time_chnnel;
443 double energydeposit;
445 double nXStrips[3]={0,0,0};
446 double nVStrips[3]={0,0,0};
447 bool printed =
false;
448 for( ; iter_digi != cgemDigiCol->end(); ++iter_digi)
452 if(!selDigi(iter_digi,m_selGoodDigi))
continue;
456 energydeposit = (*iter_digi)->getChargeChannel();
457 time_chnnel = (*iter_digi)->getTimeChannel();
458 Q_fC = (*iter_digi)->getCharge_fc();
459 T_ns = (*iter_digi)->getTime_ns();
462 if(striptype ==
true)
465 nXStrips[layerid]+=1;
469 nVStrips[layerid]+=1;
476 cout<<
"cgemDigiCol:"<<endl;
480 <<setw(10)<<
"XV(0/1)"
481 <<setw(10)<<
"strip_ID"
494 <<setw(15)<<setprecision(10)<<Q_fC
495 <<setw(15)<<setprecision(10)<<T_ns
498 myFiredStripMap[layerid][sheetid][flagxv][stripid]=iter_digi;
502 SmartDataPtr<RecCgemClusterCol> lastCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
503 IDataProviderSvc* evtSvc = NULL;
504 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
506 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
508 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
509 return StatusCode::SUCCESS;
511 if(lastCgemClusterCol) {
512 evtSvc->unregisterObject(
"/Event/Recon/RecCgemClusterCol");
517 sc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", aCgemClusterCol);
520 log << MSG::FATAL <<
"Could not register RecCgemClusterCol" << endreq;
521 return StatusCode::SUCCESS;
525 if(myPrintFlag) cout<<
"--------------------------------------------"<<endl;
527 double sumQ(0.0),sumQX(0.0);
529 int nCluster[3][3]={{0,0,0},{0,0,0},{0,0,0}};
530 double posX[3][100],posZ[3][100],posV[3][100],phi_XV[3][100];
531 double QX[3][100],QV[3][100],QX_XV[3][100],QV_XV[3][100];
532 int nStripsX[3][100],nStripsV[3][100];
534 vector<int> iStart_cluster[3][2][2];
535 vector<int> iEnd_cluster[3][2][2];
536 vector<double> E_cluster[3][2][2];
537 vector<int> id_cluster[3][2][3];
538 vector<double> vecPos_cluster[3][2][3];
539 vector<int> idxCluster[3][2][2];
540 vector<int> idxBoundaryXVcluster[3][2][2];
543 for(
int i=0; i<3; i++)
545 if(myPrintFlag) cout<<
"---- layer "<<i<<
" ----"<<endl;
546 for(
int j=0; j<myNSheets[i]; j++)
548 if(myPrintFlag) cout<<
"---- sheet "<<j<<
":: "<<endl;
550 for(
int k=0; k<2; k++)
552 if(myPrintFlag) cout<<
"---- XV "<<k<<
": "<<endl;
554 map<int,CgemDigiCol::iterator>::iterator
iter=myFiredStripMap[i][j][k].begin();
555 map<int,CgemDigiCol::iterator>::iterator iter_end=myFiredStripMap[i][j][k].end();
556 int i1(-1),i2(-1),idLast(-2);
559 if((
iter->first-idLast)>1)
563 double posCluster(9999.);
565 posCluster = sumQX/sumQ;
567 if(k==0) cout<<
"find X cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" rad"<<endl;
568 if(k==1) cout<<
"find V cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" mm"<<endl;
570 int clusterId=aCgemClusterCol->size();
571 iStart_cluster[i][j][k].push_back(i1);
572 iEnd_cluster[i][j][k].push_back(i2);
573 vecPos_cluster[i][j][k].push_back(posCluster);
574 E_cluster[i][j][k].push_back(sumQ);
575 id_cluster[i][j][k].push_back(clusterId);
584 if(k==0) pt_recCluster->
setrecphi(posCluster);
585 if(k==1) pt_recCluster->
setrecv(posCluster);
586 aCgemClusterCol->push_back(pt_recCluster);
588 if(k==0&&nCluster[i][k]<100)
590 posX[i][nCluster[i][k]]=posCluster;
591 QX[i][nCluster[i][k]]=sumQ;
592 nStripsX[i][nCluster[i][k]]=i2-i1+1;
597 if(nCluster[i][k]<100) {
598 nStripsV[i][nCluster[i][k]]=i2-i1+1;
599 posV[i][nCluster[i][k]]=posCluster;
600 QV[i][nCluster[i][k]]=sumQ;
602 int nXCluster=iStart_cluster[i][j][0].size();
603 for(
int iX=0; iX<nXCluster; iX++)
605 double Z_pos = readoutPlane->
getZFromPhiV(vecPos_cluster[i][j][0][iX],posCluster);
607 if(readoutPlane->
OnThePlane(vecPos_cluster[i][j][0][iX],Z_pos))
609 if(myPrintFlag) cout<<
"find a XV cluster, Z="<<Z_pos<<endl;
610 int iV=iStart_cluster[i][j][1].size()-1;
611 clusterId=aCgemClusterCol->size();
612 vecPos_cluster[i][j][2].push_back(Z_pos);
613 id_cluster[i][j][2].push_back(clusterId);
614 idxCluster[i][j][0].push_back(iX);
615 idxCluster[i][j][1].push_back(iV);
622 pt2_recCluster->
setclusterflag(id_cluster[i][j][0][iX],id_cluster[i][j][1][iV]);
623 pt2_recCluster->
setrecphi(vecPos_cluster[i][j][0][iX]);
624 pt2_recCluster->
setrecv(vecPos_cluster[i][j][1][iV]);
625 pt2_recCluster->
setRecZ(Z_pos);
627 aCgemClusterCol->push_back(pt2_recCluster);
629 if(nCluster[i][2]<100) {
630 posZ[i][nCluster[i][2]]=Z_pos;
631 phi_XV[i][nCluster[i][2]]=vecPos_cluster[i][j][0][iX];
633 if( (iEnd_cluster[i][j][0][iX]+1)==readoutPlane->
getNXstrips() )
634 idxBoundaryXVcluster[i][j][0].push_back(idxCluster[i][j][1].size()-1);
635 if(iStart_cluster[i][j][0][iX]==0)
636 idxBoundaryXVcluster[i][j][1].push_back(idxCluster[i][j][1].size()-1);
644 cout<<
"sumQ<=0!: sumQX,sumQ="<<sumQX<<
","<<sumQ<<endl;
656 if(myPrintFlag) cout<<
"fired strip "<<idLast<<endl;
658 double energy=(*(
iter->second))->getCharge_fc();
668 double posCluster(9999.);
670 posCluster = sumQX/sumQ;
672 if(k==0) cout<<
"find X cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" rad"<<endl;
673 if(k==1) cout<<
"find V cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" mm"<<endl;
675 int clusterId=aCgemClusterCol->size();
676 iStart_cluster[i][j][k].push_back(i1);
677 iEnd_cluster[i][j][k].push_back(i2);
678 vecPos_cluster[i][j][k].push_back(posCluster);
679 E_cluster[i][j][k].push_back(sumQ);
680 id_cluster[i][j][k].push_back(clusterId);
689 if(k==0) pt_recCluster->
setrecphi(posCluster);
690 if(k==1) pt_recCluster->
setrecv(posCluster);
691 aCgemClusterCol->push_back(pt_recCluster);
693 if(k==0&&nCluster[i][k]<100) {
694 posX[i][nCluster[i][k]]=posCluster;
695 QX[i][nCluster[i][k]]=sumQ;
696 nStripsX[i][nCluster[i][k]]=i2-i1+1;
701 if(nCluster[i][k]<100) {
702 nStripsV[i][nCluster[i][k]]=i2-i1+1;
703 posV[i][nCluster[i][k]]=posCluster;
704 QV[i][nCluster[i][k]]=sumQ;
706 int nXCluster=iStart_cluster[i][j][0].size();
707 for(
int iX=0; iX<nXCluster; iX++)
709 double Z_pos = readoutPlane->
getZFromPhiV(vecPos_cluster[i][j][0][iX],posCluster);
711 if(readoutPlane->
OnThePlane(vecPos_cluster[i][j][0][iX],Z_pos))
713 if(myPrintFlag) cout<<
"find a XV cluster, Z="<<Z_pos<<endl;
714 clusterId=aCgemClusterCol->size();
715 vecPos_cluster[i][j][2].push_back(Z_pos);
716 id_cluster[i][j][2].push_back(clusterId);
717 int iV=iStart_cluster[i][j][1].size()-1;
724 pt2_recCluster->
setclusterflag(id_cluster[i][j][0][iX],id_cluster[i][j][1][iV]);
725 pt2_recCluster->
setrecphi(vecPos_cluster[i][j][0][iX]);
726 pt2_recCluster->
setrecv(vecPos_cluster[i][j][1][iV]);
727 pt2_recCluster->
setRecZ(Z_pos);
729 aCgemClusterCol->push_back(pt2_recCluster);
731 if(nCluster[i][2]<100) {
732 posZ[i][nCluster[i][2]]=Z_pos;
733 phi_XV[i][nCluster[i][2]]=vecPos_cluster[i][j][0][iX];
735 idxCluster[i][j][0].push_back(iX);
736 idxCluster[i][j][1].push_back(iEnd_cluster[i][j][1].size()-1);
737 if( (iEnd_cluster[i][j][0][iX]+1)==readoutPlane->
getNXstrips() )
738 idxBoundaryXVcluster[i][j][0].push_back(idxCluster[i][j][1].size()-1);
739 if(iStart_cluster[i][j][0][iX]==0)
740 idxBoundaryXVcluster[i][j][1].push_back(idxCluster[i][j][1].size()-1);
747 else cout<<
"sumQ<=0!: sumQX,sumQ="<<sumQX<<
","<<sumQ<<endl;
754 if(nCluster[i][0]>100) nCluster[i][0]=100;
755 if(nCluster[i][1]>100) nCluster[i][1]=100;
756 if(nCluster[i][2]>100) nCluster[i][2]=100;
759 for(
int j=0; j<myNSheets[i]; j++)
763 if(j_next==myNSheets[i]) j_next=0;
767 double xmin_next = nextReadoutPlane->
getXmin();
769 int nXV_atXEnd=idxBoundaryXVcluster[i][j][0].size();
770 int nXV_atXStart=idxBoundaryXVcluster[i][j_next][1].size();
771 if(nXV_atXEnd==0||nXV_atXStart==0)
continue;
772 for(
int iXV_atXEnd=0; iXV_atXEnd<nXV_atXEnd; iXV_atXEnd++)
774 int iXVCluster = idxBoundaryXVcluster[i][j][0][iXV_atXEnd];
775 int iXCluster = idxCluster[i][j][0][iXVCluster];
776 int iVCluster = idxCluster[i][j][1][iXVCluster];
777 int VID1=iStart_cluster[i][j][1][iVCluster];
778 int VID2=iEnd_cluster[i][j][1][iVCluster];
781 for(
int iXV_atXStart=0; iXV_atXStart<nXV_atXStart; iXV_atXStart++)
783 int iXVCluster_next = idxBoundaryXVcluster[i][j_next][1][iXV_atXStart];
784 int iXCluster_next = idxCluster[i][j_next][0][iXVCluster_next];
785 int iVCluster_next = idxCluster[i][j_next][1][iXVCluster_next];
786 int VID1_next=iStart_cluster[i][j_next][1][iVCluster_next];
787 int VID2_next=iEnd_cluster[i][j_next][1][iVCluster_next];
788 if( !( (VID1_next-VID2_extend)>1 || (VID1_extend-VID2_next)>1 ) )
790 int XID1=iStart_cluster[i][j][0][iXCluster];
791 int XID2=iEnd_cluster[i][j][0][iXCluster];
792 int XID1_next=iStart_cluster[i][j_next][0][iXCluster_next];
793 int XID2_next=iEnd_cluster[i][j_next][0][iXCluster_next];
794 int clusterId=aCgemClusterCol->size();
801 int id1=id_cluster[i][j][2][iXVCluster];
802 int id2=id_cluster[i][j_next][2][iXVCluster_next];
805 double phi1=vecPos_cluster[i][j][0][iXCluster];
806 double phi2=vecPos_cluster[i][j_next][0][iXCluster_next];
812 double E1=E_cluster[i][j][0][iXCluster];
813 double E2=E_cluster[i][j_next][0][iXCluster_next];
814 double phiAverage=(E1*
phi1+E2*
phi2)/(E1+E2);
817 double v1=vecPos_cluster[i][j][1][iVCluster];
819 double v2=vecPos_cluster[i][j_next][1][iVCluster_next];
820 E1=E_cluster[i][j][1][iVCluster];
821 E2=E_cluster[i][j_next][1][iVCluster_next];
822 double V_average_next=(E1*v1+E2*v2)/(E1+E2);
823 pt_recCluster->
setrecv(V_average_next);
825 double z_average = nextReadoutPlane->
getZFromPhiV(phiAverage,V_average_next,0);
826 pt_recCluster->
setRecZ(z_average);
828 aCgemClusterCol->push_back(pt_recCluster);
831 cout<<
"one combinational cluster found: "<<endl;
832 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;
833 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;
834 cout<<
" averagePhi:"<<phiAverage<<
", v_average:"<<V_average_next<<
", z_average:"<<z_average<<endl;
846 double evttime=m_timer->
elapsed();
849 if(myPrintFlag) checkRecCgemClusterCol();
853 myNTupleHelper->
fillLong(
"run",(
long)run);
854 myNTupleHelper->
fillLong(
"evt",(
long)evt);
856 myNTupleHelper->
fillArray(
"nXstrips",
"nLayer",(
double*) nXStrips,3);
857 myNTupleHelper->
fillArray(
"nVstrips",
"nLayer",(
double*) nVStrips,3);
859 myNTupleHelper->
fillArray(
"phiClusterLay1",
"nXClusterLay1",(
double*) posX[0],nCluster[0][0]);
860 myNTupleHelper->
fillArrayInt(
"nXStripsLay1",
"nXClusterLay1",(
int*) nStripsX[0],nCluster[0][0]);
861 myNTupleHelper->
fillArray(
"QXLay1",
"nXClusterLay1",(
double*) QX[0],nCluster[0][0]);
863 myNTupleHelper->
fillArray(
"VClusterLay1",
"nVClusterLay1",(
double*) posV[0],nCluster[0][1]);
864 myNTupleHelper->
fillArrayInt(
"nVStripsLay1",
"nVClusterLay1",(
int*) nStripsV[0],nCluster[0][1]);
865 myNTupleHelper->
fillArray(
"QVLay1",
"nVClusterLay1",(
double*) QV[0],nCluster[0][1]);
867 myNTupleHelper->
fillArray(
"zClusterLay1",
"nXVClusterLay1",(
double*) posZ[0],nCluster[0][2]);
868 myNTupleHelper->
fillArray(
"phiXVClusterLay1",
"nXVClusterLay1",(
double*) phi_XV[0],nCluster[0][2]);
870 myNTupleHelper->
fillArray(
"phiClusterLay2",
"nXClusterLay2",(
double*) posX[1],nCluster[1][0]);
871 myNTupleHelper->
fillArrayInt(
"nXStripsLay2",
"nXClusterLay2",(
int*) nStripsX[1],nCluster[1][0]);
872 myNTupleHelper->
fillArray(
"QXLay2",
"nXClusterLay2",(
double*) QX[1],nCluster[1][0]);
874 myNTupleHelper->
fillArray(
"VClusterLay2",
"nVClusterLay2",(
double*) posV[1],nCluster[1][1]);
875 myNTupleHelper->
fillArrayInt(
"nVStripsLay2",
"nVClusterLay2",(
int*) nStripsV[1],nCluster[1][1]);
876 myNTupleHelper->
fillArray(
"QVLay2",
"nVClusterLay2",(
double*) QV[1],nCluster[1][1]);
878 myNTupleHelper->
fillArray(
"zClusterLay2",
"nXVClusterLay2",(
double*) posZ[1],nCluster[1][2]);
879 myNTupleHelper->
fillArray(
"phiXVClusterLay2",
"nXVClusterLay2",(
double*) phi_XV[1],nCluster[1][2]);
881 myNTupleHelper->
fillArray(
"phiClusterLay3",
"nXClusterLay3",(
double*) posX[2],nCluster[2][0]);
882 myNTupleHelper->
fillArrayInt(
"nXStripsLay3",
"nXClusterLay3",(
int*) nStripsX[2],nCluster[2][0]);
883 myNTupleHelper->
fillArray(
"QXLay3",
"nXClusterLay3",(
double*) QX[2],nCluster[2][0]);
885 myNTupleHelper->
fillArray(
"VClusterLay3",
"nVClusterLay3",(
double*) posV[2],nCluster[2][1]);
886 myNTupleHelper->
fillArrayInt(
"nVStripsLay3",
"nVClusterLay3",(
int*) nStripsV[2],nCluster[2][1]);
887 myNTupleHelper->
fillArray(
"QVLay3",
"nVClusterLay3",(
double*) QV[2],nCluster[2][1]);
889 myNTupleHelper->
fillArray(
"zClusterLay3",
"nXVClusterLay3",(
double*) posZ[2],nCluster[2][2]);
890 myNTupleHelper->
fillArray(
"phiXVClusterLay3",
"nXVClusterLay3",(
double*) phi_XV[2],nCluster[2][2]);
892 myNTupleHelper->
fillDouble(
"evtTime",evttime);
894 myNTupleHelper->
write();
896 if(myPrintFlag) cout<<
"End of CgemClusterCreate::method1()"<<endl;
898 return StatusCode::SUCCESS;
901StatusCode CgemClusterCreate::method2()
906 MsgStream log(
msgSvc(), name());
907 log << MSG::INFO <<
"in method1()" << endreq;
910 resetFiredStripMap();
914 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
917 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
918 return StatusCode::FAILURE;
920 int run=evtHead->runNumber();
921 int evt=evtHead->eventNumber();
927 cout<<
"-----------------------------------------------"<<endl;
928 cout<<
"CgemClusterCreate::execute: run "<<run<<
", evt "<<evt<<endl;
931 if(run<0) fillMCTruth();
933 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
936 log << MSG::WARNING <<
"Could not retrieve Cgem digi list" << endreq;
937 return StatusCode::FAILURE;
941 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
942 int layerid,sheetid,stripid,time_chnnel;
943 double energydeposit;
945 double nXStrips[3]={0,0,0};
946 double nVStrips[3]={0,0,0};
947 bool printed =
false;
948 for( ; iter_digi != cgemDigiCol->end(); ++iter_digi)
950 if(run<0&&myDropHit==1) {
951 if(m_nStripRead==0) {
952 Rndm::Numbers flat(randSvc(), Rndm::Flat(0,64));
953 m_iStripToDrop=int(flat());
959 int iStrip = m_nStripRead++;
960 if(m_nStripRead==64) {
965 if(iStrip==m_iStripToDrop) {
974 if(!selDigi(iter_digi,m_selGoodDigi))
continue;
978 energydeposit = (*iter_digi)->getChargeChannel();
979 time_chnnel = (*iter_digi)->getTimeChannel();
980 Q_fC = (*iter_digi)->getCharge_fc();
981 T_ns = (*iter_digi)->getTime_ns();
984 if(striptype ==
true)
987 nXStrips[layerid]+=1;
991 nVStrips[layerid]+=1;
998 cout<<
"cgemDigiCol:"<<endl;
1002 <<setw(10)<<
"XV(0/1)"
1003 <<setw(10)<<
"strip_ID"
1016 <<setw(15)<<setprecision(10)<<Q_fC
1017 <<setw(15)<<setprecision(10)<<T_ns
1020 myFiredStripMap[layerid][sheetid][flagxv][stripid]=iter_digi;
1025 SmartDataPtr<RecCgemClusterCol> lastCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
1026 IDataProviderSvc* evtSvc = NULL;
1027 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
1029 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
1031 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
1032 return StatusCode::SUCCESS;
1034 if(lastCgemClusterCol) {
1035 evtSvc->unregisterObject(
"/Event/Recon/RecCgemClusterCol");
1040 sc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", aCgemClusterCol);
1043 log << MSG::FATAL <<
"Could not register RecCgemClusterCol" << endreq;
1044 return StatusCode::SUCCESS;
1048 if(myPrintFlag) cout<<
"--------------------------------------------"<<endl;
1051 double sumQ(0.0),sumQX(0.0);
1054 vector<double> pos_strips;
1055 vector<double> drift_strips;
1056 vector<double> q_strips;
1057 vector<int> id_strips;
1058 double tposX[3][100],tposZ[3][100],tposV[3][100];
1059 vector<double> vecTPos_cluster[3][2][3];
1063 double pos_tpc(9999.0), a_tpc(0.0), b_tpc(0.0);
1064 double sum_x_tpc(0.), sum_y_tpc(0.), sum_xx_tpc(0.), sum_yy_tpc(0.), sum_xy_tpc(0.);
1066 double a_tpc_cluster_X[3][100];
1067 double b_tpc_cluster_X[3][100];
1068 double pos_tpc_cluster_X[3][100];
1069 double a_tpc_cluster_V[3][100];
1070 double b_tpc_cluster_V[3][100];
1071 double pos_tpc_cluster_V[3][100];
1074 int nCluster[3][3]={{0,0,0},{0,0,0},{0,0,0}};
1075 double posX[3][100],posZ[3][100],posV[3][100],phi_XV[3][100];
1076 double QX[3][100],QV[3][100],QX_XV[3][100],QV_XV[3][100];
1077 int nStripsX[3][100],nStripsV[3][100];
1078 vector<int> iStart_cluster[3][2][2];
1079 vector<int> iEnd_cluster[3][2][2];
1080 vector<double> E_cluster[3][2][2];
1081 vector<int> id_cluster[3][2][3];
1082 vector<double> vecPos_cluster[3][2][3];
1083 vector<int> idxCluster[3][2][2];
1084 vector<int> idxBoundaryXVcluster[3][2][2];
1087 for(
int i=0; i<3; i++)
1089 if(myPrintFlag) cout<<
"---- layer "<<i<<
" ----"<<endl;
1090 for(
int j=0; j<myNSheets[i]; j++)
1092 if(myPrintFlag) cout<<
"---- sheet "<<j<<
":: "<<endl;
1094 for(
int k=0; k<2; k++)
1096 if(myPrintFlag) cout<<
"---- XV "<<k<<
": "<<endl;
1098 map<int,CgemDigiCol::iterator>::iterator
iter=myFiredStripMap[i][j][k].begin();
1099 map<int,CgemDigiCol::iterator>::iterator iter_end=myFiredStripMap[i][j][k].end();
1100 map<int,CgemDigiCol::iterator>::iterator iter_next=
iter;
1101 int i1(-1),i2(-1),idLast(-2);
1102 bool clusterFound=
true;
1105 if(myPrintFlag) cout<<
"fired strip "<<
iter->first<<endl;
1108 double energy=(*(
iter->second))->getCharge_fc();
1110 double time=(*(
iter->second))->getTime_ns();
1120 pos_strips.push_back(pos);
1124 double time_gap = time_falling-time_rising;
1125 double drift_velocity =
drift_gap/time_gap;
1127 double time_ns=get_Time(
iter->second);
1128 if(myPrintFlag) cout<<
"T_r, T_f = "<<time_rising<<
", "<<time_falling<<
", time_ns="<<
time<<endl;
1129 drift_strips.push_back(time_ns*drift_velocity);
1130 q_strips.push_back(
energy);
1131 id_strips.push_back(
iter->first);
1135 double drift = time_ns*drift_velocity;
1138 sum_xx_tpc+=pos*pos;
1139 sum_yy_tpc+=drift*drift;
1140 sum_xy_tpc+=pos*drift;
1151 int strip_gap_deadstrip = clustering_gap+1;
1152 if(iter_next==iter_end||(iter_next->first-
iter->first)>strip_gap_deadstrip)
1155 double posCluster_CC(9999.);
1157 cout<<
"sumQ<=0!: sumQX,sumQ="<<sumQX<<
","<<sumQ<<endl;
1160 posCluster_CC = sumQX/sumQ;
1164 double slope2(-9999);
1165 double inter2(-9999);
1167 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);
1168 b_tpc = (n_tpc*sum_xy_tpc-sum_x_tpc*sum_y_tpc)/(n_tpc*sum_xx_tpc-sum_x_tpc*sum_x_tpc);
1169 if(
abs(b_tpc) > 1e-10) {
1180 double tposCluster(9999.);
1181 double slope(-9999);
1182 double inter(-9999);
1183 int n_Strips=pos_strips.size();
1186 double *
x =
new double[n_Strips];
1187 double *tx =
new double[n_Strips];
1188 double *ex =
new double[n_Strips];
1189 double *etx =
new double[n_Strips];
1190 int *stripID =
new int[n_Strips];
1192 double x_max = -999;
1194 for(
int ix=0; ix<n_Strips; ix++)
1196 x[ix] = pos_strips[ix];
1197 tx[ix] = drift_strips[ix];
1200 ex[ix]=sqrt(pow((
W_pitch/anode_mid_gap_radius[i])/sqrt(12.),2)+pow((
W_pitch/anode_mid_gap_radius[i])/sqrt(12.)*sumQ/(n_Strips*q_strips[ix]),2));
1201 etx[ix] = 5*drift_velocity;
1202 stripID[ix] = id_strips[ix];
1203 if(x[ix]>x_max) x_max=
x[ix];
1204 if(x[ix]<x_min) x_min=
x[ix];
1206 cout<<
"t = "<<tx[ix]<<
", q = "<<q_strips[ix]<<
", x= "<<
x[ix]<<endl;
1209 float clsize_real = 1+ stripID[n_Strips-1]-stripID[0];
1211 float p0_tpc_corr = 0;
1212 float p1_tpc_corr = 0;
1213 float shift0_tpc_corr = 0;
1214 if(uTPC_correction){
1216 p0_tpc_corr = 0.003206 + clsize_real * (-0.0006184);
1217 p1_tpc_corr = -0.000500 + clsize_real * ( 0.0001325);
1218 shift0_tpc_corr = 0.003489 + clsize_real * ( 0.0003489);
1220 p0_tpc_corr += 0.001030 + clsize_real * (-0.0006295);
1221 p1_tpc_corr += 0.000902;
1222 shift0_tpc_corr += 0.001105 + clsize_real * (-0.0002084);
1224 p1_tpc_corr += 0.0005;
1226 p1_tpc_corr += 0.0005;
1228 p1_tpc_corr += 0.0005;
1230 p1_tpc_corr += 0.0005;
1232 p1_tpc_corr += 0.0005;
1234 p1_tpc_corr += 0.0010;
1236 p1_tpc_corr += 0.0010;
1238 vector <double> v_deltaX;
1241 for(
int ix=0; ix<n_Strips; ix++){
1242 float deltaX_corr = 0;
1244 if(a_tpc*posCluster_CC<0){
1247 deltaX_corr -= (p0_tpc_corr - shift0_tpc_corr);
1250 real_ix+=stripID[ix]-stripID[ix-1];
1257 deltaX_corr += (p0_tpc_corr - shift0_tpc_corr);
1260 if(ix!=0) real_ix+=stripID[ix]-stripID[ix-1];
1263 x[ix] += deltaX_corr;
1264 v_deltaX.push_back(deltaX_corr);
1268 TGraphErrors xline(n_Strips, x, tx, ex, etx);
1270 TF1
f1(
"f1",
"[0]*x + [1]", x_min, x_max);
1271 f1.SetParameters(b_tpc,a_tpc);
1272 xline.Fit(&
f1,
"Q");
1273 TF1* f2 = xline.GetFunction(
"f1");
1275 f2->GetParameters(xpar);
1276 double *expar=f2->GetParErrors();
1282 tposCluster=(
drift_gap/2.-xpar[1])/xpar[0];
1283 if(fabs(tposCluster)>9999) tposCluster=9999.0;
1307 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;
1308 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;
1313 int clusterId=aCgemClusterCol->size();
1314 iStart_cluster[i][j][k].push_back(i1);
1315 iEnd_cluster[i][j][k].push_back(i2);
1316 vecPos_cluster[i][j][k].push_back(posCluster_CC);
1317 if(m_selectTPC==1) {
1318 vecTPos_cluster[i][j][k].push_back(tposCluster);
1320 else if(m_selectTPC==2) {
1321 vecTPos_cluster[i][j][k].push_back(pos_tpc);
1324 E_cluster[i][j][k].push_back(sumQ);
1325 id_cluster[i][j][k].push_back(clusterId);
1337 pt_recCluster->
setrecphi(posCluster_CC);
1339 if(m_selectTPC==1) {
1344 else if(m_selectTPC==2) {
1351 pt_recCluster->
setrecv(posCluster_CC);
1353 if(m_selectTPC==1) {
1358 else if(m_selectTPC==2){
1364 aCgemClusterCol->push_back(pt_recCluster);
1368 if(k==0&&nCluster[i][k]<100)
1371 nStripsX[i][nCluster[i][k]]=i2-i1+1;
1372 posX[i][nCluster[i][k]]=posCluster_CC;
1373 QX[i][nCluster[i][k]]=sumQ;
1376 tposX[i][nCluster[i][k]]=tposCluster;
1379 a_tpc_cluster_X[i][nCluster[i][k]]=a_tpc;
1380 b_tpc_cluster_X[i][nCluster[i][k]]=b_tpc;
1381 pos_tpc_cluster_X[i][nCluster[i][k]]=pos_tpc;
1388 if(nCluster[i][k]<100) {
1390 nStripsV[i][nCluster[i][k]]=i2-i1+1;
1391 posV[i][nCluster[i][k]]=posCluster_CC;
1392 QV[i][nCluster[i][k]]=sumQ;
1395 tposV[i][nCluster[i][k]]=tposCluster;
1399 int nXCluster=iStart_cluster[i][j][0].size();
1400 for(
int iX=0; iX<nXCluster; iX++)
1402 double Z_pos = readoutPlane->
getZFromPhiV(vecPos_cluster[i][j][0][iX],posCluster_CC);
1403 double tZ_pos =9999.0;
1404 if(vecTPos_cluster[i][j][0][iX]!=9999.0&&tposCluster!=9999.0)
1405 tZ_pos = readoutPlane->
getZFromPhiV(vecTPos_cluster[i][j][0][iX],tposCluster);
1407 if(readoutPlane->
OnThePlane(vecPos_cluster[i][j][0][iX],Z_pos))
1409 if(myPrintFlag) cout<<
"find a XV cluster, Z="<<Z_pos<<endl;
1410 int iV=iStart_cluster[i][j][1].size()-1;
1411 clusterId=aCgemClusterCol->size();
1412 vecPos_cluster[i][j][2].push_back(Z_pos);
1413 id_cluster[i][j][2].push_back(clusterId);
1414 idxCluster[i][j][0].push_back(iX);
1415 idxCluster[i][j][1].push_back(iV);
1423 pt2_recCluster->
setclusterflag(id_cluster[i][j][0][iX],id_cluster[i][j][1][iV]);
1424 pt2_recCluster->
setrecphi(vecPos_cluster[i][j][0][iX]);
1425 pt2_recCluster->
setrecphi_CC(vecPos_cluster[i][j][0][iX]);
1427 pt2_recCluster->
setrecv(vecPos_cluster[i][j][1][iV]);
1428 pt2_recCluster->
setrecv_CC(vecPos_cluster[i][j][1][iV]);
1429 pt2_recCluster->
setrecv_mTPC(vecTPos_cluster[i][j][1][iV]);
1430 pt2_recCluster->
setRecZ(Z_pos);
1433 aCgemClusterCol->push_back(pt2_recCluster);
1436 if(nCluster[i][2]<100) {
1437 posZ[i][nCluster[i][2]]=Z_pos;
1438 tposZ[i][nCluster[i][2]]=tZ_pos;
1439 phi_XV[i][nCluster[i][2]]=vecPos_cluster[i][j][0][iX];
1441 if( (iEnd_cluster[i][j][0][iX]+1)==readoutPlane->
getNXstrips() )
1442 idxBoundaryXVcluster[i][j][0].push_back(idxCluster[i][j][1].size()-1);
1443 if(iStart_cluster[i][j][0][iX]==0)
1444 idxBoundaryXVcluster[i][j][1].push_back(idxCluster[i][j][1].size()-1);
1459 drift_strips.clear();
1479 for(
int j=0; j<myNSheets[i]; j++)
1483 if(j_next==myNSheets[i]) j_next=0;
1487 double xmin_next = nextReadoutPlane->
getXmin();
1489 int nXV_atXEnd=idxBoundaryXVcluster[i][j][0].size();
1490 int nXV_atXStart=idxBoundaryXVcluster[i][j_next][1].size();
1491 if(nXV_atXEnd==0||nXV_atXStart==0)
continue;
1492 for(
int iXV_atXEnd=0; iXV_atXEnd<nXV_atXEnd; iXV_atXEnd++)
1494 int iXVCluster = idxBoundaryXVcluster[i][j][0][iXV_atXEnd];
1495 int iXCluster = idxCluster[i][j][0][iXVCluster];
1496 int iVCluster = idxCluster[i][j][1][iXVCluster];
1497 int VID1=iStart_cluster[i][j][1][iVCluster];
1498 int VID2=iEnd_cluster[i][j][1][iVCluster];
1501 for(
int iXV_atXStart=0; iXV_atXStart<nXV_atXStart; iXV_atXStart++)
1503 int iXVCluster_next = idxBoundaryXVcluster[i][j_next][1][iXV_atXStart];
1504 int iXCluster_next = idxCluster[i][j_next][0][iXVCluster_next];
1505 int iVCluster_next = idxCluster[i][j_next][1][iXVCluster_next];
1506 int VID1_next=iStart_cluster[i][j_next][1][iVCluster_next];
1507 int VID2_next=iEnd_cluster[i][j_next][1][iVCluster_next];
1508 if( !( (VID1_next-VID2_extend)>1 || (VID1_extend-VID2_next)>1 ) )
1510 int XID1=iStart_cluster[i][j][0][iXCluster];
1511 int XID2=iEnd_cluster[i][j][0][iXCluster];
1512 int XID1_next=iStart_cluster[i][j_next][0][iXCluster_next];
1513 int XID2_next=iEnd_cluster[i][j_next][0][iXCluster_next];
1514 int clusterId=aCgemClusterCol->size();
1521 int id1=id_cluster[i][j][2][iXVCluster];
1522 int id2=id_cluster[i][j_next][2][iXVCluster_next];
1525 double phi1=vecPos_cluster[i][j][0][iXCluster];
1526 double phi2=vecPos_cluster[i][j_next][0][iXCluster_next];
1532 double E1=E_cluster[i][j][0][iXCluster];
1533 double E2=E_cluster[i][j_next][0][iXCluster_next];
1534 double phiAverage=(E1*
phi1+E2*
phi2)/(E1+E2);
1537 double v1=vecPos_cluster[i][j][1][iVCluster];
1539 double v2=vecPos_cluster[i][j_next][1][iVCluster_next];
1540 E1=E_cluster[i][j][1][iVCluster];
1541 E2=E_cluster[i][j_next][1][iVCluster_next];
1542 double V_average_next=(E1*v1+E2*v2)/(E1+E2);
1543 pt_recCluster->
setrecv(V_average_next);
1545 double z_average = nextReadoutPlane->
getZFromPhiV(phiAverage,V_average_next,0);
1546 pt_recCluster->
setRecZ(z_average);
1548 aCgemClusterCol->push_back(pt_recCluster);
1551 cout<<
"one combinational cluster found: "<<endl;
1552 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;
1553 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;
1554 cout<<
" averagePhi:"<<phiAverage<<
", v_average:"<<V_average_next<<
", z_average:"<<z_average<<endl;
1561 if(nCluster[i][0]>100) nCluster[i][0]=100;
1562 if(nCluster[i][1]>100) nCluster[i][1]=100;
1563 if(nCluster[i][2]>100) nCluster[i][2]=100;
1568 double evttime=m_timer->
elapsed();
1571 if(myPrintFlag) checkRecCgemClusterCol();
1576 myNTupleHelper->
fillLong(
"run",(
long)run);
1577 myNTupleHelper->
fillLong(
"evt",(
long)evt);
1579 myNTupleHelper->
fillArray(
"nXstrips",
"nLayer",(
double*) nXStrips,3);
1580 myNTupleHelper->
fillArray(
"nVstrips",
"nLayer",(
double*) nVStrips,3);
1582 myNTupleHelper->
fillArray(
"phiClusterLay1",
"nXClusterLay1",(
double*) posX[0],nCluster[0][0]);
1583 myNTupleHelper->
fillArray(
"tphiClusterLay1",
"nXClusterLay1",(
double*) tposX[0],nCluster[0][0]);
1584 myNTupleHelper->
fillArrayInt(
"nXStripsLay1",
"nXClusterLay1",(
int*) nStripsX[0],nCluster[0][0]);
1585 myNTupleHelper->
fillArray(
"QXLay1",
"nXClusterLay1",(
double*) QX[0],nCluster[0][0]);
1586 myNTupleHelper->
fillArray(
"a_tpc_XLay1" ,
"nXClusterLay1",(
double*) a_tpc_cluster_X[0] ,nCluster[0][0]);
1587 myNTupleHelper->
fillArray(
"b_tpc_XLay1" ,
"nXClusterLay1",(
double*) b_tpc_cluster_X[0] ,nCluster[0][0]);
1588 myNTupleHelper->
fillArray(
"pos_tpc_XLay1" ,
"nXClusterLay1",(
double*) pos_tpc_cluster_X[0],nCluster[0][0]);
1590 myNTupleHelper->
fillArray(
"VClusterLay1",
"nVClusterLay1",(
double*) posV[0],nCluster[0][1]);
1591 myNTupleHelper->
fillArray(
"tVClusterLay1",
"nVClusterLay1",(
double*) tposV[0],nCluster[0][1]);
1592 myNTupleHelper->
fillArrayInt(
"nVStripsLay1",
"nVClusterLay1",(
int*) nStripsV[0],nCluster[0][1]);
1593 myNTupleHelper->
fillArray(
"QVLay1",
"nVClusterLay1",(
double*) QV[0],nCluster[0][1]);
1595 myNTupleHelper->
fillArray(
"zClusterLay1",
"nXVClusterLay1",(
double*) posZ[0],nCluster[0][2]);
1596 myNTupleHelper->
fillArray(
"tzClusterLay1",
"nXVClusterLay1",(
double*) tposZ[0],nCluster[0][2]);
1597 myNTupleHelper->
fillArray(
"phiXVClusterLay1",
"nXVClusterLay1",(
double*) phi_XV[0],nCluster[0][2]);
1599 myNTupleHelper->
fillArray(
"phiClusterLay2",
"nXClusterLay2",(
double*) posX[1],nCluster[1][0]);
1600 myNTupleHelper->
fillArray(
"tphiClusterLay2",
"nXClusterLay2",(
double*) tposX[1],nCluster[1][0]);
1601 myNTupleHelper->
fillArrayInt(
"nXStripsLay2",
"nXClusterLay2",(
int*) nStripsX[1],nCluster[1][0]);
1602 myNTupleHelper->
fillArray(
"QXLay2",
"nXClusterLay2",(
double*) QX[1],nCluster[1][0]);
1603 myNTupleHelper->
fillArray(
"a_tpc_XLay2" ,
"nXClusterLay2",(
double*) a_tpc_cluster_X[1] ,nCluster[1][0]);
1604 myNTupleHelper->
fillArray(
"b_tpc_XLay2" ,
"nXClusterLay2",(
double*) b_tpc_cluster_X[1] ,nCluster[1][0]);
1605 myNTupleHelper->
fillArray(
"pos_tpc_XLay2" ,
"nXClusterLay2",(
double*) pos_tpc_cluster_X[1],nCluster[1][0]);
1607 myNTupleHelper->
fillArray(
"VClusterLay2",
"nVClusterLay2",(
double*) posV[1],nCluster[1][1]);
1608 myNTupleHelper->
fillArray(
"tVClusterLay2",
"nVClusterLay2",(
double*) tposV[1],nCluster[1][1]);
1609 myNTupleHelper->
fillArrayInt(
"nVStripsLay2",
"nVClusterLay2",(
int*) nStripsV[1],nCluster[1][1]);
1610 myNTupleHelper->
fillArray(
"QVLay2",
"nVClusterLay2",(
double*) QV[1],nCluster[1][1]);
1612 myNTupleHelper->
fillArray(
"zClusterLay2",
"nXVClusterLay2",(
double*) posZ[1],nCluster[1][2]);
1613 myNTupleHelper->
fillArray(
"tzClusterLay2",
"nXVClusterLay2",(
double*) tposZ[1],nCluster[1][2]);
1614 myNTupleHelper->
fillArray(
"phiXVClusterLay2",
"nXVClusterLay2",(
double*) phi_XV[1],nCluster[1][2]);
1616 myNTupleHelper->
fillArray(
"phiClusterLay3",
"nXClusterLay3",(
double*) posX[2],nCluster[2][0]);
1617 myNTupleHelper->
fillArray(
"tphiClusterLay3",
"nXClusterLay3",(
double*) tposX[2],nCluster[2][0]);
1618 myNTupleHelper->
fillArrayInt(
"nXStripsLay3",
"nXClusterLay3",(
int*) nStripsX[2],nCluster[2][0]);
1619 myNTupleHelper->
fillArray(
"QXLay3",
"nXClusterLay3",(
double*) QX[2],nCluster[2][0]);
1620 myNTupleHelper->
fillArray(
"a_tpc_XLay3" ,
"nXClusterLay3",(
double*) a_tpc_cluster_X[2] ,nCluster[2][0]);
1621 myNTupleHelper->
fillArray(
"b_tpc_XLay3" ,
"nXClusterLay3",(
double*) b_tpc_cluster_X[2] ,nCluster[2][0]);
1622 myNTupleHelper->
fillArray(
"pos_tpc_XLay3" ,
"nXClusterLay3",(
double*) pos_tpc_cluster_X[2],nCluster[2][0]);
1624 myNTupleHelper->
fillArray(
"VClusterLay3",
"nVClusterLay3",(
double*) posV[2],nCluster[2][1]);
1625 myNTupleHelper->
fillArray(
"tVClusterLay3",
"nVClusterLay3",(
double*) tposV[2],nCluster[2][1]);
1626 myNTupleHelper->
fillArrayInt(
"nVStripsLay3",
"nVClusterLay3",(
int*) nStripsV[2],nCluster[2][1]);
1627 myNTupleHelper->
fillArray(
"QVLay3",
"nVClusterLay3",(
double*) QV[2],nCluster[2][1]);
1629 myNTupleHelper->
fillArray(
"zClusterLay3",
"nXVClusterLay3",(
double*) posZ[2],nCluster[2][2]);
1630 myNTupleHelper->
fillArray(
"tzClusterLay3",
"nXVClusterLay3",(
double*) tposZ[2],nCluster[2][2]);
1631 myNTupleHelper->
fillArray(
"phiXVClusterLay3",
"nXVClusterLay3",(
double*) phi_XV[2],nCluster[2][2]);
1633 myNTupleHelper->
fillDouble(
"evtProcessTime",evttime);
1635 myNTupleHelper->
write();
1637 if(myPrintFlag) cout<<
"End of CgemClusterCreate::method2()"<<endl;
1639 return StatusCode::SUCCESS;
1642StatusCode CgemClusterCreate::toyCluster()
1644 MsgStream log(
msgSvc(),name());
1647 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
1650 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
1651 return StatusCode::FAILURE;
1653 int run=evtHead->runNumber();
1654 int evt=evtHead->eventNumber();
1655 if(myPrintFlag) cout<<
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "<<evt<<endl;
1658 IDataProviderSvc* evtSvc = NULL;
1659 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
1661 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
1663 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
1664 return StatusCode::SUCCESS;
1668 sc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", aCgemClusterCol);
1671 log << MSG::FATAL <<
"Could not register RecCgemClusterCol" << endreq;
1672 return StatusCode::SUCCESS;
1676 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
1679 log << MSG::WARNING <<
"Could not retrieve CgemMcHitCol list" << endreq;
1680 return StatusCode::FAILURE;
1685 double phi_truth[100], z_truth[100], r_truth[100], x_truth[100], v_truth[100], cosTh_truth[100], z_check[100];
1686 double phi_gen[100], z_gen[100], x_gen[100], v_gen[100];
1688 int nCgemMcHit = cgemMcHitCol->size();
if(myPrintFlag) cout<<
"nCgemMcHit = "<<nCgemMcHit<<endl;
1689 vector<int> idxXClusters[4][2], idxVClusters[4][2];
1690 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
1692 for(; iter_truth!=cgemMcHitCol->end(); iter_truth++ )
1694 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster(): creator process = "<<(*iter_truth)->GetCreatorProcess()<<endl;
1695 string creatorProcess = (*iter_truth)->GetCreatorProcess();
1696 if(creatorProcess==
"Generator"||creatorProcess==
"Decay")
1699 if(myClusterEff>0.&&myClusterEff<1.0) {
1700 Rndm::Numbers flat(randSvc(), Rndm::Flat(0,1));
1701 if(flat()>myClusterEff) {
1702 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() skip one cluster! "<<endl;
1707 int iLayer = (*iter_truth)->GetLayerID();
1708 double x_pre = (*iter_truth)->GetPositionXOfPrePoint();
1709 double y_pre = (*iter_truth)->GetPositionYOfPrePoint();
1710 double z_pre = (*iter_truth)->GetPositionZOfPrePoint();
1711 double x_post = (*iter_truth)->GetPositionXOfPostPoint();
1712 double y_post = (*iter_truth)->GetPositionYOfPostPoint();
1713 double z_post = (*iter_truth)->GetPositionZOfPostPoint();
1714 double x_mid = 0.5*(x_pre+x_post);
1715 double y_mid = 0.5*(y_pre+y_post);
1716 double z_mid = 0.5*(z_pre+z_post);
1717 double r_pre = sqrt(x_pre*x_pre+y_pre*y_pre+z_pre*z_pre);
1718 double r_post = sqrt(x_post*x_post+y_post*y_post+z_post*z_post);
1719 double v_x = x_post-x_pre;
1720 double v_y = y_post-y_pre;
1721 double v_z = z_post-z_pre;
1722 double cth_v = v_z/sqrt(v_x*v_x+v_y*v_y+v_z*v_z);
1728 double v_tot = sqrt(v_x*v_x+v_y*v_y+v_z*v_z);
1729 double theta_v = acos(v_z/v_tot);
1730 double phi_v = atan2(v_y, v_x);
1732 double r_middle = sqrt(x_mid*x_mid+y_mid*y_mid);
1733 if(myPrintFlag) cout<<
"iLayer, r_middle = "<<iLayer<<
", "<<r_middle<<endl;
1734 Hep3Vector pos_mid(x_mid, y_mid, z_mid);
1735 double phi_mid = pos_mid.phi();
1736 while(phi_mid>CLHEP::twopi) phi_mid-=CLHEP::twopi;
1737 while(phi_mid<0.) phi_mid+=CLHEP::twopi;
1739 double dPhi = phi_v-phi_mid;
1740 while(dPhi>CLHEP::pi) dPhi-=CLHEP::twopi;
1741 while(dPhi<-CLHEP::pi) dPhi+=CLHEP::twopi;
1745 for(
int i=0; i<myNSheets[iLayer]; i++)
1755 if(readoutPlane==NULL)
continue;
1757 double v_loc = readoutPlane->
getVFromPhiZ(phi_mid, z_mid);
1758 if(iCgemMcHit<100) {
1759 phi_truth[iCgemMcHit]=phi_mid;
1760 z_truth[iCgemMcHit]=z_mid;
1761 r_truth[iCgemMcHit]=r_middle;
1762 x_truth[iCgemMcHit]=phi_mid*myRXstrips[iLayer];
1763 v_truth[iCgemMcHit]=v_loc;
1764 cosTh_truth[iCgemMcHit]=cth_v;
1765 z_check[iCgemMcHit] = readoutPlane->
getZFromPhiV(phi_mid, v_loc);
1767 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() iLayer "<<iLayer<<
", MC hit: phi, z, V = "<<phi_mid<<
", "<<z_mid<<
", "<<v_loc<<endl;
1771 int iView(0), mode(2);
1772 double Q(100), T(100);
1773 double sigma_X = myCgemCalibSvc->
getSigma(iLayer,iView,mode,dPhi,Q,T);
1774 Rndm::Numbers gauss(randSvc(), Rndm::Gauss(0,1));
1775 double phi_mid_gen = phi_mid+gauss()*sigma_X/myRXstrips[iLayer];
1777 while(!(readoutPlane->
OnThePlane(phi_mid_gen,z_mid))) {
1778 phi_mid_gen = phi_mid+gauss()*sigma_X/myRXstrips[iLayer];
1780 if(iGenTried>=10)
break;
1783 if(myPrintFlag) cout<<
"Generation of phi with 10 times!"<<endl;
1786 if(myPrintFlag) cout<<
"generated phi: "<<phi_mid_gen<<endl;
1789 double sigma_V = myCgemCalibSvc->
getSigma(iLayer,iView,mode,dPhi,Q,T);
1791 double v_loc_gen = v_loc+gauss()*sigma_V;
1792 double z_mid_gen = readoutPlane->
getZFromPhiV(phi_mid_gen, v_loc_gen);
1794 while(!(readoutPlane->
OnThePlane(phi_mid_gen,z_mid_gen)))
1796 v_loc_gen = v_loc+gauss()*sigma_V;
1797 z_mid_gen = readoutPlane->
getZFromPhiV(phi_mid_gen, v_loc_gen);
1798 if(myPrintFlag) cout<<
"try generated V, z: "<<v_loc_gen<<
", "<<z_mid_gen<<endl;
1800 if(iGenTried>=10)
break;
1803 if(myPrintFlag) cout<<
"Generation of V with 10 times!"<<endl;
1807 if(iCgemMcHit<100) {
1808 phi_gen[iCgemMcHit]=phi_mid_gen;
1809 z_gen[iCgemMcHit]=z_mid_gen;
1810 x_gen[iCgemMcHit]=phi_mid_gen*myRXstrips[iLayer];
1811 v_gen[iCgemMcHit]=v_loc_gen;
1817 int clusterId=aCgemClusterCol->size();
1828 aCgemClusterCol->push_back(pt_recCluster);
1829 idxXClusters[iLayer][iSheet].push_back(clusterId);
1830 (*iter_truth)->AddXclusterIdx(clusterId);
1832 clusterId=aCgemClusterCol->size();
1839 pt_recCluster->
setrecv(v_loc_gen);
1840 aCgemClusterCol->push_back(pt_recCluster);
1841 idxVClusters[iLayer][iSheet].push_back(clusterId);
1842 (*iter_truth)->AddVclusterIdx(clusterId);
1845 int pdg = (*iter_truth)->GetPDGCode();
1846 double px = (*iter_truth)->GetMomentumXOfPrePoint();
1847 double py = (*iter_truth)->GetMomentumYOfPrePoint();
1848 double pz = (*iter_truth)->GetMomentumZOfPrePoint();
1849 Hep3Vector truth_p(px/1000.,py/1000.,pz/1000.);
1851 HepPoint3D truth_position(x_pre/10.,y_pre/10.,z_pre/10.);
1852 if(myPrintFlag&&fabs(pdg)==13)
1854 int charge = -1*pdg/fabs(pdg);
1857 tmp_helix->
pivot(tmp_pivot);
1859 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;
1869 if(myRandomCluster>0) {
1870 Rndm::Numbers flat(randSvc(), Rndm::Flat(0,1));
1871 for(
int i=0; i<myNCgemLayers; i++) {
1872 Rndm::Numbers poisson(randSvc(), Rndm::Poisson(myNoiseRate[i]/myNSheets[i]));
1873 for(
int j=0; j<myNSheets[i]; j++)
1877 for(
int k=0; k<nBK; k++) {
1878 double phi=flat()*(2.0*
M_PI)/myNSheets[i]+(j-1)*
M_PI;
1884 int clusterId=aCgemClusterCol->size();
1892 aCgemClusterCol->push_back(pt_recCluster);
1893 idxXClusters[i][j].push_back(clusterId);
1897 clusterId=aCgemClusterCol->size();
1904 pt_recCluster->
setrecv(v_loc);
1905 aCgemClusterCol->push_back(pt_recCluster);
1906 idxVClusters[i][j].push_back(clusterId);
1916 RecCgemClusterCol::iterator it_cluster0 = aCgemClusterCol->begin();
1917 RecCgemClusterCol::iterator it_cluster;
1918 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() start searching XV clusters: "<<endl;
1919 for(
int i=0; i<myNCgemLayers; i++)
1921 for(
int j=0; j<myNSheets[i]; j++)
1923 if(myPrintFlag) cout<<
"iLayer, iSheet = "<<i<<
", "<<j<<endl;
1925 for(
int iV=0; iV<idxVClusters[i][j].size(); iV++)
1927 if(myPrintFlag) cout<<
"iV: "<<iV;
1928 it_cluster = it_cluster0+idxVClusters[i][j][iV];
1930 double V_loc = (*it_cluster)->getrecv();
1932 for(
int iX=0; iX<idxXClusters[i][j].size(); iX++)
1934 if(myPrintFlag) cout<<
" iX: "<<iX<<endl;
1935 it_cluster = it_cluster0+idxXClusters[i][j][iX];
1936 double phi = (*it_cluster)->getrecphi();
1938 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() check phi, z, V = "<<phi<<
", "<<z<<
", "<<V_loc<<
", layer "<<i<<
", sheet "<<j<<endl;
1941 int clusterId=aCgemClusterCol->size();
1948 pt_recCluster->
setclusterflag(idxXClusters[i][j][iX], idxVClusters[i][j][iV]);
1950 pt_recCluster->
setrecv(V_loc);
1952 aCgemClusterCol->push_back(pt_recCluster);
1953 it_cluster0 = aCgemClusterCol->begin();
1954 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() finds a XV cluster"<<endl;
1962 if(myPrintFlag) cout<<
"nCgemCluster = "<<aCgemClusterCol->size()<<endl;
1964 if(myPrintFlag) checkRecCgemClusterCol();
1965 if(run<0) fillMCTruth();
1968 if(iCgemMcHit>100) iCgemMcHit=100;
1969 myNTupleHelper->
fillArray(
"phi_mc",
"nCgemMcHit",(
double*)phi_truth,iCgemMcHit);
1970 myNTupleHelper->
fillArray(
"z_mc",
"nCgemMcHit",(
double*)z_truth,iCgemMcHit);
1971 myNTupleHelper->
fillArray(
"z_mc_check",
"nCgemMcHit",(
double*)z_check,iCgemMcHit);
1972 myNTupleHelper->
fillArray(
"r_mc",
"nCgemMcHit",(
double*)r_truth,iCgemMcHit);
1973 myNTupleHelper->
fillArray(
"x_mc",
"nCgemMcHit",(
double*)x_truth,iCgemMcHit);
1974 myNTupleHelper->
fillArray(
"v_mc",
"nCgemMcHit",(
double*)v_truth,iCgemMcHit);
1975 myNTupleHelper->
fillArray(
"cth_mc",
"nCgemMcHit",(
double*)cosTh_truth,iCgemMcHit);
1976 myNTupleHelper->
fillArray(
"phi",
"nCgemMcHit",(
double*)phi_gen,iCgemMcHit);
1977 myNTupleHelper->
fillArray(
"z",
"nCgemMcHit",(
double*)z_gen,iCgemMcHit);
1978 myNTupleHelper->
fillArray(
"x",
"nCgemMcHit",(
double*)x_gen,iCgemMcHit);
1979 myNTupleHelper->
fillArray(
"v",
"nCgemMcHit",(
double*)v_gen,iCgemMcHit);
1980 myNTupleHelper->
write();
1990 return StatusCode::SUCCESS;
1993void CgemClusterCreate::fillMCTruth(
int run,
int evt)
1997 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
2000 std::cout <<
"Could not retrieve cgemMcHitCol" << std::endl;
2003 m_mc_nhit = cgemMcHitCol->size();
2005 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
2006 for(
int iHit=0; iter_truth!= cgemMcHitCol->end(); iter_truth++,iHit++)
2008 m_mc_trackID[iHit] = (*iter_truth)->GetTrackID();
2009 m_mc_layerID[iHit] = (*iter_truth)->GetLayerID();
2010 m_mc_pdg[iHit] = (*iter_truth)->GetPDGCode();
2011 m_mc_parentID[iHit] = (*iter_truth)->GetParentID();
2012 m_mc_E_deposit[iHit] = (*iter_truth)->GetTotalEnergyDeposit();
2013 m_mc_XYZ_pre_x[iHit] = (*iter_truth)->GetPositionXOfPrePoint();
2014 m_mc_XYZ_pre_y[iHit] = (*iter_truth)->GetPositionYOfPrePoint();
2015 m_mc_XYZ_pre_z[iHit] = (*iter_truth)->GetPositionZOfPrePoint();
2016 m_mc_XYZ_post_x[iHit] = (*iter_truth)->GetPositionXOfPostPoint();
2017 m_mc_XYZ_post_y[iHit] = (*iter_truth)->GetPositionYOfPostPoint();
2018 m_mc_XYZ_post_z[iHit] = (*iter_truth)->GetPositionZOfPostPoint();
2019 m_mc_P_pre_x[iHit] = (*iter_truth)->GetMomentumXOfPrePoint();
2020 m_mc_P_pre_y[iHit] = (*iter_truth)->GetMomentumYOfPrePoint();
2021 m_mc_P_pre_z[iHit] = (*iter_truth)->GetMomentumZOfPrePoint();
2022 m_mc_P_post_x[iHit] = (*iter_truth)->GetMomentumXOfPostPoint();
2023 m_mc_P_post_y[iHit] = (*iter_truth)->GetMomentumYOfPostPoint();
2024 m_mc_P_post_z[iHit] = (*iter_truth)->GetMomentumZOfPostPoint();
2031void CgemClusterCreate::fillRecData(
int run,
int evt)
2037 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
2038 if(!recCgemClusterCol)
2040 cout <<
"Could not retrieve RecCgemClusterCol" << endl;
2042 m_rec_ncluster = recCgemClusterCol->size();
2044 RecCgemClusterCol::iterator iter_cluster=recCgemClusterCol->begin();
2045 for(; iter_cluster!=recCgemClusterCol->end(); iter_cluster++)
2047 if(m_fillOption == -1){
2048 m_rec_clusterid[iCluster] = (*iter_cluster)->getclusterid();
2049 m_rec_layerid[iCluster] = (*iter_cluster)->getlayerid();
2050 m_rec_sheetid[iCluster] = (*iter_cluster)->getsheetid();
2051 m_rec_flag[iCluster] = (*iter_cluster)->getflag();
2052 m_rec_energydeposit[iCluster] = (*iter_cluster)->getenergydeposit();
2053 m_rec_recphi[iCluster] = (*iter_cluster)->getrecphi();
2054 m_rec_recv[iCluster] = (*iter_cluster)->getrecv();
2055 m_rec_recZ[iCluster] = (*iter_cluster)->getRecZ();
2056 m_rec_clusterflagb[iCluster] = (*iter_cluster)->getclusterflagb();
2057 m_rec_clusterflage[iCluster] = (*iter_cluster)->getclusterflage();
2059 }
else if(m_fillOption==(*iter_cluster)->getflag()){
2060 m_rec_clusterid[iCluster] = (*iter_cluster)->getclusterid();
2061 m_rec_layerid[iCluster] = (*iter_cluster)->getlayerid();
2062 m_rec_sheetid[iCluster] = (*iter_cluster)->getsheetid();
2063 m_rec_flag[iCluster] = (*iter_cluster)->getflag();
2064 m_rec_energydeposit[iCluster] = (*iter_cluster)->getenergydeposit();
2065 m_rec_recphi[iCluster] = (*iter_cluster)->getrecphi();
2066 m_rec_recv[iCluster] = (*iter_cluster)->getrecv();
2067 m_rec_recZ[iCluster] = (*iter_cluster)->getRecZ();
2068 m_rec_clusterflagb[iCluster] = (*iter_cluster)->getclusterflagb();
2069 m_rec_clusterflage[iCluster] = (*iter_cluster)->getclusterflage();
2072 if(iCluster>1000)
break;
2075 m_rec_ncluster = iCluster;
2080void CgemClusterCreate::hist_def(){
2082 NTuplePtr nt_rec(
ntupleSvc(),
"RecCgem/RecCluster");
2083 if( nt_rec ) m_rec_nt = nt_rec;
2085 m_rec_nt=
ntupleSvc()->book(
"RecCgem/RecCluster",CLID_ColumnWiseTuple,
"RecCluster");
2087 status = m_rec_nt->addItem(
"rec_run" ,m_rec_run);
2088 status = m_rec_nt->addItem(
"rec_evt" ,m_rec_evt);
2089 status = m_rec_nt->addItem(
"rec_ncluster" ,m_rec_ncluster,0,1000);
2090 status = m_rec_nt->addItem(
"rec_clusterid" ,m_rec_ncluster,m_rec_clusterid);
2091 status = m_rec_nt->addItem(
"rec_layerid" ,m_rec_ncluster,m_rec_layerid);
2092 status = m_rec_nt->addItem(
"rec_sheetid" ,m_rec_ncluster,m_rec_sheetid);
2093 status = m_rec_nt->addItem(
"rec_flag" ,m_rec_ncluster,m_rec_flag);
2094 status = m_rec_nt->addItem(
"rec_energydeposit" ,m_rec_ncluster,m_rec_energydeposit);
2095 status = m_rec_nt->addItem(
"rec_recphi" ,m_rec_ncluster,m_rec_recphi);
2096 status = m_rec_nt->addItem(
"rec_recv" ,m_rec_ncluster,m_rec_recv);
2097 status = m_rec_nt->addItem(
"rec_recZ" ,m_rec_ncluster,m_rec_recZ);
2098 status = m_rec_nt->addItem(
"rec_clusterflagb" ,m_rec_ncluster,m_rec_clusterflagb);
2099 status = m_rec_nt->addItem(
"rec_clusterflage" ,m_rec_ncluster,m_rec_clusterflage);
2103 NTuplePtr nt_mc(
ntupleSvc(),
"RecCgem/McHit");
2104 if( nt_mc ) m_mc_nt = nt_mc;
2106 m_mc_nt =
ntupleSvc()->book(
"RecCgem/McHit",CLID_ColumnWiseTuple,
"McHit");
2108 status = m_mc_nt->addItem(
"mc_run" ,m_mc_run);
2109 status = m_mc_nt->addItem(
"mc_evt" ,m_mc_evt);
2110 status = m_mc_nt->addItem(
"mc_nhit" ,m_mc_nhit,0,1000);
2111 status = m_mc_nt->addItem(
"mc_trackID" ,m_mc_nhit,m_mc_trackID);
2112 status = m_mc_nt->addItem(
"mc_layerID" ,m_mc_nhit,m_mc_layerID);
2113 status = m_mc_nt->addItem(
"mc_pdg" ,m_mc_nhit,m_mc_pdg);
2114 status = m_mc_nt->addItem(
"mc_parentID" ,m_mc_nhit,m_mc_parentID);
2115 status = m_mc_nt->addItem(
"mc_E_deposit" ,m_mc_nhit,m_mc_E_deposit);
2116 status = m_mc_nt->addItem(
"mc_XYZ_pre_x" ,m_mc_nhit,m_mc_XYZ_pre_x);
2117 status = m_mc_nt->addItem(
"mc_XYZ_pre_y" ,m_mc_nhit,m_mc_XYZ_pre_y);
2118 status = m_mc_nt->addItem(
"mc_XYZ_pre_z" ,m_mc_nhit,m_mc_XYZ_pre_z);
2119 status = m_mc_nt->addItem(
"mc_XYZ_post_x" ,m_mc_nhit,m_mc_XYZ_post_x);
2120 status = m_mc_nt->addItem(
"mc_XYZ_post_y" ,m_mc_nhit,m_mc_XYZ_post_y);
2121 status = m_mc_nt->addItem(
"mc_XYZ_post_z" ,m_mc_nhit,m_mc_XYZ_post_z);
2122 status = m_mc_nt->addItem(
"mc_P_pre_x" ,m_mc_nhit,m_mc_P_pre_x);
2123 status = m_mc_nt->addItem(
"mc_P_pre_y" ,m_mc_nhit,m_mc_P_pre_y);
2124 status = m_mc_nt->addItem(
"mc_P_pre_z" ,m_mc_nhit,m_mc_P_pre_z);
2125 status = m_mc_nt->addItem(
"mc_P_post_x" ,m_mc_nhit,m_mc_P_post_x);
2126 status = m_mc_nt->addItem(
"mc_P_post_y" ,m_mc_nhit,m_mc_P_post_y);
2127 status = m_mc_nt->addItem(
"mc_P_post_z" ,m_mc_nhit,m_mc_P_post_z);
2134 MsgStream log(
msgSvc(),name());
2135 log << MSG::INFO <<
"in finalize(): Number of events in CgemClusterCreate" << m_totEvt << endreq;
2138 return StatusCode::SUCCESS;
2141void CgemClusterCreate::reset() {
2142 for (
int i=0; i<3; i++)
2144 for (
int j=0; j<2; j++)
2146 for (
int k=0; k<2; k++)
2148 for (
int l=0; l<1500; l++)
2150 m_strip[i][j][k][l] = -1;
2151 m_edep[i][j][k][l] = 0;
2161 m_trans_map.clear();
2162 m_driftrec_map.clear();
2164 m_strip_map.clear();
2168void CgemClusterCreate::resetFiredStripMap()
2170 for (
int i=0; i<3; i++)
2172 for (
int j=0; j<2; j++)
2174 for (
int k=0; k<2; k++)
2176 myFiredStripMap[i][j][k].clear();
2191void CgemClusterCreate:: processstrips(
int k){
2193 for(
int i=0;i<3;i++){
2194 for(
int j=0;j<2;j++){
2199 static int N_cluster;
2201 for(
int l=1;l<1500;l++){
2203 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]>0){
2207 if(m_strip[i][j][k][l]<0&&m_strip[i][j][k][l-1]>0){
2209 N_cluster= N_cluster + 1;
2211 m_x_group.push_back(cluster);
2232 posxfind(reccluster);
2234 m_x_map[
key] = reccluster;
2238 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]<0){
2246 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]>0){
2252 if(m_strip[i][j][k][l]<0&&m_strip[i][j][k][l-1]>0){
2256 m_v_group.push_back(cluster);
2276 posvfind(reccluster);
2278 m_v_map[
key] = reccluster;
2282 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]<0){
2296void CgemClusterCreate:: transcluster(){
2298 for(
int i=0;i<3;i++){
2299 for(
int j=0;j<2;j++){
2300 for(
int l=0;l<1500;l++){
2302 keytype
key((10*i+j),l);
2303 m_v_map_it = m_v_map.find(
key);
2304 if(m_v_map_it != m_v_map.end()){
2324 transflag.first = vcluster;
2325 transflag.second = cluster;
2326 m_trans_map[
key]= transflag;
2334void CgemClusterCreate::mixcluster(){
2336 for(
int i=0;i<3;i++){
2337 for(
int j=0;j<2;j++){
2338 for(
int l=0;l<1500;l++){
2340 keytype
key((10*i+j),l);
2341 m_x_map_it = m_x_map.find(
key);
2342 if(m_x_map_it != m_x_map.end()){
2350 for(
int ll=0;ll<1500;ll++){
2351 keytype mkey((10*i+j),ll);
2352 m_trans_map_it = m_trans_map.find(mkey);
2353 if(m_trans_map_it == m_trans_map.end()){
continue;}
2356 flagxv transflag = (*m_trans_map_it).second;
2365 v.end = cluster.
end;
2369 m_xv_group.push_back(XV);
2370 m_mid_group.push_back(vcluster);
2376 posxvfind(reccluster);
2378 m_xv_map[
key] = reccluster;
2379 posindrift(reccluster);
2394 m_mid_group.clear();
2405 for(
int k=begin;k<=end;k++){
2406 phi = phi + m_edep[layerid][sheetid][0][k]*k*
W_pitch;
2417 for(
int k=begin;k<=end;k++){
2418 v =
v + m_edep[layerid][sheetid][1][k]*k*
W_pitch;
2435 double xenergy = 0.0;
2436 double venergy = 0.0;
2439 for(
int ii=
x.begin;ii<=
x.end;ii++){
2440 for(
int jj=
v.begin;jj<=
v.end;jj++){
2443 xenergy = xenergy + m_edep[layerid][sheetid][0][ii];
2444 phi = phi + m_edep[layerid][sheetid][0][ii]*ii*
W_pitch;
2446 m_sameID.push_back(ii);
2454 for(
int kk=mid.
begin;kk<=mid.
end;kk++){
2460 for(
int ll=0;ll<(int)m_sameID.size();ll++){
2461 if(pa<=m_sameID[ll]&&pb>=m_sameID[ll]){
2463 venergy = venergy + m_edep[layerid][sheetid][1][kk];
2464 recv = recv + m_edep[layerid][sheetid][1][kk]*kk*
W_pitch;
2476 int nxstrip = m_sameID.size();
2480 keytype
key((10*layerid+sheetid),clusterid);
2481 pphi = pphi/nxstrip;
2483 keytype strip(nxstrip,nvstrip);
2484 postype pos(pphi,pv);
2487 m_strip_map[
key]=strip;
2494 reccluster->
setrecv(recv/venergy);
2503 double posphi =
dr_layer[layerid]*dphi;
2504 for(
int vv =0;vv<
n_sheet[layerid];vv++){
2506 posphi = posphi-vv*
dw_sheet[layerid];
2514 postype positiond(posphi,posv);
2515 keytype
key((10*layerid+sheetid),clusterid);
2516 m_driftrec_map[
key] = positiond;
2519void CgemClusterCreate::fillMCTruth()
2521 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
2524 std::cout <<
"Could not retrieve McParticelCol" << std::endl;
2532 double Pmc[100],costhmc[100],phimc[100];
2533 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
2534 for (; iter_mc != mcParticleCol->end(); iter_mc++)
2536 int idx = (*iter_mc)->trackIndex();
2537 int pdgid = (*iter_mc)->particleProperty();
2538 int mother_pdg = ((*iter_mc)->mother()).particleProperty();
2539 int mother_idx = (*iter_mc)->mother().trackIndex();
2540 int primaryParticle = (*iter_mc)->primaryParticle();
2541 int fromGenerator = (*iter_mc)->decayFromGenerator();
2542 if(primaryParticle==1)
continue;
2543 if(fromGenerator==0)
continue;
2544 if(pdgid==myMotherParticleID) {
2548 if(foundMom==0)
continue;
2549 if(mother_pdg==myMotherParticleID) {
2553 if(pdgid!=myMotherParticleID&&foundMom>0&&startDecay==0)
2558 mother_idx=mother_idx-foundMom-itmp;
2560 if(myPrintFlag==1) {
2562 cout<<
"****** MC particles ****** "<<endl;
2563 cout <<setw(10)<<
"index"
2565 <<setw(16)<<
"primaryParticle"
2566 <<setw(15)<<
"fromGenerator"
2567 <<setw(15)<<
"from_trk"
2570 cout <<setw(10)<<i_mc
2572 <<setw(16)<<primaryParticle
2573 <<setw(15)<<fromGenerator
2574 <<setw(15)<<mother_idx
2580 HepLorentzVector p4_mc = (*iter_mc)->initialFourMomentum();
2581 Pmc[i_mc]=p4_mc.rho();
2582 costhmc[i_mc]=p4_mc.cosTheta();
2583 phimc[i_mc]=p4_mc.phi();
2587 if(i_mc>=100) i_mc=100;
2589 int nTruth[3]={0,0,0};
2590 int trkID_Layer1[100], trkID_Layer2[100], trkID_Layer3[100];
2591 int pdg_Layer1[100], pdg_Layer2[100], pdg_Layer3[100];
2592 double x_pre_Layer1[100], x_pre_Layer2[100], x_pre_Layer3[100];
2593 double y_pre_Layer1[100], y_pre_Layer2[100], y_pre_Layer3[100];
2594 double z_pre_Layer1[100], z_pre_Layer2[100], z_pre_Layer3[100];
2595 double x_post_Layer1[100], x_post_Layer2[100], x_post_Layer3[100];
2596 double y_post_Layer1[100], y_post_Layer2[100], y_post_Layer3[100];
2597 double z_post_Layer1[100], z_post_Layer2[100], z_post_Layer3[100];
2598 double phi_Layer1[100], phi_Layer2[100], phi_Layer3[100];
2599 double z_Layer1[100], z_Layer2[100], z_Layer3[100];
2600 double V_Layer1[100], V_Layer2[100], V_Layer3[100];
2601 double px_pre_Layer1[100], px_pre_Layer2[100], px_pre_Layer3[100];
2602 double py_pre_Layer1[100], py_pre_Layer2[100], py_pre_Layer3[100];
2603 double pz_pre_Layer1[100], pz_pre_Layer2[100], pz_pre_Layer3[100];
2604 double en_Layer1[100], en_Layer2[100], en_Layer3[100];
2605 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
2608 std::cout <<
"Could not retrieve cgemMcHitCol" << std::endl;
2611 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
2612 for (; iter_truth!= cgemMcHitCol->end(); iter_truth++)
2614 int iLayer = (*iter_truth)->GetLayerID();
2615 int trkID = (*iter_truth)->GetTrackID();
2616 int pdg = (*iter_truth)->GetPDGCode();
2617 double x_pre = (*iter_truth)->GetPositionXOfPrePoint();
2618 double y_pre = (*iter_truth)->GetPositionYOfPrePoint();
2619 double z_pre = (*iter_truth)->GetPositionZOfPrePoint();
2620 double x_post = (*iter_truth)->GetPositionXOfPostPoint();
2621 double y_post = (*iter_truth)->GetPositionYOfPostPoint();
2622 double z_post = (*iter_truth)->GetPositionZOfPostPoint();
2623 double x_middle = 0.5*(x_pre+x_post);
2624 double y_middle = 0.5*(y_pre+y_post);
2625 double z_middle = 0.5*(z_pre+z_post);
2626 double r_middle = sqrt(x_middle*x_middle+y_middle*y_middle);
2627 double phi_middle = atan2(y_middle, x_middle);
2628 double px_pre = (*iter_truth)->GetMomentumXOfPrePoint();
2629 double py_pre = (*iter_truth)->GetMomentumYOfPrePoint();
2630 double pz_pre = (*iter_truth)->GetMomentumZOfPrePoint();
2631 double en = (*iter_truth)->GetTotalEnergyDeposit();
2635 for(
int j=0; j<myNSheets[iLayer]; j++)
2640 if(readoutPlane->
OnThePlane(phi_middle,z_middle))
break;
2643 double V_mid = 9999;
2644 if(readoutPlane==NULL) {
2645 if(myPrintFlag) cout<<
"CgemClusterCreate::fillMCTruth() readoutPlane not found with phi_middle = "<<phi_middle<<
", layer = "<<iLayer<<endl;
2650 V_mid = readoutPlane->
getVFromPhiZ(phi_middle,z_middle);
2658 if(nTruth[0]>=100)
break;
2659 trkID_Layer1[nTruth[0]]=trkID;
2660 pdg_Layer1[nTruth[0]]=pdg;
2661 x_pre_Layer1[nTruth[0]]=x_pre;
2662 y_pre_Layer1[nTruth[0]]=y_pre;
2663 z_pre_Layer1[nTruth[0]]=z_pre;
2664 x_post_Layer1[nTruth[0]]=x_post;
2665 y_post_Layer1[nTruth[0]]=y_post;
2666 z_post_Layer1[nTruth[0]]=z_post;
2667 phi_Layer1[nTruth[0]]=atan2(y_post+y_pre,x_post+x_pre);
2668 z_Layer1[nTruth[0]]=z_middle;
2669 V_Layer1[nTruth[0]]=V_mid;
2670 px_pre_Layer1[nTruth[0]]=px_pre;
2671 py_pre_Layer1[nTruth[0]]=py_pre;
2672 pz_pre_Layer1[nTruth[0]]=pz_pre;
2673 en_Layer1[nTruth[0]]=en;
2676 if(nTruth[1]>=100)
break;
2677 trkID_Layer2[nTruth[1]]=trkID;
2678 pdg_Layer2[nTruth[1]]=pdg;
2679 x_pre_Layer2[nTruth[1]]=x_pre;
2680 y_pre_Layer2[nTruth[1]]=y_pre;
2681 z_pre_Layer2[nTruth[1]]=z_pre;
2682 x_post_Layer2[nTruth[1]]=x_post;
2683 y_post_Layer2[nTruth[1]]=y_post;
2684 z_post_Layer2[nTruth[1]]=z_post;
2685 phi_Layer2[nTruth[1]]=atan2(y_post+y_pre,x_post+x_pre);
2686 z_Layer2[nTruth[1]]=z_middle;
2687 V_Layer2[nTruth[1]]=V_mid;
2688 px_pre_Layer2[nTruth[1]]=px_pre;
2689 py_pre_Layer2[nTruth[1]]=py_pre;
2690 pz_pre_Layer2[nTruth[1]]=pz_pre;
2691 en_Layer2[nTruth[1]]=en;
2694 if(nTruth[2]>=100)
break;
2695 trkID_Layer3[nTruth[2]]=trkID;
2696 pdg_Layer3[nTruth[2]]=pdg;
2697 x_pre_Layer3[nTruth[2]]=x_pre;
2698 y_pre_Layer3[nTruth[2]]=y_pre;
2699 z_pre_Layer3[nTruth[2]]=z_pre;
2700 x_post_Layer3[nTruth[2]]=x_post;
2701 y_post_Layer3[nTruth[2]]=y_post;
2702 z_post_Layer3[nTruth[2]]=z_post;
2703 phi_Layer3[nTruth[2]]=atan2(y_post+y_pre,x_post+x_pre);
2704 z_Layer3[nTruth[2]]=z_middle;
2705 V_Layer3[nTruth[2]]=V_mid;
2706 px_pre_Layer3[nTruth[2]]=px_pre;
2707 py_pre_Layer3[nTruth[2]]=py_pre;
2708 pz_pre_Layer3[nTruth[2]]=pz_pre;
2709 en_Layer3[nTruth[2]]=en;
2712 cout<<
"wrong layer ID for CGEM: "<<iLayer<<endl;
2716 for(
int i=0; i<3; i++)
if(nTruth[i]>100) nTruth[i]=100;
2720 myNTupleHelper->
fillArrayInt(
"pdgmc",
"nmc",(
int*)mcPDG,i_mc);
2721 myNTupleHelper->
fillArray(
"pmc",
"nmc",(
double*)Pmc,i_mc);
2722 myNTupleHelper->
fillArray(
"costhmc",
"nmc",(
double*)costhmc,i_mc);
2723 myNTupleHelper->
fillArray(
"phimc",
"nmc",(
double*)phimc,i_mc);
2725 myNTupleHelper->
fillArrayInt(
"trkID_Layer1",
"nTruthLay1",(
int*) trkID_Layer1, nTruth[0]);
2726 myNTupleHelper->
fillArrayInt(
"pdg_Layer1",
"nTruthLay1",(
int*) pdg_Layer1, nTruth[0]);
2727 myNTupleHelper->
fillArray(
"x_pre_Layer1",
"nTruthLay1",(
double*) x_pre_Layer1, nTruth[0]);
2728 myNTupleHelper->
fillArray(
"y_pre_Layer1",
"nTruthLay1",(
double*) y_pre_Layer1, nTruth[0]);
2729 myNTupleHelper->
fillArray(
"z_pre_Layer1",
"nTruthLay1",(
double*) z_pre_Layer1, nTruth[0]);
2730 myNTupleHelper->
fillArray(
"x_post_Layer1",
"nTruthLay1",(
double*) x_post_Layer1, nTruth[0]);
2731 myNTupleHelper->
fillArray(
"y_post_Layer1",
"nTruthLay1",(
double*) y_post_Layer1, nTruth[0]);
2732 myNTupleHelper->
fillArray(
"z_post_Layer1",
"nTruthLay1",(
double*) z_post_Layer1, nTruth[0]);
2733 myNTupleHelper->
fillArray(
"px_pre_Layer1",
"nTruthLay1",(
double*) px_pre_Layer1, nTruth[0]);
2734 myNTupleHelper->
fillArray(
"py_pre_Layer1",
"nTruthLay1",(
double*) py_pre_Layer1, nTruth[0]);
2735 myNTupleHelper->
fillArray(
"pz_pre_Layer1",
"nTruthLay1",(
double*) pz_pre_Layer1, nTruth[0]);
2736 myNTupleHelper->
fillArray(
"en_Layer1",
"nTruthLay1",(
double*) en_Layer1, nTruth[0]);
2737 myNTupleHelper->
fillArray(
"phi_Layer1",
"nTruthLay1",(
double*) phi_Layer1, nTruth[0]);
2738 myNTupleHelper->
fillArray(
"V_Layer1",
"nTruthLay1",(
double*) V_Layer1, nTruth[0]);
2740 myNTupleHelper->
fillArrayInt(
"trkID_Layer2",
"nTruthLay2",(
int*) trkID_Layer2, nTruth[1]);
2741 myNTupleHelper->
fillArrayInt(
"pdg_Layer2",
"nTruthLay2",(
int*) pdg_Layer2, nTruth[1]);
2742 myNTupleHelper->
fillArray(
"x_pre_Layer2",
"nTruthLay2",(
double*) x_pre_Layer2, nTruth[1]);
2743 myNTupleHelper->
fillArray(
"y_pre_Layer2",
"nTruthLay2",(
double*) y_pre_Layer2, nTruth[1]);
2744 myNTupleHelper->
fillArray(
"z_pre_Layer2",
"nTruthLay2",(
double*) z_pre_Layer2, nTruth[1]);
2745 myNTupleHelper->
fillArray(
"x_post_Layer2",
"nTruthLay2",(
double*) x_post_Layer2, nTruth[1]);
2746 myNTupleHelper->
fillArray(
"y_post_Layer2",
"nTruthLay2",(
double*) y_post_Layer2, nTruth[1]);
2747 myNTupleHelper->
fillArray(
"z_post_Layer2",
"nTruthLay2",(
double*) z_post_Layer2, nTruth[1]);
2748 myNTupleHelper->
fillArray(
"px_pre_Layer2",
"nTruthLay2",(
double*) px_pre_Layer2, nTruth[1]);
2749 myNTupleHelper->
fillArray(
"py_pre_Layer2",
"nTruthLay2",(
double*) py_pre_Layer2, nTruth[1]);
2750 myNTupleHelper->
fillArray(
"pz_pre_Layer2",
"nTruthLay2",(
double*) pz_pre_Layer2, nTruth[1]);
2751 myNTupleHelper->
fillArray(
"en_Layer2",
"nTruthLay2",(
double*) en_Layer2, nTruth[1]);
2752 myNTupleHelper->
fillArray(
"phi_Layer2",
"nTruthLay2",(
double*) phi_Layer2, nTruth[1]);
2753 myNTupleHelper->
fillArray(
"V_Layer2",
"nTruthLay2",(
double*) V_Layer2, nTruth[1]);
2755 myNTupleHelper->
fillArrayInt(
"trkID_Layer3",
"nTruthLay3",(
int*) trkID_Layer3, nTruth[2]);
2756 myNTupleHelper->
fillArrayInt(
"pdg_Layer3",
"nTruthLay3",(
int*) pdg_Layer3, nTruth[2]);
2757 myNTupleHelper->
fillArray(
"x_pre_Layer3",
"nTruthLay3",(
double*) x_pre_Layer3, nTruth[2]);
2758 myNTupleHelper->
fillArray(
"y_pre_Layer3",
"nTruthLay3",(
double*) y_pre_Layer3, nTruth[2]);
2759 myNTupleHelper->
fillArray(
"z_pre_Layer3",
"nTruthLay3",(
double*) z_pre_Layer3, nTruth[2]);
2760 myNTupleHelper->
fillArray(
"x_post_Layer3",
"nTruthLay3",(
double*) x_post_Layer3, nTruth[2]);
2761 myNTupleHelper->
fillArray(
"y_post_Layer3",
"nTruthLay3",(
double*) y_post_Layer3, nTruth[2]);
2762 myNTupleHelper->
fillArray(
"z_post_Layer3",
"nTruthLay3",(
double*) z_post_Layer3, nTruth[2]);
2763 myNTupleHelper->
fillArray(
"px_pre_Layer3",
"nTruthLay3",(
double*) px_pre_Layer3, nTruth[2]);
2764 myNTupleHelper->
fillArray(
"py_pre_Layer3",
"nTruthLay3",(
double*) py_pre_Layer3, nTruth[2]);
2765 myNTupleHelper->
fillArray(
"pz_pre_Layer3",
"nTruthLay3",(
double*) pz_pre_Layer3, nTruth[2]);
2766 myNTupleHelper->
fillArray(
"en_Layer3",
"nTruthLay3",(
double*) en_Layer3, nTruth[2]);
2767 myNTupleHelper->
fillArray(
"phi_Layer3",
"nTruthLay3",(
double*) phi_Layer3, nTruth[2]);
2768 myNTupleHelper->
fillArray(
"V_Layer3",
"nTruthLay3",(
double*) V_Layer3, nTruth[2]);
2773void CgemClusterCreate::checkRecCgemClusterCol()
2775 SmartDataPtr<RecCgemClusterCol> aCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
2778 RecCgemClusterCol::iterator iter_cluster=aCgemClusterCol->begin();
2779 int nCluster = aCgemClusterCol->size();
2780 cout<<
"~~~~~~~~~~~~~~~~~~~~~~~~ check RecCgemClusterCol:"<<endl;
2781 cout <<setw(10)<<
"idx"
2784 <<setw(10)<<
"XVFlag"
2791 for(; iter_cluster!=aCgemClusterCol->end(); iter_cluster++)
2793 cout <<setw(10)<<(*iter_cluster)->getclusterid()
2794 <<setw(10)<<(*iter_cluster)->getlayerid()
2795 <<setw(10)<<(*iter_cluster)->getsheetid()
2796 <<setw(10)<<(*iter_cluster)->getflag()
2797 <<setw(10)<<(*iter_cluster)->getclusterflagb()
2798 <<setw(10)<<(*iter_cluster)->getclusterflage()
2799 <<setw(15)<<setprecision(10)<<(*iter_cluster)->getrecphi()
2800 <<setw(15)<<setprecision(10)<<(*iter_cluster)->getrecv()
2801 <<setw(15)<<setprecision(10)<<(*iter_cluster)->getRecZ()
2804 cout<<
"~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
2806 else cout<<
"CgemClusterCreate::checkRecCgemClusterCol(): RecCgemClusterCol not accessible!"<<endl;
2809bool CgemClusterCreate::isGoodDigi(CgemDigiCol::iterator
iter)
2811 double time = (*iter)->getTime_ns();
2814 double Q = (*iter)->getCharge_fc();
2815 if(Q<0.)
return false;
2820bool CgemClusterCreate::selDigi(CgemDigiCol::iterator
iter,
int sel)
2822 if(sel==0)
return true;
2824 double time = (*iter)->getTime_ns();
2825 bool timeIsGood=
true;
2828 double Q = (*iter)->getCharge_fc();
2829 bool chargeIsGood=
true;
2830 if(Q<myQMin) chargeIsGood=
false;
2832 const Identifier ident = (*iter)->identify();
2838 if(is_xstrip ==
true) view = 0;
2839 int quality = lutreader->
GetQuality(layer, sheet, view, strip);
2840 bool qualityIsGood=
true;
2841 if(quality!=0) qualityIsGood=
false;
2843 if(sel==1)
return timeIsGood&&chargeIsGood;
2844 else if(sel==-1)
return !timeIsGood&&chargeIsGood;
2845 else if(sel==2)
return timeIsGood&&chargeIsGood&&qualityIsGood;
2851float CgemClusterCreate::get_Time(CgemDigiCol::iterator iDigiCol){
2853 float time = (*iDigiCol)->getTime_ns();
2855 float time_rising = get_TimeRising(iDigiCol);
2857 float time_walk = get_TimeWalk(iDigiCol);
2859 float time_reference = get_TimeReference(iDigiCol);
2861 float time_shift_custom = -35;
2863 time-=(time_rising+time_walk+time_reference+time_shift_custom);
2868float CgemClusterCreate::get_TimeRising(CgemDigiCol::iterator iDigiCol){
2869 float time_rising=0;
2871 const Identifier ident = (*iDigiCol)->identify();
2877 if(is_xstrip ==
true) view = 0;
2878 float charge = (*iDigiCol)->getCharge_fc();
2880 time_rising = myCgemCalibSvc->
getTimeRising(layerid, view, sheetid, stripid, charge, 0.);
2884float CgemClusterCreate::get_TimeWalk(CgemDigiCol::iterator iDigiCol){
2886 const Identifier ident = (*iDigiCol)->identify();
2892 if(is_xstrip ==
true) view = 0;
2893 float thr = lutreader->
Get_thr_T_fC(layerid, sheetid, view, stripid);
2894 float charge = (*iDigiCol)->getChargeChannel();
2895 time_walk = myCgemCalibSvc->
getTimeWalk(charge,thr);
2899float CgemClusterCreate::get_TimeReference(CgemDigiCol::iterator iDigiCol){
2900 float time_reference=0;
2901 const Identifier ident = (*iDigiCol)->identify();
2907 if(is_xstrip ==
true) view = 0;
2910 return time_reference;
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
double abs(const EvtComplex &c)
************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
ObjectVector< RecCgemCluster > RecCgemClusterCol
*************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
int getNumberOfChannelX() const
bool getOrientation() const
double getOuterROfAnodeCu2() const
double getInnerROfAnodeCu2() const
double getVFromPhiZ(double phi, double z, bool checkRange=true) 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 getVInNextSheetFromV(double v, double phiminNext) const
CgemGeoLayer * getCgemLayer(int i) const
int 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)
float GetSignal_StartTime_ns(int ilayer, int isheet, int iview, int istrip)
int GetQuality(int ilayer, int isheet, int iview, int istrip)
float Get_thr_T_fC(int ilayer, int isheet, int iview, int istrip)
float GetSignal_FEBStartTime_ns(int ilayer, int isheet, int iview, int istrip)
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
virtual double getTimeWalk(int layer, int xvFlag, int sheet, int stripID, double Q) const =0
virtual CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) 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)
void setInter_mTPC(double q)
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