void ExtractCine::execute() { Common::Filename infilename(_inputPaths[0].path); std::string fname = infilename.getFullName(); std::transform(fname.begin(), fname.end(), fname.begin(), toupper); if (fname == "VOL.CNF") { /* Unpack all archive files listed in 'vol.cnf' */ unpackAllResourceFiles(infilename); } else { /* Unpack a single archive file */ Common::File f(infilename, "rb"); unpackFile(f); } }
int evaluate( std::string filelist, std::string outfile ) { gStyle->SetOptStat(0); TCanvas *ctemp = new TCanvas(); TCanvas *cres = new TCanvas("TimeDependence"); TH1F* hres = new TH1F("hres","",100,0,650); hres->GetYaxis()->SetRangeUser(0,50); hres->SetTitle(""); hres->GetXaxis()->SetTitle("time (s)"); hres->GetYaxis()->SetTitle("B_{int} (mT)"); hres->Draw(); leg = new TLegend(0.2,0.6,0.9,0.9); // leg->SetHeader("The Legend Title"); // option "C" allows to center the header leg->SetNColumns(5); vector< double > v_Bint; vector< double > v_BintErr; vector< double > v_Bext; vector< double > v_BextErr; /* Loop over all lines in input file */ std::ifstream infilelist(filelist); std::string line; unsigned colorcounter=38; while (std::getline(infilelist, line)) { // skip lines with '#' and empty lines if ( line.find("#") != string::npos ) { cout << "Skip line " << line << endl; continue; } if ( line == "" ) continue; //cout << "Processing file " << line << endl; TString infilename("data_calib/"); infilename.Append(line); TFile *fin = new TFile( infilename ); TTree *tin = (TTree*)fin->Get("t"); ctemp->cd(); tin->Draw("Bi:time"); TGraph *gtime = new TGraph(tin->GetEntries(), &(tin->GetV2()[0]), &(tin->GetV1()[0])); gtime->SetLineColor(colorcounter); colorcounter++; TH1F* hBext = new TH1F("hBext","",100,0,1000); tin->Draw("Bo >> hBext"); cres->cd(); gtime->Draw("lsame"); double Bext_i = hBext->GetMean(); double BextErr_i = hBext->GetRMS(); double Bint_i = gtime->Eval(590); double BintErr_i = 0; /* add legend entry */ TString legname("B_ext ~ "); legname += (int)Bext_i; leg->AddEntry(gtime,legname,"l"); cout << "B_ext: " << Bext_i << " \t B_int: " << Bint_i << endl; v_Bint.push_back(Bint_i); v_BintErr.push_back(BintErr_i); v_Bext.push_back(Bext_i); v_BextErr.push_back(BextErr_i); } cres->cd(); leg->Draw(); TGraphErrors *gfinal = new TGraphErrors(v_Bext.size(), &(v_Bext[0]), &(v_Bint[0]), &(v_BextErr[0]), &(v_BintErr[0])); gfinal->Sort(); gfinal->SetName("Bint_Vs_Bext"); gfinal->SetTitle(""); gfinal->GetXaxis()->SetTitle("B_{ext} (mT)"); gfinal->GetYaxis()->SetTitle("B_{int} (mT)"); TCanvas *cfinal = new TCanvas(); gfinal->Draw("APL"); /* Save output graph */ TString outfilename("output/"); outfilename.Append(outfile); TFile *fout = new TFile(outfilename,"RECREATE"); cres->Write(); gfinal->Write(); fout->Close(); /* Write result to txt output file */ TString outfilenametxt = outfilename; outfilenametxt.ReplaceAll(".root",".txt"); ofstream foutxt; foutxt.open( outfilenametxt ); foutxt << "# Bo sig_Bo Bi sig_Bi shield sig_shield sf sig_sf time_dependent" << endl; for ( int i = 0; i < gfinal->GetN(); i++ ) { double Bo = gfinal->GetX()[i]; double sig_Bo = gfinal->GetEX()[i]; double Bi = gfinal->GetY()[i]; double sig_Bi = gfinal->GetEY()[i]; double shield = 0; double sig_shield = 0; double sf = 0; double sig_sf = 0; double time_dependent = 0; foutxt << Bo << " " << sig_Bo << " " << Bi << " " << sig_Bi << " " << shield << " " << sig_shield << " " << sf << " " << sig_sf << " " << time_dependent << endl; } return 0; }
/** * \brief Main function in astro namespace */ int main(int argc, char *argv[]) { int c; double gamma = 1.0; double minimum = -1.; double maximum = -1.; bool force = false; // parse the command line int longindex; while (EOF != (c = getopt_long(argc, argv, "df?hm:M:g:", longopts, &longindex))) switch (c) { case 'd': debuglevel = LOG_DEBUG; break; case 'f': force = true; break; case 'g': gamma = std::stod(optarg); break; case 'm': minimum = std::stod(optarg); break; case 'M': maximum = std::stod(optarg); break; case '?': case 'h': usage(argv[0]); return EXIT_SUCCESS; break; default: throw std::runtime_error("unknown option"); } // two more arguments are required: infile and outfile if (2 != argc - optind) { std::string msg("wrong number of arguments"); debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str()); throw std::runtime_error(msg); } std::string infilename(argv[optind++]); std::string outfilename(argv[optind]); debug(LOG_DEBUG, DEBUG_LOG, 0, "calibrate %s to %s", infilename.c_str(), outfilename.c_str()); // read the infile FITSin infile(infilename); ImagePtr image = infile.read(); // convert pixels according to luminance ConstPixelValueAdapter<double> from(image); // get the minimum and maximum values from the input image if (maximum < 0) { maximum = Max<double, double>()(from); } if (minimum < 0) { minimum = Min<double, double>()(from); } debug(LOG_DEBUG, DEBUG_LOG, 0, "min = %f, max = %f", minimum, maximum); // clamping filter ClampingAdapter<double, double> ca(from, minimum, maximum); // rescaling double scale = 1. / (maximum - minimum); RescalingAdapter<double> ra(ca, minimum, scale); // gamma correction GammaAdapter<double> ga(ra, gamma); // rescale back to the range 0-255 RescalingAdapter<double> ra2(ga, 0, 255.); // create image from last adapter Image<double> *outimage = new Image<double>(ra2); ImagePtr outimageptr(outimage); // remove previous file if (force) { unlink(outfilename.c_str()); } // after all the calibrations have been performed, write the output // file FITSout outfile(outfilename); outfile.write(outimageptr); // that's it return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { int c; int longindex; std::string outfilename; bool force = false; float alpha = 0.001; while (EOF != (c = getopt_long(argc, argv, "a:dfho:", longopts, &longindex))) switch (c) { case 'a': alpha = std::stof(optarg); break; case 'd': debuglevel = LOG_DEBUG; break; case 'f': force = true; break; case 'h': usage(argv[0]); return EXIT_SUCCESS; case 'o': outfilename = std::string(optarg); break; default: throw std::runtime_error("unknown option"); } // get the file name if (argc <= optind) { throw std::runtime_error("input file name missing"); } std::string infilename(argv[optind++]); debug(LOG_DEBUG, DEBUG_LOG, 0, "processing image %s", infilename.c_str()); // read the input file FITSin infile(infilename); ImagePtr image = infile.read(); ImagePtr outimage; // prepare a background extractor BackgroundExtractor extractor(alpha); // if this is a mono image, we just use luminance for background // extraction switch (image->planes()) { case 1: { // make image accessible as an image with float pixels ConstPixelValueAdapter<float> from(image); // get the background Background<float> bg = extractor(image->center(), true, BackgroundExtractor::QUADRATIC, from); // subtract the background BackgroundFunctionAdapter bfa(from, bg.G()); // write the result to the output outimage = ImagePtr(new Image<float>(bfa)); } break; case 3: { // make image accessible as an RGB<float> image ConstPixelValueAdapter<RGB<float> > from(image); // get the background Background<float> bg = extractor(image->center(), true, BackgroundExtractor::QUADRATIC, from); // subtract the background BackgroundSubtractionAdapter bsa(from, bg); // write the result to the output outimage = ImagePtr(new Image<RGB<float> >(bsa)); } break; default: std::string msg = stringprintf("don't know how to handle " "background for images with %d planes", image->planes()); debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str()); throw std::runtime_error(msg); } // we give up here, because we don't want to write the changed file if (0 == outfilename.size()) { return EXIT_SUCCESS; } FITSout outfile(outfilename); outfile.setPrecious(!force); outfile.write(outimage); // that's it return EXIT_SUCCESS; }
void makeTemplatesWe() { gBenchmark->Start("makeTemplatesWe"); //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== const Double_t PT_CUT = 25; const Double_t ETA_CUT = 2.5; // input W signal file TString infilename("/data/blue/Bacon/Run2/wz_flat_07_23/Wenu/ntuples/we_select.root"); // file name with Zll data TString datafname("ZeeData/fits_mva.root"); // file name with Zl MC TString zllMCfname("ZeeMC/fits.root"); // file name with Wp MC TString wpMCfname("WepMC/fits.root"); // file name with Wm MC TString wmMCfname("WemMC/fits.root"); // output file name TString outfilename("./testWe.root"); //-------------------------------------------------------------------------------------------------------------- // Main analysis code //============================================================================================================== // Access recoil corrections //RecoilCorrector recoilCorr(datafname,zllMCfname,wpMCfname,wmMCfname); RecoilCorrector recoilCorr(datafname); // // Declare variables to read in ntuple // UInt_t runNum, lumiSec, evtNum; UInt_t npv, npu; Float_t genVPt, genVPhi; Float_t weight, scale1fb, puWeight; Float_t met, metPhi, sumEt, mt, u1, u2; Int_t q; TLorentzVector *lep=0; TLorentzVector *sc=0; // // Set up output TTrees // Float_t out_met; TFile *outFile = new TFile(outfilename,"RECREATE"); TTree *rawWeTree = new TTree("RawWe","RawWe"); rawWeTree->Branch("weight", &weight, "weight/F"); rawWeTree->Branch("out_met", &out_met, "out_met/F"); TTree *rawWepTree = new TTree("RawWep","RawWep"); rawWepTree->Branch("weight", &weight, "weight/F"); rawWepTree->Branch("out_met", &out_met, "out_met/F"); TTree *rawWemTree = new TTree("RawWem","RawWem"); rawWemTree->Branch("weight", &weight, "weight/F"); rawWemTree->Branch("out_met", &out_met, "out_met/F"); TTree *corrWeTree = new TTree("CorrWe","corrWe"); corrWeTree->Branch("weight", &weight, "weight/F"); corrWeTree->Branch("out_met", &out_met, "out_met/F"); TTree *corrWepTree = new TTree("CorrWep","corrWep"); corrWepTree->Branch("weight", &weight, "weight/F"); corrWepTree->Branch("out_met", &out_met, "out_met/F"); TTree *corrWemTree = new TTree("CorrWem","corrWem"); corrWemTree->Branch("weight", &weight, "weight/F"); corrWemTree->Branch("out_met", &out_met, "out_met/F"); TTree *corrUpWeTree = new TTree("CorrUpWe","corrUpWe"); corrUpWeTree->Branch("weight", &weight, "weight/F"); corrUpWeTree->Branch("out_met", &out_met, "out_met/F"); TTree *corrUpWepTree = new TTree("CorrUpWep","corrUpWep"); corrUpWepTree->Branch("weight", &weight, "weight/F"); corrUpWepTree->Branch("out_met", &out_met, "out_met/F"); TTree *corrUpWemTree = new TTree("CorrUpWem","corrUpWem"); corrUpWemTree->Branch("weight", &weight, "weight/F"); corrUpWemTree->Branch("out_met", &out_met, "out_met/F"); TTree *corrDownWeTree = new TTree("CorrDownWe","corrDownWe"); corrDownWeTree->Branch("weight", &weight, "weight/F"); corrDownWeTree->Branch("out_met", &out_met, "out_met/F"); TTree *corrDownWepTree = new TTree("CorrDownWep","corrDownWep"); corrDownWepTree->Branch("weight", &weight, "weight/F"); corrDownWepTree->Branch("out_met", &out_met, "out_met/F"); TTree *corrDownWemTree = new TTree("CorrDownWem","corrDownWem"); corrDownWemTree->Branch("weight", &weight, "weight/F"); corrDownWemTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepScaleUpWeTree = new TTree("LepScaleUpWe","lepScaleUpWe"); lepScaleUpWeTree->Branch("weight", &weight, "weight/F"); lepScaleUpWeTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepScaleUpWepTree = new TTree("LepScaleUpWep","lepScaleUpWep"); lepScaleUpWepTree->Branch("weight", &weight, "weight/F"); lepScaleUpWepTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepScaleUpWemTree = new TTree("LepScaleUpWem","lepScaleUpWem"); lepScaleUpWemTree->Branch("weight", &weight, "weight/F"); lepScaleUpWemTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepScaleDownWeTree = new TTree("LepScaleDownWe","lepScaleDownWe"); lepScaleDownWeTree->Branch("weight", &weight, "weight/F"); lepScaleDownWeTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepScaleDownWepTree = new TTree("LepScaleDownWep","lepScaleDownWep"); lepScaleDownWepTree->Branch("weight", &weight, "weight/F"); lepScaleDownWepTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepScaleDownWemTree = new TTree("LepScaleDownWem","lepScaleDownWem"); lepScaleDownWemTree->Branch("weight", &weight, "weight/F"); lepScaleDownWemTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepResUpWeTree = new TTree("LepResUpWe","lepResUpWe"); lepResUpWeTree->Branch("weight", &weight, "weight/F"); lepResUpWeTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepResUpWepTree = new TTree("LepResUpWep","lepResUpWep"); lepResUpWepTree->Branch("weight", &weight, "weight/F"); lepResUpWepTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepResUpWemTree = new TTree("LepResUpWem","lepResUpWem"); lepResUpWemTree->Branch("weight", &weight, "weight/F"); lepResUpWemTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepResDownWeTree = new TTree("LepResDownWe","lepResDownWe"); lepResDownWeTree->Branch("weight", &weight, "weight/F"); lepResDownWeTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepResDownWepTree = new TTree("LepResDownWep","lepResDownWep"); lepResDownWepTree->Branch("weight", &weight, "weight/F"); lepResDownWepTree->Branch("out_met", &out_met, "out_met/F"); TTree *lepResDownWemTree = new TTree("LepResDownWem","lepResDownWem"); lepResDownWemTree->Branch("weight", &weight, "weight/F"); lepResDownWemTree->Branch("out_met", &out_met, "out_met/F"); TFile *infile=0; TTree *intree=0; // Read input file and get the TTrees cout << "Processing " << infilename << "..." << endl; infile = TFile::Open(infilename); assert(infile); intree = (TTree*)infile->Get("Events"); assert(intree); intree->SetBranchAddress("runNum", &runNum); // event run number intree->SetBranchAddress("lumiSec", &lumiSec); // event lumi section intree->SetBranchAddress("evtNum", &evtNum); // event number intree->SetBranchAddress("npv", &npv); // number of primary vertices intree->SetBranchAddress("npu", &npu); // number of in-time PU events (MC) intree->SetBranchAddress("genVPt", &genVPt); // GEN W boson pT (signal MC) intree->SetBranchAddress("genVPhi", &genVPhi); // GEN W boson phi (signal MC) intree->SetBranchAddress("scale1fb", &scale1fb); // event weight per 1/fb (MC) intree->SetBranchAddress("puWeight", &puWeight); // pileup reweighting intree->SetBranchAddress("mvaMet", &met); // MET intree->SetBranchAddress("mvaMetPhi",&metPhi); // phi(MET) intree->SetBranchAddress("mvaSumEt", &sumEt); // Sum ET intree->SetBranchAddress("mvaMt", &mt); // transverse mass intree->SetBranchAddress("mvaU1", &u1); // parallel component of recoil intree->SetBranchAddress("mvaU2", &u2); // perpendicular component of recoil intree->SetBranchAddress("q", &q); // lepton charge intree->SetBranchAddress("lep", &lep); // lepton 4-vector intree->SetBranchAddress("sc", &sc); // electron Supercluster 4-vector // // loop over events // for(UInt_t ientry=0; ientry<intree->GetEntries(); ientry++) { intree->GetEntry(ientry); weight=scale1fb*puWeight; if(sc->Pt() < PT_CUT) continue; if(fabs(sc->Eta()) > ETA_CUT) continue; // uncorrected MET out_met = met; rawWeTree->Fill(); if(q>0) rawWepTree->Fill(); else rawWemTree->Fill(); Double_t corrMet=met, corrMetPhi=metPhi; Double_t lepPt=lep->Pt(), lepPhi=lep->Phi(); // apply recoil corrections with nominal lepton scale and resolution corrections lepPt = gRandom->Gaus(lep->Pt()*getEleScaleCorr(lep->Eta(),0), getEleResCorr(lep->Eta(),0)); recoilCorr.Correct(corrMet,corrMetPhi,genVPt,genVPhi,lepPt,lepPhi,0,0); out_met = corrMet; corrWeTree->Fill(); if(q>0) corrWepTree->Fill(); else corrWemTree->Fill(); // recoil corrections "up" recoilCorr.Correct(corrMet,corrMetPhi,genVPt,genVPhi,lepPt,lepPhi,1,0); out_met = corrMet; corrUpWeTree->Fill(); if(q>0) corrUpWepTree->Fill(); else corrUpWemTree->Fill(); // recoil corrections "down" recoilCorr.Correct(corrMet,corrMetPhi,genVPt,genVPhi,lepPt,lepPhi,-1,0); out_met = corrMet; corrDownWeTree->Fill(); if(q>0) corrDownWepTree->Fill(); else corrDownWemTree->Fill(); // lepton scale "up" lepPt = gRandom->Gaus(lep->Pt()*getEleScaleCorr(lep->Eta(),1), getEleResCorr(lep->Eta(),0)); recoilCorr.Correct(corrMet,corrMetPhi,genVPt,genVPhi,lepPt,lepPhi,0,0); out_met = corrMet; lepScaleUpWeTree->Fill(); if(q>0) lepScaleUpWepTree->Fill(); else lepScaleUpWemTree->Fill(); // lepton scale "down" lepPt = gRandom->Gaus(lep->Pt()*getEleScaleCorr(lep->Eta(),-1), getEleResCorr(lep->Eta(),0)); recoilCorr.Correct(corrMet,corrMetPhi,genVPt,genVPhi,lepPt,lepPhi,0,0); out_met = corrMet; lepScaleDownWeTree->Fill(); if(q>0) lepScaleDownWepTree->Fill(); else lepScaleDownWemTree->Fill(); // lepton resolution "up" lepPt = gRandom->Gaus(lep->Pt()*getEleScaleCorr(lep->Eta(),0), getEleResCorr(lep->Eta(),1)); recoilCorr.Correct(corrMet,corrMetPhi,genVPt,genVPhi,lepPt,lepPhi,0,0); out_met = corrMet; lepResUpWeTree->Fill(); if(q>0) lepResUpWepTree->Fill(); else lepResUpWemTree->Fill(); // lepton resolution "down" lepPt = gRandom->Gaus(lep->Pt()*getEleScaleCorr(lep->Eta(),0), TMath::Max(getEleResCorr(lep->Eta(),-1),0.0)); recoilCorr.Correct(corrMet,corrMetPhi,genVPt,genVPhi,lepPt,lepPhi,0,0); out_met = corrMet; lepResDownWeTree->Fill(); if(q>0) lepResDownWepTree->Fill(); else lepResDownWemTree->Fill(); } delete infile; infile=0, intree=0; //-------------------------------------------------------------------------------------------------------------- // Output //============================================================================================================== cout << "*" << endl; cout << "* SUMMARY" << endl; cout << "*--------------------------------------------------" << endl; outFile->Write(); outFile->Close(); delete outFile; cout << endl; cout << " <> Output: " << outfilename << endl; cout << endl; gBenchmark->Show("makeTemplatesWe"); }
int main(int argc, char** argv) { const int NUM_ARGS = 3; if (argc != NUM_ARGS+1) { printUsage(argc, argv); return 1; } string infilename(argv[1]); string outfilename(argv[2]); int iterations = atoi(argv[3]); PatternBlock tblock; FieldReader reader; byte *in = new byte[(NUMBER_OF_ROWS+2)*(NUMBER_OF_COLS+2)]; #ifdef MEASUREMENTS byte *cpuout = new byte[(NUMBER_OF_ROWS+2)*(NUMBER_OF_COLS+2)]; #endif assert(reader.readFile(infilename)); assert(reader.buildField(in,NUMBER_OF_COLS+2,NUMBER_OF_ROWS+2)); //< leave dead margin clearMargin(in,NUMBER_OF_COLS+2,NUMBER_OF_ROWS+2); #ifdef MEASUREMENTS writeBufToFile(outfilename,"in",in,NUMBER_OF_COLS,NUMBER_OF_ROWS); #endif byte *gpuout = host(in,iterations); #ifndef MEASUREMENTS writeBufToFile(outfilename,gpuout,NUMBER_OF_COLS,NUMBER_OF_ROWS); #else writeBufToFile(outfilename,"gpu",gpuout,NUMBER_OF_COLS,NUMBER_OF_ROWS); cpuSim(iterations,in,cpuout,NUMBER_OF_COLS,NUMBER_OF_ROWS); if (iterations % 2 == 0) { byte *tmp = cpuout; cpuout = in; in = tmp; } writeBufToFile(outfilename,"cpu",cpuout,NUMBER_OF_COLS,NUMBER_OF_ROWS); int errors = 0; for(int j=0;j<NUMBER_OF_ROWS;j++) { for(int i=0;i<NUMBER_OF_COLS;i++) { if (cpuout[(j+1)*(NUMBER_OF_COLS+2) + (i+1)] != gpuout[(j+1)*(NUMBER_OF_COLS+2) + (i+1)]) { errors +=1; std::cout << "f****d " << j << " " << i << " (CPU=[" << (int)(cpuout[(j+1)*(NUMBER_OF_COLS+2) + (i+1)]) << "],GPU=[" << (int)(gpuout[(j+1)*(NUMBER_OF_COLS+2) + (i+1)]) << "])\n"; if (errors == 5) break; } } if (errors == 5) break; } if(errors > 0) { std::cout << "Errors Detected" << "\n"; } else { std::cout << "all good\n"; } delete[] cpuout; #endif delete[] in; delete[] gpuout; return 0; }
/** * \brief Main function in astro namespace */ int main(int argc, char *argv[]) { int c; const char *darkfilename = NULL; const char *flatfilename = NULL; double minvalue = -1; double maxvalue = -1; bool demosaic = false; bool interpolate = false; // parse the command line while (EOF != (c = getopt(argc, argv, "dD:F:?hm:M:bi"))) switch (c) { case 'd': debuglevel = LOG_DEBUG; break; case 'D': darkfilename = optarg; break; case 'F': flatfilename = optarg; break; case 'm': minvalue = atof(optarg); break; case 'M': maxvalue = atof(optarg); break; case 'b': demosaic = true; break; case 'i': interpolate = true; break; case '?': case 'h': usage(argv[0]); return EXIT_SUCCESS; break; } // two more arguments are required: infile and outfile if (2 != argc - optind) { std::string msg("wrong number of arguments"); debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str()); throw std::runtime_error(msg); } std::string infilename(argv[optind++]); std::string outfilename(argv[optind]); debug(LOG_DEBUG, DEBUG_LOG, 0, "calibrate %s to %s", infilename.c_str(), outfilename.c_str()); // read the infile FITSin infile(infilename); ImagePtr image = infile.read(); // build the Imager Imager imager; // if we have a dark correction, apply it ImagePtr dark; if (NULL != darkfilename) { debug(LOG_DEBUG, DEBUG_LOG, 0, "dark correct: %s", darkfilename); FITSin darkin(darkfilename); dark = darkin.read(); imager.dark(dark); imager.darksubtract(true); } // if we have a flat file, we perform flat correction if (NULL != flatfilename) { debug(LOG_DEBUG, DEBUG_LOG, 0, "flat correction: %s", flatfilename); FITSin flatin(flatfilename); ImagePtr flat = flatin.read(); imager.flat(flat); imager.flatdivide(true); } // perform bad pixel interpolation if (interpolate) { imager.interpolate(true); } // apply imager corrections imager(image); // if minvalue or maxvalue are set, clamp the image values if ((minvalue >= 0) || (maxvalue >= 0)) { if (minvalue < 0) { minvalue = 0; } if (maxvalue < 0) { maxvalue = std::numeric_limits<double>::infinity(); } Clamper clamp(minvalue, maxvalue); clamp(image); } // after all the calibrations have been performed, write the output // file FITSout outfile(outfilename); // if demosaic is requested we do that now if (demosaic) { ImagePtr demosaiced = demosaic_bilinear(image); outfile.write(demosaiced); } else { outfile.write(image); } // that's it return EXIT_SUCCESS; }