Changeset 19951 for trunk/Mars
- Timestamp:
- 04/29/20 21:48:05 (5 years ago)
- Location:
- trunk/Mars/hawc
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/hawc/callisto.C
r19825 r19951 27 27 28 28 To run the macro from the command line (assuming you are in a directory 29 Mars/build where you have built your Mars environment) ou can do29 Mars/build where you have built your Mars environment) you can do 30 30 31 31 root ../hawc/callisto.C\(\"20191002_018.fits.fz\",\"20191002_013.drs.fits\"\) … … 54 54 55 55 // mapping file (found in Mars/hawc) 56 const char *mmap = usemap ? " ../hawc/FAMOUSmap171218.txt" : NULL;56 const char *mmap = usemap ? "/home/giangdo/Documents/Master/MA/Software/Mars/hawc/HAWCsEyemap181214.txt" : NULL; 57 57 58 58 //const char *pulse_template = "template-pulse.root"; … … 76 76 // Calibration constant (for the moment a single constant to 77 77 // convert the extracted charge to photo-electrons) 78 double scale = 1./22.553;//0.2; 78 //double scale = 1./22.553;//0.2; 79 double scale = 1./17.557; 79 80 80 81 // ------------------------------------------------------ … … 317 318 write5.AddContainer("MSimSourcePos", "Events", kFALSE); 318 319 write5.AddContainer("MTime", "Events", kFALSE); 320 write5.AddContainer("MRawBoardsFACT", "Events", kFALSE); 319 321 write5.AddContainer("MSrcPosCam", "Events", kFALSE); 320 322 -
trunk/Mars/hawc/extract_pulse.C
r19876 r19951 60 60 }; 61 61 62 //Storage class to k Keep a list of the extracted single62 //Storage class to keep a list of the extracted single 63 63 class MSingles : public MParContainer, public MCamEvent 64 64 { … … 68 68 69 69 public: 70 MSingles(const char *name=NULL, const char *title=NULL) : fIntegrationWindow( 30)70 MSingles(const char *name=NULL, const char *title=NULL) : fIntegrationWindow(40) 71 71 { 72 72 fName = name ? name : "MSingles"; 73 fName = title ? title : "Stor eage for vector of singles";73 fName = title ? title : "Storage for vector of singles"; 74 74 } 75 75 … … 109 109 110 110 public: 111 MHBaseline() : fPedestal(0), fSkipStart( 20), fSkipEnd(10)111 MHBaseline() : fPedestal(0), fSkipStart(5), fSkipEnd(10) 112 112 { 113 113 fName = "MHBaseline"; … … 185 185 for (int x=0; x<64; x++) 186 186 { 187 //exclude the pixels without cones 188 if (x == 61) 189 continue; 190 if (x == 62) 191 continue; 192 if (x == 63) 193 continue; 194 187 195 // Get the corresponding slice from the histogram 188 196 TH1D *hist = fBaseline.ProjectionY("proj", x+1, x+1); … … 286 294 class MHSingles : public MH 287 295 { 288 TH2F fSignalAll; 296 TH2F fSignals; // all signals, without normalization 297 TH2F fOsicllation; 298 299 TH2F fSignalAll; // Histogram of all signals 289 300 TH2F fSignalOut; 290 TH2F fSignal1; 291 TH2F fSignal2; 301 TH2F fSignal1; // Histogram of signals with 1pe 302 TH2F fSignal2; // Histogram of signals with 2pe 292 303 TH2F fSignal3; 293 304 TH2F fSignal4; … … 320 331 321 332 // Setup histograms 333 334 fSignals.SetName("Signals"); 335 fSignals.SetTitle(""); 336 fSignals.SetXTitle("Time [ns]"); 337 fSignals.SetYTitle("Amplitude [mV]"); 338 fSignals.GetXaxis()->CenterTitle(); 339 fSignals.GetXaxis()->SetTitleSize(0.045); 340 fSignals.GetYaxis()->SetTitleSize(0.045); 341 fSignals.SetDirectory(NULL); 342 fSignals.SetStats(kFALSE); 343 344 fOsicllation.SetName("Oscillations"); 345 fOsicllation.SetTitle(""); 346 fOsicllation.SetXTitle("Oscillation's Amplitude [mV]"); 347 fOsicllation.SetYTitle("Pulse's Amplitude [mV]"); 348 fOsicllation.GetXaxis()->CenterTitle(); 349 fOsicllation.GetXaxis()->SetTitleSize(0.045); 350 fOsicllation.GetYaxis()->SetTitleSize(0.045); 351 fOsicllation.SetDirectory(NULL); 352 fOsicllation.SetStats(kFALSE); 353 322 354 fSignalAll.SetName("SignalAll"); 323 355 fSignalAll.SetTitle(""); … … 498 530 //const Int_t w = fSingles->GetIntegrationWindow(); 499 531 500 MBinning binsx, binsy ;532 MBinning binsx, binsy, bin_time, bin_pulse, binosc, binpulse; 501 533 binsx.SetEdges(1024, -512, 512); 502 534 binsy.SetEdges( 800, -20, 20); 535 536 bin_time.SetEdges(1024, -512, 512); 537 bin_pulse.SetEdges(240, -60, 60); //bin width is about 1 dac count = 0.5mV 538 539 binosc.SetEdges(140, -65, 5); 540 binpulse.SetEdges(140, -5, 65); 541 542 MH::SetBinning(fSignals, bin_time, bin_pulse); 543 MH::SetBinning(fOsicllation, binosc, binpulse); 503 544 504 545 MH::SetBinning(fSignalAll, binsx, binsy); … … 579 620 continue; 580 621 581 if (idx!= 0)622 if (idx!=43) 582 623 continue; 583 624 584 const double gain = hgain->GetBinContent(idx+1)/ 30;625 const double gain = hgain->GetBinContent(idx+1)/40; 585 626 const double base = hbase->GetBinContent(idx+1); 586 627 … … 594 635 // Fill pulse shape 595 636 const double tm = result[0].fTime; 596 const double sig = result[0].fSignal/ 30 - base;637 const double sig = result[0].fSignal/40 - base; 597 638 598 639 bool ok = true;//tm>3 && (ptr[int(tm)-3]-ped-base)/gain > -5; 599 640 600 double mean = 0; 601 602 for (int s=20; s<roi-20; s++) 641 double corr = -0.25; 642 643 // Make histograms to check correlation between signals and oscillations 644 for(int s=0; s<roi-10; s++) 645 { double time = (s-tm)/2; 646 double pulse = ptr[s]-ped-base; // corrected pulse without normalization 647 648 // Fill all extracted signals into one histogram 649 fSignals.Fill(time, pulse); 650 } 651 652 int t_arrival = (int)tm; 653 double max_pulse = ptr[t_arrival]-ped-base; 654 int max_pulse_pos = 0; // position of the maximal pulse in sample 655 // Find pulse's amplitude 656 for(int s = tm; s < tm + 15; s++) 603 657 { 604 double x = (s - tm)/2; // [ns] 658 if (ptr[s]-ped-base > max_pulse) 659 max_pulse = ptr[s]-ped-base; 660 max_pulse_pos = s; 661 } 662 //cout << "________Check if the filled histograms are correct________" << endl; 663 //cout << "Arrival time: " << tm << ",Amplitude: " << ptr[t_arrival]-ped-base << endl; 664 //cout << "Pulse's position: "<< max_pulse_pos << ",Max. Pulse's Amplitude: " << ptr[max_pulse_pos]-ped-base << endl; 665 666 // Find maximal oscillation's amplitude 667 double max_osc = 0; 668 for (int osc = max_pulse_pos; osc < max_pulse_pos+40; osc++) 669 { 670 if (ptr[osc]-ped-base < max_osc) 671 { 672 max_osc = ptr[osc]-ped-base; 673 } 674 else 675 continue; 676 } 677 fOsicllation.Fill(max_osc, max_pulse); 678 679 // Set conditions for 1pe signals 680 for (int s=5; s<roi-10; s++) 681 { 682 double x = (s - tm)/2; // return the time in [ns] 605 683 double y = (ptr[s]-ped-base)/gain; 606 684 607 if (x>-100 && x<-10) 608 mean += y/90; 609 610 if (y<-3) 685 //if (x>-100 && x<-10) 686 // mean += y/90; 687 688 if (x>5 && y>2.5+x*-0.01) 689 ok = false; 690 if (y<-1.5) 611 691 ok = false; 612 692 if (x>5 && x<40 && y<=x/40*-0.5) … … 614 694 if (x>-150 && x<-5 && y>1.5) 615 695 ok = false; 616 if ( y>2.5)696 if (x<0 && y > 1.2) 617 697 ok = false; 698 618 699 } 619 700 620 // Nothing at or bleow zero from 5 to 40machen 621 701 // Fill nPE signals into histograms 702 703 // Set conditions for signals with n PE 704 // Nothing at or below zero from 5 to 40machen 622 705 bool ok1 = sig>gain*0.5 && sig<gain*1.5; 623 706 bool ok2 = sig>gain*1.5 && sig<gain*2.5; … … 630 713 631 714 632 for (int s= 20; s<roi-20; s++)715 for (int s=5; s<roi-10; s++) 633 716 { 634 717 double x = (s - tm)/2; // [ns] 635 double y = (ptr[s]-ped-base)/gain - mean;718 double y = (ptr[s]-ped-base)/gain - corr; 636 719 637 720 int ix = TMath::Nint((x-x0)/wx*nx); … … 642 725 643 726 int bin = (iy+1)*(nx+2)+(ix+1); 727 644 728 645 729 if (ok) … … 724 808 725 809 // Getter for histograms 810 TH2 *GetSignals() { return &fSignals; } 811 TH2 *GetOscillation() { return &fOsicllation; } 726 812 TH2 *GetSignalAll() { return &fSignalAll; } 727 813 TH2 *GetSignalOut() { return &fSignalOut; } … … 774 860 gPad->SetFrameBorderMode(0); 775 861 fSignal8.Draw("colz"); 776 //fProf8.Draw("same");862 fProf8.Draw("same"); 777 863 } 778 864 … … 836 922 MExtractSingles() : fSingles(0), fPedestal(0), fEvent(0), 837 923 fExtractionRange(64), 838 fNumAverage(10), fStartSkip( 20), fEndSkip(10),839 fIntegrationSize( 3*10), fMaxSearchWindow(30)924 fNumAverage(10), fStartSkip(10), fEndSkip(10), 925 fIntegrationSize(4*10), fMaxSearchWindow(20) 840 926 { 841 927 } … … 877 963 878 964 const size_t navg = fNumAverage; 879 const float threshold = fThreshold; 965 const float threshold = fThreshold; 880 966 const UInt_t start_skip = fStartSkip; 881 967 const UInt_t end_skip = fEndSkip; … … 934 1020 if (k_max == i+5 || k_max == i + max_search_window-1) 935 1021 continue; 1022 1023 //Make sure the pulse is isolated (area after the maximum is empty) 1024 UInt_t k_falling = k_max+200; 1025 for (UInt_t k_after = k_falling; k_after < k_max +250; k_after++) 1026 { 1027 if (val[k_after] > val[k_falling] && 1028 val[k_after + fNumAverage/2] > val[k_falling]) 1029 continue; 1030 } 936 1031 937 1032 //search for half maximum before maximum … … 946 1041 } 947 1042 } 1043 948 1044 // Check if the finding makes sense 949 1045 if (k_half_max+integration_size > roi-navg-end_skip) … … 954 1050 continue; 955 1051 956 // FIXME: Evaluate arrival time more precisely!!! 957 // FIXME: Get a better integration window 1052 //cout << "________Check if the finding makes sense________" << endl; 1053 //cout << "Pulse's position: " << k_max << ", Max. Pulse's Amplitude: " << val[k_max] << endl; 1054 //cout << "Half maximum: " << k_half_max << ", Pulse at half maximum: " << val[k_half_max] << endl; 1055 958 1056 959 1057 // Compile "single" … … 970 1068 // Add single to list 971 1069 result.push_back(single); 1070 break; //accept only one pulse per event 972 1071 973 1072 // skip falling edge … … 985 1084 Int_t max_dist = 14, 986 1085 Double_t threshold = 5, 987 const char *runfile = "/ media/tbretz/d84f26d3-fc9b-4b30-8cfd-85246846dd1a/hawcseye01/raw/2019/10/27/20191027_",1086 const char *runfile = "/home/giangdo/Documents/Master/MA/pulse/data_single_pe/20191027_", 988 1087 int firstRunID = 6, 989 1088 int lastRunID = 6, 990 const char *drsfile = "/ media/tbretz/d84f26d3-fc9b-4b30-8cfd-85246846dd1a/hawcseye01/raw/2019/10/27/20191027_003.drs.fits",1089 const char *drsfile = "/home/giangdo/Documents/Master/MA/pulse/data_single_pe/20191027_004.drs.fits", 991 1090 const char *outpath = "." 992 1091 ) 993 1092 { 994 1093 // ====================================================== 995 if (!pmap.Read(" ../hawc/FAMOUSmap171218.txt"))996 { 997 gLog << err << " ../hawc/FAMOUSmap171218.txt not found." << endl;1094 if (!pmap.Read("/home/giangdo/Documents/Master/MA/Software/Mars/hawc/HAWCsEyemap181214.txt")) 1095 { 1096 gLog << err << "HAWCsEyemap181214.txt not found." << endl; 998 1097 return 1; 999 1098 } … … 1005 1104 1006 1105 // built output filename and path 1007 TString outfile = " 20191027_006_006-pulse.root";1008 TString infile = " 20190227_006_006-fit.root";1106 TString outfile = "/home/giangdo/Documents/Master/MA/pulse/data_single_pe/extracted/20191027_006_006_pulse.root"; 1107 TString infile = "/home/giangdo/Documents/Master/MA/pulse/data_single_pe/extracted/20191027_006_006_fit.root"; 1009 1108 1010 1109 //if (!gSystem->AccessPathName(outfile)) … … 1048 1147 1049 1148 // map file to use (get that from La Palma!) 1050 const char *map = usemap ? " ../hawc/FAMOUSmap171218.txt" : NULL;1149 const char *map = usemap ? "/home/giangdo/Documents/Master/MA/Software/Mars/hawc/HAWCsEyemap181214.txt" : NULL; 1051 1150 1052 1151 // ------------------------------------------------------ 1053 1152 1054 Long_t max0 = 0;1055 Long_t max1 = 0;1153 Long_t max0 = 10000; 1154 Long_t max1 = 10000; 1056 1155 1057 1156 // ====================================================== … … 1097 1196 MBadPixelsCam badpixels; 1098 1197 badpixels.InitSize(64); 1099 badpixels[7].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 1100 badpixels[17].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 1198 badpixels[43].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 1101 1199 1102 1200 MH::SetPalette(); … … 1219 1317 gStyle->SetOptStat(10); 1220 1318 1319 TH2 *hsignals = h->GetSignals(); 1320 TH2 *hoscillation = h->GetOscillation(); 1321 1322 TH2 *hall = h->GetSignalAll(); 1323 1221 1324 TH1 *h1 = h->GetSignal1(); 1222 1325 TH1 *p1 = h->GetProf1(); 1223 1326 1327 cout << "Entries:\t" << (p1->GetEntries()) << endl; 1328 1224 1329 TH1 *h2 = h->GetSignal2(); 1225 1330 TH1 *p2 = h->GetProf2(); … … 1243 1348 TH1 *p8 = h->GetProf8(); 1244 1349 1245 TF1 pulse("pulse", "[0]*(1-exp(-x*x/[1]))*exp(-x/[2])", 0, 300); 1246 pulse.SetLineColor(kBlack); 1247 pulse.SetParameters(0, 1./0.094, 1./0.05); 1350 // This is the old fit 1351 //TF1 pulse("pulse", "[0]*(1-exp(-x*x/[1]))*exp(-x/[2])", 0, 300); 1352 //pulse.SetLineColor(kBlack); 1353 //pulse.SetParameters(0, 1./0.094, 1./0.05); 1354 1355 TF1 pulse("pulse", "[0]*(1-1/(1+exp((x-[1])/[2])))*exp(-(x-[1])/[3])", 0, 250); 1356 pulse.SetLineColor(kRed); 1357 pulse.SetParLimits(1, 1.0, 3); 1358 pulse.SetParLimits(2, 0.5, 2.0); 1359 pulse.SetParLimits(3, 50, 110); 1248 1360 1249 1361 // ===== … … 1259 1371 1260 1372 // ===== 1261 1373 d->AddTab("Extracted Signals"); 1374 gPad->SetGrid(); 1375 gPad->SetLeftMargin(0.1); 1376 gPad->SetTopMargin(0.1); 1377 gPad->SetRightMargin(0.15); 1378 hsignals->DrawCopy("colz"); 1379 1380 d->AddTab("OscillationAmpl"); 1381 gPad->SetGrid(); 1382 gPad->SetLeftMargin(0.1); 1383 gPad->SetTopMargin(0.1); 1384 gPad->SetRightMargin(0.15); 1385 hoscillation->DrawCopy("colz"); 1386 1387 1388 d->AddTab("All Signals"); 1389 gPad->SetGrid(); 1390 gPad->SetLeftMargin(0.1); 1391 gPad->SetTopMargin(0.1); 1392 gPad->SetRightMargin(0.15); 1393 hall->DrawCopy("colz"); 1394 1395 1396 // ===== 1262 1397 d->AddTab("1"); 1263 1398 gPad->SetGrid(); 1264 gPad->SetLeftMargin(0. 07);1265 gPad->SetTopMargin(0. 01);1399 gPad->SetLeftMargin(0.1); 1400 gPad->SetTopMargin(0.1); 1266 1401 gPad->SetRightMargin(0.15); 1267 1402 h1->DrawCopy("colz"); 1268 1403 p1->DrawCopy("same"); 1269 1404 1270 pulse.SetParameter(0, 1*1.3);1271 p1->Fit(&pulse, "N0", "", 1.5, 25);1272 TF1 *f1 = pulse.DrawCopy("same");1405 //pulse.FixParameter(0, 1*1.5); 1406 //p1->Fit(&pulse, "N0", "", 1, 70); 1407 //TF1 *f1 = pulse.DrawCopy("same"); 1273 1408 1274 1409 // ===== … … 1276 1411 d->AddTab("2"); 1277 1412 gPad->SetGrid(); 1278 gPad->SetLeftMargin(0. 07);1279 gPad->SetTopMargin(0. 01);1413 gPad->SetLeftMargin(0.1); 1414 gPad->SetTopMargin(0.1); 1280 1415 gPad->SetRightMargin(0.15); 1281 1416 h2->DrawCopy("colz"); … … 1290 1425 d->AddTab("3"); 1291 1426 gPad->SetGrid(); 1292 gPad->SetLeftMargin(0. 07);1293 gPad->SetTopMargin(0. 01);1427 gPad->SetLeftMargin(0.1); 1428 gPad->SetTopMargin(0.1); 1294 1429 gPad->SetRightMargin(0.15); 1295 1430 h3->DrawCopy("colz"); … … 1304 1439 d->AddTab("4"); 1305 1440 gPad->SetGrid(); 1306 gPad->SetLeftMargin(0. 07);1307 gPad->SetTopMargin(0. 01);1441 gPad->SetLeftMargin(0.1); 1442 gPad->SetTopMargin(0.1); 1308 1443 gPad->SetRightMargin(0.15); 1309 1444 h4->DrawCopy("colz"); … … 1318 1453 d->AddTab("5"); 1319 1454 gPad->SetGrid(); 1320 gPad->SetLeftMargin(0. 07);1321 gPad->SetTopMargin(0. 01);1455 gPad->SetLeftMargin(0.1); 1456 gPad->SetTopMargin(0.1); 1322 1457 gPad->SetRightMargin(0.15); 1323 1458 h5->DrawCopy("colz"); … … 1332 1467 d->AddTab("6"); 1333 1468 gPad->SetGrid(); 1334 gPad->SetLeftMargin(0. 07);1335 gPad->SetTopMargin(0. 01);1469 gPad->SetLeftMargin(0.1); 1470 gPad->SetTopMargin(0.1); 1336 1471 gPad->SetRightMargin(0.15); 1337 1472 h6->DrawCopy("colz"); … … 1346 1481 d->AddTab("7"); 1347 1482 gPad->SetGrid(); 1348 gPad->SetLeftMargin(0. 07);1349 gPad->SetTopMargin(0. 01);1483 gPad->SetLeftMargin(0.1); 1484 gPad->SetTopMargin(0.1); 1350 1485 gPad->SetRightMargin(0.15); 1351 1486 h7->DrawCopy("colz"); … … 1360 1495 d->AddTab("8"); 1361 1496 gPad->SetGrid(); 1362 gPad->SetLeftMargin(0. 07);1363 gPad->SetTopMargin(0. 01);1497 gPad->SetLeftMargin(0.1); 1498 gPad->SetTopMargin(0.1); 1364 1499 gPad->SetRightMargin(0.15); 1365 1500 h8->DrawCopy("colz"); … … 1374 1509 d->AddTab("Pulse"); 1375 1510 gPad->SetGrid(); 1376 gPad->SetLeftMargin(0. 07);1377 gPad->SetTopMargin(0. 01);1511 gPad->SetLeftMargin(0.1); 1512 gPad->SetTopMargin(0.1); 1378 1513 gPad->SetRightMargin(0.15); 1379 1514 p8->SetStats(kFALSE); … … 1394 1529 p1->DrawCopy("same"); 1395 1530 1396 f1->Draw("same");1531 //f1->Draw("same"); 1397 1532 f2->Draw("same"); 1398 1533 f3->Draw("same"); … … 1406 1541 1407 1542 1543 1544 d->SaveAs(outfile); 1545 1546 TFile f(outfile, "UPDATE"); 1408 1547 /* 1409 d->SaveAs(outfile);1410 1411 TFile f(outfile, "UPDATE");1412 1413 1548 MParameterI par("NumEvents"); 1414 1549 par.SetVal(fill.GetNumExecutions()); -
trunk/Mars/hawc/extract_singles.C
r19857 r19951 57 57 { 58 58 Int_t fIntegrationWindow; 59 60 59 vector<vector<Single>> fData; 61 60 62 61 public: 63 MSingles(const char *name=NULL, const char *title=NULL) : fIntegrationWindow( 30)62 MSingles(const char *name=NULL, const char *title=NULL) : fIntegrationWindow(40) 64 63 { 65 64 fName = name ? name : "MSingles"; … … 88 87 ClassDef(MSingles, 1) 89 88 }; 90 91 89 // Histogram class to extract the baseline 92 90 class MHBaseline : public MH … … 102 100 103 101 public: 104 MHBaseline() : fPedestal(0), fSkipStart( 20), fSkipEnd(10)102 MHBaseline() : fPedestal(0), fSkipStart(10), fSkipEnd(10) 105 103 { 106 104 fName = "MHBaseline"; … … 108 106 // Setup the histogram 109 107 fBaseline.SetName("Baseline"); 110 fBaseline.SetTitle(" Median spectrum");108 fBaseline.SetTitle("Baseline Spectrum"); 111 109 fBaseline.SetXTitle("Pixel [idx]"); 112 fBaseline.SetYTitle(" Median baseline [mV]");110 fBaseline.SetYTitle("Amplitude [mV]"); 113 111 fBaseline.SetDirectory(NULL); 114 112 } … … 282 280 TH2F fTime; 283 281 TProfile2D fPulse; 282 TH2F fPulse2D; //plot the extracted singles in a 2D plot vs samples(time) 284 283 285 284 UInt_t fNumEntries; … … 296 295 // Setup histograms 297 296 fSignal.SetName("Signal"); 298 fSignal.SetTitle(" pulse integral spectrum");297 fSignal.SetTitle("Pulse Integral Spectrum"); 299 298 fSignal.SetXTitle("pixel [SoftID]"); 300 299 fSignal.SetYTitle("time [a.u.]"); … … 302 301 303 302 fTime.SetName("Time"); 304 fTime.SetTitle(" arival time spectrum");303 fTime.SetTitle("Arrival Time Spectrum"); 305 304 fTime.SetXTitle("pixel [SoftID]"); 306 305 fTime.SetYTitle("time [a.u.]"); … … 308 307 309 308 fPulse.SetName("Pulse"); 310 fPulse.SetTitle(" average pulse shape spectrum");309 fPulse.SetTitle("Average Pulse Shape Spectrum"); 311 310 fPulse.SetXTitle("pixel [SoftID]"); 312 311 fPulse.SetYTitle("time [a.u.]"); 313 312 fPulse.SetDirectory(NULL); 313 314 fPulse2D.SetName("Pulse2D"); 315 fPulse2D.SetTitle("Extracted Pulses"); 316 fPulse2D.SetXTitle("time [a.u.]"); 317 fPulse2D.SetYTitle("amplitude [a.u.]"); 318 fPulse2D.SetDirectory(NULL); 314 319 } 315 320 … … 363 368 364 369 // Correct for DRS timing!! 370 371 //Setup binning for the average time spectrum 365 372 MBinning binst(roi, -0.5, roi-0.5); 366 373 MH::SetBinning(fTime, binsx, binst); 367 374 375 //Setup binning for the average pulse spectrum 368 376 MBinning binspy(2*roi, -roi-0.5, roi-0.5); 377 //MBinning binspy(1024, -522-0.5, 522-0.5); 369 378 MH::SetBinning(fPulse, binsx, binspy); 379 380 //Setup binning for the 2D plot amplitude vs time 381 MBinning bins_time(2*roi, -roi-0.5, roi-0.5); 382 //MBinning bins_time(1024, -522-0.5, 522-0.5); 383 MBinning bins_ampl(160, -30, 50); //N_bin is chosen such that 1 DAC = 0.5mV 384 MH::SetBinning(fPulse2D, bins_time, bins_ampl); 370 385 371 386 return kTRUE; … … 402 417 for (int s=0; s<roi; s++) 403 418 fPulse.Fill(i, s-tm, ptr[s]); 419 420 for (int s=0; s<roi; s++) 421 fPulse2D.Fill(s-tm, ptr[s]); 404 422 } 405 423 … … 416 434 const TH2 *GetTime() const { return &fTime; } 417 435 const TH2 *GetPulse() const { return &fPulse; } 436 const TH2F *GetPulse2D() const {return &fPulse2D;} 418 437 419 438 UInt_t GetNumEntries() const { return fNumEntries; } … … 441 460 gPad->SetFrameBorderMode(0); 442 461 fPulse.Draw("colz"); 462 463 pad->cd(4); 464 gPad->SetBorderMode(0); 465 gPad->SetFrameBorderMode(0); 466 fPulse2D.Draw("colz"); 443 467 } 444 468 … … 465 489 gPad->SetFrameBorderMode(0); 466 490 fPulse.DrawCopy("colz"); 491 492 pad->cd(4); 493 gPad->SetBorderMode(0); 494 gPad->SetFrameBorderMode(0); 495 fPulse2D.Draw("colz"); 467 496 } 468 497 … … 497 526 MExtractSingles() : fSingles(0), fPedestal(0), fEvent(0), 498 527 fExtractionRange(64), 499 fNumAverage(10), fStartSkip( 20), fEndSkip(10),500 fIntegrationSize( 3*10), fMaxSearchWindow(30)528 fNumAverage(10), fStartSkip(10), fEndSkip(10), 529 fIntegrationSize(4*10), fMaxSearchWindow(20) 501 530 { 502 531 } … … 538 567 539 568 const size_t navg = fNumAverage; 540 const float threshold = fThreshold; 569 const float threshold = fThreshold; 541 570 const UInt_t start_skip = fStartSkip; 542 571 const UInt_t end_skip = fEndSkip; … … 595 624 if (k_max == i+5 || k_max == i + max_search_window-1) 596 625 continue; 626 627 //Make sure the pulse is isolated (area after the maximum is empty) 628 UInt_t k_falling = k_max+200; 629 for (UInt_t k_after = k_falling; k_after < k_max +250; k_after++) 630 { 631 if (val[k_after] > val[k_falling] && 632 val[k_after + fNumAverage/2] > val[k_falling]) 633 continue; 634 } 597 635 598 636 //search for half maximum before maximum … … 623 661 single.fTime = k_half_max; 624 662 625 // Crossing of the threshold is at 5663 // Crossing of the threshold is at 7 626 664 for (UInt_t j=k_half_max; j<k_half_max+integration_size; j++) 627 665 single.fSignal += ptr[j]; … … 631 669 // Add single to list 632 670 result.push_back(single); 671 break; //accept only one pulse per event 633 672 634 673 // skip falling edge … … 644 683 645 684 int extract_singles( 646 Int_t max_dist = 14,647 Double_t threshold =5,648 const char *runfile = "raw/2019/10/27/20191027_",649 int firstRunID = 6,650 int lastRunID = 6,651 const char *drsfile = "raw/2019/10/27/20191027_003.drs.fits",652 const char *outpath = "."685 Int_t max_dist = 14, 686 Double_t threshold = 5, 687 const char *runfile = "/home/giangdo/Documents/Master/MA/pulse/data_single_pe/20191027_", 688 int firstRunID = 6, 689 int lastRunID = 6, 690 const char *drsfile = "/home/giangdo/Documents/Master/MA/pulse/data_single_pe/20191027_004.drs.fits", 691 const char *outpath = "/home/giangdo/Documents/Master/MA/pulse/data_single_pe/extracted" 653 692 ) 654 693 { … … 688 727 689 728 // map file to use (get that from La Palma!) 690 const char *map = usemap ? " ../hawc/FAMOUSmap171218.txt" : NULL;729 const char *map = usemap ? "/home/giangdo/Documents/Master/MA/Software/Mars/hawc/HAWCsEyemap181214.txt" : NULL; 691 730 692 731 // ------------------------------------------------------ … … 856 895 const TH2 *htime = h->GetTime(); 857 896 const TH2 *hpulse = h->GetPulse(); 897 const TH2F *ppulse2d = h->GetPulse2D(); 858 898 859 899 d->AddTab("Time"); … … 869 909 hp->Draw(); 870 910 911 d->AddTab("2DPulse"); 912 ppulse2d->DrawCopy("colz"); 913 871 914 d->SaveAs(outfile); 872 915 -
trunk/Mars/hawc/fit_singles.C
r19875 r19951 93 93 94 94 // Print function parameters 95 void PrintFunc(TF1 &f, float integration_window= 30)95 void PrintFunc(TF1 &f, float integration_window=40) 96 96 { 97 97 //cout << "--------------------" << endl; … … 113 113 // The parameters for the function are the filenam from the gain extraction 114 114 // and the output filename 115 int fit_singles(const char *filename = " 20191027_006_006.root",116 const char *outfile = " 20190227_006_006-fit.root",115 int fit_singles(const char *filename = "/home/giangdo/Documents/Master/MA/pulse/data_single_pe/extracted/20191027_006_006.root", 116 const char *outfile = "/home/giangdo/Documents/Master/MA/pulse/data_single_pe/extracted/20191027_006_006_fit.root", 117 117 bool fixednoise=false) 118 118 { 119 119 // Read the mapping between bias channels and hardware channels 120 120 PixelMap pmap; 121 if (!pmap.Read(" ../hawc/FAMOUSmap171218.txt"))122 { 123 cout << " FAMOUSmap171218.txt not found." << endl;121 if (!pmap.Read("/home/giangdo/Documents/Master/MA/Software/Mars/hawc/HAWCsEyemap181214.txt")) 122 { 123 cout << "HAWCsEyemap181214.txt not found." << endl; 124 124 return 1; 125 125 } 126 126 127 127 // It is more correct to fit the integral, but this is super 128 // slow , especially for 1440 pixel. To get that, one would have128 // slow. To get that, one would have 129 129 // to analytically integrate and fit this function. 130 // (Currently the integral is switched off for the 1440 individual131 // spectra in all cases)132 130 bool fast = false; // Switch off using integral 133 131 134 132 // Values which should be read from the file but not available atm 135 Int_t integration_window = 30;133 Int_t integration_window = 40; 136 134 137 135 // Map for which pixel shall be plotted and which not … … 266 264 TH1F hCoeffR2 ("CoeffR2", "Coefficient R", 90, -1, 2); 267 265 268 // Hist igram for the sum of all spectrums269 TH1F hSum("Sum1", "Signal spectrum of all pixels ",266 // Histogram for the sum of all spectrums 267 TH1F hSum("Sum1", "Signal spectrum of all pixels (excl. blind pixels)", 270 268 hsignal->GetNbinsY(), hsignal->GetYaxis()->GetXmin(), hsignal->GetYaxis()->GetXmax()); 271 269 hSum.SetXTitle("pulse integral [mV sample]"); … … 275 273 276 274 // Histogram for the sum of all pixels excluding the ones with faulty fits 277 TH1F hSumClear1("SumC1", "Signal spectrum of all pixels ( incl TM)",275 TH1F hSumClear1("SumC1", "Signal spectrum of all pixels (excl. faulty and blind pixels)", 278 276 hsignal->GetNbinsY(), hsignal->GetYaxis()->GetXmin(), hsignal->GetYaxis()->GetXmax()); 279 277 hSumClear1.SetXTitle("pulse integral [mV sample]"); … … 303 301 hPulse.SetStats(false); 304 302 305 // Spe ktrum for the normalized individual spectra306 TH1F hSumScale1("SumScale1", "Signal spectrum of all pixels ( incl TM)", 120, 0.05, 12.05);303 // Spectrum for the normalized individual spectra 304 TH1F hSumScale1("SumScale1", "Signal spectrum of all pixels (excl. blind pixels)", 120, 0.05, 12.05); 307 305 hSumScale1.SetXTitle("pulse integral [pe]"); 308 306 hSumScale1.SetYTitle("Rate"); … … 332 330 if (usePixel[pixel]==0) 333 331 continue; 332 333 //exclude the pixels without cones 334 if (pixel == 61) 335 continue; 336 if (pixel == 62) 337 continue; 338 if (pixel == 63) 339 continue; 340 341 342 334 343 335 344 TH1D *hist = hsignal->ProjectionY("proj", pixel+1, pixel+1); … … 434 443 if (usePixel[pixel]==0) 435 444 continue; 445 446 // Exclude pixels without cones 447 if (pixel == 61) 448 continue; 449 if (pixel == 62) 450 continue; 451 if (pixel == 63) 452 continue; 436 453 437 454 //Projectipon of a certain Pixel out of Ampl.Spectrum -
trunk/Mars/hawc/plot_trace.C
r19846 r19951 1 #include <TStyle.h> 2 #include <TCanvas.h> 3 #include <TSystem.h> 4 #include <TF1.h> 5 #include <TProfile.h> 6 #include <TProfile2D.h> 7 #include <TMath.h> 8 #include <TGraph.h> 9 #include <TLine.h> 10 #include <TFitResultPtr.h> 11 #include <TFitResult.h> 12 #include <TFile.h> 13 #include <TLine.h> 14 15 #include <cstdio> 16 #include <stdio.h> 17 #include <stdint.h> 18 19 #include "Getline.h" 20 #include "MH.h" 21 #include "MArrayI.h" 22 #include "MDirIter.h" 23 #include "MFillH.h" 24 #include "MEvtLoop.h" 25 #include "MCamEvent.h" 26 #include "MGeomApply.h" 27 #include "MTaskList.h" 28 #include "MParList.h" 29 #include "MContinue.h" 30 #include "MBinning.h" 31 #include "MDrsCalibApply.h" 32 #include "MDrsCalibration.h" 33 #include "MRawFitsRead.h" 34 #include "MStatusDisplay.h" 35 #include "MTaskInteractive.h" 36 #include "MPedestalSubtractedEvt.h" 37 #include "MGeomCamFAMOUS.h" 38 #include "MRawRunHeader.h" 39 #include "MPedestalCam.h" 40 #include "MPedestalPix.h" 41 #include "MParameters.h" 42 1 43 // ========================================================================== 2 44 // ============ see plot_callisto function at the end of the file =========== … … 21 63 22 64 // Create a histogram for the trace 23 TH1D hist("Trace", "Waveform", 1024, -0.25, 511.75); 65 //TH1D hist("Trace", "Waveform", 1024, -0.25, 511.75); //range = [-0.25,511.75]ns 66 TH1D hist("Trace", "Waveform (Pixel 5, Event 1)", 1024, -0.5, 1024-0.5); 24 67 25 68 // All 'data members' that are required globally … … 34 77 { 35 78 fEvt = (MPedestalSubtractedEvt*)plist->FindObject("MPedestalSubtractedEvt"); 36 if (!fEvt) 37 { 38 gfLog << err << "MPedestalSubtractedEvt not found... aborting." << endl; 39 return kALSE; 40 } 79 80 //if (!fEvt) 81 //{ 82 // gfLog << err << "MPedestalSubtractedEvt not found... aborting." << endl; 83 // return kFALSE; 84 //} 41 85 42 86 // Create a canvas and plot the histogram into it 43 c = new TCanvas ;87 c = new TCanvas(); 44 88 hist.SetStats(kFALSE); 45 89 hist.Draw(); 46 47 TF1 constant("zero", "[0]", -0.25, 511.75); 90 hist.SetXTitle("Samples"); 91 hist.SetYTitle("Amplitude [a.u.]"); 92 93 //TF1 constant("zero", "[0]", -0.25, 511.75); 94 TF1 constant("zero", "[0]", -0.5, 1024); 48 95 constant.SetParameter(0, 0); 49 96 constant.SetLineColor(kBlack); … … 59 106 constant.DrawCopy("same"); 60 107 108 61 109 return kTRUE; 62 110 } … … 64 112 Int_t Process() 65 113 { 66 int pixel_index = 0; 114 int pixel_index = 6; //plot trace only of this pixel 115 int skipstart = 5; 116 int skipend = 10; 67 117 68 118 // Number of samples per pixel (usually 1024) … … 73 123 hist.Reset(); 74 124 for (int i=0; i<numsamples; i++) 75 hist.Fill(i *0.5, cal[i]); // Convert sample to nano-second125 hist.Fill(i, cal[i]); // 0.5ns = 1 sample 76 126 77 127 // Reset min/max range 78 hist.SetMinimum(); 79 hist.SetMaximum(); 80 81 // Set a reasonable range 82 if (hist.GetMinimum()>-50) 83 hist.SetMinimum(-50); 84 if (hist.GetMaximum()<250) 85 hist.SetMaximum(250); 128 hist.SetMinimum(-50); 129 hist.SetMaximum(50); 130 131 //// Set a reasonable range 132 //if (hist.GetMinimum()>-30) 133 // hist.SetMinimum(-20); 134 //if (hist.GetMaximum()<60) 135 // hist.SetMaximum(50); 136 137 138 139 TLine *line = new TLine(skipstart, 50, skipstart, -50); 140 line->SetLineStyle(kSolid); 141 line->SetLineColor(kRed); 142 line->Draw(); 143 144 TLine *line2 = new TLine(1024-skipend, 50, 1024-skipend, -50); 145 line2->SetLineStyle(kSolid); 146 line2->SetLineColor(kRed); 147 line2->Draw(); 86 148 87 149 // Signal root to update the canvas/pad 88 150 c->Modified(); 89 151 c->Update(); 152 //c->SaveAs("/home/giangdo/Documents/Master/MA/pulse/data_single_pe/traces/pixel3/event_0.png"); 153 90 154 91 155 bool rc = HandleInput(); … … 131 195 132 196 // mapping file (found in Mars/hawc) 133 const char *mmap = usemap ? " ../hawc/FAMOUSmap171218.txt" : NULL;197 const char *mmap = usemap ? "/home/giangdo/Documents/Master/MA/Software/Mars/hawc/HAWCsEyemap181214.txt" : NULL; 134 198 135 199 // ====================================================== … … 193 257 MEvtLoop loop(gSystem->BaseName(datafile)); 194 258 loop.SetParList(&plist); 195 196 if (!loop.Eventloop( ))259 260 if (!loop.Eventloop(100)) 197 261 return 4; 198 262 -
trunk/Mars/hawc/star.C
r19821 r19951 18 18 19 19 To run the macro from the command line (assuming you are in a directory 20 Mars/build where you have built your Mars environment) ou can do20 Mars/build where you have built your Mars environment) you can do 21 21 22 22 root ../hawc/star.C\(\"00000015.003_Y_MonteCarlo003_Events.root\"\) … … 206 206 write.AddContainer("MPointingPos", "Events", kFALSE); 207 207 write.AddContainer("MTime", "Events", kFALSE); 208 write.AddContainer("MRawBoardsFACT", "Events", kFALSE); 208 209 write.AddContainer("MSrcPosCam", "Events", kFALSE); 209 210
Note:
See TracChangeset
for help on using the changeset viewer.