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");
90 if(myMethod==0) reset();
91 else if(myMethod==1||myMethod==3) resetFiredStripMap();
103 MsgStream log(
msgSvc(), name());
104 log << MSG::INFO <<
"in initialize()" << endreq;
119 tsc = service(
"BesTimerSvc", m_timersvc);
120 if( tsc.isFailure() )
122 log << MSG::WARNING << name() <<
" Unable to locate BesTimerSvc" << endreq;
123 return StatusCode::FAILURE;
125 m_timer = m_timersvc->
addItem(
"Execution");
127 if(myNtuple) myNTupleHelper=
new NTupleHelper(
ntupleSvc()->book(
"RecCgem/CgemCluster",CLID_ColumnWiseTuple,
"CgemCluster"));
129 if(myMethod==0||myMethod==2) {
130 if(myNtuple) hist_def();
134 ISvcLocator* svcLocator = Gaudi::svcLocator();
136 StatusCode sc=svcLocator->service(
"CgemGeomSvc", ISvc);
139 if (!sc.isSuccess()) log<< MSG::INFO <<
"CgemClusterCreate::initialize(): Could not open CGEM geometry file" << endreq;
141 if(myPrintFlag) cout<<
"CgemClusterCreate::initialize() "<<myNCgemLayers<<
" Cgem layers"<<endl;
142 for(
int i=0; i<myNCgemLayers; i++)
153 if(myPrintFlag) cout<<
"layer "<<i<<
": "<<myNSheets[i]<<
" sheets"<<
", is reversed "<<IsReverse<<
", RX="<<myRXstrips[i]<<
", RY="<<myRVstrips[i]<<endl;
157 sc = service (
"CgemCalibFunSvc", myCgemCalibSvc);
158 if ( sc.isFailure() ){
159 cout<< name() <<
"Could not load MdcCalibFunSvc!" << endl;
169 return StatusCode::SUCCESS;
174 MsgStream log(
msgSvc(), name());
175 log << MSG::INFO <<
"in execute()" << endreq;
178 DataObject *aReconEvent;
179 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
180 if(aReconEvent==NULL) {
182 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon",aReconEvent);
183 if(sc!=StatusCode::SUCCESS) {
184 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
185 return( StatusCode::FAILURE);
190 if(myMethod==0) method0();
191 else if(myMethod==1) method1();
192 else if(myMethod==2) toyCluster();
193 else if(myMethod==3) method2();
196 return StatusCode::SUCCESS;
199StatusCode CgemClusterCreate::method0()
204 MsgStream log(
msgSvc(), name());
205 log << MSG::INFO <<
"in method0()" << endreq;
211 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
214 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
215 return StatusCode::FAILURE;
217 int run=evtHead->runNumber();
218 int evt=evtHead->eventNumber();
223 cout<<
"-----------------------------------------------"<<endl;
224 cout<<
"CgemClusterCreate::execute: run "<<run<<
", evt "<<evt<<endl;
228 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
231 log << MSG::WARNING <<
"Could not retrieve Cgem digi list" << endreq;
232 return StatusCode::FAILURE;
236 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
237 int layerid,sheetid,stripid,time_chnnel;
238 double energydeposit;
239 double nXStrips[3]={0,0,0};
240 double nVStrips[3]={0,0,0};
241 for( ; iter_digi != cgemDigiCol->end(); ++iter_digi)
246 energydeposit = (*iter_digi)->getChargeChannel();
247 time_chnnel = (*iter_digi)->getTimeChannel();
250 if(striptype ==
true)
253 nXStrips[layerid]+=1;
257 nVStrips[layerid]+=1;
261 if(iter_digi==cgemDigiCol->begin())
263 cout<<
"cgemDigiCol:"<<endl;
267 <<setw(10)<<
"XV(0/1)"
268 <<setw(10)<<
"strip_ID"
278 <<setw(15)<<setprecision(10)<<energydeposit
279 <<setw(15)<<setprecision(10)<<time_chnnel
282 m_strip[layerid][sheetid][flagxv][stripid] = 1;
283 m_edep[layerid][sheetid][flagxv][stripid] = energydeposit;
295 IDataProviderSvc* evtSvc = NULL;
296 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
298 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
300 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
301 return StatusCode::SUCCESS;
304 StatusCode clustersc;
305 IDataManagerSvc *dataManSvc;
306 dataManSvc=
dynamic_cast<IDataManagerSvc*
>(evtSvc);
307 DataObject *aClusterCol;
308 evtSvc->findObject(
"/Event/Recon/RecCgemClusterCol",aClusterCol);
309 if(aClusterCol != NULL) {
310 dataManSvc->clearSubTree(
"/Event/Recon/RecCgemClusterCol");
311 evtSvc->unregisterObject(
"/Event/Recon/RecCgemClusterCol");
314 clustersc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", clustercol);
315 if( clustersc.isFailure() ) {
316 log << MSG::FATAL <<
"Could not register RecCgemCluster" << endreq;
317 return StatusCode::SUCCESS;
319 log << MSG::INFO <<
"RecCgemClusterCol registered successfully!" <<endreq;
322 for(m_x_map_it = m_x_map.begin();m_x_map_it!=m_x_map.end();++m_x_map_it){
324 clustercol->push_back(reccluster);
326 for(m_v_map_it = m_v_map.begin();m_v_map_it!=m_v_map.end();++m_v_map_it){
328 clustercol->push_back(reccluster);
330 for(m_xv_map_it = m_xv_map.begin();m_xv_map_it!=m_xv_map.end();++m_xv_map_it){
332 clustercol->push_back(reccluster);
336 SmartDataPtr<RecCgemClusterCol> cgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
337 if (!cgemClusterCol){
338 log << MSG::WARNING <<
"Could not retrieve Cgem cluster list" << endreq;
339 return StatusCode::FAILURE;
342 m_evt = evtHead->eventNumber();
343 m_evt1 = evtHead->eventNumber();
346 RecCgemClusterCol::iterator iter_cluster = cgemClusterCol->begin();
348 for( ; iter_cluster != cgemClusterCol->end(); ++iter_cluster){
349 if((*iter_cluster)->getflag()==2){
351 m_layerid[ii] = (*iter_cluster)->getlayerid();
352 m_sheetid[ii] = (*iter_cluster)->getsheetid();
353 m_clusterid[ii]= (*iter_cluster)->getclusterid();
354 m_flag[ii] = (*iter_cluster)->getflag();
355 m_energy[ii] = (*iter_cluster)->getenergydeposit();
356 m_recphi[ii] = (*iter_cluster)->getrecphi();
357 m_recv[ii] = (*iter_cluster)->getrecv();
371 return StatusCode::SUCCESS;
374StatusCode CgemClusterCreate::method1()
379 MsgStream log(
msgSvc(), name());
380 log << MSG::INFO <<
"in method1()" << endreq;
383 resetFiredStripMap();
386 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
389 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
390 return StatusCode::FAILURE;
392 int run=evtHead->runNumber();
393 int evt=evtHead->eventNumber();
398 cout<<
"-----------------------------------------------"<<endl;
399 cout<<
"CgemClusterCreate::execute: run "<<run<<
", evt "<<evt<<endl;
402 if(run<0) fillMCTruth();
404 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
407 log << MSG::WARNING <<
"Could not retrieve Cgem digi list" << endreq;
408 return StatusCode::FAILURE;
412 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
413 int layerid,sheetid,stripid,time_chnnel;
414 double energydeposit;
416 double nXStrips[3]={0,0,0};
417 double nVStrips[3]={0,0,0};
418 bool printed =
false;
419 for( ; iter_digi != cgemDigiCol->end(); ++iter_digi)
423 if(!selDigi(iter_digi,m_selGoodDigi))
continue;
427 energydeposit = (*iter_digi)->getChargeChannel();
428 time_chnnel = (*iter_digi)->getTimeChannel();
429 Q_fC = (*iter_digi)->getCharge_fc();
430 T_ns = (*iter_digi)->getTime_ns();
433 if(striptype ==
true)
436 nXStrips[layerid]+=1;
440 nVStrips[layerid]+=1;
447 cout<<
"cgemDigiCol:"<<endl;
451 <<setw(10)<<
"XV(0/1)"
452 <<setw(10)<<
"strip_ID"
465 <<setw(15)<<setprecision(10)<<Q_fC
466 <<setw(15)<<setprecision(10)<<T_ns
469 myFiredStripMap[layerid][sheetid][flagxv][stripid]=iter_digi;
473 SmartDataPtr<RecCgemClusterCol> lastCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
474 IDataProviderSvc* evtSvc = NULL;
475 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
477 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
479 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
480 return StatusCode::SUCCESS;
482 if(lastCgemClusterCol) {
483 evtSvc->unregisterObject(
"/Event/Recon/RecCgemClusterCol");
488 sc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", aCgemClusterCol);
491 log << MSG::FATAL <<
"Could not register RecCgemClusterCol" << endreq;
492 return StatusCode::SUCCESS;
496 if(myPrintFlag) cout<<
"--------------------------------------------"<<endl;
498 double sumQ(0.0),sumQX(0.0);
500 int nCluster[3][3]={{0,0,0},{0,0,0},{0,0,0}};
501 double posX[3][100],posZ[3][100],posV[3][100],phi_XV[3][100];
502 double QX[3][100],QV[3][100],QX_XV[3][100],QV_XV[3][100];
503 int nStripsX[3][100],nStripsV[3][100];
505 vector<int> iStart_cluster[3][2][2];
506 vector<int> iEnd_cluster[3][2][2];
507 vector<double> E_cluster[3][2][2];
508 vector<int> id_cluster[3][2][3];
509 vector<double> vecPos_cluster[3][2][3];
510 vector<int> idxCluster[3][2][2];
511 vector<int> idxBoundaryXVcluster[3][2][2];
514 for(
int i=0; i<3; i++)
516 if(myPrintFlag) cout<<
"---- layer "<<i<<
" ----"<<endl;
517 for(
int j=0; j<myNSheets[i]; j++)
519 if(myPrintFlag) cout<<
"---- sheet "<<j<<
":: "<<endl;
521 for(
int k=0; k<2; k++)
523 if(myPrintFlag) cout<<
"---- XV "<<k<<
": "<<endl;
525 map<int,CgemDigiCol::iterator>::iterator
iter=myFiredStripMap[i][j][k].begin();
526 map<int,CgemDigiCol::iterator>::iterator iter_end=myFiredStripMap[i][j][k].end();
527 int i1(-1),i2(-1),idLast(-2);
530 if((
iter->first-idLast)>1)
534 double posCluster(9999.);
536 posCluster = sumQX/sumQ;
538 if(k==0) cout<<
"find X cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" rad"<<endl;
539 if(k==1) cout<<
"find V cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" mm"<<endl;
541 int clusterId=aCgemClusterCol->size();
542 iStart_cluster[i][j][k].push_back(i1);
543 iEnd_cluster[i][j][k].push_back(i2);
544 vecPos_cluster[i][j][k].push_back(posCluster);
545 E_cluster[i][j][k].push_back(sumQ);
546 id_cluster[i][j][k].push_back(clusterId);
555 if(k==0) pt_recCluster->
setrecphi(posCluster);
556 if(k==1) pt_recCluster->
setrecv(posCluster);
557 aCgemClusterCol->push_back(pt_recCluster);
559 if(k==0&&nCluster[i][k]<100)
561 posX[i][nCluster[i][k]]=posCluster;
562 QX[i][nCluster[i][k]]=sumQ;
563 nStripsX[i][nCluster[i][k]]=i2-i1+1;
568 if(nCluster[i][k]<100) {
569 nStripsV[i][nCluster[i][k]]=i2-i1+1;
570 posV[i][nCluster[i][k]]=posCluster;
571 QV[i][nCluster[i][k]]=sumQ;
573 int nXCluster=iStart_cluster[i][j][0].size();
574 for(
int iX=0; iX<nXCluster; iX++)
576 double Z_pos = readoutPlane->
getZFromPhiV(vecPos_cluster[i][j][0][iX],posCluster);
578 if(readoutPlane->
OnThePlane(vecPos_cluster[i][j][0][iX],Z_pos))
580 if(myPrintFlag) cout<<
"find a XV cluster, Z="<<Z_pos<<endl;
581 int iV=iStart_cluster[i][j][1].size()-1;
582 clusterId=aCgemClusterCol->size();
583 vecPos_cluster[i][j][2].push_back(Z_pos);
584 id_cluster[i][j][2].push_back(clusterId);
585 idxCluster[i][j][0].push_back(iX);
586 idxCluster[i][j][1].push_back(iV);
593 pt2_recCluster->
setclusterflag(id_cluster[i][j][0][iX],id_cluster[i][j][1][iV]);
594 pt2_recCluster->
setrecphi(vecPos_cluster[i][j][0][iX]);
595 pt2_recCluster->
setrecv(vecPos_cluster[i][j][1][iV]);
596 pt2_recCluster->
setRecZ(Z_pos);
598 aCgemClusterCol->push_back(pt2_recCluster);
600 if(nCluster[i][2]<100) {
601 posZ[i][nCluster[i][2]]=Z_pos;
602 phi_XV[i][nCluster[i][2]]=vecPos_cluster[i][j][0][iX];
604 if( (iEnd_cluster[i][j][0][iX]+1)==readoutPlane->
getNXstrips() )
605 idxBoundaryXVcluster[i][j][0].push_back(idxCluster[i][j][1].size()-1);
606 if(iStart_cluster[i][j][0][iX]==0)
607 idxBoundaryXVcluster[i][j][1].push_back(idxCluster[i][j][1].size()-1);
615 cout<<
"sumQ<=0!: sumQX,sumQ="<<sumQX<<
","<<sumQ<<endl;
627 if(myPrintFlag) cout<<
"fired strip "<<idLast<<endl;
629 double energy=(*(
iter->second))->getCharge_fc();
639 double posCluster(9999.);
641 posCluster = sumQX/sumQ;
643 if(k==0) cout<<
"find X cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" rad"<<endl;
644 if(k==1) cout<<
"find V cluster "<<nCluster[i][k]<<
" from strip "<<i1<<
" to "<<i2<<
", position = "<<posCluster<<
" mm"<<endl;
646 int clusterId=aCgemClusterCol->size();
647 iStart_cluster[i][j][k].push_back(i1);
648 iEnd_cluster[i][j][k].push_back(i2);
649 vecPos_cluster[i][j][k].push_back(posCluster);
650 E_cluster[i][j][k].push_back(sumQ);
651 id_cluster[i][j][k].push_back(clusterId);
660 if(k==0) pt_recCluster->
setrecphi(posCluster);
661 if(k==1) pt_recCluster->
setrecv(posCluster);
662 aCgemClusterCol->push_back(pt_recCluster);
664 if(k==0&&nCluster[i][k]<100) {
665 posX[i][nCluster[i][k]]=posCluster;
666 QX[i][nCluster[i][k]]=sumQ;
667 nStripsX[i][nCluster[i][k]]=i2-i1+1;
672 if(nCluster[i][k]<100) {
673 nStripsV[i][nCluster[i][k]]=i2-i1+1;
674 posV[i][nCluster[i][k]]=posCluster;
675 QV[i][nCluster[i][k]]=sumQ;
677 int nXCluster=iStart_cluster[i][j][0].size();
678 for(
int iX=0; iX<nXCluster; iX++)
680 double Z_pos = readoutPlane->
getZFromPhiV(vecPos_cluster[i][j][0][iX],posCluster);
682 if(readoutPlane->
OnThePlane(vecPos_cluster[i][j][0][iX],Z_pos))
684 if(myPrintFlag) cout<<
"find a XV cluster, Z="<<Z_pos<<endl;
685 clusterId=aCgemClusterCol->size();
686 vecPos_cluster[i][j][2].push_back(Z_pos);
687 id_cluster[i][j][2].push_back(clusterId);
688 int iV=iStart_cluster[i][j][1].size()-1;
695 pt2_recCluster->
setclusterflag(id_cluster[i][j][0][iX],id_cluster[i][j][1][iV]);
696 pt2_recCluster->
setrecphi(vecPos_cluster[i][j][0][iX]);
697 pt2_recCluster->
setrecv(vecPos_cluster[i][j][1][iV]);
698 pt2_recCluster->
setRecZ(Z_pos);
700 aCgemClusterCol->push_back(pt2_recCluster);
702 if(nCluster[i][2]<100) {
703 posZ[i][nCluster[i][2]]=Z_pos;
704 phi_XV[i][nCluster[i][2]]=vecPos_cluster[i][j][0][iX];
706 idxCluster[i][j][0].push_back(iX);
707 idxCluster[i][j][1].push_back(iEnd_cluster[i][j][1].size()-1);
708 if( (iEnd_cluster[i][j][0][iX]+1)==readoutPlane->
getNXstrips() )
709 idxBoundaryXVcluster[i][j][0].push_back(idxCluster[i][j][1].size()-1);
710 if(iStart_cluster[i][j][0][iX]==0)
711 idxBoundaryXVcluster[i][j][1].push_back(idxCluster[i][j][1].size()-1);
718 else cout<<
"sumQ<=0!: sumQX,sumQ="<<sumQX<<
","<<sumQ<<endl;
725 if(nCluster[i][0]>100) nCluster[i][0]=100;
726 if(nCluster[i][1]>100) nCluster[i][1]=100;
727 if(nCluster[i][2]>100) nCluster[i][2]=100;
730 for(
int j=0; j<myNSheets[i]; j++)
734 if(j_next==myNSheets[i]) j_next=0;
738 double xmin_next = nextReadoutPlane->
getXmin();
740 int nXV_atXEnd=idxBoundaryXVcluster[i][j][0].size();
741 int nXV_atXStart=idxBoundaryXVcluster[i][j_next][1].size();
742 if(nXV_atXEnd==0||nXV_atXStart==0)
continue;
743 for(
int iXV_atXEnd=0; iXV_atXEnd<nXV_atXEnd; iXV_atXEnd++)
745 int iXVCluster = idxBoundaryXVcluster[i][j][0][iXV_atXEnd];
746 int iXCluster = idxCluster[i][j][0][iXVCluster];
747 int iVCluster = idxCluster[i][j][1][iXVCluster];
748 int VID1=iStart_cluster[i][j][1][iVCluster];
749 int VID2=iEnd_cluster[i][j][1][iVCluster];
752 for(
int iXV_atXStart=0; iXV_atXStart<nXV_atXStart; iXV_atXStart++)
754 int iXVCluster_next = idxBoundaryXVcluster[i][j_next][1][iXV_atXStart];
755 int iXCluster_next = idxCluster[i][j_next][0][iXVCluster_next];
756 int iVCluster_next = idxCluster[i][j_next][1][iXVCluster_next];
757 int VID1_next=iStart_cluster[i][j_next][1][iVCluster_next];
758 int VID2_next=iEnd_cluster[i][j_next][1][iVCluster_next];
759 if( !( (VID1_next-VID2_extend)>1 || (VID1_extend-VID2_next)>1 ) )
761 int XID1=iStart_cluster[i][j][0][iXCluster];
762 int XID2=iEnd_cluster[i][j][0][iXCluster];
763 int XID1_next=iStart_cluster[i][j_next][0][iXCluster_next];
764 int XID2_next=iEnd_cluster[i][j_next][0][iXCluster_next];
765 int clusterId=aCgemClusterCol->size();
772 int id1=id_cluster[i][j][2][iXVCluster];
773 int id2=id_cluster[i][j_next][2][iXVCluster_next];
776 double phi1=vecPos_cluster[i][j][0][iXCluster];
777 double phi2=vecPos_cluster[i][j_next][0][iXCluster_next];
783 double E1=E_cluster[i][j][0][iXCluster];
784 double E2=E_cluster[i][j_next][0][iXCluster_next];
785 double phiAverage=(E1*
phi1+E2*
phi2)/(E1+E2);
788 double v1=vecPos_cluster[i][j][1][iVCluster];
790 double v2=vecPos_cluster[i][j_next][1][iVCluster_next];
791 E1=E_cluster[i][j][1][iVCluster];
792 E2=E_cluster[i][j_next][1][iVCluster_next];
793 double V_average_next=(E1*v1+E2*v2)/(E1+E2);
794 pt_recCluster->
setrecv(V_average_next);
796 double z_average = nextReadoutPlane->
getZFromPhiV(phiAverage,V_average_next,0);
797 pt_recCluster->
setRecZ(z_average);
799 aCgemClusterCol->push_back(pt_recCluster);
802 cout<<
"one combinational cluster found: "<<endl;
803 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;
804 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;
805 cout<<
" averagePhi:"<<phiAverage<<
", v_average:"<<V_average_next<<
", z_average:"<<z_average<<endl;
817 double evttime=m_timer->
elapsed();
820 if(myPrintFlag) checkRecCgemClusterCol();
824 myNTupleHelper->
fillLong(
"run",(
long)run);
825 myNTupleHelper->
fillLong(
"evt",(
long)evt);
827 myNTupleHelper->
fillArray(
"nXstrips",
"nLayer",(
double*) nXStrips,3);
828 myNTupleHelper->
fillArray(
"nVstrips",
"nLayer",(
double*) nVStrips,3);
830 myNTupleHelper->
fillArray(
"phiClusterLay1",
"nXClusterLay1",(
double*) posX[0],nCluster[0][0]);
831 myNTupleHelper->
fillArrayInt(
"nXStripsLay1",
"nXClusterLay1",(
int*) nStripsX[0],nCluster[0][0]);
832 myNTupleHelper->
fillArray(
"QXLay1",
"nXClusterLay1",(
double*) QX[0],nCluster[0][0]);
834 myNTupleHelper->
fillArray(
"VClusterLay1",
"nVClusterLay1",(
double*) posV[0],nCluster[0][1]);
835 myNTupleHelper->
fillArrayInt(
"nVStripsLay1",
"nVClusterLay1",(
int*) nStripsV[0],nCluster[0][1]);
836 myNTupleHelper->
fillArray(
"QVLay1",
"nVClusterLay1",(
double*) QV[0],nCluster[0][1]);
838 myNTupleHelper->
fillArray(
"zClusterLay1",
"nXVClusterLay1",(
double*) posZ[0],nCluster[0][2]);
839 myNTupleHelper->
fillArray(
"phiXVClusterLay1",
"nXVClusterLay1",(
double*) phi_XV[0],nCluster[0][2]);
841 myNTupleHelper->
fillArray(
"phiClusterLay2",
"nXClusterLay2",(
double*) posX[1],nCluster[1][0]);
842 myNTupleHelper->
fillArrayInt(
"nXStripsLay2",
"nXClusterLay2",(
int*) nStripsX[1],nCluster[1][0]);
843 myNTupleHelper->
fillArray(
"QXLay2",
"nXClusterLay2",(
double*) QX[1],nCluster[1][0]);
845 myNTupleHelper->
fillArray(
"VClusterLay2",
"nVClusterLay2",(
double*) posV[1],nCluster[1][1]);
846 myNTupleHelper->
fillArrayInt(
"nVStripsLay2",
"nVClusterLay2",(
int*) nStripsV[1],nCluster[1][1]);
847 myNTupleHelper->
fillArray(
"QVLay2",
"nVClusterLay2",(
double*) QV[1],nCluster[1][1]);
849 myNTupleHelper->
fillArray(
"zClusterLay2",
"nXVClusterLay2",(
double*) posZ[1],nCluster[1][2]);
850 myNTupleHelper->
fillArray(
"phiXVClusterLay2",
"nXVClusterLay2",(
double*) phi_XV[1],nCluster[1][2]);
852 myNTupleHelper->
fillArray(
"phiClusterLay3",
"nXClusterLay3",(
double*) posX[2],nCluster[2][0]);
853 myNTupleHelper->
fillArrayInt(
"nXStripsLay3",
"nXClusterLay3",(
int*) nStripsX[2],nCluster[2][0]);
854 myNTupleHelper->
fillArray(
"QXLay3",
"nXClusterLay3",(
double*) QX[2],nCluster[2][0]);
856 myNTupleHelper->
fillArray(
"VClusterLay3",
"nVClusterLay3",(
double*) posV[2],nCluster[2][1]);
857 myNTupleHelper->
fillArrayInt(
"nVStripsLay3",
"nVClusterLay3",(
int*) nStripsV[2],nCluster[2][1]);
858 myNTupleHelper->
fillArray(
"QVLay3",
"nVClusterLay3",(
double*) QV[2],nCluster[2][1]);
860 myNTupleHelper->
fillArray(
"zClusterLay3",
"nXVClusterLay3",(
double*) posZ[2],nCluster[2][2]);
861 myNTupleHelper->
fillArray(
"phiXVClusterLay3",
"nXVClusterLay3",(
double*) phi_XV[2],nCluster[2][2]);
863 myNTupleHelper->
fillDouble(
"evtTime",evttime);
865 myNTupleHelper->
write();
867 if(myPrintFlag) cout<<
"End of CgemClusterCreate::method1()"<<endl;
869 return StatusCode::SUCCESS;
872StatusCode CgemClusterCreate::method2()
877 MsgStream log(
msgSvc(), name());
878 log << MSG::INFO <<
"in method1()" << endreq;
881 resetFiredStripMap();
885 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
888 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
889 return StatusCode::FAILURE;
891 int run=evtHead->runNumber();
892 int evt=evtHead->eventNumber();
898 cout<<
"-----------------------------------------------"<<endl;
899 cout<<
"CgemClusterCreate::execute: run "<<run<<
", evt "<<evt<<endl;
902 if(run<0) fillMCTruth();
904 SmartDataPtr<CgemDigiCol> cgemDigiCol(eventSvc(),
"/Event/Digi/CgemDigiCol");
907 log << MSG::WARNING <<
"Could not retrieve Cgem digi list" << endreq;
908 return StatusCode::FAILURE;
912 CgemDigiCol::iterator iter_digi = cgemDigiCol->begin();
913 int layerid,sheetid,stripid,time_chnnel;
914 double energydeposit;
916 double nXStrips[3]={0,0,0};
917 double nVStrips[3]={0,0,0};
918 bool printed =
false;
919 for( ; iter_digi != cgemDigiCol->end(); ++iter_digi)
923 if(!selDigi(iter_digi,m_selGoodDigi))
continue;
927 energydeposit = (*iter_digi)->getChargeChannel();
928 time_chnnel = (*iter_digi)->getTimeChannel();
929 Q_fC = (*iter_digi)->getCharge_fc();
930 T_ns = (*iter_digi)->getTime_ns();
933 if(striptype ==
true)
936 nXStrips[layerid]+=1;
940 nVStrips[layerid]+=1;
947 cout<<
"cgemDigiCol:"<<endl;
951 <<setw(10)<<
"XV(0/1)"
952 <<setw(10)<<
"strip_ID"
965 <<setw(15)<<setprecision(10)<<Q_fC
966 <<setw(15)<<setprecision(10)<<T_ns
969 myFiredStripMap[layerid][sheetid][flagxv][stripid]=iter_digi;
974 SmartDataPtr<RecCgemClusterCol> lastCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
975 IDataProviderSvc* evtSvc = NULL;
976 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
978 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
980 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
981 return StatusCode::SUCCESS;
983 if(lastCgemClusterCol) {
984 evtSvc->unregisterObject(
"/Event/Recon/RecCgemClusterCol");
989 sc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", aCgemClusterCol);
992 log << MSG::FATAL <<
"Could not register RecCgemClusterCol" << endreq;
993 return StatusCode::SUCCESS;
997 if(myPrintFlag) cout<<
"--------------------------------------------"<<endl;
1000 double sumQ(0.0),sumQX(0.0);
1003 vector<double> pos_strips;
1004 vector<double> drift_strips;
1005 vector<double> q_strips;
1006 double tposX[3][100],tposZ[3][100],tposV[3][100];
1007 vector<double> vecTPos_cluster[3][2][3];
1011 double pos_tpc(9999.0), a_tpc(0.0), b_tpc(0.0);
1012 double sum_x_tpc(0.), sum_y_tpc(0.), sum_xx_tpc(0.), sum_yy_tpc(0.), sum_xy_tpc(0.);
1014 double a_tpc_cluster_X[3][100];
1015 double b_tpc_cluster_X[3][100];
1016 double pos_tpc_cluster_X[3][100];
1017 double a_tpc_cluster_V[3][100];
1018 double b_tpc_cluster_V[3][100];
1019 double pos_tpc_cluster_V[3][100];
1022 int nCluster[3][3]={{0,0,0},{0,0,0},{0,0,0}};
1023 double posX[3][100],posZ[3][100],posV[3][100],phi_XV[3][100];
1024 double QX[3][100],QV[3][100],QX_XV[3][100],QV_XV[3][100];
1025 int nStripsX[3][100],nStripsV[3][100];
1026 vector<int> iStart_cluster[3][2][2];
1027 vector<int> iEnd_cluster[3][2][2];
1028 vector<double> E_cluster[3][2][2];
1029 vector<int> id_cluster[3][2][3];
1030 vector<double> vecPos_cluster[3][2][3];
1031 vector<int> idxCluster[3][2][2];
1032 vector<int> idxBoundaryXVcluster[3][2][2];
1035 for(
int i=0; i<3; i++)
1037 if(myPrintFlag) cout<<
"---- layer "<<i<<
" ----"<<endl;
1038 for(
int j=0; j<myNSheets[i]; j++)
1040 if(myPrintFlag) cout<<
"---- sheet "<<j<<
":: "<<endl;
1042 for(
int k=0; k<2; k++)
1044 if(myPrintFlag) cout<<
"---- XV "<<k<<
": "<<endl;
1046 map<int,CgemDigiCol::iterator>::iterator
iter=myFiredStripMap[i][j][k].begin();
1047 map<int,CgemDigiCol::iterator>::iterator iter_end=myFiredStripMap[i][j][k].end();
1048 map<int,CgemDigiCol::iterator>::iterator iter_next=
iter;
1049 int i1(-1),i2(-1),idLast(-2);
1050 bool clusterFound=
true;
1053 if(myPrintFlag) cout<<
"fired strip "<<
iter->first<<endl;
1056 double energy=(*(
iter->second))->getCharge_fc();
1058 double time=(*(
iter->second))->getTime_ns();
1068 pos_strips.push_back(pos);
1072 double time_gap = time_falling-time_rising;
1073 double drift_velocity =
drift_gap/time_gap;
1075 double time_ns=get_Time(
iter->second);
1076 if(myPrintFlag) cout<<
"T_r, T_f = "<<time_rising<<
", "<<time_falling<<
", time_ns="<<
time<<endl;
1077 drift_strips.push_back(time_ns*drift_velocity);
1078 q_strips.push_back(
energy);
1082 double drift = time_ns*drift_velocity;
1085 sum_xx_tpc+=pos*pos;
1086 sum_yy_tpc+=drift*drift;
1087 sum_xy_tpc+=pos*drift;
1098 if(iter_next==iter_end||(iter_next->first-
iter->first)>1)
1101 double posCluster_CC(9999.);
1103 cout<<
"sumQ<=0!: sumQX,sumQ="<<sumQX<<
","<<sumQ<<endl;
1106 posCluster_CC = sumQX/sumQ;
1110 double tposCluster(9999.);
1111 double slope(-9999);
1112 int n_Strips=pos_strips.size();
1115 double *
x =
new double[n_Strips];
1116 double *tx =
new double[n_Strips];
1117 double *ex =
new double[n_Strips];
1118 double *etx =
new double[n_Strips];
1119 for(
int ix=0; ix<n_Strips; ix++)
1121 x[ix] = pos_strips[ix];
1122 tx[ix] = drift_strips[ix];
1126 cout<<
"t = "<<tx[ix]<<
", q = "<<q_strips[ix]<<
", x= "<<
x[ix]<<endl;
1128 TGraphErrors xline(n_Strips, x, tx, ex, etx);
1129 TF1
f1(
"f1",
"[0]*x + [1]", -10000, 10000);
1130 xline.Fit(&
f1,
"Q");
1131 TF1* f2 = xline.GetFunction(
"f1");
1133 f2->GetParameters(xpar);
1134 double *expar=f2->GetParErrors();
1139 tposCluster=(
drift_gap/2.-xpar[1])/xpar[0];
1140 if(fabs(tposCluster)>9999) tposCluster=9999.0;
1150 double slope2(-9999);
1152 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);
1153 b_tpc = (n_tpc*sum_xy_tpc-sum_x_tpc*sum_y_tpc)/(n_tpc*sum_xx_tpc-sum_x_tpc*sum_x_tpc);
1164 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;
1165 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;
1170 int clusterId=aCgemClusterCol->size();
1171 iStart_cluster[i][j][k].push_back(i1);
1172 iEnd_cluster[i][j][k].push_back(i2);
1173 vecPos_cluster[i][j][k].push_back(posCluster_CC);
1174 if(m_selectTPC==1) {
1175 vecTPos_cluster[i][j][k].push_back(tposCluster);
1177 else if(m_selectTPC==2) {
1178 vecTPos_cluster[i][j][k].push_back(pos_tpc);
1181 E_cluster[i][j][k].push_back(sumQ);
1182 id_cluster[i][j][k].push_back(clusterId);
1194 pt_recCluster->
setrecphi(posCluster_CC);
1196 if(m_selectTPC==1) {
1200 else if(m_selectTPC==2) {
1206 pt_recCluster->
setrecv(posCluster_CC);
1208 if(m_selectTPC==1) {
1212 else if(m_selectTPC==2){
1217 aCgemClusterCol->push_back(pt_recCluster);
1221 if(k==0&&nCluster[i][k]<100)
1224 nStripsX[i][nCluster[i][k]]=i2-i1+1;
1225 posX[i][nCluster[i][k]]=posCluster_CC;
1226 QX[i][nCluster[i][k]]=sumQ;
1229 tposX[i][nCluster[i][k]]=tposCluster;
1232 a_tpc_cluster_X[i][nCluster[i][k]]=a_tpc;
1233 b_tpc_cluster_X[i][nCluster[i][k]]=b_tpc;
1234 pos_tpc_cluster_X[i][nCluster[i][k]]=pos_tpc;
1241 if(nCluster[i][k]<100) {
1243 nStripsV[i][nCluster[i][k]]=i2-i1+1;
1244 posV[i][nCluster[i][k]]=posCluster_CC;
1245 QV[i][nCluster[i][k]]=sumQ;
1248 tposV[i][nCluster[i][k]]=tposCluster;
1252 int nXCluster=iStart_cluster[i][j][0].size();
1253 for(
int iX=0; iX<nXCluster; iX++)
1255 double Z_pos = readoutPlane->
getZFromPhiV(vecPos_cluster[i][j][0][iX],posCluster_CC);
1256 double tZ_pos =9999.0;
1257 if(vecTPos_cluster[i][j][0][iX]!=9999.0&&tposCluster!=9999.0)
1258 tZ_pos = readoutPlane->
getZFromPhiV(vecTPos_cluster[i][j][0][iX],tposCluster);
1260 if(readoutPlane->
OnThePlane(vecPos_cluster[i][j][0][iX],Z_pos))
1262 if(myPrintFlag) cout<<
"find a XV cluster, Z="<<Z_pos<<endl;
1263 int iV=iStart_cluster[i][j][1].size()-1;
1264 clusterId=aCgemClusterCol->size();
1265 vecPos_cluster[i][j][2].push_back(Z_pos);
1266 id_cluster[i][j][2].push_back(clusterId);
1267 idxCluster[i][j][0].push_back(iX);
1268 idxCluster[i][j][1].push_back(iV);
1276 pt2_recCluster->
setclusterflag(id_cluster[i][j][0][iX],id_cluster[i][j][1][iV]);
1277 pt2_recCluster->
setrecphi(vecPos_cluster[i][j][0][iX]);
1278 pt2_recCluster->
setrecphi_CC(vecPos_cluster[i][j][0][iX]);
1280 pt2_recCluster->
setrecv(vecPos_cluster[i][j][1][iV]);
1281 pt2_recCluster->
setrecv_CC(vecPos_cluster[i][j][1][iV]);
1282 pt2_recCluster->
setrecv_mTPC(vecTPos_cluster[i][j][1][iV]);
1283 pt2_recCluster->
setRecZ(Z_pos);
1286 aCgemClusterCol->push_back(pt2_recCluster);
1289 if(nCluster[i][2]<100) {
1290 posZ[i][nCluster[i][2]]=Z_pos;
1291 tposZ[i][nCluster[i][2]]=tZ_pos;
1292 phi_XV[i][nCluster[i][2]]=vecPos_cluster[i][j][0][iX];
1294 if( (iEnd_cluster[i][j][0][iX]+1)==readoutPlane->
getNXstrips() )
1295 idxBoundaryXVcluster[i][j][0].push_back(idxCluster[i][j][1].size()-1);
1296 if(iStart_cluster[i][j][0][iX]==0)
1297 idxBoundaryXVcluster[i][j][1].push_back(idxCluster[i][j][1].size()-1);
1312 drift_strips.clear();
1331 for(
int j=0; j<myNSheets[i]; j++)
1335 if(j_next==myNSheets[i]) j_next=0;
1339 double xmin_next = nextReadoutPlane->
getXmin();
1341 int nXV_atXEnd=idxBoundaryXVcluster[i][j][0].size();
1342 int nXV_atXStart=idxBoundaryXVcluster[i][j_next][1].size();
1343 if(nXV_atXEnd==0||nXV_atXStart==0)
continue;
1344 for(
int iXV_atXEnd=0; iXV_atXEnd<nXV_atXEnd; iXV_atXEnd++)
1346 int iXVCluster = idxBoundaryXVcluster[i][j][0][iXV_atXEnd];
1347 int iXCluster = idxCluster[i][j][0][iXVCluster];
1348 int iVCluster = idxCluster[i][j][1][iXVCluster];
1349 int VID1=iStart_cluster[i][j][1][iVCluster];
1350 int VID2=iEnd_cluster[i][j][1][iVCluster];
1353 for(
int iXV_atXStart=0; iXV_atXStart<nXV_atXStart; iXV_atXStart++)
1355 int iXVCluster_next = idxBoundaryXVcluster[i][j_next][1][iXV_atXStart];
1356 int iXCluster_next = idxCluster[i][j_next][0][iXVCluster_next];
1357 int iVCluster_next = idxCluster[i][j_next][1][iXVCluster_next];
1358 int VID1_next=iStart_cluster[i][j_next][1][iVCluster_next];
1359 int VID2_next=iEnd_cluster[i][j_next][1][iVCluster_next];
1360 if( !( (VID1_next-VID2_extend)>1 || (VID1_extend-VID2_next)>1 ) )
1362 int XID1=iStart_cluster[i][j][0][iXCluster];
1363 int XID2=iEnd_cluster[i][j][0][iXCluster];
1364 int XID1_next=iStart_cluster[i][j_next][0][iXCluster_next];
1365 int XID2_next=iEnd_cluster[i][j_next][0][iXCluster_next];
1366 int clusterId=aCgemClusterCol->size();
1373 int id1=id_cluster[i][j][2][iXVCluster];
1374 int id2=id_cluster[i][j_next][2][iXVCluster_next];
1377 double phi1=vecPos_cluster[i][j][0][iXCluster];
1378 double phi2=vecPos_cluster[i][j_next][0][iXCluster_next];
1384 double E1=E_cluster[i][j][0][iXCluster];
1385 double E2=E_cluster[i][j_next][0][iXCluster_next];
1386 double phiAverage=(E1*
phi1+E2*
phi2)/(E1+E2);
1389 double v1=vecPos_cluster[i][j][1][iVCluster];
1391 double v2=vecPos_cluster[i][j_next][1][iVCluster_next];
1392 E1=E_cluster[i][j][1][iVCluster];
1393 E2=E_cluster[i][j_next][1][iVCluster_next];
1394 double V_average_next=(E1*v1+E2*v2)/(E1+E2);
1395 pt_recCluster->
setrecv(V_average_next);
1397 double z_average = nextReadoutPlane->
getZFromPhiV(phiAverage,V_average_next,0);
1398 pt_recCluster->
setRecZ(z_average);
1400 aCgemClusterCol->push_back(pt_recCluster);
1403 cout<<
"one combinational cluster found: "<<endl;
1404 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;
1405 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;
1406 cout<<
" averagePhi:"<<phiAverage<<
", v_average:"<<V_average_next<<
", z_average:"<<z_average<<endl;
1413 if(nCluster[i][0]>100) nCluster[i][0]=100;
1414 if(nCluster[i][1]>100) nCluster[i][1]=100;
1415 if(nCluster[i][2]>100) nCluster[i][2]=100;
1420 double evttime=m_timer->
elapsed();
1423 if(myPrintFlag) checkRecCgemClusterCol();
1428 myNTupleHelper->
fillLong(
"run",(
long)run);
1429 myNTupleHelper->
fillLong(
"evt",(
long)evt);
1431 myNTupleHelper->
fillArray(
"nXstrips",
"nLayer",(
double*) nXStrips,3);
1432 myNTupleHelper->
fillArray(
"nVstrips",
"nLayer",(
double*) nVStrips,3);
1434 myNTupleHelper->
fillArray(
"phiClusterLay1",
"nXClusterLay1",(
double*) posX[0],nCluster[0][0]);
1435 myNTupleHelper->
fillArray(
"tphiClusterLay1",
"nXClusterLay1",(
double*) tposX[0],nCluster[0][0]);
1436 myNTupleHelper->
fillArrayInt(
"nXStripsLay1",
"nXClusterLay1",(
int*) nStripsX[0],nCluster[0][0]);
1437 myNTupleHelper->
fillArray(
"QXLay1",
"nXClusterLay1",(
double*) QX[0],nCluster[0][0]);
1438 myNTupleHelper->
fillArray(
"a_tpc_XLay1" ,
"nXClusterLay1",(
double*) a_tpc_cluster_X[0] ,nCluster[0][0]);
1439 myNTupleHelper->
fillArray(
"b_tpc_XLay1" ,
"nXClusterLay1",(
double*) b_tpc_cluster_X[0] ,nCluster[0][0]);
1440 myNTupleHelper->
fillArray(
"pos_tpc_XLay1" ,
"nXClusterLay1",(
double*) pos_tpc_cluster_X[0],nCluster[0][0]);
1442 myNTupleHelper->
fillArray(
"VClusterLay1",
"nVClusterLay1",(
double*) posV[0],nCluster[0][1]);
1443 myNTupleHelper->
fillArray(
"tVClusterLay1",
"nVClusterLay1",(
double*) tposV[0],nCluster[0][1]);
1444 myNTupleHelper->
fillArrayInt(
"nVStripsLay1",
"nVClusterLay1",(
int*) nStripsV[0],nCluster[0][1]);
1445 myNTupleHelper->
fillArray(
"QVLay1",
"nVClusterLay1",(
double*) QV[0],nCluster[0][1]);
1447 myNTupleHelper->
fillArray(
"zClusterLay1",
"nXVClusterLay1",(
double*) posZ[0],nCluster[0][2]);
1448 myNTupleHelper->
fillArray(
"tzClusterLay1",
"nXVClusterLay1",(
double*) tposZ[0],nCluster[0][2]);
1449 myNTupleHelper->
fillArray(
"phiXVClusterLay1",
"nXVClusterLay1",(
double*) phi_XV[0],nCluster[0][2]);
1451 myNTupleHelper->
fillArray(
"phiClusterLay2",
"nXClusterLay2",(
double*) posX[1],nCluster[1][0]);
1452 myNTupleHelper->
fillArray(
"tphiClusterLay2",
"nXClusterLay2",(
double*) tposX[1],nCluster[1][0]);
1453 myNTupleHelper->
fillArrayInt(
"nXStripsLay2",
"nXClusterLay2",(
int*) nStripsX[1],nCluster[1][0]);
1454 myNTupleHelper->
fillArray(
"QXLay2",
"nXClusterLay2",(
double*) QX[1],nCluster[1][0]);
1455 myNTupleHelper->
fillArray(
"a_tpc_XLay2" ,
"nXClusterLay2",(
double*) a_tpc_cluster_X[1] ,nCluster[1][0]);
1456 myNTupleHelper->
fillArray(
"b_tpc_XLay2" ,
"nXClusterLay2",(
double*) b_tpc_cluster_X[1] ,nCluster[1][0]);
1457 myNTupleHelper->
fillArray(
"pos_tpc_XLay2" ,
"nXClusterLay2",(
double*) pos_tpc_cluster_X[1],nCluster[1][0]);
1459 myNTupleHelper->
fillArray(
"VClusterLay2",
"nVClusterLay2",(
double*) posV[1],nCluster[1][1]);
1460 myNTupleHelper->
fillArray(
"tVClusterLay2",
"nVClusterLay2",(
double*) tposV[1],nCluster[1][1]);
1461 myNTupleHelper->
fillArrayInt(
"nVStripsLay2",
"nVClusterLay2",(
int*) nStripsV[1],nCluster[1][1]);
1462 myNTupleHelper->
fillArray(
"QVLay2",
"nVClusterLay2",(
double*) QV[1],nCluster[1][1]);
1464 myNTupleHelper->
fillArray(
"zClusterLay2",
"nXVClusterLay2",(
double*) posZ[1],nCluster[1][2]);
1465 myNTupleHelper->
fillArray(
"tzClusterLay2",
"nXVClusterLay2",(
double*) tposZ[1],nCluster[1][2]);
1466 myNTupleHelper->
fillArray(
"phiXVClusterLay2",
"nXVClusterLay2",(
double*) phi_XV[1],nCluster[1][2]);
1468 myNTupleHelper->
fillArray(
"phiClusterLay3",
"nXClusterLay3",(
double*) posX[2],nCluster[2][0]);
1469 myNTupleHelper->
fillArray(
"tphiClusterLay3",
"nXClusterLay3",(
double*) tposX[2],nCluster[2][0]);
1470 myNTupleHelper->
fillArrayInt(
"nXStripsLay3",
"nXClusterLay3",(
int*) nStripsX[2],nCluster[2][0]);
1471 myNTupleHelper->
fillArray(
"QXLay3",
"nXClusterLay3",(
double*) QX[2],nCluster[2][0]);
1472 myNTupleHelper->
fillArray(
"a_tpc_XLay3" ,
"nXClusterLay3",(
double*) a_tpc_cluster_X[2] ,nCluster[2][0]);
1473 myNTupleHelper->
fillArray(
"b_tpc_XLay3" ,
"nXClusterLay3",(
double*) b_tpc_cluster_X[2] ,nCluster[2][0]);
1474 myNTupleHelper->
fillArray(
"pos_tpc_XLay3" ,
"nXClusterLay3",(
double*) pos_tpc_cluster_X[2],nCluster[2][0]);
1476 myNTupleHelper->
fillArray(
"VClusterLay3",
"nVClusterLay3",(
double*) posV[2],nCluster[2][1]);
1477 myNTupleHelper->
fillArray(
"tVClusterLay3",
"nVClusterLay3",(
double*) tposV[2],nCluster[2][1]);
1478 myNTupleHelper->
fillArrayInt(
"nVStripsLay3",
"nVClusterLay3",(
int*) nStripsV[2],nCluster[2][1]);
1479 myNTupleHelper->
fillArray(
"QVLay3",
"nVClusterLay3",(
double*) QV[2],nCluster[2][1]);
1481 myNTupleHelper->
fillArray(
"zClusterLay3",
"nXVClusterLay3",(
double*) posZ[2],nCluster[2][2]);
1482 myNTupleHelper->
fillArray(
"tzClusterLay3",
"nXVClusterLay3",(
double*) tposZ[2],nCluster[2][2]);
1483 myNTupleHelper->
fillArray(
"phiXVClusterLay3",
"nXVClusterLay3",(
double*) phi_XV[2],nCluster[2][2]);
1485 myNTupleHelper->
fillDouble(
"evtProcessTime",evttime);
1487 myNTupleHelper->
write();
1489 if(myPrintFlag) cout<<
"End of CgemClusterCreate::method2()"<<endl;
1491 return StatusCode::SUCCESS;
1494StatusCode CgemClusterCreate::toyCluster()
1496 MsgStream log(
msgSvc(),name());
1499 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
1502 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
1503 return StatusCode::FAILURE;
1505 int run=evtHead->runNumber();
1506 int evt=evtHead->eventNumber();
1507 if(myPrintFlag) cout<<
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "<<evt<<endl;
1510 IDataProviderSvc* evtSvc = NULL;
1511 Gaudi::svcLocator()->service(
"EventDataSvc",evtSvc);
1513 log << MSG::INFO <<
"makeTds:event Svc has been found" << endreq;
1515 log << MSG::FATAL <<
"makeTds:Could not find eventSvc" << endreq;
1516 return StatusCode::SUCCESS;
1520 sc = evtSvc->registerObject(
"/Event/Recon/RecCgemClusterCol", aCgemClusterCol);
1523 log << MSG::FATAL <<
"Could not register RecCgemClusterCol" << endreq;
1524 return StatusCode::SUCCESS;
1528 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
1531 log << MSG::WARNING <<
"Could not retrieve CgemMcHitCol list" << endreq;
1532 return StatusCode::FAILURE;
1537 double phi_truth[100], z_truth[100], r_truth[100], x_truth[100], v_truth[100], cosTh_truth[100], z_check[100];
1538 double phi_gen[100], z_gen[100], x_gen[100], v_gen[100];
1540 int nCgemMcHit = cgemMcHitCol->size();
if(myPrintFlag) cout<<
"nCgemMcHit = "<<nCgemMcHit<<endl;
1541 vector<int> idxXClusters[4][2], idxVClusters[4][2];
1542 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
1544 for(; iter_truth!=cgemMcHitCol->end(); iter_truth++ )
1546 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster(): creator process = "<<(*iter_truth)->GetCreatorProcess()<<endl;
1547 string creatorProcess = (*iter_truth)->GetCreatorProcess();
1548 if(creatorProcess==
"Generator"||creatorProcess==
"Decay")
1551 if(myClusterEff>0.&&myClusterEff<1.0) {
1552 Rndm::Numbers flat(randSvc(), Rndm::Flat(0,1));
1553 if(flat()>myClusterEff) {
1554 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() skip one cluster! "<<endl;
1559 int iLayer = (*iter_truth)->GetLayerID();
1560 double x_pre = (*iter_truth)->GetPositionXOfPrePoint();
1561 double y_pre = (*iter_truth)->GetPositionYOfPrePoint();
1562 double z_pre = (*iter_truth)->GetPositionZOfPrePoint();
1563 double x_post = (*iter_truth)->GetPositionXOfPostPoint();
1564 double y_post = (*iter_truth)->GetPositionYOfPostPoint();
1565 double z_post = (*iter_truth)->GetPositionZOfPostPoint();
1566 double x_mid = 0.5*(x_pre+x_post);
1567 double y_mid = 0.5*(y_pre+y_post);
1568 double z_mid = 0.5*(z_pre+z_post);
1569 double r_pre = sqrt(x_pre*x_pre+y_pre*y_pre+z_pre*z_pre);
1570 double r_post = sqrt(x_post*x_post+y_post*y_post+z_post*z_post);
1571 double v_x = x_post-x_pre;
1572 double v_y = y_post-y_pre;
1573 double v_z = z_post-z_pre;
1574 double cth_v = v_z/sqrt(v_x*v_x+v_y*v_y+v_z*v_z);
1580 double v_tot = sqrt(v_x*v_x+v_y*v_y+v_z*v_z);
1581 double theta_v = acos(v_z/v_tot);
1582 double phi_v = atan2(v_y, v_x);
1584 double r_middle = sqrt(x_mid*x_mid+y_mid*y_mid);
1585 if(myPrintFlag) cout<<
"iLayer, r_middle = "<<iLayer<<
", "<<r_middle<<endl;
1586 Hep3Vector pos_mid(x_mid, y_mid, z_mid);
1587 double phi_mid = pos_mid.phi();
1588 while(phi_mid>CLHEP::twopi) phi_mid-=CLHEP::twopi;
1589 while(phi_mid<0.) phi_mid+=CLHEP::twopi;
1591 double dPhi = phi_v-phi_mid;
1592 while(dPhi>CLHEP::pi) dPhi-=CLHEP::twopi;
1593 while(dPhi<-CLHEP::pi) dPhi+=CLHEP::twopi;
1597 for(
int i=0; i<myNSheets[iLayer]; i++)
1607 if(readoutPlane==NULL)
continue;
1609 double v_loc = readoutPlane->
getVFromPhiZ(phi_mid, z_mid);
1610 if(iCgemMcHit<100) {
1611 phi_truth[iCgemMcHit]=phi_mid;
1612 z_truth[iCgemMcHit]=z_mid;
1613 r_truth[iCgemMcHit]=r_middle;
1614 x_truth[iCgemMcHit]=phi_mid*myRXstrips[iLayer];
1615 v_truth[iCgemMcHit]=v_loc;
1616 cosTh_truth[iCgemMcHit]=cth_v;
1617 z_check[iCgemMcHit] = readoutPlane->
getZFromPhiV(phi_mid, v_loc);
1619 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() iLayer "<<iLayer<<
", MC hit: phi, z, V = "<<phi_mid<<
", "<<z_mid<<
", "<<v_loc<<endl;
1623 int iView(0), mode(2);
1624 double Q(100), T(100);
1625 double sigma_X = myCgemCalibSvc->
getSigma(iLayer,iView,mode,dPhi,Q,T);
1626 Rndm::Numbers gauss(randSvc(), Rndm::Gauss(0,1));
1627 double phi_mid_gen = phi_mid+gauss()*sigma_X/myRXstrips[iLayer];
1629 while(!(readoutPlane->
OnThePlane(phi_mid_gen,z_mid))) {
1630 phi_mid_gen = phi_mid+gauss()*sigma_X/myRXstrips[iLayer];
1632 if(iGenTried>=10)
break;
1635 if(myPrintFlag) cout<<
"Generation of phi with 10 times!"<<endl;
1638 if(myPrintFlag) cout<<
"generated phi: "<<phi_mid_gen<<endl;
1641 double sigma_V = myCgemCalibSvc->
getSigma(iLayer,iView,mode,dPhi,Q,T);
1643 double v_loc_gen = v_loc+gauss()*sigma_V;
1644 double z_mid_gen = readoutPlane->
getZFromPhiV(phi_mid_gen, v_loc_gen);
1646 while(!(readoutPlane->
OnThePlane(phi_mid_gen,z_mid_gen)))
1648 v_loc_gen = v_loc+gauss()*sigma_V;
1649 z_mid_gen = readoutPlane->
getZFromPhiV(phi_mid_gen, v_loc_gen);
1650 if(myPrintFlag) cout<<
"try generated V, z: "<<v_loc_gen<<
", "<<z_mid_gen<<endl;
1652 if(iGenTried>=10)
break;
1655 if(myPrintFlag) cout<<
"Generation of V with 10 times!"<<endl;
1659 if(iCgemMcHit<100) {
1660 phi_gen[iCgemMcHit]=phi_mid_gen;
1661 z_gen[iCgemMcHit]=z_mid_gen;
1662 x_gen[iCgemMcHit]=phi_mid_gen*myRXstrips[iLayer];
1663 v_gen[iCgemMcHit]=v_loc_gen;
1669 int clusterId=aCgemClusterCol->size();
1680 aCgemClusterCol->push_back(pt_recCluster);
1681 idxXClusters[iLayer][iSheet].push_back(clusterId);
1682 (*iter_truth)->AddXclusterIdx(clusterId);
1684 clusterId=aCgemClusterCol->size();
1691 pt_recCluster->
setrecv(v_loc_gen);
1692 aCgemClusterCol->push_back(pt_recCluster);
1693 idxVClusters[iLayer][iSheet].push_back(clusterId);
1694 (*iter_truth)->AddVclusterIdx(clusterId);
1697 int pdg = (*iter_truth)->GetPDGCode();
1698 double px = (*iter_truth)->GetMomentumXOfPrePoint();
1699 double py = (*iter_truth)->GetMomentumYOfPrePoint();
1700 double pz = (*iter_truth)->GetMomentumZOfPrePoint();
1701 Hep3Vector truth_p(px/1000.,py/1000.,pz/1000.);
1703 HepPoint3D truth_position(x_pre/10.,y_pre/10.,z_pre/10.);
1704 if(myPrintFlag&&fabs(pdg)==13)
1706 int charge = -1*pdg/fabs(pdg);
1709 tmp_helix->
pivot(tmp_pivot);
1711 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;
1723 RecCgemClusterCol::iterator it_cluster0 = aCgemClusterCol->begin();
1724 RecCgemClusterCol::iterator it_cluster;
1725 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() start searching XV clusters: "<<endl;
1726 for(
int i=0; i<myNCgemLayers; i++)
1728 for(
int j=0; j<myNSheets[i]; j++)
1730 if(myPrintFlag) cout<<
"iLayer, iSheet = "<<i<<
", "<<j<<endl;
1732 for(
int iV=0; iV<idxVClusters[i][j].size(); iV++)
1734 if(myPrintFlag) cout<<
"iV: "<<iV;
1735 it_cluster = it_cluster0+idxVClusters[i][j][iV];
1737 double V_loc = (*it_cluster)->getrecv();
1739 for(
int iX=0; iX<idxXClusters[i][j].size(); iX++)
1741 if(myPrintFlag) cout<<
" iX: "<<iX<<endl;
1742 it_cluster = it_cluster0+idxXClusters[i][j][iX];
1743 double phi = (*it_cluster)->getrecphi();
1745 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() check phi, z, V = "<<phi<<
", "<<z<<
", "<<V_loc<<
", layer "<<i<<
", sheet "<<j<<endl;
1748 int clusterId=aCgemClusterCol->size();
1755 pt_recCluster->
setclusterflag(idxXClusters[i][j][iX], idxVClusters[i][j][iV]);
1757 pt_recCluster->
setrecv(V_loc);
1759 aCgemClusterCol->push_back(pt_recCluster);
1760 it_cluster0 = aCgemClusterCol->begin();
1761 if(myPrintFlag) cout<<
"CgemClusterCreate::toyCluster() finds a XV cluster"<<endl;
1769 if(myPrintFlag) cout<<
"nCgemCluster = "<<aCgemClusterCol->size()<<endl;
1771 if(myPrintFlag) checkRecCgemClusterCol();
1772 if(run<0) fillMCTruth();
1775 if(iCgemMcHit>100) iCgemMcHit=100;
1776 myNTupleHelper->
fillArray(
"phi_mc",
"nCgemMcHit",(
double*)phi_truth,iCgemMcHit);
1777 myNTupleHelper->
fillArray(
"z_mc",
"nCgemMcHit",(
double*)z_truth,iCgemMcHit);
1778 myNTupleHelper->
fillArray(
"z_mc_check",
"nCgemMcHit",(
double*)z_check,iCgemMcHit);
1779 myNTupleHelper->
fillArray(
"r_mc",
"nCgemMcHit",(
double*)r_truth,iCgemMcHit);
1780 myNTupleHelper->
fillArray(
"x_mc",
"nCgemMcHit",(
double*)x_truth,iCgemMcHit);
1781 myNTupleHelper->
fillArray(
"v_mc",
"nCgemMcHit",(
double*)v_truth,iCgemMcHit);
1782 myNTupleHelper->
fillArray(
"cth_mc",
"nCgemMcHit",(
double*)cosTh_truth,iCgemMcHit);
1783 myNTupleHelper->
fillArray(
"phi",
"nCgemMcHit",(
double*)phi_gen,iCgemMcHit);
1784 myNTupleHelper->
fillArray(
"z",
"nCgemMcHit",(
double*)z_gen,iCgemMcHit);
1785 myNTupleHelper->
fillArray(
"x",
"nCgemMcHit",(
double*)x_gen,iCgemMcHit);
1786 myNTupleHelper->
fillArray(
"v",
"nCgemMcHit",(
double*)v_gen,iCgemMcHit);
1787 myNTupleHelper->
write();
1797 return StatusCode::SUCCESS;
1800void CgemClusterCreate::fillMCTruth(
int run,
int evt)
1804 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
1807 std::cout <<
"Could not retrieve cgemMcHitCol" << std::endl;
1810 m_mc_nhit = cgemMcHitCol->size();
1812 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
1813 for(
int iHit=0; iter_truth!= cgemMcHitCol->end(); iter_truth++,iHit++)
1815 m_mc_trackID[iHit] = (*iter_truth)->GetTrackID();
1816 m_mc_layerID[iHit] = (*iter_truth)->GetLayerID();
1817 m_mc_pdg[iHit] = (*iter_truth)->GetPDGCode();
1818 m_mc_parentID[iHit] = (*iter_truth)->GetParentID();
1819 m_mc_E_deposit[iHit] = (*iter_truth)->GetTotalEnergyDeposit();
1820 m_mc_XYZ_pre_x[iHit] = (*iter_truth)->GetPositionXOfPrePoint();
1821 m_mc_XYZ_pre_y[iHit] = (*iter_truth)->GetPositionYOfPrePoint();
1822 m_mc_XYZ_pre_z[iHit] = (*iter_truth)->GetPositionZOfPrePoint();
1823 m_mc_XYZ_post_x[iHit] = (*iter_truth)->GetPositionXOfPostPoint();
1824 m_mc_XYZ_post_y[iHit] = (*iter_truth)->GetPositionYOfPostPoint();
1825 m_mc_XYZ_post_z[iHit] = (*iter_truth)->GetPositionZOfPostPoint();
1826 m_mc_P_pre_x[iHit] = (*iter_truth)->GetMomentumXOfPrePoint();
1827 m_mc_P_pre_y[iHit] = (*iter_truth)->GetMomentumYOfPrePoint();
1828 m_mc_P_pre_z[iHit] = (*iter_truth)->GetMomentumZOfPrePoint();
1829 m_mc_P_post_x[iHit] = (*iter_truth)->GetMomentumXOfPostPoint();
1830 m_mc_P_post_y[iHit] = (*iter_truth)->GetMomentumYOfPostPoint();
1831 m_mc_P_post_z[iHit] = (*iter_truth)->GetMomentumZOfPostPoint();
1838void CgemClusterCreate::fillRecData(
int run,
int evt)
1844 SmartDataPtr<RecCgemClusterCol> recCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
1845 if(!recCgemClusterCol)
1847 cout <<
"Could not retrieve RecCgemClusterCol" << endl;
1849 m_rec_ncluster = recCgemClusterCol->size();
1851 RecCgemClusterCol::iterator iter_cluster=recCgemClusterCol->begin();
1852 for(; iter_cluster!=recCgemClusterCol->end(); iter_cluster++)
1854 if(m_fillOption == -1){
1855 m_rec_clusterid[iCluster] = (*iter_cluster)->getclusterid();
1856 m_rec_layerid[iCluster] = (*iter_cluster)->getlayerid();
1857 m_rec_sheetid[iCluster] = (*iter_cluster)->getsheetid();
1858 m_rec_flag[iCluster] = (*iter_cluster)->getflag();
1859 m_rec_energydeposit[iCluster] = (*iter_cluster)->getenergydeposit();
1860 m_rec_recphi[iCluster] = (*iter_cluster)->getrecphi();
1861 m_rec_recv[iCluster] = (*iter_cluster)->getrecv();
1862 m_rec_recZ[iCluster] = (*iter_cluster)->getRecZ();
1863 m_rec_clusterflagb[iCluster] = (*iter_cluster)->getclusterflagb();
1864 m_rec_clusterflage[iCluster] = (*iter_cluster)->getclusterflage();
1866 }
else if(m_fillOption==(*iter_cluster)->getflag()){
1867 m_rec_clusterid[iCluster] = (*iter_cluster)->getclusterid();
1868 m_rec_layerid[iCluster] = (*iter_cluster)->getlayerid();
1869 m_rec_sheetid[iCluster] = (*iter_cluster)->getsheetid();
1870 m_rec_flag[iCluster] = (*iter_cluster)->getflag();
1871 m_rec_energydeposit[iCluster] = (*iter_cluster)->getenergydeposit();
1872 m_rec_recphi[iCluster] = (*iter_cluster)->getrecphi();
1873 m_rec_recv[iCluster] = (*iter_cluster)->getrecv();
1874 m_rec_recZ[iCluster] = (*iter_cluster)->getRecZ();
1875 m_rec_clusterflagb[iCluster] = (*iter_cluster)->getclusterflagb();
1876 m_rec_clusterflage[iCluster] = (*iter_cluster)->getclusterflage();
1879 if(iCluster>1000)
break;
1882 m_rec_ncluster = iCluster;
1887void CgemClusterCreate::hist_def(){
1889 NTuplePtr nt_rec(
ntupleSvc(),
"RecCgem/RecCluster");
1890 if( nt_rec ) m_rec_nt = nt_rec;
1892 m_rec_nt=
ntupleSvc()->book(
"RecCgem/RecCluster",CLID_ColumnWiseTuple,
"RecCluster");
1894 status = m_rec_nt->addItem(
"rec_run" ,m_rec_run);
1895 status = m_rec_nt->addItem(
"rec_evt" ,m_rec_evt);
1896 status = m_rec_nt->addItem(
"rec_ncluster" ,m_rec_ncluster,0,1000);
1897 status = m_rec_nt->addItem(
"rec_clusterid" ,m_rec_ncluster,m_rec_clusterid);
1898 status = m_rec_nt->addItem(
"rec_layerid" ,m_rec_ncluster,m_rec_layerid);
1899 status = m_rec_nt->addItem(
"rec_sheetid" ,m_rec_ncluster,m_rec_sheetid);
1900 status = m_rec_nt->addItem(
"rec_flag" ,m_rec_ncluster,m_rec_flag);
1901 status = m_rec_nt->addItem(
"rec_energydeposit" ,m_rec_ncluster,m_rec_energydeposit);
1902 status = m_rec_nt->addItem(
"rec_recphi" ,m_rec_ncluster,m_rec_recphi);
1903 status = m_rec_nt->addItem(
"rec_recv" ,m_rec_ncluster,m_rec_recv);
1904 status = m_rec_nt->addItem(
"rec_recZ" ,m_rec_ncluster,m_rec_recZ);
1905 status = m_rec_nt->addItem(
"rec_clusterflagb" ,m_rec_ncluster,m_rec_clusterflagb);
1906 status = m_rec_nt->addItem(
"rec_clusterflage" ,m_rec_ncluster,m_rec_clusterflage);
1910 NTuplePtr nt_mc(
ntupleSvc(),
"RecCgem/McHit");
1911 if( nt_mc ) m_mc_nt = nt_mc;
1913 m_mc_nt =
ntupleSvc()->book(
"RecCgem/McHit",CLID_ColumnWiseTuple,
"McHit");
1915 status = m_mc_nt->addItem(
"mc_run" ,m_mc_run);
1916 status = m_mc_nt->addItem(
"mc_evt" ,m_mc_evt);
1917 status = m_mc_nt->addItem(
"mc_nhit" ,m_mc_nhit,0,1000);
1918 status = m_mc_nt->addItem(
"mc_trackID" ,m_mc_nhit,m_mc_trackID);
1919 status = m_mc_nt->addItem(
"mc_layerID" ,m_mc_nhit,m_mc_layerID);
1920 status = m_mc_nt->addItem(
"mc_pdg" ,m_mc_nhit,m_mc_pdg);
1921 status = m_mc_nt->addItem(
"mc_parentID" ,m_mc_nhit,m_mc_parentID);
1922 status = m_mc_nt->addItem(
"mc_E_deposit" ,m_mc_nhit,m_mc_E_deposit);
1923 status = m_mc_nt->addItem(
"mc_XYZ_pre_x" ,m_mc_nhit,m_mc_XYZ_pre_x);
1924 status = m_mc_nt->addItem(
"mc_XYZ_pre_y" ,m_mc_nhit,m_mc_XYZ_pre_y);
1925 status = m_mc_nt->addItem(
"mc_XYZ_pre_z" ,m_mc_nhit,m_mc_XYZ_pre_z);
1926 status = m_mc_nt->addItem(
"mc_XYZ_post_x" ,m_mc_nhit,m_mc_XYZ_post_x);
1927 status = m_mc_nt->addItem(
"mc_XYZ_post_y" ,m_mc_nhit,m_mc_XYZ_post_y);
1928 status = m_mc_nt->addItem(
"mc_XYZ_post_z" ,m_mc_nhit,m_mc_XYZ_post_z);
1929 status = m_mc_nt->addItem(
"mc_P_pre_x" ,m_mc_nhit,m_mc_P_pre_x);
1930 status = m_mc_nt->addItem(
"mc_P_pre_y" ,m_mc_nhit,m_mc_P_pre_y);
1931 status = m_mc_nt->addItem(
"mc_P_pre_z" ,m_mc_nhit,m_mc_P_pre_z);
1932 status = m_mc_nt->addItem(
"mc_P_post_x" ,m_mc_nhit,m_mc_P_post_x);
1933 status = m_mc_nt->addItem(
"mc_P_post_y" ,m_mc_nhit,m_mc_P_post_y);
1934 status = m_mc_nt->addItem(
"mc_P_post_z" ,m_mc_nhit,m_mc_P_post_z);
1941 MsgStream log(
msgSvc(),name());
1942 log << MSG::INFO <<
"in finalize(): Number of events in CgemClusterCreate" << m_totEvt << endreq;
1945 return StatusCode::SUCCESS;
1948void CgemClusterCreate::reset() {
1949 for (
int i=0; i<3; i++)
1951 for (
int j=0; j<2; j++)
1953 for (
int k=0; k<2; k++)
1955 for (
int l=0; l<1500; l++)
1957 m_strip[i][j][k][l] = -1;
1958 m_edep[i][j][k][l] = 0;
1968 m_trans_map.clear();
1969 m_driftrec_map.clear();
1971 m_strip_map.clear();
1975void CgemClusterCreate::resetFiredStripMap()
1977 for (
int i=0; i<3; i++)
1979 for (
int j=0; j<2; j++)
1981 for (
int k=0; k<2; k++)
1983 myFiredStripMap[i][j][k].clear();
1998void CgemClusterCreate:: processstrips(
int k){
2000 for(
int i=0;i<3;i++){
2001 for(
int j=0;j<2;j++){
2006 static int N_cluster;
2008 for(
int l=1;l<1500;l++){
2010 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]>0){
2014 if(m_strip[i][j][k][l]<0&&m_strip[i][j][k][l-1]>0){
2016 N_cluster= N_cluster + 1;
2018 m_x_group.push_back(cluster);
2039 posxfind(reccluster);
2041 m_x_map[
key] = reccluster;
2045 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]<0){
2053 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]>0){
2059 if(m_strip[i][j][k][l]<0&&m_strip[i][j][k][l-1]>0){
2063 m_v_group.push_back(cluster);
2083 posvfind(reccluster);
2085 m_v_map[
key] = reccluster;
2089 if(m_strip[i][j][k][l]>0&&m_strip[i][j][k][l-1]<0){
2103void CgemClusterCreate:: transcluster(){
2105 for(
int i=0;i<3;i++){
2106 for(
int j=0;j<2;j++){
2107 for(
int l=0;l<1500;l++){
2109 keytype
key((10*i+j),l);
2110 m_v_map_it = m_v_map.find(
key);
2111 if(m_v_map_it != m_v_map.end()){
2131 transflag.first = vcluster;
2132 transflag.second = cluster;
2133 m_trans_map[
key]= transflag;
2141void CgemClusterCreate::mixcluster(){
2143 for(
int i=0;i<3;i++){
2144 for(
int j=0;j<2;j++){
2145 for(
int l=0;l<1500;l++){
2147 keytype
key((10*i+j),l);
2148 m_x_map_it = m_x_map.find(
key);
2149 if(m_x_map_it != m_x_map.end()){
2157 for(
int ll=0;ll<1500;ll++){
2158 keytype mkey((10*i+j),ll);
2159 m_trans_map_it = m_trans_map.find(mkey);
2160 if(m_trans_map_it == m_trans_map.end()){
continue;}
2163 flagxv transflag = (*m_trans_map_it).second;
2172 v.end = cluster.
end;
2176 m_xv_group.push_back(XV);
2177 m_mid_group.push_back(vcluster);
2183 posxvfind(reccluster);
2185 m_xv_map[
key] = reccluster;
2186 posindrift(reccluster);
2201 m_mid_group.clear();
2212 for(
int k=begin;k<=end;k++){
2213 phi = phi + m_edep[layerid][sheetid][0][k]*k*
W_pitch;
2224 for(
int k=begin;k<=end;k++){
2225 v =
v + m_edep[layerid][sheetid][1][k]*k*
W_pitch;
2242 double xenergy = 0.0;
2243 double venergy = 0.0;
2246 for(
int ii=
x.begin;ii<=
x.end;ii++){
2247 for(
int jj=
v.begin;jj<=
v.end;jj++){
2250 xenergy = xenergy + m_edep[layerid][sheetid][0][ii];
2251 phi = phi + m_edep[layerid][sheetid][0][ii]*ii*
W_pitch;
2253 m_sameID.push_back(ii);
2261 for(
int kk=mid.
begin;kk<=mid.
end;kk++){
2267 for(
int ll=0;ll<(int)m_sameID.size();ll++){
2268 if(pa<=m_sameID[ll]&&pb>=m_sameID[ll]){
2270 venergy = venergy + m_edep[layerid][sheetid][1][kk];
2271 recv = recv + m_edep[layerid][sheetid][1][kk]*kk*
W_pitch;
2283 int nxstrip = m_sameID.size();
2287 keytype
key((10*layerid+sheetid),clusterid);
2288 pphi = pphi/nxstrip;
2290 keytype strip(nxstrip,nvstrip);
2291 postype pos(pphi,pv);
2294 m_strip_map[
key]=strip;
2301 reccluster->
setrecv(recv/venergy);
2310 double posphi =
dr_layer[layerid]*dphi;
2311 for(
int vv =0;vv<
n_sheet[layerid];vv++){
2313 posphi = posphi-vv*
dw_sheet[layerid];
2321 postype positiond(posphi,posv);
2322 keytype
key((10*layerid+sheetid),clusterid);
2323 m_driftrec_map[
key] = positiond;
2326void CgemClusterCreate::fillMCTruth()
2328 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
2331 std::cout <<
"Could not retrieve McParticelCol" << std::endl;
2339 double Pmc[100],costhmc[100],phimc[100];
2340 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
2341 for (; iter_mc != mcParticleCol->end(); iter_mc++)
2343 int idx = (*iter_mc)->trackIndex();
2344 int pdgid = (*iter_mc)->particleProperty();
2345 int mother_pdg = ((*iter_mc)->mother()).particleProperty();
2346 int mother_idx = (*iter_mc)->mother().trackIndex();
2347 int primaryParticle = (*iter_mc)->primaryParticle();
2348 int fromGenerator = (*iter_mc)->decayFromGenerator();
2349 if(primaryParticle==1)
continue;
2350 if(fromGenerator==0)
continue;
2351 if(pdgid==myMotherParticleID) {
2355 if(foundMom==0)
continue;
2356 if(mother_pdg==myMotherParticleID) {
2360 if(pdgid!=myMotherParticleID&&foundMom>0&&startDecay==0)
2365 mother_idx=mother_idx-foundMom-itmp;
2367 if(myPrintFlag==1) {
2369 cout<<
"****** MC particles ****** "<<endl;
2370 cout <<setw(10)<<
"index"
2372 <<setw(16)<<
"primaryParticle"
2373 <<setw(15)<<
"fromGenerator"
2374 <<setw(15)<<
"from_trk"
2377 cout <<setw(10)<<i_mc
2379 <<setw(16)<<primaryParticle
2380 <<setw(15)<<fromGenerator
2381 <<setw(15)<<mother_idx
2387 HepLorentzVector p4_mc = (*iter_mc)->initialFourMomentum();
2388 Pmc[i_mc]=p4_mc.rho();
2389 costhmc[i_mc]=p4_mc.cosTheta();
2390 phimc[i_mc]=p4_mc.phi();
2394 if(i_mc>=100) i_mc=100;
2396 int nTruth[3]={0,0,0};
2397 int trkID_Layer1[100], trkID_Layer2[100], trkID_Layer3[100];
2398 int pdg_Layer1[100], pdg_Layer2[100], pdg_Layer3[100];
2399 double x_pre_Layer1[100], x_pre_Layer2[100], x_pre_Layer3[100];
2400 double y_pre_Layer1[100], y_pre_Layer2[100], y_pre_Layer3[100];
2401 double z_pre_Layer1[100], z_pre_Layer2[100], z_pre_Layer3[100];
2402 double x_post_Layer1[100], x_post_Layer2[100], x_post_Layer3[100];
2403 double y_post_Layer1[100], y_post_Layer2[100], y_post_Layer3[100];
2404 double z_post_Layer1[100], z_post_Layer2[100], z_post_Layer3[100];
2405 double phi_Layer1[100], phi_Layer2[100], phi_Layer3[100];
2406 double z_Layer1[100], z_Layer2[100], z_Layer3[100];
2407 double V_Layer1[100], V_Layer2[100], V_Layer3[100];
2408 double px_pre_Layer1[100], px_pre_Layer2[100], px_pre_Layer3[100];
2409 double py_pre_Layer1[100], py_pre_Layer2[100], py_pre_Layer3[100];
2410 double pz_pre_Layer1[100], pz_pre_Layer2[100], pz_pre_Layer3[100];
2411 double en_Layer1[100], en_Layer2[100], en_Layer3[100];
2412 SmartDataPtr<Event::CgemMcHitCol> cgemMcHitCol(eventSvc(),
"/Event/MC/CgemMcHitCol");
2415 std::cout <<
"Could not retrieve cgemMcHitCol" << std::endl;
2418 Event::CgemMcHitCol::iterator iter_truth = cgemMcHitCol->begin();
2419 for (; iter_truth!= cgemMcHitCol->end(); iter_truth++)
2421 int iLayer = (*iter_truth)->GetLayerID();
2422 int trkID = (*iter_truth)->GetTrackID();
2423 int pdg = (*iter_truth)->GetPDGCode();
2424 double x_pre = (*iter_truth)->GetPositionXOfPrePoint();
2425 double y_pre = (*iter_truth)->GetPositionYOfPrePoint();
2426 double z_pre = (*iter_truth)->GetPositionZOfPrePoint();
2427 double x_post = (*iter_truth)->GetPositionXOfPostPoint();
2428 double y_post = (*iter_truth)->GetPositionYOfPostPoint();
2429 double z_post = (*iter_truth)->GetPositionZOfPostPoint();
2430 double x_middle = 0.5*(x_pre+x_post);
2431 double y_middle = 0.5*(y_pre+y_post);
2432 double z_middle = 0.5*(z_pre+z_post);
2433 double r_middle = sqrt(x_middle*x_middle+y_middle*y_middle);
2434 double phi_middle = atan2(y_middle, x_middle);
2435 double px_pre = (*iter_truth)->GetMomentumXOfPrePoint();
2436 double py_pre = (*iter_truth)->GetMomentumYOfPrePoint();
2437 double pz_pre = (*iter_truth)->GetMomentumZOfPrePoint();
2438 double en = (*iter_truth)->GetTotalEnergyDeposit();
2442 for(
int j=0; j<myNSheets[iLayer]; j++)
2447 if(readoutPlane->
OnThePlane(phi_middle,z_middle))
break;
2450 double V_mid = 9999;
2451 if(readoutPlane==NULL) {
2452 if(myPrintFlag) cout<<
"CgemClusterCreate::fillMCTruth() readoutPlane not found with phi_middle = "<<phi_middle<<
", layer = "<<iLayer<<endl;
2457 V_mid = readoutPlane->
getVFromPhiZ(phi_middle,z_middle);
2465 if(nTruth[0]>=100)
break;
2466 trkID_Layer1[nTruth[0]]=trkID;
2467 pdg_Layer1[nTruth[0]]=pdg;
2468 x_pre_Layer1[nTruth[0]]=x_pre;
2469 y_pre_Layer1[nTruth[0]]=y_pre;
2470 z_pre_Layer1[nTruth[0]]=z_pre;
2471 x_post_Layer1[nTruth[0]]=x_post;
2472 y_post_Layer1[nTruth[0]]=y_post;
2473 z_post_Layer1[nTruth[0]]=z_post;
2474 phi_Layer1[nTruth[0]]=atan2(y_post+y_pre,x_post+x_pre);
2475 z_Layer1[nTruth[0]]=z_middle;
2476 V_Layer1[nTruth[0]]=V_mid;
2477 px_pre_Layer1[nTruth[0]]=px_pre;
2478 py_pre_Layer1[nTruth[0]]=py_pre;
2479 pz_pre_Layer1[nTruth[0]]=pz_pre;
2480 en_Layer1[nTruth[0]]=en;
2483 if(nTruth[1]>=100)
break;
2484 trkID_Layer2[nTruth[1]]=trkID;
2485 pdg_Layer2[nTruth[1]]=pdg;
2486 x_pre_Layer2[nTruth[1]]=x_pre;
2487 y_pre_Layer2[nTruth[1]]=y_pre;
2488 z_pre_Layer2[nTruth[1]]=z_pre;
2489 x_post_Layer2[nTruth[1]]=x_post;
2490 y_post_Layer2[nTruth[1]]=y_post;
2491 z_post_Layer2[nTruth[1]]=z_post;
2492 phi_Layer2[nTruth[1]]=atan2(y_post+y_pre,x_post+x_pre);
2493 z_Layer2[nTruth[1]]=z_middle;
2494 V_Layer2[nTruth[1]]=V_mid;
2495 px_pre_Layer2[nTruth[1]]=px_pre;
2496 py_pre_Layer2[nTruth[1]]=py_pre;
2497 pz_pre_Layer2[nTruth[1]]=pz_pre;
2498 en_Layer2[nTruth[1]]=en;
2501 if(nTruth[2]>=100)
break;
2502 trkID_Layer3[nTruth[2]]=trkID;
2503 pdg_Layer3[nTruth[2]]=pdg;
2504 x_pre_Layer3[nTruth[2]]=x_pre;
2505 y_pre_Layer3[nTruth[2]]=y_pre;
2506 z_pre_Layer3[nTruth[2]]=z_pre;
2507 x_post_Layer3[nTruth[2]]=x_post;
2508 y_post_Layer3[nTruth[2]]=y_post;
2509 z_post_Layer3[nTruth[2]]=z_post;
2510 phi_Layer3[nTruth[2]]=atan2(y_post+y_pre,x_post+x_pre);
2511 z_Layer3[nTruth[2]]=z_middle;
2512 V_Layer3[nTruth[2]]=V_mid;
2513 px_pre_Layer3[nTruth[2]]=px_pre;
2514 py_pre_Layer3[nTruth[2]]=py_pre;
2515 pz_pre_Layer3[nTruth[2]]=pz_pre;
2516 en_Layer3[nTruth[2]]=en;
2519 cout<<
"wrong layer ID for CGEM: "<<iLayer<<endl;
2523 for(
int i=0; i<3; i++)
if(nTruth[i]>100) nTruth[i]=100;
2527 myNTupleHelper->
fillArrayInt(
"pdgmc",
"nmc",(
int*)mcPDG,i_mc);
2528 myNTupleHelper->
fillArray(
"pmc",
"nmc",(
double*)Pmc,i_mc);
2529 myNTupleHelper->
fillArray(
"costhmc",
"nmc",(
double*)costhmc,i_mc);
2530 myNTupleHelper->
fillArray(
"phimc",
"nmc",(
double*)phimc,i_mc);
2532 myNTupleHelper->
fillArrayInt(
"trkID_Layer1",
"nTruthLay1",(
int*) trkID_Layer1, nTruth[0]);
2533 myNTupleHelper->
fillArrayInt(
"pdg_Layer1",
"nTruthLay1",(
int*) pdg_Layer1, nTruth[0]);
2534 myNTupleHelper->
fillArray(
"x_pre_Layer1",
"nTruthLay1",(
double*) x_pre_Layer1, nTruth[0]);
2535 myNTupleHelper->
fillArray(
"y_pre_Layer1",
"nTruthLay1",(
double*) y_pre_Layer1, nTruth[0]);
2536 myNTupleHelper->
fillArray(
"z_pre_Layer1",
"nTruthLay1",(
double*) z_pre_Layer1, nTruth[0]);
2537 myNTupleHelper->
fillArray(
"x_post_Layer1",
"nTruthLay1",(
double*) x_post_Layer1, nTruth[0]);
2538 myNTupleHelper->
fillArray(
"y_post_Layer1",
"nTruthLay1",(
double*) y_post_Layer1, nTruth[0]);
2539 myNTupleHelper->
fillArray(
"z_post_Layer1",
"nTruthLay1",(
double*) z_post_Layer1, nTruth[0]);
2540 myNTupleHelper->
fillArray(
"px_pre_Layer1",
"nTruthLay1",(
double*) px_pre_Layer1, nTruth[0]);
2541 myNTupleHelper->
fillArray(
"py_pre_Layer1",
"nTruthLay1",(
double*) py_pre_Layer1, nTruth[0]);
2542 myNTupleHelper->
fillArray(
"pz_pre_Layer1",
"nTruthLay1",(
double*) pz_pre_Layer1, nTruth[0]);
2543 myNTupleHelper->
fillArray(
"en_Layer1",
"nTruthLay1",(
double*) en_Layer1, nTruth[0]);
2544 myNTupleHelper->
fillArray(
"phi_Layer1",
"nTruthLay1",(
double*) phi_Layer1, nTruth[0]);
2545 myNTupleHelper->
fillArray(
"V_Layer1",
"nTruthLay1",(
double*) V_Layer1, nTruth[0]);
2547 myNTupleHelper->
fillArrayInt(
"trkID_Layer2",
"nTruthLay2",(
int*) trkID_Layer2, nTruth[1]);
2548 myNTupleHelper->
fillArrayInt(
"pdg_Layer2",
"nTruthLay2",(
int*) pdg_Layer2, nTruth[1]);
2549 myNTupleHelper->
fillArray(
"x_pre_Layer2",
"nTruthLay2",(
double*) x_pre_Layer2, nTruth[1]);
2550 myNTupleHelper->
fillArray(
"y_pre_Layer2",
"nTruthLay2",(
double*) y_pre_Layer2, nTruth[1]);
2551 myNTupleHelper->
fillArray(
"z_pre_Layer2",
"nTruthLay2",(
double*) z_pre_Layer2, nTruth[1]);
2552 myNTupleHelper->
fillArray(
"x_post_Layer2",
"nTruthLay2",(
double*) x_post_Layer2, nTruth[1]);
2553 myNTupleHelper->
fillArray(
"y_post_Layer2",
"nTruthLay2",(
double*) y_post_Layer2, nTruth[1]);
2554 myNTupleHelper->
fillArray(
"z_post_Layer2",
"nTruthLay2",(
double*) z_post_Layer2, nTruth[1]);
2555 myNTupleHelper->
fillArray(
"px_pre_Layer2",
"nTruthLay2",(
double*) px_pre_Layer2, nTruth[1]);
2556 myNTupleHelper->
fillArray(
"py_pre_Layer2",
"nTruthLay2",(
double*) py_pre_Layer2, nTruth[1]);
2557 myNTupleHelper->
fillArray(
"pz_pre_Layer2",
"nTruthLay2",(
double*) pz_pre_Layer2, nTruth[1]);
2558 myNTupleHelper->
fillArray(
"en_Layer2",
"nTruthLay2",(
double*) en_Layer2, nTruth[1]);
2559 myNTupleHelper->
fillArray(
"phi_Layer2",
"nTruthLay2",(
double*) phi_Layer2, nTruth[1]);
2560 myNTupleHelper->
fillArray(
"V_Layer2",
"nTruthLay2",(
double*) V_Layer2, nTruth[1]);
2562 myNTupleHelper->
fillArrayInt(
"trkID_Layer3",
"nTruthLay3",(
int*) trkID_Layer3, nTruth[2]);
2563 myNTupleHelper->
fillArrayInt(
"pdg_Layer3",
"nTruthLay3",(
int*) pdg_Layer3, nTruth[2]);
2564 myNTupleHelper->
fillArray(
"x_pre_Layer3",
"nTruthLay3",(
double*) x_pre_Layer3, nTruth[2]);
2565 myNTupleHelper->
fillArray(
"y_pre_Layer3",
"nTruthLay3",(
double*) y_pre_Layer3, nTruth[2]);
2566 myNTupleHelper->
fillArray(
"z_pre_Layer3",
"nTruthLay3",(
double*) z_pre_Layer3, nTruth[2]);
2567 myNTupleHelper->
fillArray(
"x_post_Layer3",
"nTruthLay3",(
double*) x_post_Layer3, nTruth[2]);
2568 myNTupleHelper->
fillArray(
"y_post_Layer3",
"nTruthLay3",(
double*) y_post_Layer3, nTruth[2]);
2569 myNTupleHelper->
fillArray(
"z_post_Layer3",
"nTruthLay3",(
double*) z_post_Layer3, nTruth[2]);
2570 myNTupleHelper->
fillArray(
"px_pre_Layer3",
"nTruthLay3",(
double*) px_pre_Layer3, nTruth[2]);
2571 myNTupleHelper->
fillArray(
"py_pre_Layer3",
"nTruthLay3",(
double*) py_pre_Layer3, nTruth[2]);
2572 myNTupleHelper->
fillArray(
"pz_pre_Layer3",
"nTruthLay3",(
double*) pz_pre_Layer3, nTruth[2]);
2573 myNTupleHelper->
fillArray(
"en_Layer3",
"nTruthLay3",(
double*) en_Layer3, nTruth[2]);
2574 myNTupleHelper->
fillArray(
"phi_Layer3",
"nTruthLay3",(
double*) phi_Layer3, nTruth[2]);
2575 myNTupleHelper->
fillArray(
"V_Layer3",
"nTruthLay3",(
double*) V_Layer3, nTruth[2]);
2580void CgemClusterCreate::checkRecCgemClusterCol()
2582 SmartDataPtr<RecCgemClusterCol> aCgemClusterCol(eventSvc(),
"/Event/Recon/RecCgemClusterCol");
2585 RecCgemClusterCol::iterator iter_cluster=aCgemClusterCol->begin();
2586 int nCluster = aCgemClusterCol->size();
2587 cout<<
"~~~~~~~~~~~~~~~~~~~~~~~~ check RecCgemClusterCol:"<<endl;
2588 cout <<setw(10)<<
"idx"
2591 <<setw(10)<<
"XVFlag"
2598 for(; iter_cluster!=aCgemClusterCol->end(); iter_cluster++)
2600 cout <<setw(10)<<(*iter_cluster)->getclusterid()
2601 <<setw(10)<<(*iter_cluster)->getlayerid()
2602 <<setw(10)<<(*iter_cluster)->getsheetid()
2603 <<setw(10)<<(*iter_cluster)->getflag()
2604 <<setw(10)<<(*iter_cluster)->getclusterflagb()
2605 <<setw(10)<<(*iter_cluster)->getclusterflage()
2606 <<setw(15)<<setprecision(10)<<(*iter_cluster)->getrecphi()
2607 <<setw(15)<<setprecision(10)<<(*iter_cluster)->getrecv()
2608 <<setw(15)<<setprecision(10)<<(*iter_cluster)->getRecZ()
2611 cout<<
"~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
2613 else cout<<
"CgemClusterCreate::checkRecCgemClusterCol(): RecCgemClusterCol not accessible!"<<endl;
2616bool CgemClusterCreate::isGoodDigi(CgemDigiCol::iterator
iter)
2618 double time = (*iter)->getTime_ns();
2620 if(time<-180.||time>100.)
return false;
2621 double Q = (*iter)->getCharge_fc();
2622 if(Q<0.)
return false;
2627bool CgemClusterCreate::selDigi(CgemDigiCol::iterator
iter,
int sel)
2629 if(sel==0)
return true;
2631 double time = (*iter)->getTime_ns();
2632 bool timeIsGood=
true;
2633 if(time<m_minDigiTime||time>m_maxDigiTime) timeIsGood=
false;
2635 double Q = (*iter)->getCharge_fc();
2636 bool chargeIsGood=
true;
2637 if(Q<myQMin) chargeIsGood=
false;
2639 const Identifier ident = (*iter)->identify();
2645 if(is_xstrip ==
true) view = 0;
2646 int quality = lutreader->
GetQuality(layer, sheet, view, strip);
2647 bool qualityIsGood=
true;
2648 if(quality!=0) qualityIsGood=
false;
2650 if(sel==1)
return timeIsGood&&chargeIsGood;
2651 else if(sel==-1)
return !timeIsGood&&chargeIsGood;
2652 else if(sel==2)
return timeIsGood&&chargeIsGood&&qualityIsGood;
2658float CgemClusterCreate::get_Time(CgemDigiCol::iterator iDigiCol){
2660 float time = (*iDigiCol)->getTime_ns();
2662 float time_rising = get_TimeRising(iDigiCol);
2664 float time_walk = get_TimeWalk(iDigiCol);
2666 float time_reference = get_TimeReference(iDigiCol);
2668 float time_shift_custom = -35;
2670 time-=(time_rising+time_walk+time_reference+time_shift_custom);
2675float CgemClusterCreate::get_TimeRising(CgemDigiCol::iterator iDigiCol){
2676 float time_rising=0;
2678 const Identifier ident = (*iDigiCol)->identify();
2684 if(is_xstrip ==
true) view = 0;
2685 float charge = (*iDigiCol)->getCharge_fc();
2687 time_rising = myCgemCalibSvc->
getTimeRising(layerid, view, sheetid, stripid, charge, 0.);
2691float CgemClusterCreate::get_TimeWalk(CgemDigiCol::iterator iDigiCol){
2693 const Identifier ident = (*iDigiCol)->identify();
2699 if(is_xstrip ==
true) view = 0;
2700 float thr = lutreader->
Get_thr_T_fC(layerid, sheetid, view, stripid);
2701 float charge = (*iDigiCol)->getChargeChannel();
2702 time_walk = myCgemCalibSvc->
getTimeWalk(charge,thr);
2706float CgemClusterCreate::get_TimeReference(CgemDigiCol::iterator iDigiCol){
2707 float time_reference=0;
2708 const Identifier ident = (*iDigiCol)->identify();
2714 if(is_xstrip ==
true) view = 0;
2717 return time_reference;
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
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
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
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