Changeset 17056 for branches/Mars_MC/fact
- Timestamp:
- 08/29/13 18:17:12 (11 years ago)
- Location:
- branches/Mars_MC/fact/analysis/mc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Mars_MC/fact/analysis/mc/callisto.C
r17055 r17056 1 int callisto(const char *seqfile="seq/2012/01/23/20120123_023.seq", const char *outpath = "output", bool use_delays=true) 1 2 #include <sstream> 3 #include <iostream> 4 5 #include "TH1F.h" 6 #include "TFile.h" 7 #include "TStyle.h" 8 #include "TGraph.h" 9 #include "TLine.h" 10 11 #include "MDrsCalibration.h" 12 #include "MLogManip.h" 13 #include "MExtralgoSpline.h" 14 #include "MSequence.h" 15 #include "MStatusArray.h" 16 #include "MHCamera.h" 17 #include "MJob.h" 18 #include "MWriteRootFile.h" 19 #include "MHCamera.h" 20 #include "MBadPixelsCam.h" 21 #include "MBadPixelsPix.h" 22 #include "MDirIter.h" 23 #include "MTaskList.h" 24 #include "MFDataPhrase.h" 25 #include "MArrayF.h" 26 #include "MBadPixelsTreat.h" 27 #include "MCalibrateDrsTimes.h" 28 #include "MHSectorVsTime.h" 29 #include "MHCamEvent.h" 30 #include "MExtractTimeAndChargeSpline.h" 31 #include "MFillH.h" 32 #include "MDrsCalibApply.h" 33 #include "MGeomApply.h" 34 #include "MContinue.h" 35 #include "MRawFitsRead.h" 36 #include "MEvtLoop.h" 37 #include "MParList.h" 38 #include "MStatusDisplay.h" 39 #include "MDrsCalibrationTime.h" 40 #include "MH3.h" 41 #include "MGeomCamFACT.h" 42 #include "MCalibrateFact.h" 43 #include "MParameters.h" 44 #include "MWriteAsciiFile.h" 45 46 /* Maybe you wanna use this macro like this: 47 * 48 * 0.) ---- call root ---- 49 * root -b 50 * 51 * 1.) ---- compile the stuff ---- 52 * .L fact/analysis/callisto_buildable_no_sequence_file.C++ 53 * <read a lot of warnings> 54 * 55 * 2.) ---- you can call it then ---- 56 * Therefore you need to specify all the paths ... see below. 57 * 58 * When you wanna call the stuff directly from the bash make sure to 59 * escape the bracets and quotes correctly. 60 * 61 * your can do: 62 * root -b -q callisto_buildable_no_sequence_file.C++'("path1","path2",...)' 63 * or: 64 * root -b -q callisto_buildable_no_sequence_file.C++(\"path1\",\"$HOME\",...) 65 * using bash enviroment variables like $HOME is not possible in the upper variant. 66 */ 67 68 using namespace std; 69 70 int callisto_for_monte_carlo_simulated_data( 71 const char *drs_calib_300_path="/fhgfs/groups/app/fact/mc_test/testingdrsfile/test300samples.drs.fits", 72 const char *pedestal_file_path="/fhgfs/groups/app/fact/mc_test/ceresfitstest/mcFilesForTests/mcNsbPedestal/00000001.001_P_MonteCarlo000_Events.fits", 73 const char *data_file_path="/fhgfs/groups/app/fact/mc_test/ceresfitstest/mcFilesForTests/mcProton/00000003.387_D_MonteCarlo010_Events.fits", 74 75 const char *root_file_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto.root", 76 const char *status_display_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto_status_display.root", 77 const char *status_display_title = "callisto_status_display") 2 78 { 79 3 80 // ====================================================== 4 81 … … 10 87 11 88 // map file to use (get that from La Palma!) 12 const char *map = usemap ? "/ home/fact/FACT++/FACTmap111030.txt" : NULL;89 const char *map = usemap ? "/fhgfs/groups/app/fact/resources/monte_carlo_FACTmap.txt" : NULL; 13 90 14 91 Bool_t maximum = kTRUE; 15 92 16 93 const char *lp_template = maximum ? 17 " template-lp-extractor-maximum.root" :18 " template-lp-extractor-leading-edge.root";19 20 const char *pulse_template = " template-pulse.root";94 "/cm/shared/apps/fact/Mars_svn_LP/template-lp-extractor-maximum.root" : 95 "/cm/shared/apps/fact/Mars_svn_LP/template-lp-extractor-leading-edge.root"; 96 97 const char *pulse_template = "/cm/shared/apps/fact/Mars_svn_LP/template-pulse.root"; 21 98 22 99 // ------------------------------------------------------ … … 47 124 // Extraction type: Extract integral and half leading edge 48 125 49 const int type = maximum ? (MExtralgoSpline::kIntegralRel) : (MExtralgoSpline::kIntegralFixed);126 const MExtralgoSpline::ExtractionType_t type = maximum ? (MExtralgoSpline::kIntegralRel) : (MExtralgoSpline::kIntegralFixed); 50 127 //const int type = MExtralgoSpline::kIntegralFixed; 51 128 … … 54 131 55 132 Long_t max = 0; // All 56 Long_t max0 = max; // Time marker57 Long_t max1 = max; // Light pulser58 //Long_t max2 = 3000; // Calibration ratio59 133 Long_t max3 = max; // Pedestal Rndm 60 134 Long_t max4 = max; // Pedestal Ext 61 Long_t max5 = max; // Data62 135 63 136 // ====================================================== … … 65 138 if (map && gSystem->AccessPathName(map, kFileExists)) 66 139 { 67 gLog << "ERROR - Cannot access mapping file '" << map << "'" << endl;140 gLog << err << "ERROR - Cannot access mapping file '" << map << "'" << endl; 68 141 return 1; 69 142 } 70 143 71 // The sequence file which defines the files for the analysis 72 MSequence seq(seqfile); 73 if (!seq.IsValid()) 74 { 75 gLog << "ERROR - Sequence '" << seqfile << "' invalid!" << endl; 76 return 2; 144 TString datfile = TString(data_file_path); 145 TString drsfile = TString(drs_calib_300_path); 146 TString pedfile = TString(pedestal_file_path); 147 148 gLog.Separator("Callisto"); 149 gLog << all; 150 gLog << "Data File : " << datfile << "\n"; 151 gLog << "DRS calib 300: " << drsfile << '\n'; 152 153 MDrsCalibration drscalib300; 154 if (!drscalib300.ReadFits(drsfile.Data())) { 155 gLog << err << "ERROR - Cannot access drscallib300 file '" << drsfile << "'" << endl; 156 return 5; 77 157 } 78 79 // --------------------------------------------------------------------------------80 81 gLog .Separator("Callisto");82 gLog << " Calibrate data of sequence '" << seq.GetFileName() << "'"<< endl;83 gLog << endl;158 gLog << all; 159 gLog << "Pedestal file: " << pedfile << '\n'; 160 161 gLog << "root_file_output_path: " << root_file_output_path << endl; 162 gLog << "status_display_output_path: " << status_display_output_path << endl; 163 gLog << "status_display_title: " << status_display_title << endl; 84 164 85 165 // ------------------------------------------------------ 86 87 ostringstream drsname;88 drsname << gSystem->DirName(seqfile) << "/";89 drsname << seq.GetNight().GetNightAsInt() << "_";90 drsname << Form("%03d", seq.GetDrsSequence()) << ".drs.seq";91 92 MSequence drs(drsname.str().c_str());93 if (!drs.IsValid())94 {95 gLog << "ERROR - DRS sequence invalid!" << endl;96 return 3;97 }98 99 gLog << "DRS sequence file: " << drsname.str() << '\n' << endl;100 101 TString drsfile = seq.GetFileName(0, MSequence::kRawDrs);102 if (drsfile.IsNull())103 {104 cout << "No DRS file available in sequence." << endl;105 return 4;106 }107 108 TString timfile = drs.GetFileName(0, MSequence::kFitsDat);109 TString drs1024 = drs.GetFileName(0, MSequence::kFitsDrs);110 TString pedfile = seq.GetFileName(0, MSequence::kFitsPed);111 TString calfile = seq.GetFileName(0, MSequence::kFitsCal);112 113 gLog << "DRS calib 300: " << drsfile << '\n';114 gLog << "DRS calib 1024: " << drs1024 << "\n\n";115 116 MDrsCalibration drscalib300;117 if (!drscalib300.ReadFits(drsfile.Data()))118 return 5;119 120 MDrsCalibration drscalib1024;121 if (!drscalib1024.ReadFits(drs1024.Data()))122 return 6;123 124 gLog << "Time calibration : " << timfile << '\n';125 gLog << "Pedestal file: " << pedfile << '\n';126 gLog << "Light Pulser file: " << calfile << '\n' << endl;127 128 // ------------------------------------------------------129 130 MDirIter iter;131 if (seq.GetRuns(iter, MSequence::kFitsDat)<=0)132 {133 gLog << "ERROR - Sequence valid but without files." << endl;134 return 7;135 }136 iter.Print();137 138 // ======================================================139 140 166 MStatusArray arrt, arrp; 141 167 … … 143 169 if (arrt.Read()<=0) 144 170 { 145 cout<< "ERROR - Reading LP template from " << lp_template << endl;171 gLog << err << "ERROR - Reading LP template from " << lp_template << endl; 146 172 return 100; 147 173 } … … 150 176 if (!lpref) 151 177 { 152 cout<< "ERROR - LP Template not found in " << lp_template << endl;178 gLog << err << "ERROR - LP Template not found in " << lp_template << endl; 153 179 return 101; 154 180 } … … 158 184 if (!gain) 159 185 { 160 cout<< "ERROR - Gain not found in " << lp_template << endl;186 gLog << err << "ERROR - Gain not found in " << lp_template << endl; 161 187 return 101; 162 188 } … … 166 192 if (arrp.Read()<=0) 167 193 { 168 cout<< "ERROR - Reading Pulse template from " << pulse_template << endl;194 gLog << err << "ERROR - Reading Pulse template from " << pulse_template << endl; 169 195 return 102; 170 196 } … … 173 199 if (!hpulse) 174 200 { 175 cout<< "ERROR - Pulse Template not found in " << pulse_template << endl;201 gLog << err << "ERROR - Pulse Template not found in " << pulse_template << endl; 176 202 return 103; 177 203 } 178 204 hpulse->SetDirectory(0); 179 180 205 // ====================================================== 181 206 … … 184 209 MBadPixelsCam badpixels; 185 210 badpixels.InitSize(1440); 211 /* 186 212 badpixels[ 424].SetUnsuitable(MBadPixelsPix::kUnsuitable); 187 213 badpixels[ 583].SetUnsuitable(MBadPixelsPix::kUnsuitable); … … 190 216 badpixels[1208].SetUnsuitable(MBadPixelsPix::kUnsuitable); 191 217 badpixels[1399].SetUnsuitable(MBadPixelsPix::kUnsuitable); 192 218 */ 193 219 // Twin pixel 194 220 // 113 … … 211 237 hrate.DefineLabelY(0x400, "Ped"); 212 238 // hrate.DefaultLabelY("ERROR"); 213 214 Bool_t isinteg =215 (type&MExtralgoSpline::kIntegral) ||216 (type&MExtralgoSpline::kFixedWidth) ||217 (type&MExtralgoSpline::kDynWidth)218 ? kTRUE : kFALSE;219 220 239 gStyle->SetOptFit(kTRUE); 221 240 222 // ======================================================223 224 gLog << endl;225 gLog.Separator("Processing DRS timing calibration run");226 227 MTaskList tlist0;228 229 MParList plist0;230 plist0.AddToList(&tlist0);231 plist0.AddToList(&drscalib1024);232 plist0.AddToList(&badpixels);233 plist0.AddToList(&timecam);234 235 MEvtLoop loop0("DetermineTimeCal");236 loop0.SetDisplay(d);237 loop0.SetParList(&plist0);238 239 // ------------------ Setup the tasks ---------------240 241 MRawFitsRead read0(timfile);242 243 MContinue cont0("MRawEvtHeader.GetTriggerID!=33792", "SelectTim");244 245 MGeomApply apply0;246 247 MDrsCalibApply drsapply0;248 249 MFillH fill0("MHDrsCalibrationTime");250 fill0.SetNameTab("DeltaT");251 252 tlist0.AddToList(&read0);253 tlist0.AddToList(&apply0);254 tlist0.AddToList(&drsapply0);255 tlist0.AddToList(&cont0);256 tlist0.AddToList(&fill0);257 258 if (!loop0.Eventloop(max0))259 return 8;260 261 if (!loop0.GetDisplay())262 return 9;263 264 /*265 MHDrsCalibrationT *t = (MHDrsCalibrationT*)plist4.FindObject("MHDrsCalibrationT");266 t->SetDisplay(d);267 t->PlotAll();268 */269 270 // ======================================================271 272 gLog << endl;273 gLog.Separator("Processing external light pulser run");274 275 MTaskList tlist1;276 277 MParList plist1;278 plist1.AddToList(&tlist1);279 plist1.AddToList(&drscalib300);280 plist1.AddToList(&badpixels);281 plist1.AddToList(&timecam);282 283 MEvtLoop loop1("DetermineCalConst");284 loop1.SetDisplay(d);285 loop1.SetParList(&plist1);286 287 // ------------------ Setup the tasks ---------------288 289 MRawFitsRead read1;290 read1.LoadMap(map);291 read1.AddFile(calfile);292 293 MContinue cont1("(MRawEvtHeader.GetTriggerID&0xff00)!=0x100", "SelectCal");294 295 MGeomApply apply1;296 297 MDrsCalibApply drsapply1;298 299 /*300 MPedestalCam fPedestalCamOut1a;301 MPedestalCam fPedestalCamOut1b;302 MPedestalCam fPedestalCamOut1c;303 304 MPedCalcPedRun pedcalc1a;305 MPedCalcPedRun pedcalc1b;306 MPedCalcPedRun pedcalc1c;307 pedcalc1a.SetPedestalsOut(&fPedestalCamOut1a);308 pedcalc1b.SetPedestalsOut(&fPedestalCamOut1b);309 pedcalc1c.SetPedestalsOut(&fPedestalCamOut1c);310 311 MExtractTimeAndChargeSpline extractor1ab;312 extractor1a.SetRange(first_slice, last_slice);313 extractor1a.SetRiseTimeHiGain(rise_time);314 extractor1a.SetFallTimeHiGain(fall_time);315 extractor1a.SetChargeType(type);316 extractor1a.SetSaturationLimit(600000);317 extractor1a.SetNoiseCalculation(kFALSE);318 319 pedcalc1a.SetRandomCalculation(kTRUE);320 pedcalc1b.SetRandomCalculation(kFALSE);321 pedcalc1a.SetExtractor(&extractor1a);322 pedcalc1b.SetExtractor($extractor1a);323 pedcalc1c.SetRangeFromExtractor(&extractor1a);324 */325 326 // ---327 328 MExtractTimeAndChargeSpline extractor1b("ExtractPulse");329 extractor1b.SetRange(first_slice, last_slice);330 extractor1b.SetRiseTimeHiGain(rise_time_cal);331 extractor1b.SetFallTimeHiGain(fall_time_cal);332 extractor1b.SetHeightTm(heighttm);333 extractor1b.SetChargeType(type);334 extractor1b.SetSaturationLimit(600000);335 extractor1b.SetNoiseCalculation(kFALSE);336 337 MExtractTimeAndChargeSpline extractor1c("ExtractAmplitude");338 extractor1c.SetRange(first_slice, last_slice);339 extractor1c.SetChargeType(MExtralgoSpline::kAmplitude);340 extractor1c.SetSaturationLimit(600000);341 extractor1c.SetNoiseCalculation(kFALSE);342 extractor1c.SetNameSignalCam("Amplitude");343 extractor1c.SetNameTimeCam("AmplitudePos");344 345 // ---346 347 MHCamEvent evt1a(5, "CalRatio", "Ratio per slice between integrated signal and amplitude;; r [1/n]");348 evt1a.SetNameSub("Amplitude", kTRUE);349 MFillH fill1a(&evt1a, "MExtractedSignalCam", "FillRatio");350 fill1a.SetDrawOption("gaus");351 352 MParameterD ratio1a;353 ratio1a.SetVal(1./(fall_time_cal+rise_time_cal));354 fill1a.SetWeight(&ratio1a);355 356 // ---357 358 MHCamEvent evt1f(0, "ExtCalSig", "Extracted calibration signal;;S [mV·sl]");359 MHCamEvent evt1g(4, "ExtCalTm", "Extracted arrival times;;T [sl]");360 MHCamEvent evt1h(6, "CalCalTm", "Calibrated arrival times;;T [sl]");361 362 MHSectorVsTime hist1rmsb("ExtSigVsTm");363 MHSectorVsTime hist1tmb("CalTmVsTm");364 hist1rmsb.SetTitle("Extracted calibration vs event number;;S [mV·sl]");365 hist1rmsb.SetType(0);366 hist1tmb.SetTitle("Extracted arrival time vs event number;;T [sl]");367 //hist1tmb.SetType(4);368 hist1tmb.SetType(6);369 370 MFillH fill1f(&evt1f, "MExtractedSignalCam", "FillExtSig");371 MFillH fill1g(&evt1g, "MArrivalTimeCam", "FillExtTm");372 MFillH fill1h(&evt1h, "MSignalCam", "FillCalTm");373 MFillH fill1r(&hist1rmsb, "MExtractedSignalCam", "FillExtSigVsTm");374 //MFillH fill1j(&hist1tmb, "MArrivalTimeCam", "FillExtTmVsTm");375 MFillH fill1j(&hist1tmb, "MSignalCam", "FillCalTmVsTm");376 377 fill1f.SetDrawOption("gaus");378 fill1h.SetDrawOption("gaus");379 380 // ---381 382 MCalibrateDrsTimes calctm1a("CalibrateCalEvents");383 calctm1a.SetNameUncalibrated("UncalibratedTimes");384 385 MBadPixelsTreat treat1;386 treat1.SetProcessPedestalRun(kFALSE);387 treat1.SetProcessPedestalEvt(kFALSE);388 389 // ---390 391 MHCamEvent evt1c(6, "ExtCalTmShift", "Relative extracted arrival time of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");392 MHCamEvent evt1d(6, "CalCalTmShift", "Relative calibrated arrival time of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");393 394 evt1c.SetMedianShift();395 evt1d.SetMedianShift();396 397 MFillH fill1c(&evt1c, "UncalibratedTimes", "FillExtCalTm");398 MFillH fill1d(&evt1d, "MSignalCam", "FillCalCalTm");399 fill1d.SetDrawOption("gaus");400 401 // ------------------ Setup eventloop and run analysis ---------------402 403 tlist1.AddToList(&read1);404 tlist1.AddToList(&apply1);405 tlist1.AddToList(&drsapply1);406 tlist1.AddToList(&cont1);407 tlist1.AddToList(&extractor1b);408 if (isinteg)409 {410 tlist1.AddToList(&extractor1c);411 tlist1.AddToList(&fill1a);412 }413 tlist1.AddToList(&calctm1a);414 tlist1.AddToList(&treat1);415 tlist1.AddToList(&fill1f);416 tlist1.AddToList(&fill1g);417 tlist1.AddToList(&fill1h);418 tlist1.AddToList(&fill1r);419 tlist1.AddToList(&fill1j);420 tlist1.AddToList(&fill1c);421 tlist1.AddToList(&fill1d);422 423 if (!loop1.Eventloop(max1))424 return 10;425 426 if (!loop1.GetDisplay())427 return 11;428 429 if (use_delays)430 timecam.SetDelays(*evt1h.GetHist());431 241 432 242 // ========================= Result ================================== 433 243 434 Double_t avgS = evt1f.GetHist()->GetMean();435 Double_t medS = evt1f.GetHist()->GetMedian();436 Double_t rmsS = evt1f.GetHist()->GetRMS();437 Double_t maxS = evt1f.GetHist()->GetMaximum();244 //~ Double_t avgS = evt1f.GetHist()->GetMean(); 245 //~ Double_t medS = evt1f.GetHist()->GetMedian(); 246 //~ Double_t rmsS = evt1f.GetHist()->GetRMS(); 247 //~ Double_t maxS = evt1f.GetHist()->GetMaximum(); 438 248 439 249 MArrayF der1(hpulse->GetNbinsX()); … … 454 264 MArrayD calib(1440); 455 265 for (int i=0; i<1440; i++) 456 { 457 Double_t g = gain->GetBinContent(i+1)>0.5 ? gain->GetBinContent(i+1) : 1; 458 if (evt1f.GetHist()->GetBinContent(i+1)>0 && !badpixels[i].IsUnsuitable()) 459 calib[i] = lpref->GetBinContent(i+1) / evt1f.GetHist()->GetBinContent(i+1) / g; 460 } 266 calib[i] =1.; 461 267 462 268 gROOT->SetSelectedPad(0); … … 472 278 Double_t w = hpulse->GetBinWidth(1); 473 279 Double_t T = w*(spline.GetTime()+0.5) +ax->GetXmin(); 474 Double_t H = w*(hpulse->GetMaximumBin()+0.5)+ax->GetXmin();280 //~ Double_t H = w*(hpulse->GetMaximumBin()+0.5)+ax->GetXmin(); 475 281 476 282 TLine line; … … 704 510 MRawFitsRead read5; 705 511 read5.LoadMap(map); 706 read5.AddFile s(iter);512 read5.AddFile(datfile); 707 513 708 514 MFillH fill5a(&hrate); … … 777 583 //calctm4tm.SetFilter(&filtercal); 778 584 779 MHCamEvent evt5m(6, "ExtTm", "Extracted arrival times of calibration pulse;;\\Delta T [ns]");780 MHCamEvent evt5n(6, "CalTm", "Calibrated arrival times of calibration pulse;;\\Delta T [ns]");781 MHCamEvent evt5q(6, "ExtTmShift", "Relative extracted arrival times of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");782 MHCamEvent evt5r(6, "CalTmShift", "Relative calibrated arrival times of calibration pulse (w.r.t. event-median);;\\Delta T [ns]");783 MHCamEvent evt5s(6, "ExtTM", "Extracted absolute time marker position;;T [sl]");784 MHCamEvent evt5t(6, "CalTM", "Calibrated absolute time marker position;;T [ns]");785 MHCamEvent evt5u(6, "ExtTMshift", "Relative extracted time marker position (w.r.t. event-median);;\\Delta T [ns]");786 MHCamEvent evt5v(6, "CalTMshift", "Relative calibrated time marker position (w.r.t. event-median);;\\Delta T [ns]");787 MHCamEvent evt5w(6, "ExtDiff", "Difference between extracted arrival time of time marker and calibration pulse;;\\Delta T [ns]");788 MHCamEvent evt5x(6, "CalDiff", "Difference between calibrated arrival time of time marker and calibration pulse;;\\Delta T [ns]");789 790 evt5w.SetNameSub("UncalibratedTimes");791 evt5x.SetNameSub("MSignalCam");792 793 evt5q.SetMedianShift();794 evt5r.SetMedianShift();795 evt5u.SetMedianShift();796 evt5v.SetMedianShift();797 //evt4w.SetMedianShift();798 //evt4x.SetMedianShift();799 800 MFillH fill5m(&evt5m, "UncalibratedTimes", "FillExtTm");801 MFillH fill5n(&evt5n, "MSignalCam", "FillCalTm");802 MFillH fill5q(&evt5q, "UncalibratedTimes", "FillExtTmShift");803 MFillH fill5r(&evt5r, "MSignalCam" , "FillCalTmShift");804 MFillH fill5s(&evt5s, "UncalTimeMarker", "FillExtTM");805 MFillH fill5t(&evt5t, "TimeMarker", "FillCalTM");806 MFillH fill5u(&evt5u, "UncalTimeMarker", "FillExtTMshift");807 MFillH fill5v(&evt5v, "TimeMarker", "FillCalTMshift");808 MFillH fill5w(&evt5w, "UncalTimeMarker", "FillExtDiff");809 MFillH fill5x(&evt5x, "TimeMarker", "FillCalDiff");810 811 fill5m.SetDrawOption("gaus");812 fill5n.SetDrawOption("gaus");813 fill5q.SetDrawOption("gaus");814 fill5r.SetDrawOption("gaus");815 //fill5s.SetDrawOption("gaus");816 //fill5t.SetDrawOption("gaus");817 //fill5u.SetDrawOption("gaus");818 //fill5v.SetDrawOption("gaus");819 //fill5w.SetDrawOption("gaus");820 //fill5x.SetDrawOption("gaus");821 822 823 585 MBadPixelsTreat treat5; 824 586 treat5.SetProcessPedestalRun(kFALSE); 825 587 treat5.SetProcessPedestalEvt(kFALSE); 826 827 MHSectorVsTime hist5cal("CalVsTm");828 MHSectorVsTime hist5ped("PedVsTm");829 hist5cal.SetTitle("Median calibrated calibration signal vs event number;;Signal [~phe]");830 hist5ped.SetTitle("Median calibrated pedestal signal vs event number;;Signal [~phe]");831 hist5cal.SetType(0);832 hist5ped.SetType(0);833 hist5cal.SetMinimum(0);834 hist5ped.SetMinimum(0);835 hist5cal.SetUseMedian();836 hist5ped.SetUseMedian();837 hist5cal.SetNameTime("MTime");838 hist5ped.SetNameTime("MTime");839 840 MFillH fill5cal(&hist5cal, "MSignalCam", "FillCalVsTm");841 MFillH fill5ped(&hist5ped, "MSignalCam", "FillPedVsTm");842 fill5cal.SetFilter(&filtercal);843 fill5ped.SetFilter(&filterped);844 588 845 589 MHCamEvent evt5b(0, "ExtSig", "Extracted signal;;S [mV·sl]"); … … 868 612 //contsw.SetInverted(); 869 613 870 const TString fname(Form("s/([0-9]+_[0-9]+)[.]fits([.]gz)?$/%s\\/$1_C.root/",871 MJob::Esc(outpath).Data()));872 873 614 // The second rule is for the case reading raw-files! 874 MWriteRootFile write5(2, fname, "RECREATE", "Calibrated Data"); 615 616 MWriteRootFile write5(root_file_output_path, "RECREATE", "Calibrated Data", 2); 875 617 write5.AddContainer("MRawRunHeader", "RunHeaders"); 876 618 write5.AddContainer("MGeomCam", "RunHeaders"); … … 879 621 write5.AddContainer("MRawEvtHeader", "Events"); 880 622 //write.AddContainer("MTriggerPattern", "Events"); 881 623 624 882 625 // ------------------ Setup histograms and fill tasks ---------------- 883 626 … … 888 631 tlist5tm.AddToList(&extractor5tm); 889 632 tlist5tm.AddToList(&calctm5tm); 890 tlist5tm.AddToList(&fill5m);891 tlist5tm.AddToList(&fill5n);892 tlist5tm.AddToList(&fill5q);893 tlist5tm.AddToList(&fill5r);894 //tlist5tm.AddToList(&fill5s);895 //tlist5tm.AddToList(&fill5t);896 tlist5tm.AddToList(&fill5u);897 tlist5tm.AddToList(&fill5v);898 tlist5tm.AddToList(&fill5w);899 tlist5tm.AddToList(&fill5x);900 633 tlist5tm.SetFilter(&filtercal); 901 634 … … 922 655 tlist5.AddToList(&conv5); 923 656 tlist5.AddToList(&treat5); 924 tlist5.AddToList(&fill5ped);925 tlist5.AddToList(&fill5cal);926 657 tlist5.AddToList(&tlist5dat); 927 658 tlist5.AddToList(&write5); … … 933 664 return 19; 934 665 935 TString title = "-- Calibrated signal #"; 936 title += seq.GetSequence(); 937 title += " ("; 938 title += drsfile; 939 title += ") --"; 940 d->SetTitle(title, kFALSE); 941 942 TString path; 943 path += Form("%s/20%6d_%03d-calibration.root", outpath, 944 seq.GetSequence()/1000, seq.GetSequence()%1000); 945 946 d->SaveAs(path); 666 d->SetTitle(status_display_title, kFALSE); 667 d->SaveAs(status_display_output_path); 947 668 948 669 return 0; -
branches/Mars_MC/fact/analysis/mc/star.C
r17055 r17056 1 int star(const char *seqfile="sequences/20111205_013.seq", Double_t lvl1=7.8, Double_t lvl2=3.9, const char *inpath = "output", const char *outpath = "output") 1 #include <sstream> 2 #include <iostream> 3 4 #include "TH1F.h" 5 #include "TFile.h" 6 #include "TStyle.h" 7 #include "TGraph.h" 8 #include "TLine.h" 9 10 #include "MDrsCalibration.h" 11 #include "MLogManip.h" 12 #include "MExtralgoSpline.h" 13 #include "MSequence.h" 14 #include "MStatusArray.h" 15 #include "MHCamera.h" 16 #include "MJob.h" 17 #include "MWriteRootFile.h" 18 #include "MHCamera.h" 19 #include "MBadPixelsCam.h" 20 #include "MBadPixelsPix.h" 21 #include "MDirIter.h" 22 #include "MTaskList.h" 23 #include "MFDataPhrase.h" 24 #include "MArrayF.h" 25 #include "MBadPixelsTreat.h" 26 #include "MCalibrateDrsTimes.h" 27 #include "MHSectorVsTime.h" 28 #include "MHCamEvent.h" 29 #include "MExtractTimeAndChargeSpline.h" 30 #include "MFillH.h" 31 #include "MDrsCalibApply.h" 32 #include "MGeomApply.h" 33 #include "MContinue.h" 34 #include "MRawFitsRead.h" 35 #include "MEvtLoop.h" 36 #include "MParList.h" 37 #include "MStatusDisplay.h" 38 #include "MDrsCalibrationTime.h" 39 #include "MH3.h" 40 #include "MGeomCamFACT.h" 41 #include "MCalibrateFact.h" 42 #include "MParameters.h" 43 #include "MWriteAsciiFile.h" 44 45 #include "MMuonSetup.h" 46 #include "MReadMarsFile.h" 47 #include "MHillasCalc.h" 48 #include "MHn.h" 49 #include "MMuonSearchParCalc.h" 50 #include "MMuonCalibParCalc.h" 51 #include "MBinning.h" 52 #include "MImgCleanStd.h" 53 54 55 using namespace std; 56 57 int star_for_monte_carlo_simulated_data( 58 const char *mars_data_file_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/callisto.root", 59 const char *root_output_file_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/star.root", 60 const char *status_display_output_path = "/fhgfs/groups/app/callisto_star_test/callisto_for_mc_test_output/star_status_display.root", 61 const char *status_display_title = "star_status_display_title", 62 const char *hillas_txt_file_path = "/fhgfs/groups/app/callisto_star_test/star_hillas.txt", 63 Double_t lvl1=4.0, 64 Double_t lvl2=2.5, 65 Double_t deltat = 17.5) 2 66 { 3 double deltat = 17.5; 67 //Double_t lvl1=7.8, 68 //Double_t lvl2=3.9, 4 69 // lvl1 = 2.5; 5 70 // lvl2 = 0.5; 6 7 // The sequence file which defines the files for the analysis8 MSequence seq(seqfile);9 if (!seq.IsValid())10 {11 gLog << "ERROR - Sequence invalid!" << endl;12 return 1;13 }14 15 71 // ------------------------------------------------------ 16 72 17 73 gLog.Separator("Star"); 18 gLog << "Calculate image parameters of sequence "; 19 gLog << seq.GetFileName() << endl; 74 gLog << all << "Calculate image parameters of sequence "; 20 75 gLog << endl; 76 gLog << "mars_data_file_path: " << mars_data_file_path << endl; 77 gLog << "root_output_file_path: " << root_output_file_path << endl; 78 gLog << "status_display_output_path: " << status_display_output_path << endl; 79 gLog << "status_display_title: " << status_display_title << endl; 80 gLog << endl; 81 gLog << "lvl1: " << lvl1 <<endl; 82 gLog << "lvl2: " << lvl2 <<endl; 83 84 85 gLog << endl; 21 86 22 87 // ------------------------------------------------------ 23 24 gLog << "Inpath: " << inpath << endl;25 gLog << "Outpath: " << outpath << endl;26 27 const TString rule(Form("s/([0-9]+_[0-9]+)_C[.]root?$/%s\\/$1_I.root/",28 MJob::Esc(outpath).Data()));29 gLog << "Rule: " << rule << endl;30 31 MDirIter iter;32 if (seq.GetRuns(iter, MSequence::kFactCal, inpath)<=0)33 {34 gLog << "ERROR - Sequence valid but without files." << endl;35 return 2;36 }37 38 iter.Print();39 88 40 89 gLog.Separator(); … … 45 94 MBinning bins3( 67, -0.005, 0.665, "BinningTheta", "asin"); 46 95 MBinning bins4( 25, 0, 2.5, "BinningDist"); 47 48 96 MBinning binsM1(100, 0, 5, "BinningMuonRadius"); 49 97 MBinning binsM2( 60, 0, 0.3, "BinningMuonDeviation"); … … 54 102 MBinning binsM7( 30, 5, 5000, "BinningMuonSize", "log"); 55 103 MBinning binsM8(100, 0, 5, "BinningMuonRelTimeSigma"); 56 57 104 MBinning binsM9(100, 0, 5, "BinningRadius"); 58 105 … … 104 151 MReadMarsFile read("Events"); 105 152 read.DisableAutoScheme(); 106 read.AddFile s(iter);153 read.AddFile(mars_data_file_path); 107 154 108 155 MContinue cont("MRawEvtHeader.GetTriggerID!=4", "SelectData"); … … 228 275 // --------------------------------------------------------------- 229 276 230 MWriteRootFile write(2, rule, "RECREATE", "Image parameters"); // EffectiveOnTime 277 MWriteAsciiFile write_ascii_hillas(hillas_txt_file_path, "MHillas"); 278 write_ascii_hillas.AddColumns("MHillasExt"); 279 write_ascii_hillas.AddColumns("MHillasSrc"); 280 281 282 MWriteRootFile write(root_output_file_path, "RECREATE", "Image parameters", 2); 231 283 write.AddContainer("MTime", "Events"); 232 284 write.AddContainer("MHillas", "Events"); … … 238 290 write.AddContainer("MRawRunHeader", "RunHeaders"); 239 291 write.AddContainer("MGeomCam", "RunHeaders"); 240 241 292 MFDataPhrase fmuonhn("MMuonCalibPar.fRelTimeSigma>=0", 242 293 "MuonHistCut"); … … 274 325 //tlist.AddToList(&writem); 275 326 tlist.AddToList(&write); 327 tlist.AddToList(&write_ascii_hillas); 276 328 277 329 if (!loop.Eventloop()) … … 281 333 return 4; 282 334 283 TString title = "-- Image parameters #"; 284 title += seq.GetSequence(); 285 title += " --"; 286 d->SetTitle(title, kFALSE); 287 288 TString path; 289 path += Form("%s/20%06d_%03d-images.root", outpath, 290 seq.GetSequence()/1000, seq.GetSequence()%1000); 291 292 d->SaveAs(path); 335 d->SetTitle(status_display_title, kFALSE); 336 d->SaveAs(status_display_output_path); 293 337 294 338 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.