3 #include "FPCCDPixelHit.h"
10 #include <EVENT/LCCollection.h>
11 #include <IMPL/LCCollectionVec.h>
12 #include <IMPL/SimTrackerHitImpl.h>
13 #include <EVENT/SimTrackerHit.h>
14 #include <IMPL/TrackerHitImpl.h>
15 #include <IMPL/TrackerHitPlaneImpl.h>
16 #include <EVENT/MCParticle.h>
17 #include <UTIL/CellIDEncoder.h>
18 #include "UTIL/LCTrackerConf.h"
19 #include <UTIL/ILDConf.h>
20 #include "UTIL/LCTOOLS.h"
28 using namespace lcio ;
29 using namespace marlin ;
34 template<
class T1,
class T2,
class T3>
38 bool operator()(
const T1& object1,
const T1& object2 )
40 return object1.first->x() < object2.first->x();
54 _description =
"FPCCDDigitizer should create FPCCD's VTXPixelHits from SimTrackerHits" ;
58 registerProcessorParameter(
"CutOption_mode",
59 "true make the Cut option active.",
63 registerProcessorParameter(
"CutOption_theta_From",
68 registerProcessorParameter(
"CutOption_theta_To",
73 registerProcessorParameter(
"CutOption_phi_From",
78 registerProcessorParameter(
"CutOption_phi_To",
83 registerProcessorParameter(
"isSignalEvent_isBGEvent_forLinkerInClustering",
84 "1:SignalEvent 0:BGEvent for FPCCDOverlayBX process and linker in FPCCDClustering.",
88 registerProcessorParameter(
"Debug",
93 registerProcessorParameter(
"modifySimTrackerHit",
94 "Modify SimTrackerHit into layer",
98 registerProcessorParameter(
"OccupancyStudyMode" ,
99 "OccupancyStudyMode==1: We discreminate direct and backscatter. 0:NormalMode for tracking. Make sure HitQuality Option for discreminating signal and BG " ,
103 registerProcessorParameter(
"FPCCD_pixelSize(mm)" ,
104 "Pixel size of FPCCD (unit:mm) (default: 0.005)" ,
108 FloatVec pixelSizeVec;
109 for(
int i=0;i<6;i++){pixelSizeVec.push_back(0.005);}
111 registerProcessorParameter(
"Each_FPCCD_pixelSize(mm)",
112 "Each ladder's Pixel size of FPCCD (unit:mm) (default:0.005)",
116 registerProcessorParameter(
"PixelHeight(mm)" ,
121 registerProcessorParameter(
"sigmaConstant",
122 "ration of sigma of Landau distribution and path length",
126 registerProcessorParameter(
"HitQuality",
127 "If OccupancyStydyMode == 0, this becomes active. Then, true: digitize evt as signal. false: digitize as bkg. Then TrackerHit output from FPCCDClustering has a quality identifying signal hit or bkg hit. If you use FPCCDOverlayBX, I recommend to differentiate inputfile by this option.",
131 registerProcessorParameter(
"HelixTMomentumCriteria(MeV)" ,
132 "Transverse momentum criteria for helix approximation (MeV)",
136 registerProcessorParameter(
"Ladder_Number_encoded_in_cellID" ,
137 "Mokka has encoded the ladder number in the cellID" ,
141 registerProcessorParameter(
"EnergyLoss_almostOFF" ,
142 "false : normal mode, true : for computing Spatial Resolution." ,
147 registerInputCollection( LCIO::SIMTRACKERHIT,
148 "VTXCollectionName" ,
149 "Name of the VTX SimTrackerHit collection" ,
151 std::string(
"VXDCollection") ) ;
155 registerOutputCollection( LCIO::LCGENERICOBJECT,
156 "VTXPixelHitCollection" ,
157 "Name of the VXD PixelHit output collection" ,
159 std::string(
"VTXPixelHits") ) ;
180 const gear::ZPlanarParameters &gearVXD = Global::GEAR->getVXDParameters();
181 const gear::ZPlanarLayerLayout &layerVXD = gearVXD.getVXDLayerLayout();
182 _nLayer = layerVXD.getNLayers() ;
187 _geodata[ly].nladder = layerVXD.getNLadders(ly);
189 _geodata[ly].rmin = layerVXD.getSensitiveDistance(ly);
191 _geodata[ly].phi0 = layerVXD.getPhi0(ly);
192 _geodata[ly].sthick = layerVXD.getSensitiveThickness(ly);
193 _geodata[ly].sximin = -layerVXD.getSensitiveOffset(ly)
194 -layerVXD.getSensitiveWidth(ly)/2.0;
195 _geodata[ly].sximax = -layerVXD.getSensitiveOffset(ly)
196 +layerVXD.getSensitiveWidth(ly)/2.0;
197 _geodata[ly].hlength = layerVXD.getSensitiveLength(ly);
200 for(
int ld = 0;ld<
_geodata[ly].nladder;ld++) {
221 catch(DataNotAvailableException &
e){
222 if (
_debug == 1) { std::cout <<
"Collection " <<
_colNameVTX.c_str() <<
" is unavailable in event " <<
_nEvt << std::endl; }
231 int nSimHits =
col->getNumberOfElements() ;
235 if(
_debug == 1) { std::cout <<
"Now Range shows " << std::endl
239 for(
int i=0; i< nSimHits; i++){
240 SimTrackerHitImpl* SimTHitImpl =
dynamic_cast<SimTrackerHitImpl*
>(
col->getElementAt( i ) ) ;
241 double pos_x = SimTHitImpl->getPosition()[0];
double pos_y = SimTHitImpl->getPosition()[1];
double pos_z = SimTHitImpl->getPosition()[2];
242 double length_pos = sqrt(pow(pos_x,2) + pow(pos_y,2) + pow(pos_z,2));
243 double theta = 180/M_PI* acos( pos_z / length_pos );
244 double phi = 180/M_PI* atan2( pos_y ,pos_x);
246 if(
_debug==2){std::cout <<
"3-pos = " << pos_x <<
" , "<< pos_y <<
" , "<< pos_z << std::endl;
247 std::cout <<
"then Calc theta, phi = " << theta <<
" , " << phi << std::endl;
259 else std::cout <<
"something wrong at FPCCDDigitizer at line 246 to 256" << std::endl;
260 if(
_debug==2) std::cout <<
"accepted." << std::endl;
271 theData.packPixelHits( *fpccdDataVec );
275 std::cout <<
"dumpEvent Digitizer" << std::endl;
276 LCTOOLS::dumpEvent( evt ) ;
289 const gear::BField& gearBField = Global::GEAR->getBField();
290 double posphi = HitPosInMokka->phi();
291 if(HitPosInMokka->y()<0) posphi += 2*M_PI;
292 int layer = 0 ;
int ladderID = 0 ;
293 const int cellId = SimTHit->getCellID0();
296 streamlog_out( DEBUG3 ) <<
"Get Layer Number using StandardILD Encoding from ILDConf.h : cellId = " << cellId << std::endl;
297 UTIL::BitField64 encoder( lcio::LCTrackerCellID::encoding_string() ) ;
298 encoder.setValue(cellId) ;
299 layer = encoder[lcio::LCTrackerCellID::layer()] ; ladderID = encoder[lcio::LCTrackerCellID::module()] ;
300 streamlog_out( DEBUG3 ) <<
"layer Number = " << layer << std::endl; streamlog_out( DEBUG3 ) <<
"ladder Number = " << ladderID << std::endl;
302 else{ layer = cellId - 1 ; }
308 double momphi = MomAtHitPos->phi();
309 if(MomAtHitPos->y()<0) momphi += 2*M_PI;
314 if( mcp == 0 ) return ;
315 float charge = mcp->getCharge();
320 MomAtHitPos->x()*
_geodata[layer].cosphi[ladderID]+MomAtHitPos->y()*
_geodata[layer].sinphi[ladderID]);
323 _geodata[layer].cosphi[ladderID]*BField->x()+
_geodata[layer].sinphi[ladderID]*BField->y());
327 if( sqrt(MomAtLocalHitPos->x()*MomAtLocalHitPos->x() + MomAtLocalHitPos->z()*MomAtLocalHitPos->z()) <
_momCut*1
e-03){
328 if(
_debug == 1 ) cout <<
"========== Track of this hit is trated as a helix ==========" << endl;
334 std::cout <<
" layer = " << layer <<
" : PosIntoLadder = "<< PosInToLadder->x() <<
"," << PosInToLadder->y() <<
"," << PosInToLadder->z() << std::endl;
335 std::cout <<
" layer = " << layer <<
" : PosOutFromLadder = "<< PosOutFromLadder->x() <<
"," << PosOutFromLadder->y() <<
"," << PosOutFromLadder->z() << std::endl;
343 gear::Vector3D Path(PosOutFromLadder->x()-PosInToLadder->x(), PosOutFromLadder->y()-PosInToLadder->y(),
344 PosOutFromLadder->z()-PosInToLadder->z());
345 double PathLength = Path.r();
346 makeNewSimTHit(SimTHit, LocalHitPos, MomAtLocalHitPos, layer, ladderID, PathLength);
349 std::vector<std::pair<const gear::Vector3D*,int> >EdgeOfPixel =
getIntersectionOfTrkAndPix(layer,PosOutFromLadder,PosInToLadder);
351 sort( EdgeOfPixel.begin(), EdgeOfPixel.end(), SortByPosX<std::pair<const gear::Vector3D*, int>,
const gear::Vector3D*,
int >() );
352 std::map< std::pair< int, int>*,
double> pixel_local =
getLocalPixel(SimTHit,EdgeOfPixel);
353 std::map< std::pair< int, int>*,
double>::iterator i_pixel_local = pixel_local.begin();
355 while( i_pixel_local != pixel_local.end() ){
356 int xiID = (*i_pixel_local).first->first;
357 int zetaID = (*i_pixel_local).first->second;
358 float dE = (float)(*i_pixel_local).second;
359 FPCCDPixelHit::HitQuality_t quality;
361 if(
_isSignal && mcp->getParents().size() == 0 ){ quality = FPCCDPixelHit::kSingle; }
362 else{ quality = FPCCDPixelHit::kBKG;}
365 if( SimTHit->getTime() >10 ){ quality = FPCCDPixelHit::kSingle; }
366 else{ quality = FPCCDPixelHit::kBKG; }
368 FPCCDPixelHit aHit(layer, ladderID, xiID, zetaID, dE, quality, mcp);
369 if(nth_simthit > -1){ aHit.setOrderID(nth_simthit); }
370 else if(nth_simthit == -1){ aHit.setOrderID(-1); }
371 else{std::cout <<
"3rd argument in makepixelhit is something wrong. Please set nth_simthit value. wrong number is " << nth_simthit << std::endl;}
373 hitVec.addPixelHit(aHit,quality);
375 if(
_debug == 1 ) aHit.print();
381 if(
_debug == 1) cout <<
"This particle didn't through the sensitive region." << endl;
384 delete HitPosInMokka;
386 delete MomAtLocalHitPos;
388 delete PosOutFromLadder;
389 delete PosInToLadder;
404 streamlog_out(MESSAGE) <<
" end() " <<
name()
405 <<
" processed " <<
_nEvt <<
" events in " <<
_nRun <<
" runs "
416 std::cout <<
"layer is " << layer << std::endl;
417 double layerthickness =
_geodata[layer].sthick;
418 double radius =
_geodata[layer].rmin+0.5*layerthickness;
419 int nladder =
_geodata[layer].nladder;
421 double offset_phi =
_geodata[layer].phi0;
422 double posphi = pos->phi();
423 double posR = pos->rho();
426 double local_phi = 50.;
427 for(
int j=0; j<nladder; j++){
428 local_phi = posphi - dphi*j - offset_phi;
429 if((posR*cos(local_phi)-radius >= -layerthickness) && (posR*cos(local_phi)-radius <= layerthickness)){
434 if(ladderID>100) cout <<
"LADDERID>100!: " << ladderID << endl;
435 local_phi = posphi - dphi*(ladderID+1) - offset_phi;
436 if((posR*cos(local_phi)-radius >= -layerthickness) && (posR*cos(local_phi)-radius <= layerthickness)){
440 for(
int j=0; j<nladder; j++){
441 local_phi = posphi - dphi*j - offset_phi;
442 if((posR*cos(local_phi)-radius >= -1.*layerthickness) && (posR*cos(local_phi)-radius <= 1.*layerthickness)){
448 if(ladderID==50) cout <<
"LADDERID==50!" << endl;
449 if(ladderID>100) cout <<
"LADDERID>100!..." << ladderID << endl;
456 double posR = pos->rho();
457 double posphi = pos->phi();
460 posR*(cos(posphi)*
_geodata[layer].sinphi[ladder]-sin(posphi)*
_geodata[layer].cosphi[ladder]),
462 posR*(cos(posphi)*
_geodata[layer].cosphi[ladder]+sin(posphi)*
_geodata[layer].sinphi[ladder])-radius
471 double top_y = (mom->y()/mom->z())*(f_z-pos->z())+pos->y();
472 double top_x = (mom->x()/mom->z())*(f_z-pos->z())+pos->x();
474 double bottom_y = (mom->y()/mom->z())*(-f_z-pos->z())+pos->y();
475 double bottom_x = (mom->x()/mom->z())*(-f_z-pos->z())+pos->x();
477 if( (mom->x() > 0 && top_x > bottom_x) || (mom->x() < 0 && top_x < bottom_x ) ) {
490 (outpos->y()+inpos->y())/2 ,
491 (outpos->z()+inpos->z())/2);
498 double sximin =
_geodata[f_layer].sximin;
499 double sximax =
_geodata[f_layer].sximax;
500 double szetamin = -
_geodata[f_layer].hlength;
501 double szetamax =
_geodata[f_layer].hlength;
503 double preposx = bemodifiedpos->x();
504 double preposy = bemodifiedpos->y();
505 double preposz = bemodifiedpos->z();
507 if(preposx < sximin){
508 if(
_debug ==1 ) cout <<
"this hit was modified Sx" << endl;
510 preposy = (mom->y()/mom->x())*(preposx-pos->x())+pos->y();
511 preposz = (mom->z()/mom->x())*(preposx-pos->x())+pos->z();
512 }
else if(preposx > sximax){
513 if(
_debug ==1 ) cout <<
"this hit was modified Ex" << endl;
515 preposy = (mom->y()/mom->x())*(preposx-pos->x())+pos->y();
516 preposz = (mom->z()/mom->x())*(preposx-pos->x())+pos->z();
518 if(preposy < szetamin){
519 if(
_debug ==1 ) cout <<
"this hit was modified Sy" << endl;
521 preposx = (mom->x()/mom->y())*(preposy-pos->y())+pos->x();
522 preposz = (mom->z()/mom->y())*(preposy-pos->y())+pos->z();
523 }
else if(preposy > szetamax){
524 if(
_debug ==1 ) cout <<
"this hit was modified Ey" << endl;
526 preposx = (mom->x()/mom->y())*(preposy-pos->y())+pos->x();
527 preposz = (mom->z()/mom->y())*(preposy-pos->y())+pos->z();
530 *bemodifiedpos = prepos;
542 double sximin =
_geodata[layer].sximin;
543 double sximax =
_geodata[layer].sximax;
544 double szetamin = -
_geodata[layer].hlength;
545 double szetamax =
_geodata[layer].hlength;
552 double radius = (tmom.r()/(0.29979*BField->r()*fabs(Charge)))*1
e+03;
559 double init_pos[3] = {pos->x(),pos->y(),pos->z()};
560 double init_dir[3] = {mom->x()/tmom.r(),
563 double v_y = radius*init_dir[1];
565 double offset_pos[3];
567 double asin_offset = -(1/Charge)*asin(init_dir[0]/(Charge));
568 double acos_offset = (1/Charge)*acos(init_dir[2]/(Charge));
570 asin_offset*Charge >= 0 ? offset_phi = acos_offset : offset_phi = -acos_offset;
572 fabs(acos_offset*Charge) > PI/2 ? sign = -1 : sign = 1;
574 offset_pos[0] = init_pos[0]-radius*cos(Charge*offset_phi);
575 offset_pos[1] = init_pos[1]-v_y*offset_phi;
576 offset_pos[2] = init_pos[2]-radius*sin(Charge*offset_phi);
578 double outerZ_phi = 0;
579 double innerZ_phi = 0;
581 if( fabs((outerZ-offset_pos[2])/radius) <= 1. ) outerZ_phi = 1 / Charge*asin((outerZ-offset_pos[2])/radius) - asin_offset;
582 if( fabs((innerZ-offset_pos[2])/radius) <= 1. ) innerZ_phi = 1 / Charge*asin((innerZ-offset_pos[2])/radius) - asin_offset;
584 double outphi = sign*outerZ_phi ;
585 double inphi = sign*innerZ_phi ;
588 if( radius*cos(Charge*(outphi + offset_phi)) + offset_pos[0] <= sximin
589 || radius*cos(Charge*(outphi + offset_phi)) + offset_pos[0] >= sximax
590 || v_y*(outphi + offset_phi) + offset_pos[1] <= szetamin
591 || v_y*(outphi + offset_phi) + offset_pos[1] >= szetamax ) flag = flag + 1;
593 if( radius*cos(Charge*(inphi + offset_phi)) + offset_pos[0] <= sximin
594 || radius*cos(Charge*(inphi + offset_phi)) + offset_pos[0] >= sximax
595 || v_y*(inphi + offset_phi) + offset_pos[1] <= szetamin
596 || v_y*(inphi + offset_phi) + offset_pos[1] >= szetamax ) flag = flag + 2;
601 double sximin_phi = 1
e+8;
602 double sximax_phi = 1
e+8;
603 if(fabs((sximin-offset_pos[0])/radius) <= 1.) sximin_phi = sign*(1 / Charge*acos((sximin - offset_pos[0])/radius) - acos_offset);
604 if(fabs((sximax-offset_pos[0])/radius) <= 1.) sximax_phi = sign*(1 / Charge*acos((sximax - offset_pos[0])/radius) - acos_offset);
605 double szetamin_phi = (szetamin - offset_pos[1]) / v_y - offset_phi;
606 double szetamax_phi = (szetamax - offset_pos[1]) / v_y - offset_phi;
608 if(fabs(sximin_phi) <= fabs(sximax_phi) && fabs(sximin_phi) <= fabs(szetamin_phi) && fabs(sximin_phi) <= fabs(szetamax_phi)){
612 else if(fabs(sximax_phi) <= fabs(szetamin_phi) && fabs(sximax_phi) <= fabs(szetamax_phi)){
616 else if(fabs(szetamin_phi) <= fabs(szetamax_phi)){
617 tmpphi = szetamin_phi;
621 tmpphi = szetamax_phi;
624 if(flag == 1) outphi = tmpphi;
625 if(flag == 2) inphi = tmpphi;
628 if(fabs(sximin_phi) <= fabs(sximax_phi) && fabs(sximin_phi) <= fabs(szetamin_phi) && fabs(sximin_phi) <= fabs(szetamax_phi)) tmpphi = sximin_phi;
629 else if(fabs(sximax_phi) <= fabs(szetamin_phi) && fabs(sximax_phi) <= fabs(szetamax_phi)) tmpphi = sximax_phi;
630 else if(fabs(szetamin_phi) <= fabs(szetamax_phi))tmpphi = szetamin_phi;
631 else tmpphi = szetamax_phi;
635 out[0] = radius*cos(Charge*(outphi+offset_phi)) + offset_pos[0];
636 out[1] = v_y * (outphi+offset_phi)+ offset_pos[1];
637 out[2] = radius*sin(Charge*(outphi+offset_phi)) + offset_pos[2];
639 in[0] = radius*cos(Charge*(inphi+offset_phi)) + offset_pos[0];
640 in[1] = v_y * (inphi+offset_phi)+ offset_pos[1];
641 in[2] = radius*sin(Charge*(inphi+offset_phi)) + offset_pos[2];
643 double center_phi = (outphi+inphi)/2;
644 *pos =
gear::Vector3D(radius*cos(Charge*(center_phi+offset_phi)) + offset_pos[0],
645 v_y*(center_phi+offset_phi) + offset_pos[1],
646 radius*sin(Charge*(center_phi+offset_phi)) + offset_pos[2]);
647 *mom =
gear::Vector3D(-radius*sin(Charge*(center_phi+offset_phi)),
649 radius*cos(Charge*(center_phi+offset_phi)));
658 std::vector<std::pair<const gear::Vector3D*, int> > EdgeOfPixel;
659 double sximin =
_geodata[f_layer].sximin;
660 double szetamin = -
_geodata[f_layer].hlength;
665 if(top->x()>=bottom->x()){ large_localx = top->x(); small_localx = bottom->x(); }
666 else { large_localx = bottom->x(); small_localx = top->x(); }
667 if(top->y()>=bottom->y()) {large_localy = top->y(); small_localy = bottom->y(); }
668 else { large_localy = bottom->y(); small_localy = top->y(); }
671 int sloopx = (int)ceil((small_localx-sximin)/
_pixelSize) ;
672 int eloopx = (int)ceil((large_localx-sximin)/
_pixelSize) - 1;
673 int sloopy = (int)ceil((small_localy-szetamin)/
_pixelSize) ;
674 int eloopy = (int)ceil((large_localy-szetamin)/
_pixelSize) - 1;
676 int nloopx = eloopx - sloopx + 1;
677 int nloopy = eloopy - sloopy + 1;
679 std::cout <<
"check sximin,szetamin = " << sximin <<
" , " << szetamin << std::endl;
680 std::cout <<
"check small_localx, large_localx = " << small_localx <<
" , " << large_localx << std::endl;
681 std::cout <<
"check small_localy, large_localy = " << small_localy <<
" , " << large_localy << std::endl;
682 std::cout <<
"check sloopx, eloopx = " << sloopx <<
" , " << eloopx << std::endl;
683 std::cout <<
"check sloopy, eloopy = " << sloopy <<
" , " << eloopy << std::endl;
684 std::cout <<
"check nloopx, nloopy = " << nloopx <<
" , " << nloopy << std::endl;
687 for(
int j=0; j<
nloopx; j++){
688 double XEdgeOfPixelZ = ((top->z()-bottom->z())/(top->x()-bottom->x()))*(sximin+(sloopx+j)*
_pixelSize-(top->x()+bottom->x())/2.)+(top->z()+bottom->z())/2.;
689 double XEdgeOfPixelX = sximin+(sloopx+j)*
_pixelSize;
690 double XEdgeOfPixelY = ((top->y()-bottom->y())/(top->x()-bottom->x()))*(sximin+(sloopx+j)*
_pixelSize-(top->x()+bottom->x())/2.)+(top->y()+bottom->y())/2.;
693 EdgeOfPixel.push_back(std::pair<gear::Vector3D*,int>(XEdgeOfPixel,1));
695 for(
int j=0; j<
nloopy; j++){
696 double YEdgeOfPixelZ = ((top->z()-bottom->z())/(top->y()-bottom->y()))*(szetamin+(sloopy+j)*
_pixelSize-(top->y()+bottom->y())/2.)+(top->z()+bottom->z())/2.;
697 double YEdgeOfPixelX = ((top->x()-bottom->x())/(top->y()-bottom->y()))*(szetamin+(sloopy+j)*
_pixelSize-(top->y()+bottom->y())/2.)+(top->x()+bottom->x())/2.;
698 double YEdgeOfPixelY = szetamin+(sloopy+j)*
_pixelSize;
701 EdgeOfPixel.push_back(std::pair<gear::Vector3D*,int>(YEdgeOfPixel,2));
703 EdgeOfPixel.push_back(std::pair<gear::Vector3D*,int>(top,0));
704 EdgeOfPixel.push_back(std::pair<gear::Vector3D*,int>(bottom,0));
710 std::map<pair< int, int>*,
double> pixel_local;
711 UTIL::BitField64 encoder( lcio::LCTrackerCellID::encoding_string() ) ;
712 encoder.setValue(simthit->getCellID0()) ;
713 int f_layer = encoder[lcio::LCTrackerCellID::layer()] ;
716 dEdx = simthit->getEDep()*1
e+9;
726 double path_length = simthit->getPathLength();
731 std::vector<std::pair<const gear::Vector3D*,int> >::iterator nxt = edgeofpixel.begin();
732 while( nxt != edgeofpixel.end()-1 ){
733 std::vector<std::pair<const gear::Vector3D*,int> >::iterator fst = nxt;
736 double diffx = (*nxt).first->x() - (*fst).first->x();
737 double diffy = (*nxt).first->y() - (*fst).first->y();
738 double diffz = (*nxt).first->z() - (*fst).first->z();
739 double L_through_pixel = sqrt(diffx*diffx + diffy*diffy + diffz*diffz);
741 mpv = (dEdx/path_length)*L_through_pixel;
744 dE = gRandom->Landau( mpv, sigma)*1
e-9;
746 std::pair< int, int>* pixID =
FindPixel((*fst),(*nxt),f_layer);
747 pixel_local.insert(std::map< std::pair<int, int>*,
double>::value_type( pixID, dE));
753 std::pair< int, int>*
FPCCDDigitizer::FindPixel(std::pair<const gear::Vector3D*,int> fst, std::pair<const gear::Vector3D*,int> nxt,
int layer){
755 std::pair<int,int> fst_array[4] ;
756 std::pair<int,int> nxt_array[4] ;
761 std::pair<int,int>* pixID =
new std::pair< int, int>(0,0);
762 for(
int i=0; i<4; i++){
763 for(
int j=0; j<4; j++){
764 if(fst_array[i].first >= 0 && fst_array[i] == nxt_array[j] ){
765 pixID->first = fst_array[i].first;
766 pixID->second = fst_array[i].second;
778 std::pair<int,int> candID1(-1,-1);
779 std::pair<int,int> candID2(-1,-1);
780 std::pair<int,int> candID3(-1,-1);
781 std::pair<int,int> candID4(-1,-1);
783 double hlength =
_geodata[layer].hlength;
784 double sximin =
_geodata[layer].sximin;
786 double quotient_x = (edge.first->x()-sximin)/
_pixelSize ;
787 double quotient_y = (edge.first->y()+hlength)/
_pixelSize ;
789 double mergin = 1
e-5;
794 candID1.first = (int)floor(quotient_x);
795 if ( quotient_x - candID1.first < mergin/
_pixelSize ) candID2.first = candID1.first - 1;
796 else if( quotient_x - candID1.first > 1 - mergin/
_pixelSize ) candID2.first = candID1.first + 1;
797 else candID2.first = candID1.first;
799 candID1.second = (int)floor(quotient_y);
800 if ( quotient_y - candID1.second < mergin/
_pixelSize ) candID2.second = candID1.second - 1;
801 else if( quotient_y - candID1.second > 1 - mergin/
_pixelSize )candID2.second = candID1.second + 1;
802 else candID2.second = candID1.second;
806 candID1.first = (int)floor(quotient_x + 0.5);
807 candID2.first = candID1.first - 1;
808 candID1.second = (int)floor(quotient_y);
809 candID2.second = candID1.second;
811 if ( quotient_y - candID1.second < mergin/
_pixelSize){
812 candID3.first = candID1.first;
813 candID3.second = candID1.second - 1;
814 candID4.first = candID2.first;
815 candID4.second = candID2.second - 1;
817 else if( quotient_y - candID1.second > 1 - mergin/
_pixelSize){
818 candID3.first = candID1.first;
819 candID3.second = candID1.second + 1;
820 candID4.first = candID2.first;
821 candID4.second = candID2.second + 1;
826 candID1.first = (int)floor(quotient_x);
827 candID2.first = candID1.first;
828 candID1.second = (int)floor(quotient_y + 0.5);
829 candID2.second = candID1.second - 1;
831 if ( quotient_x - candID1.first < mergin/
_pixelSize){
832 candID3.first = candID1.first - 1;
833 candID3.second = candID1.second;
834 candID4.first = candID2.first - 1;
835 candID4.second = candID2.second;
837 else if( quotient_x - candID1.first > 1 - mergin/
_pixelSize){
838 candID3.first = candID1.first + 1;
839 candID3.second = candID1.second;
840 candID4.first = candID2.first + 1;
841 candID4.second = candID2.second;
845 if(
_debug == 1) std::cout <<
"pixel candidates cannot found. : " << edge.second << std::endl;
848 *cand_array = candID1;
849 *(cand_array+1) = candID2;
850 *(cand_array+2) = candID3;
851 *(cand_array+3) = candID4;
859 float newdEdx = simthit->getEDep()*newPathLength/simthit->getPathLength();
861 double pos[3] = {newpos->x()*
_geodata[layer].sinphi[ladder]+eta0*
_geodata[layer].cosphi[ladder],
862 -newpos->x()*
_geodata[layer].cosphi[ladder]+eta0*
_geodata[layer].sinphi[ladder],
864 float mom[3] = {(float)(newmom->x()*
_geodata[layer].cosphi[ladder] - newmom->z()*
_geodata[layer].sinphi[ladder]),
865 (
float)(newmom->x()*
_geodata[layer].sinphi[ladder] + newmom->z()*
_geodata[layer].cosphi[ladder]),
868 CellIDEncoder<SimTrackerHitImpl> cellid_encoder( lcio::LCTrackerCellID::encoding_string() ,
col) ;
869 cellid_encoder[ lcio::LCTrackerCellID::subdet() ] = lcio::ILDDetID::VXD ;
870 cellid_encoder[ lcio::LCTrackerCellID::side() ] = 0 ;
871 cellid_encoder[ lcio::LCTrackerCellID::layer() ] = layer ;
872 cellid_encoder[ lcio::LCTrackerCellID::module() ] = ladder ;
873 cellid_encoder[ lcio::LCTrackerCellID::sensor() ] = 0 ;
874 cellid_encoder.setCellID( simthit );
875 simthit->setEDep( newdEdx );
876 simthit->setPathLength( (
float)newPathLength );
877 simthit->setPosition( pos );
878 simthit->setMomentum( mom );
885 || fabs(pos->y()) >
_geodata[layer].hlength + 1
e-5
886 || pos->x() >
_geodata[layer].sximax + 1
e-5
887 || pos->x() <
_geodata[layer].sximin - 1
e-5){
std::string _outColNameVTX
std::vector< std::pair< const gear::Vector3D *, int > > getIntersectionOfTrkAndPix(const int layer, gear::Vector3D *top, gear::Vector3D *bottom)
FPCCDDigitizer aFPCCDDigitizer
void getInOutPosOfHelixOnLadder(int layer, gear::Vector3D *outpos, gear::Vector3D *inpos, gear::Vector3D *pos, gear::Vector3D *mom, gear::Vector3D *BField, float charge)
int getLadderID(const gear::Vector3D *pos, const int layer)
virtual void modifyEvent(LCEvent *evt)
CLHEP::Hep3Vector Vector3D
std::map< std::pair< int, int > *, double > getLocalPixel(IMPL::SimTrackerHitImpl *simthit, std::vector< std::pair< const gear::Vector3D *, int > > edgeofpixel)
bool inSensitiveRegion(gear::Vector3D *pos, int layer)
std::vector< GeoData_t > _geodata
virtual void end()
Called after data processing for clean up.
virtual void init()
Called at the begin of the job before anything is read.
void makePixelHits(IMPL::SimTrackerHitImpl *simHit, FPCCDData &pxHits)
bool _ladder_Number_encoded_in_cellID
void makeCandidates(std::pair< const gear::Vector3D *, int > edge, std::pair< int, int > *cand_array, int layer)
virtual void processRunHeader(LCRunHeader *run)
Called for every run.
void ModifyIntoLadder(gear::Vector3D *bemodifiedpos, const int layer, gear::Vector3D *pos, gear::Vector3D *mom)
gear::Vector3D * getLocalPos(const gear::Vector3D *pos, const int layer, const int ladder)
std::pair< int, int > * FindPixel(std::pair< const gear::Vector3D *, int > f_fst, std::pair< const gear::Vector3D *, int > f_nxt, int f_layer)
void makeNewSimTHit(IMPL::SimTrackerHitImpl *simthit, gear::Vector3D *newpos, gear::Vector3D *newmom, int layer, int ladder, double newPathLength)
MCParticle * getMCParticle(ReconstructedParticle *recPart, LCCollection *colMCTL)
std::vector< LCCollection * > LCCollectionVec
void getInOutPosOnLadder(int layer, gear::Vector3D *outpos, gear::Vector3D *inpos, gear::Vector3D *pos, gear::Vector3D *mom)
virtual const std::string & name() const
virtual void check(LCEvent *evt)
Called for every event - the working horse.