// this is the new analysis code to read and analyze the data from // 5 f1TDC in slots 4 to 8 and 2 FADCs in slot 13 and 14 and one // CAEN ADC in slot 19 // // f1TDC slot 1: IU-chambers x bottom input 1, 2, 3, 4 // slot 2: IU-chambers y bottom input 1, 2, 3, IU-chamber x top 4 // slot 3: IU-chambers x top 1, 2, IU-chambers y top 3, 4 // slot 4: IU-chambers y top 1, // slot 5: FADC-chamber 1, Trigger Scintillators 3, 4 // // include files */ #include #include #include #include #include using namespace std; // root include files #include "TFile.h" #include "TH1.h" #include "TH1F.h" #include "TH2F.h" #include "TH3F.h" #include "TF1.h" #include "TMath.h" #include "TTree.h" #include "TGraph.h" #include "TCanvas.h" #include #include "channelnumbers.h" Int_t DEBUG1 = 0; Float_t PI = 3.1415926; Float_t PIh = 1.5707963; Float_t strip_pitch = 5.0; // distance between strips is 5mm (4mm width!) Float_t strip_angle = PI/180.*15.0; Float_t HWindow = 30.*strip_pitch/sin(strip_angle); // horizontal width of the cathode frame Float_t YOffset = HWindow*tan(PI-strip_angle) ; // vertical width of the cathode frame Float_t sd = strip_pitch; // distance between two strips projected on vertical axis (wire axis) Float_t CellRadius = 12.5 ; //units in mm Float_t XCathOffSet = -47.5; // in units of strips Float_t YCathOffSet = 0.5; // in units of strips Float_t getCathodeXpos(Float_t xpos, Float_t ypos){ // return (xpos*sin(strip_angle)+ypos*cos(strip_angle)); // return (xpos-ypos)/2./tan(strip_angle); Float_t b1, b2,x0; //b1 = YOffset + (xpos-15.5)*sd; //b2 = (ypos-15.5)*sd; //x0 = (b1-b2)/2./tan(strip_angle); //b1 = xpos*(sin(strip_angle)+cos(strip_angle)*cos(strip_angle)/sin(strip_angle))*sd; //b2 = ypos/tan(strip_angle)*sd; //x0 = (b1-b2)/2./tan(PI-strip_angle); //b1 = xpos/cos(strip_angle)*sd; //b2 = ypos/cos(strip_angle)*sd; //x0 = (b2-b1)/2./tan(strip_angle); x0 = (xpos-ypos)*strip_pitch/2./sin(strip_angle); return x0; } Float_t getCathodeYpos(Float_t xpos, Float_t ypos){ //return (xpos*cos(strip_angle)-ypos*sin(strip_angle)); //return (xpos-ypos)/2.; Float_t b1, b2 ,y0; //b1 = YOffset - sd/2. + (xpos-15.)*sd; //b2 = -sd/2. + (ypos-15.)*sd; //y0 = (b1-b2)/2.+b2; //b1 = xpos*(sin(strip_angle)+cos(strip_angle)*cos(strip_angle)/sin(strip_angle))*sd; //b2 = ypos/tan(strip_angle)*sd; //y0 = (b1-b2)/2.+b2 - 200.; //b1 = xpos/cos(strip_angle)*sd; //b2 = ypos/cos(strip_angle)*sd; //y0 = (b1+b2)/2.; y0 = (xpos+ypos)*strip_pitch/2./cos(strip_angle); return y0; } Int_t GetMaxBin(Float_t *p,Int_t k){ Float_t max = 0; Int_t ind = -9999; for (Int_t i=0;imax){ max = p[i]; ind = i; } } return ind; } Float_t T2D_FDC[2][42]; void ReadT2Ddata_FDC(char* fnam){ ifstream INF; INF.open(fnam,ios::in); if (!INF.is_open()){ cout<<"Error open file "<> T2D_FDC[0][j] >> T2D_FDC[1][j]; //cout<< T2D_FDC[0][j] <<" "<< T2D_FDC[1][j]<T2D_FDC[0][42]) return CellRadius; if (timeT2D_FDC[0][j]){ k = k/2; j = j + k; } else{ j = j - k; } if (k<1) notfound = 0; } //cout<<"FDC t2d: "<701.) return 77777.; Float_t dist = 2516.82 -32.2102*t + 0.175796*t*t - 0.000530658*t*t*t + 9.57064e-07*t*t*t*t - 1.03134e-09*t*t*t*t*t + 6.14844e-13*t*t*t*t*t*t - 1.5643e-16*t*t*t*t*t*t*t; dist *= CellRadius; return dist; } Int_t ReadDriftTimeZeros(char * fnam, Double_t * DTZ){ ifstream INF; INF.open(fnam, ios::in); if (!INF.is_open()){ cout<<"Error open DriftTime zero file: "<>k; INF>>DTZ[k]; cnt++; } INF.close(); return cnt; } // struct Hit{ Int_t plane; Int_t wire; Float_t drifttime; Float_t driftdist; Float_t x0; Float_t x; Float_t z; Float_t dx; }; struct Hit HitListX[4][20]; struct Hit HitListY[4][20]; struct Hit FDC_X[16]; struct fitres{ Float_t val; Float_t dval; }; void iu_fit(struct Hit *list, Int_t l, fitres *a, fitres *b, Float_t *chi2){ unsigned int i; Float_t wt,t,sxoss,sx=0.0,sy=0.0,st2=0.0,ss=0.0; //b->val=0.0; // Accumulate sums //for (i=0;ival+=t*list[i].x/list[i].dx; //} //b->val/=st2; // Solve for a,b,siga,sigb //a->val=(sy-sx*(b->val))/ss; //a->dval=sqrt((1.+sx*sx/(ss*st2))/ss); //b->dval=sqrt(1.0/st2); // Compute the chi2 for the fit //*chi2=0.0; //for (i=0;ival)-(b->val)*list[i].z)/list[i].dx) * ((list[i].x-(a->val)-(b->val)* // list[i].z)/list[i].dx); //} Float_t Sw = 0.; Float_t Sx = 0.; Float_t Sz = 0.; Float_t Sxx = 0.; Float_t Sxz = 0.; for (i=0;ival = (Sxx*Sz-Sx*Sxz)/delta; b->val = (Sw*Sxz-Sx*Sz)/delta; *chi2 = 0; for (i=0;ival)-(b->val)*list[i].z) / list[i].dx ) * ( (list[i].x-(a->val)-(b->val)*list[i].z) / list[i].dx ); } } Float_t fit_trackX(Int_t Npoints, Int_t* FDC_N, fitres *interseptx, fitres *slopex){ struct Hit HLX[10]; Float_t oldchi2 = 99999.; Float_t chi2 = 99999; fitres a,b; for (Int_t n1=-1;n1<2;n1+=2){ HLX[0].x = HitListX[0][0].x + ((Float_t)n1)*HitListX[0][0].driftdist; HLX[0].z = HitListX[0][0].z; HLX[0].dx = HitListX[0][0].dx; for (Int_t n2=-1;n2<2;n2+=2){ HLX[1].x = HitListX[1][0].x + ((Float_t)n2)*HitListX[1][0].driftdist; HLX[1].z = HitListX[1][0].z; HLX[1].dx = HitListX[1][0].dx; for (Int_t n3=-1;n3<2;n3+=2){ HLX[2].x = HitListX[2][0].x + ((Float_t)n3)*HitListX[2][0].driftdist; HLX[2].z = HitListX[2][0].z; HLX[2].dx = HitListX[2][0].dx; for (Int_t n4=-1;n4<2;n4+=2){ HLX[3].x = HitListX[3][0].x + ((Float_t)n4)*HitListX[3][0].driftdist; HLX[3].z = HitListX[3][0].z; HLX[3].dx = HitListX[3][0].dx; if (Npoints==5){ Int_t cntx = 0; // get the wire in the second plane while (FDC_X[cntx].wire>271){ cntx++; } for (Int_t n5=-1;n5<2;n5+=2){ HLX[4].x = FDC_X[cntx].x + ((Float_t)n5)*FDC_X[cntx].driftdist; HLX[4].z = 684.; HLX[4].dx = 0.5; iu_fit(HLX, 5, &a, &b, &chi2); if (chi2val = a.val; interseptx->dval = a.dval; slopex->val = b.val; slopex->dval = b.dval; *FDC_N = n5; } } } else { iu_fit(HLX, 4, &a, &b, &chi2); if (chi2val = a.val; interseptx->dval = a.dval; slopex->val = b.val; slopex->dval = b.dval; } } } } } } return oldchi2; } Float_t fit_trackY(Int_t Npoints, Float_t ypos, fitres *intersepty, fitres *slopey){ struct Hit HLY[10]; Float_t oldchi2 = 99999.; Float_t chi2 = 99999; fitres a,b; for (Int_t n1=-1;n1<2;n1+=2){ HLY[0].x = HitListY[0][0].x + ((Float_t)n1)*HitListY[0][0].driftdist; HLY[0].z = HitListY[0][0].z; HLY[0].dx = HitListY[0][0].dx; for (Int_t n2=-1;n2<2;n2+=2){ HLY[1].x = HitListY[1][0].x + ((Float_t)n2)*HitListY[1][0].driftdist; HLY[1].z = HitListY[1][0].z; HLY[1].dx = HitListY[1][0].dx; for (Int_t n3=-1;n3<2;n3+=2){ HLY[2].x = HitListY[2][0].x + ((Float_t)n3)*HitListY[2][0].driftdist; HLY[2].z = HitListY[2][0].z; HLY[2].dx = HitListY[2][0].dx; for (Int_t n4=-1;n4<2;n4+=2){ HLY[3].x = HitListY[3][0].x + ((Float_t)n4)*HitListY[3][0].driftdist; HLY[3].z = HitListY[3][0].z; HLY[3].dx = HitListY[3][0].dx; if (Npoints==5){ Int_t cntx = 0; // get the wire in the second plane while (FDC_X[cntx].wire>271){ cntx++; } HLY[4].x = ypos + 206.8; HLY[4].z = 684; HLY[4].dx = 0.5; iu_fit(HLY, 5, &a, &b, &chi2); } else { iu_fit(HLY, 4, &a, &b, &chi2); } if (chi2val = a.val; intersepty->dval = a.dval; slopey->val = b.val; slopey->dval = b.dval; } } } } } return oldchi2; } // // // Main analysis code looping over events // Int_t analyze1(Int_t runnumber, char* dfil, TH1F** fadc, TH1F** fadcNP, TH1F** histT, TH2F **hist2d, TH1F **qadc, TH1F ** DriftTimes, Int_t Flag1, Int_t FLAG2) { ////////////////////////////////////////////////////////// // This file has been automatically generated // (Wed Jul 22 17:53:42 2009 by ROOT version5.18/00) // from TTree fdctest/FDC response // found on file: fdcTest_000012.root ////////////////////////////////////////////////////////// //Reset ROOT and connect tree file //TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(dfil); //if (!f) { TFile *f = new TFile(dfil); //} TTree *fdctest = (TTree*)gDirectory->Get("fdctest"); //Declaration of leaves types Int_t nevent; Int_t ntdc; Float_t tdc[500]; Int_t tdc_chan[500]; Int_t nFADC; Float_t FADC_SUM[32]; Float_t FADC_SUMSUB[32]; Int_t nCAENADC; Float_t CAEN_ADC[64]; Float_t CAEN_OVFL[64]; Float_t QDC_ped[2][64]; Float_t QDC_sig[2][64]; Float_t QDC_lim[64]; Float_t FADC_ped[2][32]; Float_t FADC_sig[2][32]; Float_t FADC_lim[32]; Float_t SigCut = 3.5; // cut above pedestal for strip signals Float_t Chi2X; Float_t Chi2Y; // Set branch addresses. fdctest->SetBranchAddress("nevent",&nevent); fdctest->SetBranchAddress("ntdc",&ntdc); fdctest->SetBranchAddress("tdc",tdc); fdctest->SetBranchAddress("tdc_chan",tdc_chan); fdctest->SetBranchAddress("nFADC",&nFADC); fdctest->SetBranchAddress("FADC_SUM",FADC_SUM); fdctest->SetBranchAddress("FADC_SUMSUB",FADC_SUMSUB); fdctest->SetBranchAddress("nCAENADC",&nCAENADC); fdctest->SetBranchAddress("CAEN_ADC",&CAEN_ADC); fdctest->SetBranchAddress("CAEN_OVFL",&CAEN_OVFL); // This is the loop skeleton // To read only selected branches, Insert statements like: // fdctest->SetBranchStatus("*",0); // disable all branches // TTreePlayer->SetBranchStatus("branchname",1); // activate branchname Long64_t nentries = fdctest->GetEntries(); cout<<"Number of Entries: "< bin size Float_t T_Ref = 0; // TDC time reference take always the last channel Float_t wireTime[300]; Int_t wireChan[300]; Int_t wireNum; Int_t wireHit[300]; Int_t FDCHit[80]; Int_t FDCHits; Int_t FDC_Hits[2]; Int_t FHits; Int_t FDCHits_Chan[300]; Float_t FDCHits_Time[300]; Float_t Planes[2][48]; Float_t Xaxis[48]; Int_t PlaneCnt[2]; Float_t WTOffset = 500.; Int_t IUHits = 0; Int_t FDC_Hit_Counter[2][16]; for (Int_t k=0;k<48;k++) Xaxis[k] = k; // read pedestal data for QADC and FADC ifstream INF; char fn1[128]; sprintf(fn1,"qadc_pedestals_run%d.dat",runnumber); //if (!access(fn1,F_OK)){ // test for file existance // cout << "Pedestal file for curernt run not found try previous run"<>Nchan; for (Int_t k=0;k>l>>QDC_ped[0][k]>>QDC_ped[1][k]>>QDC_sig[0][k]>>QDC_sig[1][k]>>dummy; //cout< set Flag1 to zero"<>l>>FADC_ped[0][k]>>FADC_ped[1][k]>>FADC_sig[0][k]>>FADC_sig[1][k]>>dummy; // FADC_lim[k] = FADC_ped[0][k] - FADC_sig[0][k]*SigCut; // } // INF.close(); //} else { // cout<<"No FADC pedestal file "<> chan1 >> Pedestals[k1] >> Gains[k1]; //cout<SetFillColor(42); c1->SetGrid(); Int_t imod = 10000; Float_t TrackHitCounter[6] = {0., 0., 0., 0., 0., 0.}; // !!!THE BIG LOOP!!! // loop over data // Long64_t nbytes = 0; for (Long64_t i=0; iGetEntry(i); //cout<<"Event "<287){ channel = chan-288; if (channel>15) { lr = 1; channel -=16; } Timing[lr][channel] = (Float_t)tdc[j]*TDC_Resolution; //cout << j<<" "<< tdc_chan[j]<<" :"<207){ if (chan>255){ Int_t wnum = chan-256; FDCHit[wnum] = 1; } } else IUHits++; } } } // Reference time is the trigger signal fed to channel 16 of the second // Camac discriminator T_Ref = Timing[1][15]; // calculate TDC time difference and position of trigger scintillators UInt_t TOP; UInt_t BOT; TOP = 0; BOT = 0; Int_t Tcnt = 0; Int_t Bcnt = 0; Int_t Top, Bot; Float_t DistT = 0.0; Float_t DistB = 0.0; for(Int_t j=0;j<8;j++){ deltaT[j] = Timing[0][j] - Timing[1][j] ; Distance[j] = deltaT[j]*Time2Dist/2.; sumT[j] = Timing[0][j] + Timing[1][j] ; if (TMath::Abs(Distance[j])<120){ BOT = BOT | (0x01<Fill(deltaT[j],1); histT[j+16]->Fill(Distance[j],1); hist2d[15]->Fill(Distance[j],(Float_t)j); } for(Int_t j=8;j<16;j++){ deltaT[j] = Timing[0][j] - Timing[1][j] ; Distance[j] = deltaT[j]*Time2Dist/2.; sumT[j] = Timing[0][j] + Timing[1][j] ; if (TMath::Abs(Distance[j])<120){ //cout<<"intop!"<<(0x01<<(j-8))<Fill(deltaT[j],1); histT[j+16]->Fill(Distance[j],1); hist2d[16]->Fill(Distance[j],(Float_t)(j-8)); } // only look at events with one hit per scintillator plane if ((Tcnt>1)||(Bcnt>1)){ continue; } if ((Tcnt==0)||(Bcnt==0)){ continue; } if (((Top-8<2)&&(Top-8>3)) || ((Bot<2)&&(Bot>3))){ continue; } if (TMath::Abs(DistB)>50.) continue; if (TMath::Abs(DistT)>50.) continue; histT[32]->Fill((sumT[Top]-sumT[Bot])/2.,1); //cout<<"TOP AND BOT: "<Fill((Float_t)Bot+0.5, (Float_t)Top-8.0+0.5, 1); Int_t Flag2 = FLAG2; Flag2 = 1; Int_t HitCounterX[4]; Int_t HitCounterY[4]; for (Int_t j=0;j<4;j++){ HitCounterX[j] = 0; HitCounterY[j] = 0; } // loop over all wire chamber hits Float_t ChamberOff = 0.; for (Int_t k=0;kwireTime[k]){ //cout<255){ Int_t wnum = Chan-256; Float_t drifttime = wireTime[k]-DriftTimeZero[wireChan[k]]; FDC_X[FDCHits].plane = 0; FDC_X[FDCHits].wire = wnum; if ((drifttime<=164.5)&& (drifttime>=0.)){ FDC_X[FDCHits].drifttime = drifttime; FDC_X[FDCHits].driftdist = time2distFDC_Inter(drifttime); FDC_X[FDCHits].x = -1.*(wnum*10.- 130.) + 200.; //cout << FDCHits<<": drifttime/driftdist " << drifttime << " " << FDC_X[FDCHits].driftdist << endl; }else{ FDC_X[FDCHits].drifttime = 99999.; FDC_X[FDCHits].driftdist = 99999.; } FDCHits_Chan[FDCHits] = wireChan[k]; FDCHits_Time[FDCHits] = wireTime[k]; FDCHits++; if (Chan<272){ FDC_Hits[0]++; } else { FDC_Hits[1]++; } } } }// Flag2 }// end loop over wire hits if (FDC_Hits[0]==1){ //fcout<<"two hits"<271) && (cntxFill(FDCHits_Time[cntx],1); hist2d[3]->Fill(FDCHits_Time[cntx],(Float_t)FDCHits_Chan[cntx]+44.-0.5,1); } // do hit accounting to test efficiency if (FDC_Hits[1]==1){ //fcout<<"two hits"<Fill(FDCHits_Time[cntx],1); hist2d[3]->Fill(FDCHits_Time[cntx],(Float_t)FDCHits_Chan[cntx]+44.-0.5,1); } if (FDC_Hits[0]==1){ Int_t cntx = 0; while (( FDCHits_Chan[cntx]>271) && (cntx271){ Int_t wire0 = FDCHits_Chan[j] - 272; if ((wire0==wire1) || (wire0-1==wire1) || (wire0+1==wire1)) FDC_Hit_Counter[1][wire1] +=1; } } } Float_t FDCDeltaT = 999.; if ((FDC_Hits[0]==1) && (FDC_Hits[1]==1)){ //cout<<"TWO HITS"<Fill(ch2, ch1); FDCDeltaT = t1-t2; } struct fitres a, b, interseptx, slopex, intersepty, slopey; Float_t chi2 = 99999.; Int_t mulx = HitCounterX[0]*HitCounterX[1]*HitCounterX[2]*HitCounterX[3]; if (DEBUG1) { cout<<"Event "<Fill(oldchi2); histT[42]->Fill(slopex.val); if (TMath::Abs(slopex.val)<0.1) histT[44]->Fill(oldchi2); Chi2X = oldchi2; } oldchi2 = 99999.; Int_t muly = HitCounterY[0]*HitCounterY[1]*HitCounterY[2]*HitCounterY[3]; Float_t dummy =0.; if (muly==1){ oldchi2 = fit_trackY(4, dummy , &intersepty, &slopey); //cout<<"f(y) = "<Fill(oldchi2); histT[43]->Fill(slopey.val); if (TMath::Abs(slopey.val)<0.1) histT[45]->Fill(oldchi2); Chi2Y = oldchi2; } Float_t IU_x = 0.; Float_t IU_y = 0.; // FDC wire plane z-position between the IU chambers //Float_t WirePlanePos = 771.5; Float_t WirePlanePos = 781.5; if ((muly==1)&&(mulx==1)){ //cout <<"Event "<Fill(IU_x, IU_y,1.); hist2d[18]->Fill(slopey.val, slopex.val); if ((TMath::Abs(IU_x-170.)<30.) && (TMath::Abs(IU_y-410.)<30.)){ TrackHitCounter[0] += 1.; if (FDC_Hits[0]>0){ TrackHitCounter[1] += 1.; } } if ((TMath::Abs(IU_x-200.)<30.) && (TMath::Abs(IU_y-470.)<20.)){ TrackHitCounter[2] += 1.; if (FDC_Hits[0]>0){ TrackHitCounter[3] += 1.; } } if ((TMath::Abs(IU_x*slopeW - 26.844 - IU_y)<11.5) && (TMath::Abs(IU_x-225)<50.)){ TrackHitCounter[4] += 1.; if (FDC_Hits[0]>0){ TrackHitCounter[5] += 1.; } } if (FDC_Hits[0]==1){ Int_t cnt1 = 0; while ( cnt1Fill(IU_x, IU_y, 1.); Double_t yfdc = slopeW*IU_x+B[wir]; Double_t d = (yfdc-IU_y)*cos(alphaFDC); c = wir + 55; histT[c]->Fill(d); Double_t tim = FDCHits_Time[cnt1] - DriftTimeZero[FDCHits_Chan[cnt1]];; //cout<<"FDC time "<=0.)) { Double_t dFDC = time2distFDC(tim); Double_t d_diff = dFDC-d; // unit vector along track Float_t x1 = slopex.val; Float_t y1 = slopey.val; Float_t z1 = 1.; // vector normal to the direction of the FDC wire // the norm of this vector is =1.15477541 Float_t x0 = -slopeW; Float_t y0 = 1.; Float_t z0 = 0.; // angle between plane and track Float_t alpha = (x1*x0 + y1*y0) / sqrt(x1*x1+y1*y1+z1*z1)/ sqrt(1.+slopeW*slopeW) ; alpha = acos(alpha)-PIh; //cout<<"angle "<Fill(alpha, d_diff); // vector in the direction of the FDC wire // the norm of this vector is =1.15477541 Float_t x2 = 1.; Float_t y2 = slopeW; Float_t z2 = 0.; alpha = (x2*x1 + y2*y1) / sqrt(x2*x2+y2*y2+z2*z2)/ sqrt(x1*x1+y1*y1+z1*z1); alpha = acos(alpha) - PIh; //cout<<"angle "<Fill(alpha, d_diff); c = wir + 71; if ((TMath::Abs(slopex.val)<0.05) && (TMath::Abs(slopey.val)<0.05)){ histT[c]->Fill(d_diff); } //cout<<"FDC time "<Fill(alpha, FDCDeltaT); // also calculate angle between track and vertical axis (0,0,1) alpha = 1./ sqrt(x1*x1+y1*y1+z1*z1); alpha = acos(alpha); //cout<<"angle "<Fill(alpha, FDCDeltaT); } } // fill the wire hits from the second wire plane if (FDC_Hits[1]==1){ Int_t cnt1 = 0; while ( cnt1271){ Int_t c = FDCHits_Chan[cnt1] - 272 + 38; Float_t WPos = WirePlanePos+20.0; IU_x = slopex.val*WPos + interseptx.val; IU_y = slopey.val*WPos + intersepty.val; //cout<Fill(IU_x, IU_y,1.); } cnt1++; } } } // Now the FDC cathode data analysis // initialize planes memset(&Planes[0][0],0,384); //for (Int_t k=0;k<32;k++){ // Planes[0][k] = 0.; // Planes[1][k] = 0.; //} PlaneCnt[0] = PlaneCnt[1] = 0; // fill raw ADC spectra for V792 CAEN ADC for (Int_t k=0; kFill(CAEN_ADC[k]); hist2d[8]->Fill(CAEN_ADC[k],(Float_t)k); //hist2d[9]->Fill((CAEN_ADC[k]-Pedestals[k])*Gains[k]+200.,(Float_t)k); //cout << QDC_ped[0][k] << " " << QDC_sig[0][k] << " "<< Gains[k]<Fill(CAEN_ADC[2] + 200. ,CAEN_ADC[1] + 200.); hist2d[55]->Fill(CAEN_ADC[3] + 200. ,CAEN_ADC[1] + 200.); hist2d[56]->Fill(CAEN_ADC[4] + 200. ,CAEN_ADC[1] + 200.); hist2d[57]->Fill(CAEN_ADC[3] + 200. ,CAEN_ADC[2] + 200.); hist2d[58]->Fill(CAEN_ADC[4] + 200. ,CAEN_ADC[2] + 200.); hist2d[59]->Fill(CAEN_ADC[5] + 200. ,CAEN_ADC[2] + 200.); hist2d[60]->Fill(CAEN_ADC[34] + 200. ,CAEN_ADC[33] + 200.); hist2d[61]->Fill(CAEN_ADC[35] + 200. ,CAEN_ADC[34] + 200.); hist2d[62]->Fill(CAEN_ADC[36] + 200. ,CAEN_ADC[35] + 200.); hist2d[63]->Fill(CAEN_ADC[37] + 200. ,CAEN_ADC[36] + 200.); hist2d[64]->Fill(CAEN_ADC[38] + 200. ,CAEN_ADC[37] + 200.); hist2d[65]->Fill(CAEN_ADC[39] + 200. ,CAEN_ADC[38] + 200.); for (Int_t k=0; kFill( QADC,(Float_t)k); qadc[k+64]->Fill(QADC); Int_t kk = k; plane = 0; if (k>31){ plane = 1; } if (CAEN_ADC[k]>QDC_lim[k]){ //cout<Fill(FADC_SUM[k],1); //FADC_SUMSUB[k]*= -1.; //fadcNP[k]->Fill(FADC_SUMSUB[k],1); //strip = k; //Float_t rnorm = 1.; //if (k<16) //strip = 15-k; //strip = k; //if (k>15) // strip = 47-k; // //if ((FADC_SUM[k])15) // rnorm = 0.2; // Planes[plane][strip] = FADC_SUMSUB[k]*rnorm; // PlaneCnt[plane]++; //} // //} if (Flag1){ // determine Cathode positions Float_t xpos = 99999; Float_t ypos = 99999; Float_t wpos = 99999; Float_t lpos = 99999; Int_t inp; Int_t FitBoth = 0; if (PlaneCnt[0]>2){ // check if at least 3 hits are next neighours Int_t plane = 0; Int_t bool1=0; for (Int_t k=0;k<46;k++){ if ((Planes[plane][k]>0)&&(Planes[plane][k+1]>0)&&(Planes[plane][k+2]>0)) bool1++; } if (bool1){ //cout<<"fit FDC Plane 0"<Fit("gaus","Q","R",max-3.,max+3.); TF1* gf = tgr->GetFunction("gaus"); //gf->SetParameter(1,max); //gf->SetParameter(2,1.); //tgr->Fit("gaus","Q","R",max-2.,max+3.); xpos = gf->GetParameter(1) + XCathOffSet; //gf->SetLineColor(2); //tgr->Draw("AP*C"); //c1->Update(); //cout<<"INP: "; //cin>>inp; FitBoth++; } } if (PlaneCnt[1]>2){ // check if at least 3 hits are next neighours Int_t plane = 1; Int_t bool1=0; for (Int_t k=0;k<46;k++){ if ((Planes[plane][k]>0)&&(Planes[plane][k+1]>0)&&(Planes[plane][k+2]>0)) bool1++; } if (bool1){ //cout<<"fit FDC Plane 1"<GetFunction("gaus"); //gf->SetParameter(1,max); //gf->SetParameter(2,1.); //tgr->Fit("gaus","Q","R",max-2.,max+3.); ypos = gf->GetParameter(1) + YCathOffSet; //gf->SetLineColor(4); //tgr->Draw("AP*C"); //c1->Update(); //cout<<"INP: "; //cin>>inp; //c1->SaveAs("test2.jpg"); FitBoth++; } } if (FitBoth==2){ wpos = getCathodeXpos(xpos, ypos); lpos = getCathodeYpos(xpos, ypos); //cout<Fill(xpos,ypos,1); hist2d[2]->Fill(wpos,lpos,1); histT[33]->Fill(wpos,1); histT[34]->Fill(lpos,1); histT[35]->Fill(xpos,1); histT[36]->Fill(ypos,1); if (muly==1){ //oldchi2 = fit_trackY(5, lpos , &intersepty, &slopey); //cout<<"f(y) = "<Fill(oldchi2); // histT[43]->Fill(slopey.val); // if (TMath::Abs(slopey.val)<0.1) // histT[45]->Fill(oldchi2); } if (FDCHits==1){ histT[38]->Fill(wpos,1); hist2d[7]->Fill(wpos,lpos,1); Int_t cntfdchits=0; for (Int_t n=0;n<16;n++){ if (FDCHit[n]==1){ cntfdchits++; hist2d[4]->Fill(wpos,(Float_t)n, 1); hist2d[6]->Fill(lpos,(Float_t)n, 1); //cout<30.)&&(lpos<70.)){ histT[37]->Fill(wpos,1); //} } if ((muly==1)&&(mulx==1)){ //if (TMath::Abs(slopex.val+0.02)<0.05) //hist2d[11]->Fill(IU_x,wpos, 1); if ( (TMath::Abs(slopey.val)<0.45) && (TMath::Abs(slopex.val)<0.45) ) { hist2d[12]->Fill(IU_y,lpos, 1); histT[52]->Fill(lpos-IU_y,1); // project lpol to f(x)=ax+b with a=-1 and b=0 Float_t x0 = (-IU_y+lpos)/2.; if (FDCHits==1){ Float_t fdcx = FDC_X[0].x + ((Float_t)FDC_N) * FDC_X[0].driftdist; //Float_t fdcx = FDC_X[0].x + FDC_X[0].driftdist; hist2d[17]->Fill(IU_x, fdcx, 1); histT[53]->Fill(fdcx-IU_x,1); if (IU_x<280.){ histT[54]->Fill(fdcx-IU_x,1); } } histT[39]->Fill(TMath::Sqrt(2.)*TMath::Abs(x0)); if (IU_y<360){ hist2d[11]->Fill(IU_x,wpos, 1); hist2d[14]->Fill(TMath::Sqrt(2.)*TMath::Abs(x0),slopey.val); } if (TMath::Abs(IU_y-260.)<20.) histT[46]->Fill(TMath::Sqrt(2.)*TMath::Abs(x0)); if (TMath::Abs(IU_y-300.)<20.) histT[47]->Fill(TMath::Sqrt(2.)*TMath::Abs(x0)); if (TMath::Abs(IU_y-340.)<20.) histT[48]->Fill(TMath::Sqrt(2.)*TMath::Abs(x0)); if (TMath::Abs(IU_y-380.)<20.) histT[49]->Fill(TMath::Sqrt(2.)*TMath::Abs(x0)); if (TMath::Abs(IU_y-320.)<20.) histT[50]->Fill(TMath::Sqrt(2.)*TMath::Abs(x0)); if (TMath::Abs(IU_y-320.)<40.) histT[51]->Fill(TMath::Sqrt(2.)*TMath::Abs(x0)); } } } } } } fdctest->Delete(); f->Close(); cout<<"FDC WIRE COUNTERS:"<