//*-- AUTHOR : J. Markert //_HADES_CLASS_DESCRIPTION //////////////////////////////////////////////////////////////////////////// // HMdcGarCal2Maker // Reads Histograms for time1/time2 versus distance from wire from root file // produced with HMdcGarSignalReader. The values for time1 and time2 and the // corresponding errors are processed (spike removing, smoothing, cut at max // value per mdc) for all MDC's and all impact angles for time1, time2, // error of time1 and error of time2. A root file with the control hists is // written and an ascii file containing the parameters of HMdcCal2ParSim is // produced. //////////////////////////////////////////////////////////////////////////// using namespace std; #include #include #include #include "hmdcgarcal2maker.h" #include "htool.h" #include "TString.h" #include "TFile.h" #include "TDirectory.h" #include "TF1.h" #include "TH1.h" #include "TH2.h" #include "TROOT.h" #include "TKey.h" #include "TStyle.h" #include "TCanvas.h" #include "TGraph.h" #include "TMath.h" #include "TLine.h" Int_t HMdcGarCal2Maker ::maxbinNumber[72]={25,28,28,31,33,34, //25 // 6% treshold 35,35,36,37,36,35, //55 35,34,33,31,29,27, 29,32,33,35,36,37, 40,39,39,39,38,38, 37,31,34,32,30,28, //65:36->31 60,63,65,68,69,70, //36 // 10:66->65 20:70->69 25:71->70 71,71,71,70,68,66, 64,61,57,53,49,44, // 75:54->53 85: 45->44 70,75,78,81,83,85, 86,87,86,85,84,82, 79,75,71,67,62,56 }; Float_t HMdcGarCal2Maker::cutMax [4]={110,120,260,370}; ClassImp(HMdcGarCal2Maker) HMdcGarCal2Maker::HMdcGarCal2Maker(const Char_t* name,const Char_t* title) : TNamed(name,title) { // constructor for HMdcGarCal2Maker // The parameters are initialized with non valid values. initVariables(); } HMdcGarCal2Maker::~HMdcGarCal2Maker() { // destructor of HMdcGarCal2Maker outputHists->Write(); outputHists->Close(); } void HMdcGarCal2Maker::setFileNameOut(TString myfile) { // Sets ascii output of HMdcGarCal2Maker fNameAsciiOut=myfile; if(fNameAsciiOut.CompareTo("")==0) { Error("HMdcGarCal2Maker:setFileNameOut()","NO OUTPUT FILE SEPCIFIED!"); exit(1); }; cout<<"HMdcGarCal2Maker::setFileNameOut(): OUTPUT FILE= "<GetName()); } Bool_t HMdcGarCal2Maker::check(Int_t m,Int_t t) { // Checks if the Mdc m and the type t (t1,t1err,t2,t2err) // is active in the current setup Bool_t test=kFALSE; if(t!=-99&&m!=-99) { if(getMakeMdc(m)==1&&getMakeType(t)==1)test=kTRUE; else test=kFALSE; } if(t==-99&&m!=-99) { if(getMakeMdc(m)==1)test=kTRUE; else test=kFALSE; } if(t!=-99&&m==-99) { if(getMakeType(t)==1)test=kTRUE; else test=kFALSE; } return test; } void HMdcGarCal2Maker::calcBounderies(Int_t mdc,Int_t a,Float_t* cellEdge,Float_t* maxDist) { // Calulates the bounderies of the different cell types of the MDC's underr // certain impact angle "a". "cellEdge" is the max distances of a track with // minimum distance at the cell border whereas "maxDist" is the max minimum // distance of a track just hitting the cell. Double_t cellY[4]={2.5,3.0,6.0,7.0}; Double_t cellX[4]={2.5,2.6,4.0,5.0}; Double_t alphaRad=((a*5)/180.*TMath::Pi()); Double_t celledgeY=cellY[mdc]/cos(alphaRad); Double_t celledgeX; (a==0)? celledgeX=cellY[mdc] : celledgeX=cellX[mdc]/sin(alphaRad); (celledgeY>celledgeX)? *cellEdge=(Float_t)celledgeX : *cellEdge=(Float_t)celledgeY; if(a!=0) { Double_t alphaRad2=((a*5-90)/180.*TMath::Pi()); // angle of track Double_t b= cellX[mdc]-(tan(alphaRad2)*cellY[mdc]); Double_t y=-b/(tan(alphaRad2)-tan(alphaRad)); Double_t x=tan(alphaRad)*y; *maxDist =(Float_t)sqrt((y*y)+(x*x)); } else *maxDist=(Float_t)cellY[mdc]; } void HMdcGarCal2Maker::make() { // Main function to be called from the macro. cout<<"--------------------------------------------------------------"<GetBinContent(sample); mtime2 [mdctype][angle][0]=htime2->GetBinContent(sample); mtime1_err[mdctype][angle][0]=htime1->GetBinError(sample); mtime2_err[mdctype][angle][0]=htime2->GetBinError(sample); mtime1_corr [mdctype][angle][0] = mtime1 [mdctype][angle][0]; mtime1_err_corr[mdctype][angle][0] = mtime1_err[mdctype][angle][0]; mtime2_corr [mdctype][angle][0] = mtime2 [mdctype][angle][0]; mtime2_err_corr[mdctype][angle][0] = mtime2_err[mdctype][angle][0]; } if( (htime1->GetBinContent(sample))GetBinContent(sample); mtime2 [mdctype][angle][sample]=htime2->GetBinContent(sample); mtime1_err[mdctype][angle][sample]=htime1->GetBinError(sample); mtime2_err[mdctype][angle][sample]=htime2->GetBinError(sample); lastvalidBin[mdctype][angle]=sample; } else { if (lastvalidBin[mdctype][angle]<=getMaxBinNumber((mdctype*18)+angle)) { // fill range between lastvalid and maxnumber of bins mtime1 [mdctype][angle][sample]=getCutMax(mdctype) +(lastvalidBin[mdctype][angle]-sample)*-getSlope(); mtime2 [mdctype][angle][sample]=getCutMax(mdctype) +(lastvalidBin[mdctype][angle]-sample)*-getSlope(); mtime1_err[mdctype][angle][sample]=mtime1_err[mdctype][angle][lastvalidBin[mdctype][angle]]; mtime2_err[mdctype][angle][sample]=mtime2_err[mdctype][angle][lastvalidBin[mdctype][angle]]; } } //################################################################################################################# } else { // fill rest of Matrix // fill range larger max number of bins mtime1 [mdctype][angle][sample]=mtime1[mdctype][angle][getMaxBinNumber((mdctype*18)+angle)] + (getMaxBinNumber((mdctype*18)+angle)-sample)*-getSlope(); mtime2 [mdctype][angle][sample]=mtime2[mdctype][angle][getMaxBinNumber((mdctype*18)+angle)] + (getMaxBinNumber((mdctype*18)+angle)-sample)*-getSlope(); if(htime1->GetBinError(getMaxBinNumber((mdctype*18)+angle))>0) { mtime1_err[mdctype][angle][sample]=getMaxErrTime1(); } else { mtime1_err[mdctype][angle][sample]=getMaxErrTime1(); } if(htime2->GetBinError(getMaxBinNumber((mdctype*18)+angle))>0) { mtime2_err[mdctype][angle][sample]=getMaxErrTime2(); } else { mtime2_err[mdctype][angle][sample]=getMaxErrTime2(); } //################################################################################################################# } //coppy array mtime1_corr [mdctype][angle][sample] = mtime1 [mdctype][angle][sample]; mtime1_err_corr[mdctype][angle][sample] = mtime1_err[mdctype][angle][sample]; mtime2_corr [mdctype][angle][sample] = mtime2 [mdctype][angle][sample]; mtime2_err_corr[mdctype][angle][sample] = mtime2_err[mdctype][angle][sample]; } } if(getVersion()==2) { for(Int_t sample=0;sample<100;sample++) { if(sample<=maxbinNumber[(mdctype*18)+angle]) { // fill all valid values //######################################## FILL MATRIX ############################################################ if(sample==1) { // fill first bin mtime1 [mdctype][angle][0]=htime1->GetBinContent(sample); mtime2 [mdctype][angle][0]=htime2->GetBinContent(sample); mtime1_err[mdctype][angle][0]=htime1->GetBinError(sample); mtime2_err[mdctype][angle][0]=htime2->GetBinError(sample); mtime1_corr [mdctype][angle][0] = mtime1 [mdctype][angle][0]; mtime1_err_corr[mdctype][angle][0] = mtime1_err[mdctype][angle][0]; mtime2_corr [mdctype][angle][0] = mtime2 [mdctype][angle][0]; mtime2_err_corr[mdctype][angle][0] = mtime2_err[mdctype][angle][0]; } if( (htime1->GetBinContent(sample))GetBinContent(sample); mtime2 [mdctype][angle][sample]=htime2->GetBinContent(sample); mtime1_err[mdctype][angle][sample]=htime1->GetBinError(sample); mtime2_err[mdctype][angle][sample]=htime2->GetBinError(sample); lastvalidBin[mdctype][angle]=sample; } else { if (lastvalidBin[mdctype][angle]<=getMaxBinNumber((mdctype*18)+angle)) { // fill range between lastvalid and maxnumber of bins mtime1 [mdctype][angle][sample]=getCutMax(mdctype) +(lastvalidBin[mdctype][angle]-sample)*-getSlope(); mtime2 [mdctype][angle][sample]=getCutMax(mdctype) +(lastvalidBin[mdctype][angle]-sample)*-getSlope(); mtime1_err[mdctype][angle][sample]=mtime1_err[mdctype][angle][lastvalidBin[mdctype][angle]]; mtime2_err[mdctype][angle][sample]=mtime2_err[mdctype][angle][lastvalidBin[mdctype][angle]]; } } //################################################################################################################# } else { // fill rest of Matrix // fill range larger max number of bins mtime1 [mdctype][angle][sample]=mtime1[mdctype][angle][getMaxBinNumber((mdctype*18)+angle)] + (getMaxBinNumber((mdctype*18)+angle)-sample)*-getSlope(); mtime2 [mdctype][angle][sample]=mtime2[mdctype][angle][getMaxBinNumber((mdctype*18)+angle)] + (getMaxBinNumber((mdctype*18)+angle)-sample)*-getSlope(); if(htime1->GetBinError(getMaxBinNumber((mdctype*18)+angle))>0) { mtime1_err[mdctype][angle][sample]=getMaxErrTime1(); } else { mtime1_err[mdctype][angle][sample]=getMaxErrTime1(); } if(htime2->GetBinError(getMaxBinNumber((mdctype*18)+angle))>0) { mtime2_err[mdctype][angle][sample]=getMaxErrTime2(); } else { mtime2_err[mdctype][angle][sample]=getMaxErrTime2(); } //################################################################################################################# } //coppy array mtime1_corr [mdctype][angle][sample] = mtime1 [mdctype][angle][sample]; mtime1_err_corr[mdctype][angle][sample] = mtime1_err[mdctype][angle][sample]; mtime2_corr [mdctype][angle][sample] = mtime2 [mdctype][angle][sample]; mtime2_err_corr[mdctype][angle][sample] = mtime2_err[mdctype][angle][sample]; } } } void HMdcGarCal2Maker::findMax(Int_t m) { // finds maximum values inside the array of // time1err and replacing values after max by // a constant value. Float_t cellEdge; Float_t maxDist; Int_t startBin; for(Int_t a=0;a<18;a++) { // start finding spikes at 80% of the drift // cell size (10 bins = 1 mm) calcBounderies(m,a,&cellEdge,&maxDist); startBin=Int_t(cellEdge*0.8*10); // reset arrays max1[m][a] = -1.; max2[m][a] = -1.; max1bin[m][a] = 100; max2bin[m][a] = 100; // Max1 for(Int_t i=startBin;i<100;i++) { // find max1 and max1bin if(mtime1_err_corr[m][a][i]>max1[m][a]) { max1 [m][a]=mtime1_err_corr[m][a][i]; max1bin[m][a]=i; } } for(Int_t i=max1bin[m][a];i<100;i++) { // replace bins >max1bin with max1 value mtime1_err_corr[m][a][i]=max1[m][a]; } for(Int_t i=0;i<100;i++) { // replace bins >maxErrTime1 by maxErrTime1 if(mtime1_err_corr[m][a][i]>getMaxErrTime1()){ mtime1_err_corr[m][a][i]=getMaxErrTime1(); } } } } void HMdcGarCal2Maker::removeSpikes(Int_t m) { // Removes spikes from time1err //-------------------remove spikes ------------------------------- Float_t slopeSpike=0; Float_t oldslopeSpike=0; if(!getPrintMode())cout<<"mdc "<0) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i]) >getSpikeThreshold1()) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i+1])0) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i]) >getSpikeThreshold1()) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i+1])>getSpikeThreshold1()) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i+2])0) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i]) >getSpikeThreshold1()) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i+1])>getSpikeThreshold1()) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i+2])>getSpikeThreshold1()) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i+3])0) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i]) >getSpikeThreshold1()) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i+1])>getSpikeThreshold1()) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i+2])>getSpikeThreshold1()) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i+3])>getSpikeThreshold1()) && (fabs(mtime1_err_corr[m][a][i-1]-mtime1_err_corr[m][a][i+4])SetBinContent(i+1,mtime1_corr [m][a][i]); } if(type==1)for(Int_t i=0;i<100;i++){ h->SetBinContent(i+1,mtime1_err_corr[m][a][i]); } if(type==2)for(Int_t i=0;i<100;i++){ h->SetBinContent(i+1,mtime2_corr [m][a][i]); } if(type==3)for(Int_t i=0;i<100;i++){ h->SetBinContent(i+1,mtime2_err_corr[m][a][i]); } } void HMdcGarCal2Maker::copyToArray(TH1F* h,Int_t m,Int_t a,Int_t type) { // Copy working hists to arrays if(type==0)for(Int_t i=0;i<100;i++){ mtime1_corr [m][a][i]=h->GetBinContent(i+1); if(mtime1_corr[m][a][i]==0&& i<1) { Warning("HMdcGarCal2Maker::copyToArray()", "Bin content 0 in time 1 of %i %02i %02i",m,a,i); } } if(type==1)for(Int_t i=0;i<100;i++){ mtime1_err_corr[m][a][i]=h->GetBinContent(i+1); if(mtime1_err_corr[m][a][i]==0) { Warning("HMdcGarCal2Maker::copyToArray()", "Bin content 0 in time1 err of %i %02i %02i",m,a,i); } } if(type==2)for(Int_t i=0;i<100;i++){ mtime2_corr [m][a][i]=h->GetBinContent(i+1); if(mtime2_corr[m][a][i]==0) { Warning("HMdcGarCal2Maker::copyToArray()", "Bin content 0 in time2 of %i %02i %02i",m,a,i); } } if(type==3)for(Int_t i=0;i<100;i++){ mtime2_err_corr[m][a][i]=h->GetBinContent(i+1); if(mtime2_err_corr[m][a][i]==0) { Warning("HMdcGarCal2Maker::copyToArray()", "Bin content 0 in time2 err of %i %02i %02i",m,a,i); } } } Float_t HMdcGarCal2Maker::coefSavGol2(Int_t i, Int_t j, Int_t k, Int_t ni, Int_t nj, Int_t nk) { // // Compute 2nd order Savitzky-Golay polynomial coefficient c=c(i,j,k,ni,nj,nk) // if (abs(i)>ni || abs(j)>nj || abs(k)>nk) return 0.; Float_t Nijk = (2*ni+1)*(2*nj+1)*(2*nk+1); Float_t gi = (ni*(ni+1))/3.; Float_t gj = (nj*(nj+1))/3.; Float_t gk = (nk*(nk+1))/3.; Float_t termi = 5.*((Float_t)(i*i)-gi)/(4.*gi-1.); Float_t termj = 5.*((Float_t)(j*j)-gj)/(4.*gj-1.); Float_t termk = 5.*((Float_t)(k*k)-gk)/(4.*gk-1.); return (1.-termi-termj-termk)/Nijk; } void HMdcGarCal2Maker::do2dSavitzkyGolayFiltering(Float_t *data, Int_t xchan, Int_t ychan, Bool_t clip) { // // Do a 2dim symmetric second-order Savitzky-Golay noise filtering on data // // - 2dim, because data=data(i,j) // - symmetric, because nR = nL = n // - second-order, because m=2 // Int_t n=2; // fix filter window to [-2,2] Float_t work[xchan][ychan]; // temporary work matrix Float_t c[2*n+1][2*n+1]; // coefficient matrix Float_t sum = 0.; for(Int_t i=-n; i<=n; i++) { // tabulate filter coefficients for(Int_t j=-n; j<=n; j++) { sum += c[i+n][j+n] = coefSavGol2(i,j,0,n,n,0); } } if(sum != 1){ cout << "Sum of Savitzky-Golay coefficients Not 1 : " << sum <GetXaxis()->GetBinCenter( 3); x2 = h->GetXaxis()->GetBinCenter( nrange + 1); fit->SetRange(x1,x2); h->Fit(fit,"NQR"); for(Int_t bin = 0; bin < 3; bin ++) { // now replace the bin in range by fitted values h->SetBinContent(bin + 1,fit->Eval(h->GetXaxis()->GetBinCenter(bin+1))); } } if(type == 1){ lastBin = Int_t(cellEdge*1.*10); nrange = (Int_t)(cellEdge*1.*10*.3); fit = new TF1("fit","pol2"); Float_t x1,x2; x1 = h->GetXaxis()->GetBinCenter(1); x2 = h->GetXaxis()->GetBinCenter(nrange + 1); fit->SetRange(x1,x2); h->Fit(fit,"NQR"); for(Int_t bin = 0; bin <= nrange; bin ++) { // now replace the bin in range by fitted values h->SetBinContent(bin + 1,fit->Eval(h->GetXaxis()->GetBinCenter(bin+1))); } } delete fit; } void HMdcGarCal2Maker::replaceBins(TH1F* h,Int_t m,Int_t a,Int_t type) { // Replace the first bins and the bins after the maximum bin of the // workings hists after smoothing by the original bins of the working arrays. if(type==1) { for(Int_t i=0;i<100;i++){ // do not allow over shoot if(h->GetBinContent(i+1)>getMaxErrTime1()){ h->SetBinContent(i+1,getMaxErrTime1()); } } } if(type==2) { for(Int_t i=0;iSetBinContent(i+1,mtime2_corr[m][a][i]); } for(Int_t i=getMinCopy();i<100;i++){// bins after max h->SetBinContent(i+1,mtime2_corr[m][a][i]); } } } void HMdcGarCal2Maker::createGraph(Int_t m,Int_t t,Int_t l) { // Create Graphs , fill them with the working array and write // them to disk gStyle->SetPalette(50); Float_t x[100]; Float_t y[100]; TDirectory *dirTemp=NULL; if(getWriteHists()) { outputHists->cd(); if (outputHists) dirTemp=HTool::Mkdir(outputHists, "module",m); } for(Int_t a=0;a<18;a++){ if(t==0)for(Int_t i=0;i<100;i++){ y[i]=mtime1_corr[m][a][i]; x[i]=0.1*i; } if(t==1)for(Int_t i=0;i<100;i++){ y[i]=mtime1_err_corr[m][a][i]; x[i]=0.1*i; } if(t==2)for(Int_t i=0;i<100;i++){ y[i]=mtime2_corr[m][a][i]; x[i]=0.1*i; } if(t==3)for(Int_t i=0;i<100;i++){ y[i]=mtime2_err_corr[m][a][i]; x[i]=0.1*i; } Char_t namegraph[300]; sprintf(namegraph,"%s%i%s%02i%s%i%s%i%s","g[",m,"][",a,"][",t,"][",l,"]"); g[m][a][t][l]=new TGraph(100,x,y); g[m][a][t][l]->SetName(namegraph); g[m][a][t][l]->SetLineColor(getLevelColors(l)); if(getWriteHists()) { HTool::writeObject(g[m][a][t][l]); } } if(getWriteHists()) { dirTemp->TDirectory::Cd(".."); } } void HMdcGarCal2Maker::fillControl2D(Int_t mdctype,Int_t type,TString context) { // Fills a 2D Control hist from the working arrays and writes the hist to disk. if(type==0)cout<<"HMdcGarCal2Maker::fillControl2D() : Filling Hist for MDC"<cd(); gStyle->SetPalette(1); if(getBatchMode())gROOT->SetBatch(); Char_t namecanvas[300]; TString histtype; if(type==0)histtype="2D time1"; if(type==1)histtype="2D error of time1"; if(type==2)histtype="2D time2"; if(type==3)histtype="2D error of time2"; sprintf(namecanvas,"%s%s%i%s%s",histtype.Data()," for MDC",mdctype," after ",context.Data()); TCanvas *result =new TCanvas(namecanvas ,namecanvas,1000,800); result->cd(); result->Draw(); Char_t namematrix[200]; if(type==0)sprintf(namematrix,"%s%i%s%s","MDC",mdctype,"_t1_",context.Data()); if(type==1)sprintf(namematrix,"%s%i%s%s","MDC",mdctype,"_t1err_",context.Data()); if(type==2)sprintf(namematrix,"%s%i%s%s","MDC",mdctype,"_t2_",context.Data()); if(type==3)sprintf(namematrix,"%s%i%s%s","MDC",mdctype,"_t2err_",context.Data()); TH2F* hmatrix; Char_t nameHist[200]; sprintf(nameHist,"%s%i%s%i%s%s","hmatrix[",mdctype,"][",type,"]_",context.Data()); hmatrix=new TH2F(nameHist,namematrix,getNBin2D_Angle(),0,getNBin2D_Angle(),getNBin2D_Dist(),0,getNBin2D_Dist()*0.1); hmatrix->SetXTitle("angle [step(5 degree)]"); hmatrix->SetYTitle("distance from wire [mm]"); hmatrix->SetOption("lego2"); if(type==0 || type==2)hmatrix->SetZTitle("drift time [ns]"); if(type==1 || type==3)hmatrix->SetZTitle("error of drift time [ns]"); hmatrix->SetLabelSize(0.03,"x"); hmatrix->SetLabelSize(0.03,"y"); hmatrix->SetLabelSize(0.03,"z"); hmatrix->SetTitleOffset(1.5,"x"); hmatrix->SetTitleOffset(1.5,"y"); hmatrix->SetTitleOffset(1. ,"z"); for(Int_t angle=0;angle<18;angle++) { for(Int_t sample=0;sample<100;sample++) { if(type==0)hmatrix->SetBinContent(angle+1,sample+1,mtime1_corr [mdctype][angle][sample]); if(type==1)hmatrix->SetBinContent(angle+1,sample+1,mtime1_err_corr[mdctype][angle][sample]); if(type==2)hmatrix->SetBinContent(angle+1,sample+1,mtime2_corr [mdctype][angle][sample]); if(type==3)hmatrix->SetBinContent(angle+1,sample+1,mtime2_err_corr[mdctype][angle][sample]); } } hmatrix->DrawCopy(); if(getWriteHists()) { HTool::writeObject(hmatrix); } HTool::deleteObject(hmatrix); } void HMdcGarCal2Maker::fillControl1D(Int_t mdctype,Int_t type,TString context) { // Fills 1D Control hists (for each impact angle) and writes the hists to disk. if(type==0)cout<<"HMdcGarCal2Maker::fillControl1D() : Filling Hist for MDC"<cd(); if (outputHists) dirTemp=HTool::Mkdir(outputHists, "module",mdctype); } gStyle->SetPalette(50); if(getBatchMode())gROOT->SetBatch(); Char_t namecanvas[300]; TString histtype; if(type==0)histtype="1D time1"; if(type==1)histtype="1D error of time1"; if(type==2)histtype="1D time2"; if(type==3)histtype="1D error of time2"; sprintf(namecanvas,"%s%s%i%s%s",histtype.Data()," for MDC",mdctype," after ",context.Data()); TCanvas *result =new TCanvas(namecanvas ,namecanvas,1000,800); result->Divide(6,3); result->cd(); result->Draw(); Char_t namematrix[200]; if(type==0)sprintf(namematrix,"%s%i%s%s","MDC",mdctype,"_t1_" ,context.Data()); if(type==1)sprintf(namematrix,"%s%i%s%s","MDC",mdctype,"_t1err_",context.Data()); if(type==2)sprintf(namematrix,"%s%i%s%s","MDC",mdctype,"_t2_" ,context.Data()); if(type==3)sprintf(namematrix,"%s%i%s%s","MDC",mdctype,"_t2err_",context.Data()); TH1F* h[18]; Char_t nameHist[200]; for(Int_t angle=0;angle<18;angle++) { sprintf(nameHist,"%s%i%s%i%s%02i%s%s","h[",mdctype,"][",type,"][",angle,"]_",context.Data()); //h[angle]=new TH1F(nameHist,namematrix,15,0,15*0.1); h[angle]=new TH1F(nameHist,namematrix,getNBin1D_Dist(),0,getNBin1D_Dist()*0.1); h[angle]->SetYTitle("distance from wire [mm]"); h[angle]->SetMarkerStyle(8); h[angle]->SetMarkerSize(0.5); h[angle]->SetOption("LP"); if(type==0 || type==1)h[angle]->SetMarkerColor(2); if(type==2 || type==3)h[angle]->SetMarkerColor(4); if(type==0 || type==2)h[angle]->SetYTitle("drift time [ns]"); if(type==1 || type==3)h[angle]->SetYTitle("error of drift time [ns]"); for(Int_t sample=0;sample<100;sample++) { if(type==0)h[angle]->SetBinContent(sample+1,mtime1_corr [mdctype][angle][sample]); if(type==1)h[angle]->SetBinContent(sample+1,mtime1_err_corr[mdctype][angle][sample]); if(type==2)h[angle]->SetBinContent(sample+1,mtime2_corr [mdctype][angle][sample]); if(type==3)h[angle]->SetBinContent(sample+1,mtime2_err_corr[mdctype][angle][sample]); } result->cd(angle+1); if(type==1||type==3)h[angle]->SetMaximum(100); if(type==0||type==2)h[angle]->SetMaximum(1000); // 1000 h[angle]->DrawCopy(); h[angle]->SetOption(""); h[angle]->DrawCopy("same"); drawBorders(mdctype,angle,type); if(getWriteHists()) { HTool::writeObject(h[angle]); } HTool::deleteObject(h[angle]); } if(getWriteHists()) { HTool::writeObject(result); dirTemp->TDirectory::Cd(".."); } } void HMdcGarCal2Maker::plotOverlay(Int_t mdctype,Int_t type) { // Plots overlay of Graphs after the differrent working steps // (raw, spike remove, smooth and replacement of bins). if(type==0)cout<<"HMdcGarCal2Maker::plotOverLay() : Overlaying Graphs for MDC"<SetOptStat(0); gStyle->SetOptTitle(0); TH1F* dummy=new TH1F("dummy","",getNBin1D_Dist(),0,getNBin1D_Dist()*0.1); if(type==0||type==2)dummy->SetMaximum(1000); if(type==1||type==3)dummy->SetMaximum(100); TDirectory *dirTemp=NULL; if(getWriteHists()) { outputHists->cd(); if (outputHists) dirTemp=HTool::Mkdir(outputHists, "module",mdctype); } gStyle->SetPalette(50); if(getBatchMode())gROOT->SetBatch(); Char_t namecanvas[300]; TString histtype; if(type==0)histtype="Overlay 1D time1"; if(type==1)histtype="Overlay 1D error of time1"; if(type==2)histtype="Overlay 1D time2"; if(type==3)histtype="Overlay 1D error of time2"; sprintf(namecanvas,"%s%s%i",histtype.Data()," for MDC",mdctype); TCanvas *result =new TCanvas(namecanvas ,namecanvas,1000,800); result->Divide(6,3); result->cd(); result->Draw(); for(Int_t angle=0;angle<18;angle++) { result->cd(angle+1); dummy->DrawCopy(); for(Int_t l=0;l<3;l++) { if(g[mdctype][angle][type][l]) { g[mdctype][angle][type][l]->SetLineColor(getLevelColors(l)); g[mdctype][angle][type][l]->Draw(); } } drawBorders(mdctype,angle,type); } if(getWriteHists()) { HTool::writeObject(result); dirTemp->TDirectory::Cd(".."); } HTool::deleteObject(dummy); } void HMdcGarCal2Maker::drawBorders(Int_t mdctype,Int_t angle,Int_t type) { // Draw lines for max value of Celledge / max distance Float_t celledge,maxDist; calcBounderies(mdctype,angle,&celledge,&maxDist); Float_t upperY=0; if(type==1||type==3)upperY=100; if(type==0||type==2)upperY=1000; TLine *edge=new TLine(celledge,0,celledge,upperY); edge->SetLineColor(4); edge->Draw("same"); TLine *maxdist=new TLine(maxDist,0,maxDist,upperY); maxdist->SetLineColor(2); maxdist->Draw("same"); } void HMdcGarCal2Maker::writeAscii() { // Writes the created parameters form the working arrays to an ascii file. if(getWriteAscii()) { cout<<"HMdcGarCal2Maker::writeAscii() : Write output ascii file"<Reset(); if(!HTool::open(&inputRoot,fNameRootIn,"READ")) { exit(1); } inputRoot->cd(); Char_t namepath[300]; Char_t namehist[300]; for(Int_t mdctype=0;mdctype<4;mdctype++) { if(!check(mdctype,-99))continue; cout<<"mdc "<Get(namehist)); if(getVersion()==1)sprintf(namepath,"%s%02i%s%02i%s","mdc ",mdctype,"/angle ",angle*5,"/"); if(getVersion()==2)sprintf(namepath,"%s%i%s%02i%s","mdc ",mdctype,"/angle ",angle*5,"/"); sprintf(namehist,"%s%s%i%s%02i%s%02i%s",namepath,"hmeandrift_time2[",mdctype,"][",getThreshold(),"][",angle*5,"]"); htime2=(TH1F*) (inputRoot->Get(namehist)); fillArrays(htime1,htime2,mdctype,angle); HTool::deleteObject(htime1); HTool::deleteObject(htime2); } cout<<" "<