Rev 25 | Rev 70 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 25 | f9daq | 1 | #include "include/guide.h" |
| 2 | #include "src/raySimulator.cpp" |
||
| 3 | |||
| 4 | #include "TFile.h" |
||
| 5 | #include "TPolyMarker3D.h" |
||
| 6 | #include "TCanvas.h" |
||
| 7 | |||
| 8 | //extern int show_3d; |
||
| 9 | //extern int show_data; |
||
| 10 | |||
| 11 | // Set the simulation parameters |
||
| 12 | void Show3D(int b) {show_3d = b;} |
||
| 13 | void ShowData(int b) {show_data = b;} |
||
| 14 | |||
| 15 | // Set the initial detector parameters (a, b, d, activeDetector, n1, n2, n3, gap) |
||
| 16 | DetectorParameters parameters(3.0, 5.0, 3.0, 3.0, 1, 1.53, 1.52, TVector3(0.3, 0, 0)); |
||
| 17 | |||
| 18 | //void SetLGType(int in = 1, int side = 1, int out = 0) |
||
| 19 | //{detector->SetLGType(in, side, out);} |
||
| 20 | |||
| 21 | void SetLG(double SiPM0 = 3.0, double b0 = 5.0, double d0 = 3.0, double n10 = 1.0, double n20 = 1.53, double n30 = 1.52) |
||
| 22 | { parameters.setGuide(SiPM0, b0, d0, n10, n20, n30); } |
||
| 23 | |||
| 24 | void SetGap(double x_gap0 = 0.3, double y_gap0 = 0.0, double z_gap0 = 0.0) |
||
| 25 | { parameters.setGap(x_gap0, y_gap0, z_gap0); } |
||
| 26 | |||
| 27 | void SetGlass(double glassOn, double glassD) |
||
| 28 | { parameters.setGlass(glassOn, glassD); }; |
||
| 29 | |||
| 30 | void SetPlate(int plateOn = 1, double plateWidth = 1) |
||
| 31 | { parameters.setPlate(plateOn, plateWidth); } |
||
| 32 | |||
| 33 | void SetFresnel(int fresnel = 1) { parameters.setFresnel(fresnel); } |
||
| 34 | |||
| 35 | int save_ary = 0; |
||
| 36 | //------------------------------------------------------------------------------------------ |
||
| 37 | void Help() |
||
| 38 | { |
||
| 39 | printf("void SetCenter(x, y, z)\n"); |
||
| 40 | printf("void SetLGType(in, side, out)\n"); |
||
| 41 | printf("SURF_DUMMY 0, "); |
||
| 42 | printf("SURF_REFRA 1, "); |
||
| 43 | printf("SURF_REFLE 2, "); |
||
| 44 | printf("SURF_TOTAL 3, "); |
||
| 45 | printf("SURF_IMPER 4\n"); |
||
| 46 | printf("void SetLG(SiPM0, M0, d0, n10, n20, n30, R0)\n"); |
||
| 47 | printf("void SetR(R0)\n"); |
||
| 48 | printf("void SetGlass(glass_on0, glass_d0)\n"); |
||
| 49 | printf("void SetGap(x_gap0, y_gap0, z_gap0)\n"); |
||
| 50 | |||
| 51 | printf("LGG(NN, theta)\n"); |
||
| 52 | printf("LGR(NN, theta, phi)\n"); |
||
| 53 | printf("LGI(NN, theta)\n"); |
||
| 54 | |||
| 55 | printf("LGI_gap(NN, min, max, steps, theta)\n"); |
||
| 56 | printf("LGR_gap(NN, min, max, steps, theta, phi)\n"); |
||
| 57 | printf("LGR_th(NN, min, max, steps, phi)\n"); |
||
| 58 | printf("LGG_th(NN, min, max, steps)\n"); |
||
| 59 | |||
| 60 | printf("LGI_ad(NN, mina, maxa, mind, maxd, steps(memory dependent), theta)"); |
||
| 61 | } |
||
| 62 | //------------------------------------------------------------------------------------------ |
||
| 63 | int show_in_steps = 0; |
||
| 64 | void SetShowInSteps(int in = 1) |
||
| 65 | { |
||
| 66 | show_in_steps = in; |
||
| 67 | } |
||
| 68 | //------------------------------------------------------------------------------------------ |
||
| 69 | int gs_set = 0; |
||
| 70 | void SetGS() |
||
| 71 | { |
||
| 72 | const UInt_t Number = 2; |
||
| 73 | Double_t Red[Number] = { 1.00, 0.00}; |
||
| 74 | Double_t Green[Number] = { 1.00, 0.00}; |
||
| 75 | Double_t Blue[Number] = { 1.00, 0.00}; |
||
| 76 | Double_t Stops[Number] = { 0.00, 1.00}; |
||
| 77 | |||
| 78 | Int_t nb=50; |
||
| 79 | if(!gs_set) { |
||
| 80 | TColor::CreateGradientColorTable(Number,Stops,Red,Green,Blue,nb); |
||
| 81 | gs_set = 1; |
||
| 82 | } |
||
| 83 | } |
||
| 84 | //------------------------------------------------------------------------------------------ |
||
| 85 | void Draw1(CDetector *detector, int gs = 0, double range = 0.0) |
||
| 86 | { |
||
| 87 | if(gs) SetGS(); |
||
| 88 | TCanvas *cdata = new TCanvas("cdata", "2dscan", 350, 0, 500, 500); |
||
| 89 | gStyle->SetOptTitle(0); |
||
| 90 | gStyle->SetOptStat(0); |
||
| 91 | cdata->cd(0); |
||
| 92 | if(range > 0.1) { |
||
| 93 | ((detector->GetHLaser())->GetXaxis())->SetRangeUser(-range,range); |
||
| 94 | ((detector->GetHLaser())->GetYaxis())->SetRangeUser(-range,range); |
||
| 95 | } |
||
| 96 | (detector->GetHLaser())->SetTitle("Hits at LG entrance; x [mm]; y [mm]"); |
||
| 97 | (detector->GetHLaser())->Draw("COLZ"); |
||
| 98 | cdata->SaveAs("2dscan.gif"); |
||
| 99 | //gStyle->SetOptTitle(1); |
||
| 100 | //gStyle->SetOptStat(1); |
||
| 101 | } |
||
| 102 | |||
| 103 | //------------------------------------------------------------------------------------------ |
||
| 104 | |||
| 105 | |||
| 106 | TVector3 p_pol0(0.0, 0.0, 1.0); |
||
| 107 | void SetPol(double x, double y, double z) |
||
| 108 | {p_pol0.SetXYZ(x,y,z);} |
||
| 109 | |||
| 110 | void PolTest(double theta = 0.0) |
||
| 111 | { |
||
| 112 | int p_type = 1; |
||
| 113 | double p_n1 = 1.5; |
||
| 114 | double p_n2 = 1.0; |
||
| 115 | theta = 3.141593*theta/180.0; if(theta < 1e-6) theta = 1e-6; |
||
| 116 | TVector3 p_pol; |
||
| 117 | |||
| 118 | Init(); |
||
| 119 | |||
| 120 | double cx = 0.0; |
||
| 121 | TVector3 vodnik_edge[4]; |
||
| 122 | double t = 3.0; |
||
| 123 | vodnik_edge[0].SetXYZ(cx, t,-t); vodnik_edge[1].SetXYZ(cx, t, t); |
||
| 124 | vodnik_edge[2].SetXYZ(cx,-t, t); vodnik_edge[3].SetXYZ(cx,-t,-t); |
||
| 125 | /* |
||
| 126 | #define SURF_DUMMY 0 |
||
| 127 | #define SURF_REFRA 1 |
||
| 128 | #define SURF_REFLE 2 |
||
| 129 | #define SURF_TOTAL 3 |
||
| 130 | #define SURF_IMPER 4 |
||
| 131 | */ |
||
| 132 | CSurface *surf = new CSurface(p_type, vodnik_edge, p_n1, p_n2, 0.96); //surf->FlipN(); |
||
| 133 | surf->SetFresnel(0); |
||
| 134 | surf->Draw(); |
||
| 135 | |||
| 136 | CRay *ray = new CRay(cx, 0.0, 0.0, TMath::Cos(theta), 0.0, TMath::Sin(theta)); |
||
| 137 | ray->SetColor(1); |
||
| 138 | //p_pol = rotatey(p_pol0, -theta); |
||
| 139 | p_pol = p_pol0; p_pol.RotateY(-theta); |
||
| 140 | //printf("p_pol = "); printv(p_pol); |
||
| 141 | ray->SetPolarization(p_pol); |
||
| 142 | |||
| 143 | ray->DrawS(cx, -5.0); |
||
| 144 | |||
| 145 | CRay *out = new CRay; out->SetColor(2); |
||
| 146 | TVector3 *inters = new TVector3; |
||
| 147 | int fate = surf->PropagateRay(*ray, out, inters); |
||
| 148 | if(fate == 1) out->DrawS(cx, 5.0); |
||
| 149 | |||
| 150 | CRay *pp = new CRay; pp->SetColor(3); |
||
| 151 | pp->Set(ray->GetR(), p_pol); |
||
| 152 | pp->DrawS(cx, 2.0); |
||
| 153 | |||
| 154 | CRay *pn = new CRay; pn->SetColor(4); |
||
| 155 | pn->Set(ray->GetR(), surf->GetN()); |
||
| 156 | pn->DrawS(cx, 3.0); |
||
| 157 | } |
||
| 158 | |||
| 159 | void ptt() |
||
| 160 | { |
||
| 161 | for(double th = 0.0; th < 91.0; th += 5.0) { |
||
| 162 | printf("%lf ", th); |
||
| 163 | PolTest(th); |
||
| 164 | } |
||
| 165 | } |
||
| 166 | //------------------------------------------------------------------------------------------ |
||
| 167 | // Propagate single ray and show the statistics |
||
| 168 | void LGS(double xh = 0.0, double yh = 0.0, double zh = 0.0, double theta = 0.0, double phi = 0.0) |
||
| 169 | { |
||
| 170 | CDetector *detector = new CDetector(CENTER, parameters); |
||
| 171 | Init(); |
||
| 172 | double izkoristek = Single(detector, parameters, TVector3(xh,yh,zh),theta, phi); |
||
| 173 | PrintGuideHead(); |
||
| 54 | f9daq | 174 | PrintGuideStat(izkoristek); |
| 25 | f9daq | 175 | DrawData(detector, parameters, theta, izkoristek); |
| 176 | } |
||
| 177 | //------------------------------------------------------------------------------------------ |
||
| 178 | // Propagate NN rays generated as grid and show the statistics |
||
| 179 | void LGG(int NN = 10, double theta = 0.0) |
||
| 180 | { |
||
| 181 | CDetector *detector = new CDetector(TVector3(-2,0,0), parameters); |
||
| 182 | Init(); |
||
| 183 | double izkoristek = Grid(detector, parameters, NN, theta); |
||
| 184 | //printf("izkoristek = %.3lf\n", izkoristek); |
||
| 185 | PrintGuideHead(); |
||
| 54 | f9daq | 186 | PrintGuideStat(izkoristek); |
| 25 | f9daq | 187 | DrawData(detector, parameters, theta, izkoristek); |
| 188 | } |
||
| 189 | //------------------------------------------------------------------------------------------ |
||
| 190 | // Propagate NN rays genarated under the same angle theta, phi with random spacing and statistics |
||
| 191 | void LGR(int NN = 1e4, double theta = 0.0, double phi = 0.0) |
||
| 192 | { |
||
| 193 | CDetector *detector = new CDetector(TVector3(-2,0,0), parameters); |
||
| 194 | Init(); |
||
| 195 | double izkoristek = RandYZ(detector, parameters, NN, theta, phi); |
||
| 196 | //printf("izkoristek = %.3lf\n", izkoristek); |
||
| 54 | f9daq | 197 | PrintGuideHead(); PrintGuideStat(izkoristek); |
| 25 | f9daq | 198 | DrawData(detector, parameters, theta, izkoristek); |
| 199 | } |
||
| 200 | //------------------------------------------------------------------------------------------ |
||
| 201 | // Propagate NN rays isotropically generated in solid angle theta and show the statistics |
||
| 202 | void LGI(int NN = 1e4, double theta = 30.0, int nnrays = 30, int showr = 0) |
||
| 203 | { |
||
| 204 | Init(); |
||
| 205 | CDetector *detector = new CDetector(CENTER, parameters); |
||
| 206 | //CDetector detector = new CDetector(); |
||
| 207 | double izkoristek = RandIso(detector, parameters, NN, theta, nnrays, showr); |
||
| 208 | //printf("izkoristek = %.3lf\n", izkoristek); |
||
| 54 | f9daq | 209 | PrintGuideHead(); PrintGuideStat(izkoristek); |
| 25 | f9daq | 210 | DrawData(detector, parameters, theta, izkoristek); |
| 211 | //TCanvas *canvasDetector = new TCanvas("canvasDetector","canvasDetector",500,500); |
||
| 212 | //canvasDetector->cd(); |
||
| 213 | //detector->Draw(); |
||
| 214 | } |
||
| 215 | |||
| 216 | |||
| 217 | |||
| 218 | //------------------------------------------------------------------------------------------ |
||
| 219 | void LGI_gap(int NN = 1e4, double min = 0.0, double max = 2.0, const int steps = 10, double theta = 30.0) |
||
| 220 | { |
||
| 221 | int tmp3d = show_3d, tmpdata = show_data; |
||
| 222 | double step[steps], acc[steps]; |
||
| 223 | |||
| 224 | show_3d = 0; show_data = 0; |
||
| 225 | |||
| 226 | //printf(" x_gap | acceptance \n"); |
||
| 227 | PrintGuideHead(); |
||
| 228 | for(int i=0; i<=steps; i++) { |
||
| 229 | step[i] = min + i*(max - min)/(double)steps; |
||
| 230 | parameters.setGap(step[i], 0.0, 0.0); |
||
| 231 | CDetector *detector = new CDetector(CENTER, parameters); |
||
| 232 | Init(); |
||
| 233 | acc[i] = RandIso(detector, parameters, NN, theta); |
||
| 234 | //printf("%6.2lf |%6.1lf\n", step[i], acc[i]*100.0); |
||
| 54 | f9daq | 235 | PrintGuideStat(acc[i]); |
| 25 | f9daq | 236 | } |
| 237 | |||
| 238 | //char sbuff[256]; |
||
| 239 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf", |
||
| 240 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
| 241 | // (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta); |
||
| 242 | |||
| 243 | DrawAcc(steps+1, step, acc, (char*)"; x_gap;Acceptance", min, max); |
||
| 244 | |||
| 245 | show_3d = tmp3d; show_data = tmpdata; |
||
| 246 | } |
||
| 247 | //------------------------------------------------------------------------------------------ |
||
| 248 | |||
| 249 | //------------------------------------------------------------------------------------------ |
||
| 250 | void LGR_th(int NN = 1e4, double min = 0.0, double max = 30.0, const int steps = 15, double phi = 5.0) |
||
| 251 | { |
||
| 252 | int tmp3d = show_3d, tmpdata = show_data; |
||
| 253 | double step[steps], acc[steps]; |
||
| 254 | |||
| 255 | show_3d = 0; show_data = 0; |
||
| 256 | |||
| 257 | //printf(" theta | acceptance \n"); |
||
| 258 | PrintGuideHead(); |
||
| 259 | for(int i=0; i<=steps; i++) { |
||
| 260 | Init(); |
||
| 261 | step[i] = min + i*(max - min)/(double)steps; |
||
| 262 | CDetector *detector = new CDetector(TVector3(-2,0,0), parameters); |
||
| 263 | acc[i] = RandYZ(detector, parameters, NN, step[i], phi); |
||
| 264 | //printf("%6.1lf |%6.1lf\n", step[i], acc[i]*100.0); |
||
| 54 | f9daq | 265 | PrintGuideStat(acc[i]); |
| 266 | //delete detector; |
||
| 25 | f9daq | 267 | } |
| 268 | |||
| 269 | //char sbuff[256]; |
||
| 270 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap = (%.1lf, %.1lf, %.1lf)", |
||
| 271 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
| 272 | // (detector->GetVGap()).x(), (detector->GetVGap()).y(), (detector->GetVGap()).z()); |
||
| 273 | |||
| 274 | DrawAcc(steps+1, step, acc, (char*)"; #theta [deg];Acceptance", min, max); |
||
| 275 | |||
| 276 | show_3d = tmp3d; show_data = tmpdata; |
||
| 277 | } |
||
| 278 | //------------------------------------------------------------------------------------------ |
||
| 279 | |||
| 280 | // a vs. d |
||
| 281 | void LGI_ad(int NN = 1e4, double min = 2.5, double max = 3.5, double minD = 1, double maxD = 6, const int steps = 10, double theta = 30.0) |
||
| 282 | { |
||
| 283 | int tmp3d = show_3d; |
||
| 284 | int tmpdata = show_data; |
||
| 285 | //char sbuff[256]; |
||
| 286 | |||
| 287 | show_3d = 0; // don't show simulations |
||
| 288 | show_data = 1; |
||
| 289 | |||
| 290 | //double d = detector->GetD(); |
||
| 291 | const double b = parameters.getB(); // upper side of LG |
||
| 292 | //const double SiPM = 3.0; // the length of the detector itself |
||
| 293 | //double reflectivity = detector->guide->getR(); |
||
| 294 | |||
| 295 | TH2F *hAcceptance = new TH2F("hAcceptance","Acceptance",steps-1,minD,maxD,steps-1,min,max); |
||
| 296 | |||
| 297 | // Use the Fresnel eq. instead of fixed reflectivity 96% |
||
| 298 | //detector->SetFresnel(1); |
||
| 299 | |||
| 300 | printf(" d | a | Acceptance\n"); |
||
| 301 | for(int i=0; i<steps; i++) { |
||
| 302 | const double d = hAcceptance->GetXaxis()->GetBinCenter(i); |
||
| 303 | for(int j=0; j<steps; j++) { |
||
| 304 | const double a = hAcceptance->GetYaxis()->GetBinCenter(j); |
||
| 305 | const double M = b/a; |
||
| 306 | parameters.setGuide(a, M, d); |
||
| 307 | CDetector *detector = new CDetector(CENTER, parameters); |
||
| 308 | //detector->guide->setLG(y, M, x); |
||
| 309 | //Init(); exclude simulation |
||
| 310 | double acceptance = RandIso(detector, parameters, NN, theta, 0, 0); |
||
| 311 | //double acceptance = Grid(NN, theta); |
||
| 312 | //double acceptance = -1.0; |
||
| 313 | hAcceptance->Fill(d, a, acceptance); |
||
| 314 | //printf("%.2lf | %.2lf | ", x,y); |
||
| 54 | f9daq | 315 | //PrintGuideStat(izkoristek); |
| 316 | delete detector; //works fine, 50x50 grid takes ~4MB of RAM |
||
| 25 | f9daq | 317 | } |
| 318 | } |
||
| 319 | |||
| 320 | |||
| 321 | |||
| 322 | TCanvas *cp = new TCanvas("Acceptance", "Acceptance", 0, 0, 640, 480); |
||
| 323 | TVirtualPad *pacc = cp->cd(0); |
||
| 324 | |||
| 325 | pacc->SetRightMargin(0.10); |
||
| 326 | pacc->SetLeftMargin(0.10); |
||
| 327 | pacc->SetTopMargin(0.10); |
||
| 328 | |||
| 329 | TFile *file = new TFile("acceptance.root","RECREATE"); |
||
| 330 | hAcceptance->Write(); |
||
| 331 | file->Close(); |
||
| 54 | f9daq | 332 | //delete file; |
| 25 | f9daq | 333 | |
| 334 | //hAcceptance->SetContour(100); |
||
| 335 | //gStyle->SetPalette(1,0); |
||
| 336 | hAcceptance->SetTitle(";d [mm];a [mm]"); |
||
| 337 | hAcceptance->GetXaxis()->SetRangeUser(minD,maxD); |
||
| 338 | hAcceptance->Draw("COLZ"); |
||
| 339 | |||
| 340 | show_3d = tmp3d; show_data = tmpdata; |
||
| 341 | } |
||
| 342 | |||
| 343 | //------------------------------------------------------------------------------------------ |
||
| 344 | // collection efficiency vs length |
||
| 345 | // a changes, b rests the same, d changes |
||
| 346 | // still can't use this function, it has hardcoded tan 10 deg |
||
| 347 | // !very stupid! |
||
| 348 | // new 3D graph NEEDED |
||
| 349 | // d vs a vs acceptance |
||
| 350 | void LGI_d2(int NN = 1e4, double min = 0.5, double max = 3.0, const int steps = 25, double theta = 30.0) |
||
| 351 | { |
||
| 352 | TVector3 gapGuideSiPM(0.3, 0, 0); |
||
| 353 | CDetector *detector = new CDetector(TVector3(-2,0,0), parameters); |
||
| 354 | int tmp3d = show_3d, tmpdata = show_data; |
||
| 355 | double step[steps], acc[steps]; |
||
| 356 | double sipm_d, M0; |
||
| 357 | char sbuff[256]; |
||
| 358 | |||
| 359 | show_3d = 1; show_data = 1; |
||
| 360 | |||
| 361 | M0 = parameters.getM(); |
||
| 362 | |||
| 363 | PrintGuideHead(); |
||
| 364 | for(int i=0; i<=steps; i++) { |
||
| 365 | step[i] = min + i*(max - min)/(double)steps; |
||
| 366 | sipm_d = M0 - 2.0*step[i]*0.199819;//tan 11.3 deg |
||
| 367 | parameters.setGuide(sipm_d, M0/sipm_d, step[i]); |
||
| 368 | //printf("sipm = %lf, M = %lf, d = %lf\n", detector->GetSiPM(), detector->GetM(), step[i]); |
||
| 369 | printf("%.1lf | %.2lf | ", step[i], sipm_d); |
||
| 370 | Init(); |
||
| 371 | acc[i] = RandIso(detector, parameters, NN, theta); |
||
| 54 | f9daq | 372 | PrintGuideStat(acc[i]); |
| 25 | f9daq | 373 | sprintf(sbuff, "d%2d.gif", i); |
| 374 | //c3dview->SaveAs(sbuff); |
||
| 375 | } |
||
| 376 | |||
| 377 | |||
| 378 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf", |
||
| 379 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
| 380 | // (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta); |
||
| 381 | |||
| 382 | //DrawAcc(steps+1, step, acc, sbuff, (char*)"; d;Acceptance", min, max); |
||
| 383 | |||
| 384 | TCanvas *cp = new TCanvas("Acceptance", "Acceptance", 0, 0, 640, 480); |
||
| 385 | TVirtualPad *pacc = cp->cd(0); |
||
| 386 | |||
| 387 | pacc->SetRightMargin(0.05); |
||
| 388 | pacc->SetLeftMargin(0.13); |
||
| 389 | pacc->SetTopMargin(0.08); |
||
| 390 | |||
| 391 | TGraph *gacceptance = new TGraph(steps+1, step, acc); |
||
| 392 | gacceptance->SetTitle("; d [mm];Collection efficiency"); |
||
| 393 | gacceptance->SetMarkerStyle(8); |
||
| 394 | gacceptance->SetLineColor(12); |
||
| 395 | gacceptance->SetLineWidth(1); |
||
| 396 | (gacceptance->GetXaxis())->SetRangeUser(min, max); |
||
| 397 | //(gacceptance->GetYaxis())->SetRangeUser(ymin, ymax); |
||
| 398 | |||
| 399 | gacceptance->Draw("ACP"); |
||
| 400 | |||
| 401 | |||
| 402 | show_3d = tmp3d; show_data = tmpdata; |
||
| 403 | } |
||
| 404 | //------------------------------------------------------------------------------------------ |
||
| 405 | // Acceptance vs. the length |
||
| 406 | // The magnification ratio M rests the same all the time |
||
| 407 | void LGI_d(int NN = 1e4, double min = 1, double max = 6.0, const int steps = 25, double theta = 30.0) |
||
| 408 | { |
||
| 409 | int tmp3d = show_3d, tmpdata = show_data; |
||
| 410 | double step[steps], acc[steps]; |
||
| 411 | const double a = parameters.getA(); |
||
| 412 | const double magnif = parameters.getM(); |
||
| 413 | |||
| 414 | //show_3d = show_in_steps; show_data = 1; |
||
| 415 | |||
| 416 | // Use Fresnel equations |
||
| 417 | //detector->SetFresnel(1); |
||
| 418 | |||
| 419 | // Set glass (n=1.5) at the exit |
||
| 420 | //detector->SetGlass(1,0); |
||
| 421 | |||
| 422 | PrintGuideHead(); |
||
| 423 | for(int i=0; i<=steps; i++) { |
||
| 424 | step[i] = min + i*(max - min)/(double)steps; |
||
| 425 | parameters.setGuide(a, magnif, step[i]); |
||
| 426 | CDetector *detector = new CDetector(CENTER, parameters); |
||
| 427 | //printf("sipm = %lf, M = %lf, d = %lf\n", detector->GetSiPM(), detector->GetM(), step[i]); |
||
| 428 | printf("%.1lf | ", step[i]); |
||
| 429 | Init(); |
||
| 430 | acc[i] = RandIso(detector, parameters, NN, theta); |
||
| 54 | f9daq | 431 | PrintGuideStat(acc[i]); |
| 25 | f9daq | 432 | delete detector; |
| 433 | } |
||
| 434 | |||
| 435 | //char sbuff[256]; |
||
| 436 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf", |
||
| 437 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
| 438 | // (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta); |
||
| 439 | |||
| 440 | DrawAcc(steps+1, step, acc, (char*)"; d [mm];Acceptance", min, max); |
||
| 441 | |||
| 442 | show_3d = tmp3d; show_data = tmpdata; |
||
| 443 | } |
||
| 444 | //------------------------------------------------------------------------------------------ |
||
| 445 | // Magnification optimization. a and d are fixed, M and b change in steps |
||
| 446 | void LGI_M(int NN = 1e4, double min = 1.0, double max = 3.0, const int steps = 30, double theta = 30.0) |
||
| 447 | { |
||
| 448 | int tmp3d = show_3d, tmpdata = show_data; |
||
| 449 | double step[steps], acc[steps]; |
||
| 450 | |||
| 451 | const double a = parameters.getA(); |
||
| 452 | const double d = parameters.getD(); |
||
| 453 | |||
| 454 | show_3d = 0; show_data = 0; |
||
| 455 | |||
| 456 | PrintGuideHead(); |
||
| 457 | for(int i=0; i<=steps; i++) { |
||
| 458 | step[i] = min + i*(max - min)/(double)steps; |
||
| 459 | parameters.setGuide(a, step[i], d); |
||
| 460 | CDetector *detector = new CDetector(CENTER, parameters); |
||
| 461 | Init(); |
||
| 462 | acc[i] = RandIso(detector, parameters, NN, theta); |
||
| 54 | f9daq | 463 | PrintGuideStat(acc[i]); |
| 25 | f9daq | 464 | } |
| 465 | |||
| 466 | //char sbuff[256]; |
||
| 467 | //sprintf(sbuff, "SiPM = %.1lf, M = %.1lf, d = %.1lf | gap(y,z) = (%.1lf, %.1lf) | #theta = %.1lf", |
||
| 468 | // detector->GetSiPM(), detector->GetM(), detector->GetD(), |
||
| 469 | // (detector->GetVGap()).y(), (detector->GetVGap()).z(), theta); |
||
| 470 | |||
| 471 | DrawAcc(steps+1, step, acc, (char*)"; M;Acceptance", min, max); |
||
| 472 | |||
| 473 | show_3d = tmp3d; show_data = tmpdata; |
||
| 474 | } |
||
| 475 | //------------------------------------------------------------------------------------------ |
||
| 476 |