104 #include <TClonesArray.h> 131 static Short_t firstcall=0;
132 static Float_t integral[1000];
137 Float_t f,buff[1000];
146 buff[i]=pow(param,param)/TMath::Gamma(param)*pow(lambda,param-1)*exp(-param*lambda);
148 integral[i]=integral[i-1]+buff[i];
156 if(f>0.0001 && f<0.9999) check=1;
161 if(f<integral[i]/integral[999]){
230 if(
DIGI_DEBUG>3) cout <<
"Enters ActarPadSignal::ActarPadSignal()" << endl;
231 padNumber=0; padRow=0; padColumn=0;
233 initTime=0.; finalTime=0.; sigmaTime=0.;
236 if(
DIGI_DEBUG>3) cout <<
"Exits ActarPadSignal::ActarPadSignal()" << endl;
244 if(
DIGI_DEBUG>3) cout <<
"Enters ActarPadSignal::Reset()" << endl;
245 padNumber=0; padRow=0; padColumn=0;
247 initTime=0.; finalTime=0.; sigmaTime=0.;
250 if(
DIGI_DEBUG>3) cout <<
"Exits ActarPadSignal::Reset()" << endl;
255 if(
DIGI_DEBUG>3) cout <<
"Enters ActarPadSignal::operator=()" << endl;
268 if(
DIGI_DEBUG>3) cout <<
"Exits ActarPadSignal::operator=()" << endl;
317 if(
DIGI_DEBUG>3) cout <<
"Enters projectionOnPadPlane::projectionOnPadPlane()" << endl;
318 track=0; pre=
new TVector3(1,1,1); post=
new TVector3(1,1,1);
319 timePre=-1.; timePost=-1.;
320 sigmaLongAtPadPlane=-1.; sigmaTransvAtPadPlane=-1.;
322 if(
DIGI_DEBUG>3) cout <<
"Exits projectionOnPadPlane::projectionOnPadPlane()" << endl;
325 if(
DIGI_DEBUG>3) cout <<
"Enters projectionOnPadPlane::~projectionOnPadPlane()" << endl;
328 if(
DIGI_DEBUG>3) cout <<
"Exits projectionOnPadPlane::~projectionOnPadPlane()" << endl;
367 void SetPadsGeometry(
void);
370 void SetGeometryValues(Int_t geo, Int_t pad, Int_t layout, Double_t x, Double_t y, Double_t z, Double_t xBeam, Double_t yBeam,
371 Double_t ra, Double_t psi, Double_t gapx, Double_t gapz){
372 if(
DIGI_DEBUG>3) cout <<
"Enters padsGeometry::SetGeometryValues()" << endl;
373 geoType=geo; padType=pad; padLayout=layout;
374 xLength = x; yLength = y; zLength = z;
375 xBeamShift = xBeam; yBeamShift = yBeam;
376 radius=ra; padSize=psi;
377 if(padType == 1)rHexagon = 0.8660254037844386467868626478 * padSize;
379 sideBlankSpaceX = gapx; sideBlankSpaceZ = gapz;
381 if(
DIGI_DEBUG>3) cout <<
"Exits padsGeometry::SetGeometryValues()" << endl;
386 if(DetectorConfig==
"ActarTPCDemo"){
387 geoType=0; padType=0; padLayout=0;
388 radius=0.; padSize=2.;
389 xLength = 37.; yLength = 85.; zLength = 69.;
390 xBeamShift = 0.; yBeamShift = 15.;
391 sideBlankSpaceX=5.; sideBlankSpaceZ=5.;
393 if(DetectorConfig==
"ActarTPC"){
394 geoType=0; padType=0; padLayout=0;
395 radius=0.; padSize=2.;
396 xLength = 133.; yLength = 85.; zLength = 133.;
397 xBeamShift = 0.; yBeamShift = 15.;
398 sideBlankSpaceX=5.; sideBlankSpaceZ=5.;
402 if(
DIGI_DEBUG>3) cout <<
"Exits padsGeometry::SetGeometryValues()" << endl;
447 TVector3 CoordinatesCenterOfPad(Int_t pad);
448 Int_t IsInPadNumber(TVector3* point);
449 Int_t GetPadColumnFromXZValue(Double_t x, Double_t z);
450 Int_t GetPadRowFromXZValue(Double_t x, Double_t z);
454 if(
DIGI_DEBUG>3) cout <<
"Enters padsGeometry::CalculatePad()" << endl;
455 if(r<=0 || r>numberOfRows || c<=0 || c>numberOfColumns){
457 cout <<
"WARNING: padsGeometry:CalculatePad(" << r <<
"," << c
458 <<
"): row or column number out of range!" <<
" row=" << r <<
", col=" << c << endl;
462 else return ((r-1) * numberOfColumns + (c-1) + 1);
467 if(
DIGI_DEBUG>3) cout <<
"Enters padsGeometry::CalculateColumn()" << endl;
468 if(p>numberOfPads || p==0)
return 0;
469 if(p%numberOfColumns==0)
return numberOfColumns;
470 else return p%numberOfColumns;
475 if(
DIGI_DEBUG>3) cout <<
"Enters padsGeometry::CalculateRow()" << endl;
476 if(p>numberOfPads || p==0)
return 0;
477 else return (Int_t)(((p-1)/numberOfColumns)+1);}
483 if(
DIGI_DEBUG>3) cout <<
"Enters padsGeometry::padsGeometry()" << endl;
484 numberOfColumns=0; numberOfRows=0; numberOfPads=0;
485 geoType=999; padType=999; padLayout=0;
486 padSize=0.; rHexagon=0.;
487 xLength=0; yLength=0; zLength=0;
488 sideBlankSpaceX=0.; sideBlankSpaceZ=0.;
490 deltaProximityBeam=0.; sizeBeamShielding=0.;
492 if(
DIGI_DEBUG>3) cout <<
"Exits padsGeometry::padsGeometry()" << endl;
501 if(
DIGI_DEBUG>3) cout <<
"Enters padsGeometry::SetPadsGeometry()" << endl;
503 cout <<
"________________________________________________________" << endl
504 <<
"In padsGeometry::SetPadsGeometry() " << endl
505 <<
"Note that the calculation of the pads geometry could "<< endl
506 <<
"modify slightly the size of the pad you have introduced." << endl;
507 if(geoType == 0 && padType == 0){
508 numberOfRows = (Int_t) (2*(xLength-sideBlankSpaceX)/padSize);
510 cout <<
"User selected a box with square pads" << endl
511 <<
"User selected a padSize = " << padSize;
512 padSize = (2*(xLength-sideBlankSpaceX)) / numberOfRows;
514 cout <<
" after the calculation: padSize = " << padSize <<endl;
515 numberOfColumns = ((Int_t) (2*(zLength-sideBlankSpaceZ) / padSize)) - 1;
516 if((numberOfColumns+1)*padSize <= 2*(zLength-sideBlankSpaceZ)) numberOfColumns++;
517 numberOfPads = numberOfRows*numberOfColumns;
519 cout <<
"________________________________________________________" << endl
520 <<
" Output of padsGeometry::SetPadsGeometry() " << endl
521 <<
" numberOfRows = "<< numberOfRows
522 <<
", numberOfColumns = " << numberOfColumns << endl
523 <<
"________________________________________________________"<< endl;
525 else if(geoType == 0 && padType == 1 && padLayout==0){
526 numberOfColumns = (Int_t) (zLength/rHexagon);
528 cout <<
"User selected a box with hexagonal pads (MAYA-type)" << endl
529 <<
"User selected a padSize = " << padSize
530 <<
" and therefore a rHexagon = " << rHexagon<< endl;
531 rHexagon = zLength / numberOfColumns;
532 padSize = 1.154700538379251529013 * rHexagon;
534 cout <<
" after the calculation: padSize = " << padSize
535 <<
" and therefore a rHexagon = " << rHexagon << endl;
536 numberOfRows = (Int_t) ((2.*xLength-2.*padSize)/(1.5*padSize))+1;
537 sideBlankSpaceX = (2.*xLength-(numberOfRows-1)*1.5*padSize-2.*padSize )/2.;
538 numberOfPads = numberOfRows*numberOfColumns;
540 cout <<
"________________________________________________________" << endl
541 <<
" Output of padsGeometry::SetPadsGeometry() " << endl
542 <<
" numberOfRows = "<< numberOfRows
543 <<
", numberOfColumns = " << numberOfColumns << endl
544 <<
"________________________________________________________"<< endl;
546 else if(geoType == 0 && padType == 1 && padLayout==1){
547 numberOfRows = (Int_t) (xLength/rHexagon);
549 cout <<
"User selected a box with hexagonal pads (rotated wrt MAYA-type)" << endl
550 <<
"User selected a padSize = " << padSize
551 <<
" and therefore a rHexagon = " << rHexagon<< endl;
552 rHexagon = xLength / numberOfRows;
553 padSize = 1.154700538379251529013 * rHexagon;
555 cout <<
" after the calculation: padSize = " << padSize
556 <<
" and therefore a rHexagon = " << rHexagon << endl;
557 numberOfColumns = (Int_t) ((2.*zLength-2.*padSize)/(1.5*padSize)) + 1;
558 sideBlankSpaceZ = (2.*zLength -(numberOfColumns-1)*1.5*padSize-2.*padSize)/2.;
559 numberOfPads = numberOfRows*numberOfColumns;
561 cout <<
"________________________________________________________" << endl
562 <<
" Output of padsGeometry::SetPadsGeometry() " << endl
563 <<
" numberOfRows = "<< numberOfRows
564 <<
", numberOfColumns = " << numberOfColumns << endl
565 <<
"________________________________________________________"<< endl;
567 else if(geoType == 1 && padType == 0){
568 numberOfRows = (Int_t) (2*TMath::Pi()*radius / padSize);
570 cout <<
"User selected a cylinder with square pads (on the cylindrical walls)" << endl
571 <<
"User selected a padSize = " << padSize;
572 padSize = 2*TMath::Pi()*radius / numberOfRows;
574 cout <<
" after the calculation: padSize = " << padSize <<endl;
575 numberOfColumns = ((Int_t) (2*zLength / padSize)) - 1;
576 if( (numberOfColumns+1)*padSize <= 2*zLength ) numberOfColumns++;
577 numberOfPads = numberOfRows*numberOfColumns;
579 cout <<
"________________________________________________________" << endl
580 <<
" Output of padsGeometry::SetPadsGeometry() " << endl
581 <<
" numberOfRows = "<< numberOfRows
582 <<
", numberOfColumns = " << numberOfColumns << endl
583 <<
"________________________________________________________"<< endl;
585 else if(geoType == 1 && padType == 1){
586 numberOfRows = (Int_t) (TMath::Pi()*radius / rHexagon);
588 cout <<
"User selected a cylinder with hexagonal pads" << endl
589 <<
"User selected a padSize = " << padSize
590 <<
" and therefore a rHexagon = " << rHexagon<< endl;
591 rHexagon = TMath::Pi()*radius / numberOfRows;
592 padSize = 1.154700538379251529013 * rHexagon;
594 cout <<
" after the calculation: padSize = " << padSize
595 <<
" and therefore a rHexagon = " << rHexagon << endl;
596 numberOfColumns = ((Int_t) (2*zLength / (1.5*padSize))) - 1;
597 if( (numberOfColumns+1)*1.5*padSize <= 2*zLength ) numberOfColumns++;
598 numberOfPads = numberOfRows*numberOfColumns;
600 cout <<
"________________________________________________________" << endl
601 <<
" Output of padsGeometry::SetPadsGeometry() " << endl
602 <<
" numberOfRows = "<< numberOfRows
603 <<
", numberOfColumns = " << numberOfColumns << endl
604 <<
"________________________________________________________"<< endl;
608 cout <<
"ERROR: No valid geometry... Have you called " 609 <<
"SetGeometryValues() with valid arguments?" << endl << endl;
611 if(
DIGI_DEBUG>3) cout <<
"Exits padsGeometry::SetPadsGeometry()" << endl;
616 if(
DIGI_DEBUG>3) cout <<
"Enters padsGeometry::IsInPadNumber()" << endl;
617 Int_t column; Int_t row;
618 if(geoType == 0 && padType == 0) {
619 row = (Int_t) (((point->X() - sideBlankSpaceX + xLength)/ padSize) + 1);
621 column = (Int_t) (((point->Z() - sideBlankSpaceZ + zLength)/ padSize)+1);
622 if(column > 0 && column < numberOfColumns+1
623 && row > 0 && row < numberOfRows+1) {
625 cout <<
"In padsGeometry::IsInPadNumber()" << endl
626 <<
" Pad (" << row <<
"," << column <<
") for point " 627 << point->X() <<
","<< point->Y() <<
","<< point->Z()<< endl;
628 return CalculatePad(row,column);
632 cout <<
"ERROR: in padsGeometry::IsInPadNumber()" << endl
633 <<
" Invalid pad returned from requested point " 634 <<
" sideBlankSpaceZ "<<sideBlankSpaceZ <<
" Pad (" << row <<
"," << column <<
") for point " 635 << point->X() <<
","<< point->Y() <<
","<< point->Z()<< endl;
639 else if(geoType == 0 && padType == 1 && padLayout == 0){
641 if(point->X()< -xLength || point->X()>xLength || point->Z()< -zLength || point->Z()>zLength) {
643 cout <<
"ERROR: in padsGeometry::IsInPadNumber()" << endl
644 <<
" Invalid pad returned from requested point " 645 << point->X() <<
","<< point->Y() <<
","<< point->Z()<< endl;
648 row = (Int_t) ((point->X() + xLength - sideBlankSpaceX)/(1.5*padSize))+1;
649 column = (Int_t) (point->Z()/ (2*rHexagon)) + 1;
650 Double_t shorterDist = padSize; Int_t candidate=0; point->SetY(-yLength);
651 for(Int_t i=0;i<2;i++){
652 for(Int_t j=-1;j<1;j++){
653 if((column+i)>numberOfColumns || (row+j)<1 || (row+j)>numberOfRows)
continue;
654 TVector3 distance = *point - CoordinatesCenterOfPad(CalculatePad(row+j,column+i));
655 if (distance.Mag() <= rHexagon){
656 return CalculatePad(row+j,column+i);
658 if(distance.Mag() <= shorterDist) {
659 shorterDist = distance.Mag();
660 candidate = CalculatePad(row+j,column+i);
665 cout <<
"In padsGeometry::IsInPadNumber()" << endl
666 <<
" Pad (" << row <<
"," << column <<
") for point " 667 << point->X() <<
","<< point->Y() <<
","<< point->Z()<< endl;
670 else if(geoType == 0 && padType == 1 && padLayout == 1){
672 if(point->X()< -xLength || point->X()>xLength || point->Z()< -zLength || point->Z()>zLength) {
674 cout <<
"ERROR: in padsGeometry::IsInPadNumber()" << endl
675 <<
" Invalid pad returned from requested point " 676 << point->X() <<
","<< point->Y() <<
","<< point->Z()<< endl;
679 row = (Int_t) (((point->X() + xLength)/ (2*rHexagon)) + 1);
681 column = (Int_t) (((point->Z() - sideBlankSpaceZ + xLength)/(1.5*padSize))+1);
682 Double_t shorterDist = padSize; Int_t candidate=0; point->SetY(-yLength);
683 for(Int_t i=0;i<2;i++){
684 for(Int_t j=-1;j<1;j++){
685 if(row+i>numberOfRows || column+j<1 || column+j>numberOfColumns)
continue;
686 TVector3 distance = *point - CoordinatesCenterOfPad(CalculatePad(row+i,column+j));
687 if (distance.Mag() <= rHexagon)
return CalculatePad(row+i,column+j);
688 if( distance.Mag() <= shorterDist ) {
689 shorterDist = distance.Mag();
690 candidate = CalculatePad(row+i,column+j);
695 cout <<
"In padsGeometry::IsInPadNumber()" << endl
696 <<
" Pad (" << row <<
"," << column <<
") for point " 697 << point->X() <<
","<< point->Y() <<
","<< point->Z()<< endl;
700 else if(geoType == 1 && padType == 0){
701 if(point->Phi()>=0) row =(Int_t)(numberOfRows * (point->Phi()) / (2*TMath::Pi())) +1;
702 else row =(Int_t)(numberOfRows * ( point->Phi() + (2*TMath::Pi())) / (2*TMath::Pi())) +1;
703 column = (Int_t) ((point->Z() / padSize)+1);
704 if(column > 0 && column < numberOfColumns+1 &&
705 row > 0 && row < numberOfRows+1) {
707 cout <<
"In padsGeometry::IsInPadNumber()" << endl
708 <<
" Pad (" << row <<
"," << column <<
") for point " 709 << point->X() <<
","<< point->Y() <<
","<< point->Z()<< endl;
710 return CalculatePad(row,column);
714 cout <<
"ERROR: in padsGeometry::IsInPadNumber()" << endl
715 <<
" Invalid pad returned from requested point " 716 << point->X() <<
","<< point->Y() <<
","<< point->Z()<< endl;
720 else if(geoType == 1 && padType == 1){
721 if(point->Z()<0 || point->Z()>2*zLength) {
723 cout <<
"ERROR: in padsGeometry::IsInPadNumber()" << endl
724 <<
" Invalid pad returned from requested point " 725 << point->X() <<
","<< point->Y() <<
","<< point->Z()<< endl;
728 if(point->Phi()>=0) row= (Int_t)(numberOfRows * (point->Phi()) / (2*TMath::Pi())) + 1;
729 else row= (Int_t)(numberOfRows * (point->Phi()+(2*TMath::Pi())) / (2*TMath::Pi())) + 1;
730 column = (Int_t)((point->Z()/(1.5*padSize))+1);
731 Double_t shorterDist = padSize; Int_t candidate=0; point->SetPerp(radius);
732 for(Int_t i=0;i<2;i++){
733 for(Int_t j=-1;j<1;j++){
734 if(row+i>numberOfRows || column+j<1 || column+j>numberOfColumns)
continue;
735 TVector3 distance = *point - CoordinatesCenterOfPad(CalculatePad(row+i,column+j));
736 if( distance.Mag() <= shorterDist ) {
737 shorterDist = distance.Mag();
738 candidate = CalculatePad(row+i,column+j);
743 cout <<
"In padsGeometry::IsInPadNumber()" << endl
744 <<
" Pad (" << row <<
"," << column <<
") for point " 745 << point->X() <<
","<< point->Y() <<
","<< point->Z()<< endl;
750 cout <<
"No valid geometry... Have you called " 751 <<
"SetGeometryValues() with valid arguments?" <<endl<<endl;
761 TVector3 point(x, -yBeamShift-yLength, z);
763 Int_t column=0, row=0;
764 if(geoType == 0 && padType == 0){
766 column = (Int_t) numberOfColumns/2.+ ((z / padSize)+1);
769 else if(geoType == 0 && padType == 1 && padLayout == 0){
770 column = (Int_t) ((point.Z()/(2*rHexagon))+1);
773 else if(geoType == 0 && padType == 1 && padLayout == 1){
774 row = (Int_t) (((point.X() + xLength)/ (2*rHexagon)) + 1);
775 column = (Int_t) (((point.Z()-sideBlankSpaceZ)/(1.5*padSize))+1);
776 Double_t shorterDist = padSize; Int_t candidate=0; point.SetY(-yBeamShift-yLength);
777 for(Int_t i=0;i<2;i++){
778 for(Int_t j=-1;j<1;j++){
779 vec.SetXYZ(-xLength + ((2*(row+i))-1)*rHexagon,
781 padSize*((column+j)*1.5-0.5)+sideBlankSpaceZ);
782 if((column+j)%2==0) vec.SetX(vec.X()-rHexagon);
783 TVector3 distance = point - vec;
784 if (distance.Mag() <= rHexagon)
return column+j;
785 if( distance.Mag() <= shorterDist ) {
786 shorterDist = distance.Mag();
787 candidate = column+j;
792 cout <<
"In padsGeometry::IsInPadNumber()" << endl
793 <<
" Pad (" << row <<
"," << column <<
") for point " 794 << point.X() <<
","<< point.Y() <<
","<< point.Z()<< endl;
798 cout <<
"No valid geometry... Have you called " 799 <<
"SetGeometryValues() with valid arguments?" <<endl<<endl;
809 TVector3 point(x, -yBeamShift-yLength, z);
812 Int_t column=0, row=0;
813 if(geoType == 0 && padType == 0){
814 row = (Int_t) numberOfRows/2.+ ((x / padSize)+1);
818 cout <<
"No valid geometry... Have you called" 819 <<
"SetGeometryValues() with valid arguments?" <<endl<<endl;
825 if(
DIGI_DEBUG>3) cout <<
"Enters padsGeometry::CoordinatesCenterOfPad()" << endl;
826 if(pad==0 || pad> numberOfPads) {
828 cout <<
"ERROR in padsGeometry::CoordinatesCenterOfPad() " << endl
829 <<
" Invalid pad number " << pad
830 <<
" (0 or larger than maximum pad number)" << endl;
834 Int_t row = CalculateRow(pad);
835 Int_t column = CalculateColumn(pad);
836 if(geoType == 0 && padType == 0){
838 TVector3 vec(-xLength + (row-0.5)*padSize, -yBeamShift-yLength,-zLength + (column-0.5)*padSize);
840 cout <<
"________________________________________________________" << endl
841 <<
" Output of padsGeometry::CoordinatesCenterOfPad(" << pad <<
") " << endl
842 <<
" row = "<< row <<
", column = " << column << endl
843 <<
" x = "<< vec.x() <<
", y = " << vec.y() <<
", z = " << vec.z() << endl
844 <<
"________________________________________________________"<< endl;
847 else if(geoType == 0 && padType == 1 && padLayout == 0){
848 TVector3 vec(-xLength + sideBlankSpaceX + padSize*((row*1.5)-0.5),
850 (2*column-1)*rHexagon);
851 if(row%2==0) vec.SetZ(vec.Z()-rHexagon);
853 cout <<
"________________________________________________________" << endl
854 <<
" Output of padsGeometry::CoordinatesCenterOfPad(" << pad <<
") " << endl
855 <<
" row = "<< row <<
", column = " << column << endl
856 <<
" x = "<< vec.x() <<
", y = " << vec.y() <<
", z = " << vec.z() << endl
857 <<
"________________________________________________________"<< endl;
860 else if(geoType == 0 && padType == 1 && padLayout == 1){
861 TVector3 vec(-xLength + ((2*row)-1)*rHexagon,
863 padSize*((column*1.5)-0.5)+sideBlankSpaceZ);
864 if(column%2==0) vec.SetX(vec.X()-rHexagon);
866 cout <<
"________________________________________________________" << endl
867 <<
" Output of padsGeometry::CoordinatesCenterOfPad(" << pad <<
") " << endl
868 <<
" row = "<< row <<
", column = " << column << endl
869 <<
" x = "<< vec.x() <<
", y = " << vec.y() <<
", z = " << vec.z() << endl
870 <<
"________________________________________________________"<< endl;
873 else if(geoType == 1 && padType == 0){
874 TVector3 vec(radius, radius, (column-0.5)*padSize);
876 vec.SetPhi( (row-0.5) * 2 * TMath::Pi() / numberOfRows );
878 cout <<
"________________________________________________________" << endl
879 <<
" Output of padsGeometry::CoordinatesCenterOfPad(" << pad <<
") " << endl
880 <<
" row = "<< row <<
", column = " << column << endl
881 <<
" x = "<< vec.x() <<
", y = " << vec.y() <<
", z = " << vec.z() << endl
882 <<
"________________________________________________________"<< endl;
885 else if(geoType == 1 && padType == 1){
886 TVector3 vec(radius, radius, padSize*((column*1.5)-0.5));
888 if(column%2==1) vec.SetPhi( (row-0.5) * 2 * TMath::Pi() / numberOfRows ) ;
889 else vec.SetPhi( (row-1) * 2 * TMath::Pi() / numberOfRows);
891 cout <<
"________________________________________________________" << endl
892 <<
" Output of padsGeometry::CoordinatesCenterOfPad(" << pad <<
") " << endl
893 <<
" row = "<< row <<
", column = " << column << endl
894 <<
" x = "<< vec.x() <<
", y = " << vec.y() <<
", z = " << vec.z() << endl
895 <<
"________________________________________________________"<< endl;
900 cout <<
"No valid geometry... Have you called " 901 <<
"SetGeometryValues() with valid arguments?" <<endl<<endl;
902 TVector3 vec3(1.,1.,1.);
938 void SetWireAmplificationParameters(Double_t ra, Double_t s, Double_t h);
962 if(
DIGI_DEBUG>3) cout <<
"Enters amplificationManager::CalculateRhoP()" << endl;
963 lambdaP= x/ACseparation;
964 Double_t commonFactor=tanh(K2P*lambdaP)*tanh(K2P*lambdaP);
965 rhoP=K1P*(1.-commonFactor)/(1.+K3P*commonFactor);
971 if(
DIGI_DEBUG>3) cout <<
"Enters amplificationManager::CalculateRhoN()" << endl;
972 lambdaN= y/ACseparation;
973 Double_t commonFactor=tanh(K2N*lambdaN)*tanh(K2N*lambdaN);
974 rhoN=K1N*(1.-commonFactor)/(1.+K3N*commonFactor);
981 if(
DIGI_DEBUG>3) cout <<
"Enters amplificationManager::amplificationManager()" << endl;
983 radiusOfAmpliWire=0.02;
984 pitchOfAmpliWire=2.0;
986 K1P=1.; K2P=1.; K3P=1.;
987 K1N=1.; K2N=1.; K3N=1.;
988 lambdaP=1.; lambdaN=1.;
992 if(
DIGI_DEBUG>3) cout <<
"Exits amplificationManager::amplificationManager()" << endl;
1001 if(
DIGI_DEBUG>3) cout <<
"Enters amplificationManager::SetWireAmplificationParameters()" << endl;
1002 Double_t k1p=0.0, k2p=0.0, k3p=0.0, k1n=0.0, k2n=0.0, k3n=0.0;
1005 Double_t ras1=1.5e-3, ras2=2.5e-3, ras3=3.75e-3, ras4=5.25e-3, ras5=7.5e-3;
1007 Double_t ras01=ras -ras1, ras02=ras -ras2, ras03=ras -ras3, ras04=ras -ras4, ras05=ras -ras5;
1008 Double_t ras12=ras1-ras2, ras13=ras1-ras3, ras14=ras1-ras4, ras15=ras1-ras5;
1009 Double_t ras21=ras2-ras1, ras23=ras2-ras3, ras24=ras2-ras4, ras25=ras2-ras5;
1010 Double_t ras31=ras3-ras1, ras32=ras3-ras2, ras34=ras3-ras4, ras35=ras3-ras5;
1011 Double_t ras41=ras4-ras1, ras42=ras4-ras2, ras43=ras4-ras3, ras45=ras4-ras5;
1012 Double_t ras51=ras5-ras1, ras52=ras5-ras2, ras53=ras5-ras3, ras54=ras5-ras4;
1018 Double_t a14 = -0.26171, a13 = 1.0914, a12 = -1.61916, a11 = 0.765601, a10 = 0.602428;
1019 Double_t a24 = -0.287172,a23 = 1.20289,a22 = -1.79557, a21 = 0.876833, a20 = 0.547614;
1020 Double_t a34 = -0.356592,a33 = 1.45366,a32 = -2.1068, a31 = 1.02757, a30 =0.492266;
1021 Double_t a44 = -0.398035,a43 = 1.62109,a42 = -2.34602, a41 = 1.17147, a40 =0.433379;
1022 Double_t a54 = -0.449798,a53 = 1.83572,a52 = -2.66741, a51 = 1.37198, a50 =0.355622;
1024 Double_t K3P1=a14*pow(hs,4.)+a13*pow(hs,3.)+a12*hs*hs+a11*hs+a10;
1025 Double_t K3P2=a24*pow(hs,4.)+a23*pow(hs,3.)+a22*hs*hs+a21*hs+a20;
1026 Double_t K3P3=a34*pow(hs,4.)+a33*pow(hs,3.)+a32*hs*hs+a31*hs+a30;
1027 Double_t K3P4=a44*pow(hs,4.)+a43*pow(hs,3.)+a42*hs*hs+a41*hs+a40;
1028 Double_t K3P5=a54*pow(hs,4.)+a53*pow(hs,3.)+a52*hs*hs+a51*hs+a50;
1030 k3p=K3P1*(ras02*ras03*ras04*ras05)/(ras12*ras13*ras14*ras15)+
1031 K3P2*(ras01*ras03*ras04*ras05)/(ras21*ras23*ras24*ras25)+
1032 K3P3*(ras01*ras02*ras04*ras05)/(ras31*ras32*ras34*ras35)+
1033 K3P4*(ras01*ras02*ras03*ras05)/(ras41*ras42*ras43*ras45)+
1034 K3P5*(ras01*ras02*ras03*ras04)/(ras51*ras52*ras53*ras54);
1037 a14 =-0.56927 ;a13 =2.15238; a12 =-2.68646; a11 =0.815535; a10 =0.929974;
1038 a24 =-0.601139;a23 =2.2645; a22 =-2.80946; a21 =0.828462; a20 =0.932558;
1039 a34 =-0.615971;a33 =2.34445; a32 =-2.92218; a31 =0.844926; a30 =0.935198;
1040 a44 =-0.79293 ;a43 =2.94533; a42 =-3.58834; a41 = 1.08576; a40 =0.908493;
1041 a54 =-0.841875;a53 =3.10651; a52 =-3.74454; a51 =1.09552; a50 =0.914561;
1043 Double_t K3N1=a14*pow(hs,4.)+a13*pow(hs,3.)+a12*hs*hs+a11*hs+a10;
1044 Double_t K3N2=a24*pow(hs,4.)+a23*pow(hs,3.)+a22*hs*hs+a21*hs+a20;
1045 Double_t K3N3=a34*pow(hs,4.)+a33*pow(hs,3.)+a32*hs*hs+a31*hs+a30;
1046 Double_t K3N4=a44*pow(hs,4.)+a43*pow(hs,3.)+a42*hs*hs+a41*hs+a40;
1047 Double_t K3N5=a54*pow(hs,4.)+a53*pow(hs,3.)+a52*hs*hs+a51*hs+a50;
1049 k3n=K3N1*(ras02*ras03*ras04*ras05)/(ras12*ras13*ras14*ras15)+
1050 K3N2*(ras01*ras03*ras04*ras05)/(ras21*ras23*ras24*ras25)+
1051 K3N3*(ras01*ras02*ras04*ras05)/(ras31*ras32*ras34*ras35)+
1052 K3N4*(ras01*ras02*ras03*ras05)/(ras41*ras42*ras43*ras45)+
1053 K3N5*(ras01*ras02*ras03*ras04)/(ras51*ras52*ras53*ras54);
1056 Double_t a13 = -0.003152, a12 = 0.05202, a11 = -0.3206, a10 = 0.8442;
1057 Double_t a23 = -0.003285, a22 = 0.05351, a21 = -0.3215, a20 = 0.8072;
1058 Double_t a33 = -0.003576, a32 = 0.05678, a31 = -0.3279, a30 = 0.7774;
1059 Double_t a43 = -0.003753, a42 = 0.05816, a41 = -0.3257, a40 = 0.7409;
1060 Double_t a53 = -0.003850, a52 = 0.05845, a51 = -0.3184, a50 = 0.6947;
1062 Double_t K3P1=a13*pow(hs,3.)+a12*hs*hs+a11*hs+a10;
1063 Double_t K3P2=a23*pow(hs,3.)+a22*hs*hs+a21*hs+a20;
1064 Double_t K3P3=a33*pow(hs,3.)+a32*hs*hs+a31*hs+a30;
1065 Double_t K3P4=a43*pow(hs,3.)+a42*hs*hs+a41*hs+a40;
1066 Double_t K3P5=a53*pow(hs,3.)+a52*hs*hs+a51*hs+a50;
1068 k3p=K3P1*(ras02*ras03*ras04*ras05)/(ras12*ras13*ras14*ras15)+
1069 K3P2*(ras01*ras03*ras04*ras05)/(ras21*ras23*ras24*ras25)+
1070 K3P3*(ras01*ras02*ras04*ras05)/(ras31*ras32*ras34*ras35)+
1071 K3P4*(ras01*ras02*ras03*ras05)/(ras41*ras42*ras43*ras45)+
1072 K3P5*(ras01*ras02*ras03*ras04)/(ras51*ras52*ras53*ras54);
1078 Double_t sqrtK3P = sqrt(k3p);
1079 Double_t sqrtK3N = sqrt(k3n);
1082 k2p=1.571*(1.0-sqrtK3P/2.0);
1083 k2n=1.571*(1.0-sqrtK3N/2.0);
1086 k1p=k2p*sqrtK3P/(4.*atan(sqrtK3P));
1087 k1n=k2n*sqrtK3N/(4.*atan(sqrtK3N));
1089 SetRadiusOfAmpliWire(ra);
1090 SetPitchOfAmpliWire(s);
1092 SetMathiesonFactorK1P(k1p);
1093 SetMathiesonFactorK2P(k2p);
1094 SetMathiesonFactorK3P(k3p);
1095 SetMathiesonFactorK1N(k1n);
1096 SetMathiesonFactorK2N(k2n);
1097 SetMathiesonFactorK3N(k3n);
1098 if(
DIGI_DEBUG>3) cout <<
"Exits amplificationManager::SetWireAmplificationParameters()" << endl;
1132 longitudinalDiffusion = lon;
1133 transversalDiffusion = tra;
1136 void SetDriftParameters(Double_t voltage, Double_t height, Double_t pressure, TString gasName);
1153 void GetStatus(
void);
1158 void CalculatePadsWithCharge(
projectionOnPadPlane* pro, TClonesArray* clo, Int_t &numberOfPadsBeforeThisLoopStarted);
1159 void CalculatePadsWithCharge_oldStyle(Double_t k1p, Double_t k2p, Double_t k3p,
1160 Double_t k1n, Double_t k2n, Double_t k3n,
1168 longitudinalDiffusion=0.;
1169 transversalDiffusion=0.;
1171 lorentzAngle=0.;magneticField=0.;
1173 oldChargeCalculation=kFALSE;
1184 if(
DIGI_DEBUG>3) cout <<
"Enters driftManager::SetDriftParameters()" << endl;
1185 if(gasName==
"deuterium"){
1186 Double_t fieldStrength= voltage/(height/10.);
1187 Double_t eOverP = fieldStrength/(pressure*0.75006);
1188 Double_t a0=13.759, a1=0.480, a2=0.0242, a3=0.0126;
1189 Double_t velocity = exp(a0+a1*log(eOverP)+a2*pow(log(eOverP),2)+a3*pow(log(eOverP),3));
1190 a0=-1.314, a1=0.710, a2=-0.0497, a3=-0.00582;
1191 Double_t a4=0.00732, a5=0.000901;
1192 Double_t dOverMu = exp(a0+a1*log(eOverP)+a2*pow(log(eOverP),2)+a3*pow(log(eOverP),3)
1193 +a4*pow(log(eOverP),4)+a5*pow(log(eOverP),5));
1194 Double_t diffusion = dOverMu*(velocity/fieldStrength);
1195 velocity = velocity*1.0e-8;
1196 diffusion = diffusion*1.0e-7;
1197 SetDriftVelocity(velocity);
1198 SetDiffusionParameters(diffusion,diffusion);
1199 if(
DIGI_DEBUG) cout <<
"For voltage=" << voltage <<
" V, pressure=" << pressure
1200 <<
" mbar, and " << gasName <<
" gas" << endl;
1201 if(
DIGI_DEBUG) cout <<
"drift velocity=" << velocity <<
" mm/ns, diffusion parameter is " 1202 << diffusion <<
" mm^2/ns" << endl;
1204 else if(gasName==
"isobutane"){
1205 Double_t fieldStrength = (voltage/1000.)/(height/10.);
1206 Double_t eOverP = fieldStrength/(pressure*0.0009869);
1207 if(eOverP<0.1 || eOverP >1.8) cout <<
"**** NOTE: drift parameters calculated in an extrapolated region! ****" << endl;
1208 Double_t a0=-0.1441, a1=2.981, a2=0.6421, a3=-0.5853;
1209 Double_t velocity = a0 + a1*eOverP + a2*pow(eOverP,2) + a3*pow(eOverP,3);
1210 a0=1.2948, a1=-1.7737, a2=0.1617, a3=-0.003537;
1211 fieldStrength = fieldStrength*1000.;
1212 Double_t logE= log(fieldStrength);
1213 Double_t sigma0x = exp(a0+a1*logE+a2*pow(logE,2)+a3*pow(logE,3));
1214 Double_t diffusion = 0.5*velocity*pow(sigma0x,2);
1215 velocity = velocity/100.;
1216 diffusion= diffusion/10.;
1217 SetDriftVelocity(velocity);
1218 SetDiffusionParameters(diffusion,diffusion);
1219 if(
DIGI_DEBUG) cout <<
"For voltage=" << voltage <<
" V, pressure=" << pressure
1220 <<
" mbar, and " << gasName <<
" gas" << endl;
1221 if(
DIGI_DEBUG) cout <<
"drift velocity=" << velocity <<
" mm/ns, diffusion parameter is " 1222 << diffusion <<
" mm^2/ns" << endl;
1225 if(
DIGI_DEBUG) cout << endl <<
"drift and diffusion parameters for this gas are not implemented yet!" << endl << endl;
1227 if(
DIGI_DEBUG>3) cout <<
"Exits driftManager::SetDriftParameters()" << endl;
1232 if(
DIGI_DEBUG>3) cout <<
"Enters driftManager::CalculatePositionAfterDrift()" << endl;
1233 Double_t driftDistPre=0.;
1234 Double_t driftDistPost=0.;
1244 TRandom *random=
new TRandom();
1247 if(padsGeo->GetEndCapMode()==1) ;
1254 else if(rhoPre < padsGeo->GetDeltaProximityBeam() ||
1255 rhoPost < padsGeo->GetDeltaProximityBeam()) pro->
SetPosition(1);
1256 else if(rhoPre < padsGeo->GetSizeBeamShielding() &&
1257 rhoPost < padsGeo->GetSizeBeamShielding()) pro->
SetPosition(2);
1258 else if(rhoPre < padsGeo->GetSizeBeamShielding() ||
1259 rhoPost < padsGeo->GetSizeBeamShielding()) pro->
SetPosition(3);
1263 if(padsGeo->GetGeoType()==1) {
1265 rhoPre <= padsGeo->GetRadius() &&
1266 rhoPost <= padsGeo->GetRadius()) pro->
SetPosition(4);
1274 driftDistPre = padsGeo->GetRadius() - rhoPre;
1275 if(lorentzAngle==0.) {
1280 pro->
GetPre()->SetPerp(padsGeo->GetRadius());
1281 pro->
GetPre()->SetPhi(phiPre);
1284 pro->
GetPost()->SetPerp(padsGeo->GetRadius());
1285 pro->
GetPost()->SetPhi(phiPost);
1297 cout <<
"________________________________________________________" << endl
1298 <<
" Output of driftManager::CalculatePositionAfterDrift()" << endl
1299 <<
" NOT YET INTRODUCED A CYLINDRIC ACTAR WITH MAGNETIC FIELD!" << endl;
1300 pro->
GetPre()->SetPerp(padsGeo->GetRadius());
1301 pro->
GetPre()->SetPhi(phiPre);
1304 pro->
GetPost()->SetPerp(padsGeo->GetRadius());
1305 pro->
GetPost()->SetPhi(phiPost);
1311 if(padsGeo->GetGeoType()==0){
1312 if(padsGeo->GetEndCapMode()==1){
1330 else if(rhoPre < padsGeo->GetDeltaProximityBeam() ||
1331 rhoPost <padsGeo->GetDeltaProximityBeam()) pro->
SetPosition(1);
1332 else if(rhoPre < padsGeo->GetSizeBeamShielding() &&
1333 rhoPost < padsGeo->GetSizeBeamShielding()) pro->
SetPosition(2);
1334 else if(rhoPre < padsGeo->GetSizeBeamShielding() ||
1335 rhoPost < padsGeo->GetSizeBeamShielding()) pro->
SetPosition(3);
1340 pro->
GetTrack()->
GetYPost() <= padsGeo->GetYLength() - padsGeo->GetYBeamShift() &&
1341 pro->
GetTrack()->
GetYPost() >= (padsGeo->GetYBeamShift() - padsGeo->GetYLength()) &&
1350 driftDistPre = padsGeo->GetYBeamShift() + padsGeo->GetYLength() + pro->
GetTrack()->
GetYPre();
1351 driftDistPost= padsGeo->GetYBeamShift() + padsGeo->GetYLength() + pro->
GetTrack()->
GetYPost();
1353 if(lorentzAngle==0.) {
1359 pro->
GetPre()->SetY(-padsGeo->GetYLength());
1363 pro->
GetPost()->SetY(-padsGeo->GetYLength());
1369 driftDistPre = driftDistPre / cos(lorentzAngle);
1372 pro->
GetPre()->SetX(newX);
1389 cout <<
"________________________________________________________" << endl
1390 <<
" Output of driftManager::CalculatePositionAfterDrift()" << endl
1397 <<
" pre Projected = (" << pro->
GetPre()->X() <<
"," 1398 << pro->
GetPre()->Y() <<
"," 1400 <<
" post Projected = (" << pro->
GetPost()->X() <<
"," 1403 <<
"________________________________________________________"<< endl;
1412 if(
DIGI_DEBUG>3) cout <<
"Enters driftManager::CalculatePadsWithCharge()" << endl;
1414 Double_t halfPadSize = padsGeo->GetPadSize()/2.;
1415 Double_t rHexagon = padsGeo->GetRHexagon();
1416 TVector3* preOfThisProjection = pro->
GetPre();
1417 TVector3* postOfThisProjection = pro->
GetPost();
1418 Double_t preOfThisProjectionX = preOfThisProjection->X();
1419 Double_t preOfThisProjectionZ = preOfThisProjection->Z();
1420 Double_t postOfThisProjectionX = postOfThisProjection->X();
1421 Double_t postOfThisProjectionZ = postOfThisProjection->Z();
1422 Int_t initPad = padsGeo->IsInPadNumber(preOfThisProjection);
1423 Int_t finalPad = padsGeo->IsInPadNumber(postOfThisProjection);
1424 Int_t initColumn = padsGeo->CalculateColumn(initPad);
1425 Int_t initRow = padsGeo->CalculateRow(initPad);
1426 Int_t finalColumn = padsGeo->CalculateColumn(finalPad);
1427 Int_t finalRow = padsGeo->CalculateRow(finalPad);
1437 cout <<
"________________________________________________________" << endl
1438 <<
" Output of driftManager::CalculatePadsWithCharge()" << endl
1439 <<
" From (pre) " << initPad <<
" (" << initRow <<
"," << initColumn
1440 <<
") to (post) " << finalPad <<
" (" << finalRow <<
"," 1441 << finalColumn <<
")" << endl
1442 <<
" Stride Length " << strideLength <<
" mm, Energy " 1443 << 1000*energyStride <<
" keV" << endl
1444 <<
" Initial pos " << preOfThisProjectionX <<
" " 1445 << preOfThisProjectionZ << endl
1446 <<
" Final pos " << postOfThisProjectionX <<
" " 1447 << postOfThisProjectionZ << endl;
1449 Double_t energyPerPair=GetGasWvalue();
1452 Int_t nsteps=strideLength/0.5;
1456 Double_t *Xstep =
new Double_t[nsteps+2];
1457 Double_t *Zstep =
new Double_t[nsteps+2];
1458 Double_t *EnergyStep=
new Double_t[nsteps+2];
1459 Int_t *NumberOfElectrons=
new Int_t[nsteps+2];
1461 Int_t numberOfRows=padsGeo->GetNumberOfRows();
1462 Int_t numberOfColumns=padsGeo->GetNumberOfColumns();
1465 Int_t chargeOnPads[151][151]={0};
1466 Int_t chargeOnPadsAmplified[151][151]={0};
1467 Int_t chargeOnPadsTotalAmplified[151][151]={0};
1479 Int_t *rowList=
new Int_t[4000];
1480 Int_t *columnList=
new Int_t[4000];
1488 Int_t electrons_lost=0;
1490 for(Int_t k=0;k<=(nsteps+1);k++){
1492 Double_t stepx=(postOfThisProjectionX-preOfThisProjectionX)/(nsteps+1);
1493 Double_t stepz=(postOfThisProjectionZ-preOfThisProjectionZ)/(nsteps+1);
1494 Xstep[k]=preOfThisProjectionX+k*stepx;
1495 Zstep[k]=preOfThisProjectionZ+k*stepz;
1496 EnergyStep[k]=energyStride/(nsteps+1);
1497 Int_t electrons = 1e6 * EnergyStep[k] / energyPerPair;
1498 NumberOfElectrons[k]=gRandom->Poisson(electrons);
1501 Double_t electron_posX = 0;
1502 Double_t electron_posZ = 0;
1504 Int_t padColumn = 0;
1505 for(Int_t istep=0;istep<=nsteps;istep++){
1506 for(Int_t u=0;u<numberOfRows;u++){
1507 for(Int_t k=0;k<numberOfColumns;k++){
1508 chargeOnPads[u][k]=0.;
1509 chargeOnPadsAmplified[u][k]=0;
1512 Double_t strideCenterX = (Xstep[istep+1]+Xstep[istep])/2.;
1513 Double_t strideCenterZ = (Zstep[istep+1]+Zstep[istep])/2.;
1518 Double_t energyStride=EnergyStep[istep];
1519 for(Int_t ielectron=0;ielectron<NumberOfElectrons[istep]; ielectron++){
1520 electron_posX = gRandom->Gaus(strideCenterX,sigmaTrans);
1521 electron_posZ = gRandom->Gaus(strideCenterZ,sigmaTrans);
1522 padRow = padsGeo->GetPadRowFromXZValue(electron_posX,electron_posZ);
1523 padColumn = padsGeo->GetPadColumnFromXZValue(electron_posX,electron_posZ);
1525 if(padRow>0 && padColumn>0 && padRow<152 && padColumn<152 ){
1526 chargeOnPads[padRow-1][padColumn-1]++;
1527 chargeOnPadsAmplified[padRow-1][padColumn-1]+=1000*
Polya();
1529 else electrons_lost++;
1532 for(Int_t u=0;u<numberOfRows;u++){
1533 for(Int_t k=0;k<numberOfColumns;k++){
1534 if(chargeOnPads[u][k]>0){
1535 chargeOnPadsTotalAmplified[u][k]+=chargeOnPadsAmplified[u][k];
1541 Int_t padsWithSignal=0;
1542 for(Int_t u=0;u<numberOfRows;u++){
1543 for(Int_t k=0;k<numberOfColumns;k++){
1544 if(chargeOnPadsTotalAmplified[u][k]>0){
1545 rowList[padsWithSignal]=u+1;
1546 columnList[padsWithSignal]=k+1;
1555 if(padsWithSignal>0) {
1556 Float_t total_charge=0;
1560 for(Int_t iterOnPads=0;iterOnPads<padsWithSignal;iterOnPads++){
1561 padUnderTest = padsGeo->CalculatePad(rowList[iterOnPads],columnList[iterOnPads]);
1563 Float_t charge=chargeOnPadsTotalAmplified[rowList[iterOnPads]-1][columnList[iterOnPads]-1];
1565 total_charge+=charge;
1567 cout << rowList[iterOnPads] <<
" " << columnList[iterOnPads]
1568 <<
" ====================>Charge " << charge << endl;
1571 if(
DIGI_DEBUG && (rowList[iterOnPads]<0 || columnList[iterOnPads]<0))
1572 cout <<
"something WRONG: (row, column) = (" << rowList[iterOnPads] <<
"," << columnList[iterOnPads]
1573 <<
")" <<
", CHARGE=" << charge <<
"iterOnPads=" << iterOnPads << endl;
1578 thePadSignal[iterOnPads]->
SetPadRow(rowList[iterOnPads]);
1579 thePadSignal[iterOnPads]->
SetPadColumn(columnList[iterOnPads]);
1590 new((*clo)[iterOnPads+numberOfPadsBeforeThisLoopStarted])
ActarPadSignal(*thePadSignal[iterOnPads]);
1591 thePadSignal[iterOnPads]->
Reset();
1594 numberOfPadsBeforeThisLoopStarted+=padsWithSignal;
1600 cout<<
"total charge-->"<<total_charge<<
" "<<total_charge/(pro->
GetTrack()->
GetEnergyStride()*1000)*100<<
"% of total"<<endl;
1601 cout<<
"Number Of Pads With Signal: "<<padsWithSignal<<endl;
1603 for (Int_t i=0;i<padsWithSignal;i++)
delete thePadSignal[i];
1604 delete thePadSignal;
1608 delete[] EnergyStep;
1609 delete[] NumberOfElectrons;
1611 delete[] columnList;
1633 if(
DIGI_DEBUG>3) cout <<
"Exits driftManager::CalculatePadsWithCharge()" << endl;
1637 Double_t k1n, Double_t k2n, Double_t k3n,
1639 TClonesArray* clo) {
1643 if(
DIGI_DEBUG>3) cout <<
"Enters driftManager::CalculatePadsWithCharge_oldStyle()" << endl;
1645 Double_t halfPadSize = padsGeo->GetPadSize()/2.;
1646 Double_t rHexagon = padsGeo->GetRHexagon();
1648 TVector3* preOfThisProjection = pro->
GetPre();
1649 TVector3* postOfThisProjection = pro->
GetPost();
1650 Double_t preOfThisProjectionX = preOfThisProjection->X();
1651 Double_t preOfThisProjectionZ = preOfThisProjection->Z();
1652 Double_t postOfThisProjectionX = postOfThisProjection->X();
1653 Double_t postOfThisProjectionZ = postOfThisProjection->Z();
1655 Int_t initPad = padsGeo->IsInPadNumber(preOfThisProjection);
1656 Int_t finalPad = padsGeo->IsInPadNumber(postOfThisProjection);
1659 Int_t initColumn = padsGeo->CalculateColumn(initPad);
1660 Int_t initRow = padsGeo->CalculateRow(initPad);
1661 Int_t finalColumn = padsGeo->CalculateColumn(finalPad);
1662 Int_t finalRow = padsGeo->CalculateRow(finalPad);
1664 Double_t strideCenterX=(preOfThisProjectionX+postOfThisProjectionX)/2.;
1665 Double_t strideCenterZ=(preOfThisProjectionZ+postOfThisProjectionZ)/2.;
1668 cout <<
"________________________________________________________" << endl
1669 <<
" Output of driftManager::CalculatePadsWithCharge()" << endl
1670 <<
" From (pre) " << initPad <<
" (" << initRow <<
"," << initColumn
1671 <<
") to (post) " << finalPad <<
" (" << finalRow <<
"," 1672 << finalColumn <<
")" << endl;
1675 TVector3 strideOnPadPlane = *postOfThisProjection - *preOfThisProjection;
1676 Double_t alpha = 0;
char buffer[1000];
1679 if(padsGeo->GetGeoType()==0) {
1682 if(padsGeo->GetSizeBeamShielding() == 0. ) {
1688 alpha = atan2(strideOnPadPlane.X(),strideOnPadPlane.Z());
1690 else if (padsGeo->GetGeoType()==1) {
1696 padPlaneRadius = padsGeo->GetRadius();
1697 alpha = atan2((postOfThisProjection->Phi()-preOfThisProjection->Phi())*padPlaneRadius,
1698 strideOnPadPlane.Z());
1703 cout <<
"______________________________TF2__________________________" << endl
1704 <<
" Output of driftManager::CalculatePadsWithCharge()" << endl
1705 <<
" strideOnPadPlane coordinates (" << strideOnPadPlane.x() <<
"," 1706 << strideOnPadPlane.y() <<
"," << strideOnPadPlane.z() << endl
1707 <<
") with distance " << strideOnPadPlane.Mag()
1708 <<
" and angle w.r.t. Z axis " << alpha << endl;
1709 if(padsGeo->GetGeoType()==1)
1710 cout <<
"[the angle is calculated from differences in Phi] "<< endl;
1713 if(padsGeo->GetGeoType()==0) {
1714 if(ampManager->GetIsWire()==0) {
1722 "(%f/(2.50663*%f))*exp(-((x-%f)*(x-%f)+(y-%f)*(y-%f))/(2*%f*%f))",
1724 strideCenterZ, strideCenterZ, strideCenterX, strideCenterX,
1727 else if(ampManager->GetIsWire()==1){
1729 Double_t pitchWire = ampManager->GetPitchOfAmpliWire();
1730 Double_t L = ampManager->GetACseparation();
1731 Double_t zWire = (preOfThisProjectionZ + postOfThisProjectionZ)/2.;
1732 Double_t xWire = Int_t(((preOfThisProjectionX + postOfThisProjectionX)/2.)/pitchWire+0.5)*pitchWire;
1738 "%f*%f*((1.-pow(tanh(%f*abs(%f-x)/%f),2.))/(1.+%f*pow(tanh(%f*abs(%f-x)/%f),2.)))*%f*((1.-pow(tanh(%f*abs(%f-y)/%f),2.))/(1.+%f*pow(tanh(%f*abs(%f-y)/%f),2.)))",
1740 k1p, k2p, zWire, L, k3p, k2p, zWire, L,
1741 k1n, k2n, xWire, L, k3n, k2n, xWire, L
1759 else if (padsGeo->GetGeoType()==1) {
1761 "(%f/(2.50663*%f))*exp((-((x-%f)*%f-(y-%f)*%f)*((x-%f)*%f-(y-%f)*%f))/(2*%f*%f))",
1763 preOfThisProjectionZ,sin(alpha),preOfThisProjection->Phi()*padPlaneRadius,cos(alpha),
1764 preOfThisProjectionZ,sin(alpha),preOfThisProjection->Phi()*padPlaneRadius,cos(alpha),
1770 cout << endl <<
" Function to integrate " << buffer << endl;
1773 if(padsGeo->GetGeoType()==0) {
1774 if(ampManager->GetIsWire()==0){
1775 f2 =
new TF2(
"f2",buffer,
1776 strideCenterZ-10*sigma,
1777 strideCenterZ+10*sigma,
1778 strideCenterX-10*sigma,
1779 strideCenterX+10*sigma);
1781 else if(ampManager->GetIsWire()==1){
1787 f2 =
new TF2(
"f2",buffer);
1790 else if (padsGeo->GetGeoType()==1) {
1791 f2 =
new TF2(
"f2",buffer,
1792 preOfThisProjectionZ-10*sigma,
1793 preOfThisProjectionZ+10*sigma,
1794 preOfThisProjection->Phi()*padPlaneRadius-10*sigma,
1795 preOfThisProjection->Phi()*padPlaneRadius+10*sigma);
1799 if(initRow>finalRow){
1800 Int_t tempRow = initRow;
1804 if(initColumn>finalColumn){
1805 Int_t tempColumn = initColumn;
1806 initColumn = finalColumn;
1807 finalColumn = tempColumn;
1815 Int_t securityFactor = (Int_t)(2*sigma/padsGeo->GetPadSize());
1816 if(securityFactor<1) securityFactor = 1;
1821 Int_t rowsUnderTest = (finalRow +securityFactor+1) - (initRow -securityFactor);
1822 Int_t columnsUnderTest = (finalColumn+securityFactor+1) - (initColumn-securityFactor);
1825 cout <<
"________________________________________________________" << endl
1826 <<
" Output of driftManager::CalculatePadsWithCharge()" << endl
1827 <<
" securityFactor " << securityFactor
1828 <<
", rowsUnderTest " << rowsUnderTest <<
" (from " 1829 << initRow-securityFactor <<
" to " << initRow-securityFactor+rowsUnderTest
1830 <<
"), columnsUnderTest " << columnsUnderTest
1831 <<
" (from " << initColumn-securityFactor <<
" to " 1832 << initColumn-securityFactor+rowsUnderTest <<
")" << endl;
1834 Double_t charge=0; Int_t numberOfPadsWithSignal=0;
1835 Int_t padUnderTest; TVector3 centerPad;
1836 Int_t rowList[40000]={0}; Int_t columnList[40000]={0};
1837 Int_t rowNumber=0, colNumber=0;
1838 for(Int_t i = 0;i<rowsUnderTest;i++){
1839 for(Int_t j = 0;j<columnsUnderTest;j++){
1841 padUnderTest = padsGeo->CalculatePad(initRow-securityFactor+i,
1842 initColumn-securityFactor+j);
1843 centerPad = padsGeo->CoordinatesCenterOfPad(padUnderTest);
1845 cout <<
"________________________________________________________" << endl
1846 <<
" Output of driftManager::CalculatePadsWithCharge()" << endl
1847 <<
" scalar with pre " << strideOnPadPlane.Dot(centerPad-(*(pro->
GetPre())))
1848 <<
" scalar with post " << strideOnPadPlane.Dot(centerPad-(*(pro->
GetPost())))
1852 rowNumber = initRow-securityFactor+i;
1853 colNumber = initColumn-securityFactor+j;
1855 if(rowNumber>=1 && rowNumber <= padsGeo->GetNumberOfRows()
1856 && colNumber>=1 && colNumber <= padsGeo->GetNumberOfColumns()){
1857 rowList[numberOfPadsWithSignal] = rowNumber;
1858 columnList[numberOfPadsWithSignal] = colNumber;
1859 numberOfPadsWithSignal++;
1864 cout <<
"________________________________________________________" << endl
1865 <<
" Output of driftManager::CalculatePadsWithCharge()" << endl
1866 <<
" numberOfPadsWithSignal = " << numberOfPadsWithSignal<<endl;
1868 Double_t phiPad, xPad, zPad;
1870 if( numberOfPadsWithSignal>0) {
1874 for(Int_t iterOnPads=0;iterOnPads<numberOfPadsWithSignal;iterOnPads++){
1875 padUnderTest = padsGeo->CalculatePad(rowList[iterOnPads],columnList[iterOnPads]);
1876 centerPad = padsGeo->CoordinatesCenterOfPad(padUnderTest);
1878 cout <<
"________________________________________________________" << endl
1879 <<
" Output of driftManager::CalculatePadsWithCharge()" << endl
1880 <<
" Calculating charge for pad " << padUnderTest <<
" (" 1881 << rowList[iterOnPads] <<
"," << columnList[iterOnPads] <<
")" << endl;
1883 phiPad = centerPad.Phi();
1884 xPad = centerPad.X();
1885 zPad = centerPad.Z();
1887 if(padsGeo->GetGeoType()==0) {
1888 if(padsGeo->GetPadType()==0){
1889 charge = f2->Integral(zPad-halfPadSize,zPad+halfPadSize,xPad-halfPadSize,xPad+halfPadSize);
1892 else if(padsGeo->GetPadType()==1){
1893 if(padsGeo->GetPadLayout()==0){
1894 charge = f2->Integral(zPad-rHexagon,
1896 xPad-1.5*halfPadSize,
1897 xPad+1.5*halfPadSize);
1899 else if(padsGeo->GetPadLayout()==1){
1900 charge = f2->Integral(zPad-1.5*halfPadSize,
1901 zPad+1.5*halfPadSize,
1907 else if (padsGeo->GetGeoType()==1) {
1908 if(padsGeo->GetPadType()==0)
1909 charge = f2->Integral(zPad-halfPadSize,
1911 (phiPad*padPlaneRadius)-halfPadSize,
1912 (phiPad*padPlaneRadius)+halfPadSize);
1913 else if(padsGeo->GetPadType()==1)
1914 charge = f2->Integral(zPad-1.5*halfPadSize,
1915 zPad+1.5*halfPadSize,
1916 (phiPad*padPlaneRadius)-rHexagon,
1917 (phiPad*padPlaneRadius)+rHexagon);
1920 if(
DIGI_DEBUG && (rowList[iterOnPads]<0 || columnList[iterOnPads]<0))
1921 cout <<
"some thing WRONG: (row, column) = (" << rowList[iterOnPads] <<
"," 1922 << columnList[iterOnPads] <<
")" <<
", CHARGE="<< charge <<
"iterOnPads=" << iterOnPads << endl;
1927 thePadSignal[iterOnPads]->
SetPadRow(rowList[iterOnPads]);
1928 thePadSignal[iterOnPads]->
SetPadColumn(columnList[iterOnPads]);
1937 new((*clo)[iterOnPads])
ActarPadSignal(*thePadSignal[iterOnPads]);
1938 thePadSignal[iterOnPads]->
Reset();
1942 for (Int_t i=0;i<numberOfPadsWithSignal;i++)
delete thePadSignal[i];
1943 delete thePadSignal;
1946 if(
DIGI_DEBUG>3) cout <<
"Exits driftManager::CalculatePadsWithCharge_oldStyle()" << endl;
1950 if(
DIGI_DEBUG>3) cout <<
"Enters driftManager::GetStatus()" << endl;
1951 cout <<
"Connected to geometry "<< padsGeo << endl
1952 <<
"with longitudinalDiffusion = " << longitudinalDiffusion
1953 <<
", transversalDiffusion = " << transversalDiffusion << endl
1954 <<
"driftVelocity = " << driftVelocity
1955 <<
", magneticField = " << magneticField << endl;
void SetRadiusOfAmpliWire(Double_t ra)
Double_t longitudinalDiffusion
void SetGeometryValues(TString DetectorConfig)
void SetGasWvalue(Double_t value)
Double_t CalculateRhoN(Double_t y)
Int_t GetEndCapMode(void)
Int_t CalculateRow(Int_t p)
void SetRHexagon(Double_t si)
void SetGeoType(Int_t type)
void SetSigmaTime(Double_t time)
void SetPosition(Int_t pos)
Double_t GetMathiesonFactorK3N()
Double_t GetLongitudinalDiffusion(void)
ActarPadSignal & operator=(const ActarPadSignal &right)
Double_t pitchOfAmpliWire
Double_t GetACseparation()
void SetMathiesonFactorK3N(Double_t k3n)
void SetNumberOfRows(Int_t row)
void SetRadius(Double_t ra)
void SetPadNumber(Int_t pad)
Double_t GetSizeBeamShielding(void)
void SetFinalTime(Double_t time)
Double_t sigmaTransvAtPadPlane
void SetZLength(Double_t z)
Bool_t GetOldChargeCalculation(void)
void SetSideBlankSpaceX(Double_t gapx)
void SetYLength(Double_t y)
Int_t GetNumberOfRows(void)
Double_t sizeBeamShielding
void SetDiffusionParameters(Double_t lon, Double_t tra)
Double_t GetMathiesonFactorK3P()
amplificationManager * ampManager
void SetMathiesonFactorK1N(Double_t k1n)
void SetPadsGeometry(void)
Bool_t oldChargeCalculation
Int_t GetNumberOfPads(void)
void SetEventID(Int_t id)
void SetTimePre(Double_t time)
void SetPost(TVector3 *ve)
Double_t GetEnergyStride()
void SetPadType(Int_t type)
Double_t GetYLength(void)
void SetSideBlankSpaceZ(Double_t gapz)
void SetPadSize(Double_t si)
Double_t GetTransversalDiffusion(void)
void SetYPre(Double_t yc)
TVector3 CoordinatesCenterOfPad(Int_t pad)
Int_t GetPadColumnFromXZValue(Double_t x, Double_t z)
Double_t GetRHexagon(void)
Double_t radiusOfAmpliWire
void SetSigmaLongAtPadPlane(Double_t del)
Double_t GetSigmaLongAtPadPlane()
void SetPadRow(Int_t pad)
Double_t GetZLength(void)
Double_t GetDeltaProximityBeam(void)
Int_t GetPadRowFromXZValue(Double_t x, Double_t z)
ActarSimSimpleTrack * GetTrack()
void SetMagneticField(Double_t vel)
Double_t GetRadiusOfAmpliWire()
void SetDeltaProximityBeam(Double_t de)
Double_t sigmaLongAtPadPlane
void SetSizeBeamShielding(Double_t le)
virtual ~amplificationManager()
Double_t GetPitchOfAmpliWire()
ActarSimSimpleTrack * track
void SetPitchOfAmpliWire(Double_t s)
void SetMathiesonFactorK1P(Double_t k1p)
void SetDriftVelocity(Double_t vel)
void SetSigmaTransvAtPadPlane(Double_t del)
void SetLorentzAngle(Double_t vel)
Double_t GetMathiesonFactorK1N()
Double_t GetXBeamShift(void)
Double_t GetSigmaTransvAtPadPlane()
Double_t GetXLength(void)
Int_t CalculatePositionAfterDrift(projectionOnPadPlane *pro)
void SetInitTime(Double_t time)
Double_t GetMathiesonFactorK2N()
Double_t GetLorentzAngle(void)
void SetNumberOfPads(Int_t pad)
void SetXBeamShift(Double_t xBeam)
void SetZPost(Double_t zc)
void SetACseparation(Double_t h)
void SetDriftParameters(Double_t voltage, Double_t height, Double_t pressure, TString gasName)
void SetPre(TVector3 *ve)
Double_t GetYBeamShift(void)
Double_t GetMathiesonFactorK2P()
Int_t GetNumberOfStrides()
Double_t GetMagneticField(void)
void SetTimePost(Double_t time)
void SetOldChargeCalculation(void)
void SetPadLayout(Int_t layout)
Float_t Polya(Float_t param=3.2)
void SetChargeDeposited(Double_t cha)
Double_t GetGasWvalue(void)
Int_t IsInPadNumber(TVector3 *point)
Double_t deltaProximityBeam
void ConnectToGeometry(padsGeometry *pad)
Double_t CalculateRhoP(Double_t x)
void SetYBeamShift(Double_t yBeam)
Double_t GetMathiesonFactorK1P()
Int_t GetNumberOfColumns(void)
Int_t CalculatePad(Int_t r, Int_t c)
void SetWireAmplificationParameters(Double_t ra, Double_t s, Double_t h)
void SetPadColumn(Int_t pad)
Double_t GetChargeDeposited()
void SetNewChargeCalculation(void)
void CalculatePadsWithCharge(projectionOnPadPlane *pro, TClonesArray *clo, Int_t &numberOfPadsBeforeThisLoopStarted)
void SetYPost(Double_t yc)
Double_t GetDriftVelocity(void)
void ConnectToAmplificationManager(amplificationManager *amp)
virtual ~projectionOnPadPlane()
void SetXLength(Double_t x)
Double_t GetSideBlankSpaceX(void)
void SetMathiesonFactorK2N(Double_t k2n)
void SetNumberOfStrides(Int_t num)
void SetZPre(Double_t zc)
Double_t GetSideBlankSpaceZ(void)
Double_t GetStrideLength()
void SetMathiesonFactorK3P(Double_t k3p)
void SetMathiesonFactorK2P(Double_t k2p)
Double_t GetPadSize(void)
void SetGeometryValues(Int_t geo, Int_t pad, Int_t layout, Double_t x, Double_t y, Double_t z, Double_t xBeam, Double_t yBeam, Double_t ra, Double_t psi, Double_t gapx, Double_t gapz)
void SetTrack(ActarSimSimpleTrack *tr)
void CalculatePadsWithCharge_oldStyle(Double_t k1p, Double_t k2p, Double_t k3p, Double_t k1n, Double_t k2n, Double_t k3n, projectionOnPadPlane *pro, TClonesArray *clo)
Int_t CalculateColumn(Int_t p)
void SetNumberOfColumns(Int_t col)
Double_t transversalDiffusion