#include "Mille.h" #include "TRandom.h" #include using std::cout; using std::endl; #include using std::ofstream; #include using std::setprecision; using std::setw; #include using std::vector; // define detector geometry const int NPLAN = 100; // Number of detecor planes const float DETX = 10.0; // x-pos of first plane const float DISX = 10.0; // distance between planes const float THCK = 2.0; // thickness of one plane const float HEIT = 100.0; // height of detector plane const float DISPL = 0.1; // max displacement 1 mm const float DRIFT = 0.02; // max Vdrift deviation 2 % void WriteSteeringFile() { ofstream steerFile; steerFile.open ("mp2str.txt"); steerFile << "* Default test steering file"<"< &DEL) { ofstream constrainFile; constrainFile.open ("mp2con.txt"); constrainFile << " Constraint 0.0" << endl; for ( int i=0; i< NPLAN; i++) { int LABELT = CalculateUniqueLabel(i); constrainFile <<" "< &EFF, const vector &DEL, const vector &SGM, const vector &DVD, vector &XHITS, vector &IHITS, vector &YHITS, vector &YDRFT, vector &SIGMA) { // track definition with vertex and slope // Uniform distribution of the vertex between 0.45 and 0.55 of the toal // detector height // the slope is between 0 and 0.05 float YNULL= 0.5*HEIT + 0.1*HEIT*(gRandom->Uniform(1.)-1.); float SLOPE=(gRandom->Uniform(1.)-1.)*HEIT/((NPLAN-1)*DISX); if (IP != 0) { cout<<"Vertex: "<Uniform(1.); if ( ran > EFF[i]) continue; // calculate true x and y positions for the track float X=DETX+i*DISX; // detector x position float YLIN = YNULL + SLOPE*X; // true y value at position x float YBIAS = YLIN-DEL[i]; // y value in shifted detector int NWIRE = (int)(1.0+YBIAS/4.0); // wire number if (NWIRE < 0. || NWIRE > 25.) continue; NHITS++; // track hits the plane XHITS[NHITS]=X; IHITS[NHITS]=i; // calculate detector respons tacking ito account the detector // resolution and drift velocity differences float GR=gRandom->Gaus(0.,1.); float YMEAS=SGM[i]*GR; // hit smearing float YDVDS=0.0; // drift velocity correction YHITS[NHITS]=YBIAS+YMEAS+YDVDS; // measured position float YWIRE=NWIRE*4.0-2.0; // y position of wire YDRFT[NHITS]=YBIAS-YWIRE; // drift length YDVDS=YDRFT[NHITS]*DVD[i]; // position error from drift velocity YHITS[NHITS]=YBIAS+YMEAS-YDVDS; // reconstructed hit position SIGMA[NHITS]=SGM[i]; if (IP != 0) { cout << setw(4) << NHITS << setw(4) << i<< setw(5) << X << setw(10) << YLIN << setw(10) << YBIAS << setw(13) << YMEAS < EFF(NPLAN); // efficency of detector planes vector SGM(NPLAN); // measurement error (sigma) vector DVD(NPLAN); // rel. drift velocity deviation vector DEL(NPLAN); // introduced detector shift // define detector efficencies and measuremnet errors for ( int i=0; i< NPLAN; i++) { EFF[i]=0.90; SGM[i]=0.0150; } // modify one plane (7) EFF[7]=0.1; // low efficiency SGM[7]=0.0400; // and bad resolution // misalign detector planes for ( int i=0; i< NPLAN; i++) { DEL[i]=DISPL*gRandom->Gaus(0.,1.); DVD[i]=DRIFT*gRandom->Gaus(0.,1.); } // No shift for two detector planes DEL[10]=0.0; DEL[90]=0.0; WriteSteeringFile(); WriteConstrainFile(DEL); //Open MillePede Output file // Mille Mille("mp2tst.bin", false, true); // write human readable ascii file Mille Mille("mp2tst.bin", true, false); // write binary file needed by pede // events loop ------------------------------------------------------ int NCOUNT=10000; int NTHITS=0; int NHITS; int NRECDS=0; float DERLC[2]; float DERGL[2]; int LABEL[2]; vector XHITS(100); vector IHITS(100); vector YHITS(100); vector YDRFT(100); vector SIGMA(100); for(int ICOUNT=0; ICOUNT< NCOUNT; ICOUNT++) { int IP=0; if (ICOUNT == 8759) IP=1; NHITS = GenerateEvents(IP, EFF, DEL, SGM, DVD, XHITS, IHITS, YHITS, YDRFT, SIGMA); if (NHITS > 90) cout<<"hits are "<