Warning, /Validation/DTRecHits/test/plotAllWStrue.r is written in an unsupported language. File is not indexed.
0001 void plotAllWStrue(TString filename, int sector, int sl){
0002
0003
0004 if (! TString(gSystem->GetLibraries()).Contains("Histograms_h")) {
0005 gROOT->LoadMacro("$CMSSW_BASE/src/Validation/DTRecHits/interface/Histograms.h+");
0006 gROOT->LoadMacro("macros.C");
0007 gROOT->LoadMacro("ranges.C+");
0008 gROOT->LoadMacro("summaryPlot.C+");
0009 }
0010
0011
0012 bool doRes = true;
0013 bool doResVsDist = true;
0014 bool doResVsAngle = true;
0015 bool doResVsX = true;
0016 bool doResVsY = true;
0017 bool doAngleDist = true;
0018
0019 TStyle * style = getStyle("tdr");
0020 style->cd();
0021 gStyle->SetCanvasDefW(1375); // Set larger canvas
0022 gStyle->SetCanvasDefH(800);
0023 gStyle->SetTitleSize(0.05,"XYZ"); // Set larger axis titles
0024 gStyle->SetTitleOffset(1.5,"Y");
0025 gStyle->SetOptTitle(0); // remove histogram titles
0026
0027 setPalette();
0028 opt2Dplot = "col";
0029
0030 float nsigma = 2;
0031
0032 TFile *file = new TFile(filename);
0033
0034 TString canvbasename = filename;
0035 canvbasename = canvbasename.Replace(canvbasename.Length()-5,5,"") + TString("_Se") + (long) sector + "_SL" + (long) sl;
0036
0037 HRes1DHit* hRes1D[5][3]; // W, S;
0038 HRes4DHit* hRes4D[5][3];
0039
0040
0041 for (int wheel = -2; wheel<=2; ++wheel) {
0042 for (int station = 1; station<=3; ++station) {
0043
0044 int iW = wheel+2;
0045 int iSt= station-1;
0046 hRes1D[iW][iSt] = new HRes1DHit(file,wheel,station,sl,"S3");
0047 hRes4D[iW][iSt] = new HRes4DHit(file,wheel,station,0);
0048
0049 }
0050
0051 }
0052
0053
0054 if(doRes){
0055 TCanvas* c0= new TCanvas(canvbasename+"_AllWSRes", canvbasename+"_AllWSRes");
0056
0057 c0->Divide(5,3,0.0005,0.0005);
0058
0059 for (int wheel = -2; wheel<=2; ++wheel) {
0060 for (int station = 1; station<=3; ++station) {
0061 int iW = wheel+2;
0062 int iSt= station-1;
0063
0064 int ipad=iW+1 +(2-iSt)*5;
0065 c0->cd(ipad); ++ipad;
0066
0067 if(wheel<0) continue;
0068
0069 TH1F* h = hRes1D[iW][iSt]->hRes;
0070
0071 TF1* fres=drawGFit(h, nsigma, -0.4, 0.4);
0072
0073
0074 }
0075 }
0076 }
0077
0078 if(doResVsDist){
0079 TCanvas* c0= new TCanvas(canvbasename+"_AllWSResVsDist", canvbasename+"_AllWSResVsDist");
0080 c0->Divide(5,3,0.0005,0.0005);
0081
0082 for (int wheel = -2; wheel<=2; ++wheel) {
0083 for (int station = 1; station<=3; ++station) {
0084 int iW = wheel+2;
0085 int iSt= station-1;
0086 int ipad=iW+1 + (2-iSt)*5;
0087
0088 c0->cd(ipad); ++ipad;
0089 if(wheel<0) continue;
0090
0091 plotAndProfileX(hRes1D[iW][iSt]->hResVsPos,2,1,1,-.1, .1, 0., 2.1);
0092
0093 }
0094 }
0095 }
0096
0097 if(doResVsAngle){
0098 SummaryPlot hs_p0("p0");
0099 SummaryPlot hs_p1("p1");
0100
0101 TCanvas* c0= new TCanvas(canvbasename+"_AllWSResVsAngle", canvbasename+"_AllWSResVsAngle");
0102 c0->Divide(5,3,0.0005,0.0005);
0103
0104 for (int wheel = -2; wheel<=2; ++wheel) {
0105 for (int station = 1; station<=3; ++station) {
0106
0107 int iW = wheel+2;
0108 int iSt= station-1;
0109 int ipad=iW+1 + (2-iSt)*5;
0110
0111 c0->cd(ipad); ++ipad;
0112 if(wheel<0) continue;
0113
0114 float min;
0115 float max;
0116
0117 rangeAngle(wheel, station, sl, min, max);
0118
0119 TH1F* hprof = plotAndProfileX(hRes1D[iW][iSt]->hResVsAngle,1,1,1,-0.04, 0.04, min-0.03, max+0.03);
0120 TF1 *angleDep= new TF1("angleDep","[0]*cos(x+[2])+[1]", min, max);
0121 //TF1 *angleDep= new TF1("angleDep","[0]*x*x+[2]*x+[1]", min, max);
0122 angleDep->SetParameters(0.01,0.001, 0.1);
0123
0124 if(sl == 2 || (sl == 1 && (iSt!=0 ||(iSt==0 && iW==2)))) angleDep->FixParameter(2,0.);
0125
0126 if(sl == 1 && (iW == 3 ||iW == 0) && iSt == 0) angleDep->SetParameter(2,-0.12);
0127
0128 hprof->Fit(angleDep,"RQN");
0129
0130 if(sl == 2 && (iW == 0 || iW == 4) && (iSt == 0 || iSt == 1)) continue;
0131
0132 angleDep->Draw("same");
0133 float p0 = angleDep->GetParameter(0);
0134 float p1 = angleDep->GetParameter(1);
0135 float p2 = angleDep->GetParameter(2);
0136
0137 cout << "Wh:" <<wheel<< " St:"<<station << " SL:" <<sl << " "<< p0 << " " << p1 << " " << p2 << endl;
0138
0139 hs_p0.Fill(wheel, station, sector, p0);
0140 hs_p1.Fill(wheel, station, sector, p1);
0141
0142 }
0143 }
0144 // Summary plot (still being developed)
0145 TCanvas* c6= new TCanvas(canvbasename+"_AllWSAngleCorr_p0", canvbasename+"_AllWSAngleCorr_p0");
0146 hs_p0.hsumm->GetYaxis()->SetRangeUser(0.5,0.5);
0147 hs_p0.hsumm->Draw("p");
0148
0149
0150 float p0_m[3][3];
0151 float p1_m[3][3];
0152
0153 for (int wheel = 0; wheel<=2; ++wheel) {
0154 for (int station = 1; station<=3; ++station) {
0155
0156 float p0_n = hs_p0.hsumm->GetBinContent(hs_p0.bin(-wheel,station,0));
0157 float p0_p = hs_p0.hsumm->GetBinContent(hs_p0.bin(wheel,station,0));
0158 float p1_n = hs_p1.hsumm->GetBinContent(hs_p1.bin(-wheel,station,0));
0159 float p1_p = hs_p1.hsumm->GetBinContent(hs_p1.bin(wheel,station,0));
0160 p0_m[wheel][station] = (p0_n + p0_p)/2;
0161 p1_m[wheel][station] = (p1_n + p1_p)/2;
0162 // cout << wheel << " " << station << " " << p0_m[wheel][station] << " "<<p1_m[wheel][station] <<endl;
0163 }
0164
0165 }
0166
0167 }
0168
0169
0170 // if (doResVsX) {
0171 // TCanvas* c0=new TCanvas(canvbasename+"_AllWSResVsX", canvbasename+"_AllWSResVsX");
0172
0173 // c0->Divide(5,3);
0174
0175 // for (int wheel = 0; wheel<=2; ++wheel) {
0176 // for (int station = 0; station<=2; ++station) {
0177
0178 // int ipad=wheel+3 + (2-station)*5;
0179 // c0->cd(ipad); ++ipad;
0180 // plotAndProfileX(hRes1D[wheel][station]->hResDistVsX,2,1,1,-0.05, 0.05, -150, 150); // FIXME
0181 // }
0182 // }
0183 // }
0184
0185 // if (doResVsY) {
0186
0187 // TCanvas* c0=new TCanvas(canvbasename+"_AllWSResVsY", canvbasename+"_AllWSResVsY");
0188
0189 // c0->Divide(5,3);
0190
0191 // for (int wheel = 0; wheel<=2; ++wheel) {
0192 // for (int station = 0; station<=2; ++station) {
0193
0194 // int ipad=wheel+3 + (2-station)*5;
0195 // c0->cd(ipad); ++ipad;
0196 // plotAndProfileX(hRes1D[wheel][station]->hResDistVsY,2,1,1,-0.05, 0.05, -150, 150); // FIXME
0197 // }
0198 // }
0199 // }
0200
0201 if(doAngleDist){
0202 TCanvas* c0= new TCanvas(canvbasename+"_AllWSAngleDist", canvbasename+"_AllWSAngleDist");
0203 c0->Divide(5,3,0.0005,0.0005);
0204
0205 for (int wheel = -2; wheel<=2; ++wheel) {
0206 for (int station = 1; station<=3; ++station) {
0207 int iW = wheel+2;
0208 int iSt= station-1;
0209 // DTDetId detId(wheel, station, sector, sl, 0, 0);
0210 int ipad=iW+1 + (2-iSt)*5;
0211
0212 c0->cd(ipad); ++ipad;
0213 if(wheel<0) continue;
0214
0215 float min;
0216 float max;
0217
0218 rangeAngle(wheel, station, sl, min, max);
0219 // cout << "min" << min << endl;
0220 // cout << "max" << max << endl;
0221
0222 TH1F* hAngle = hRes4D[iW][iSt]->hSimAlpha;
0223 hAngle->Sumw2();
0224
0225 if(sl==2){
0226 TH1F* hAngle = hRes4D[iW][iSt]->hSimBeta;
0227 hAngle->Sumw2();
0228 }
0229
0230 hAngle->GetXaxis()->SetRangeUser(-1.2,1.2);
0231 hAngle->Draw();
0232
0233 }
0234 }
0235 }
0236
0237 }
0238
0239
0240