#include "ansi.h" #include //#include "moench03T1ZmqData.h" //#define DOUBLE_SPH //#define MANYFILES #ifdef DOUBLE_SPH #include "single_photon_hit_double.h" #endif #ifndef DOUBLE_SPH #include "single_photon_hit.h" #endif #include "etaInterpolationPosXY.h" #include "noInterpolation.h" //#include "etaInterpolationAdaptiveBins.h" //#include "etaInterpolationRandomBins.h" using namespace std; #define NC 400 #define NR 400 #define XTALK int main(int argc, char *argv[]) { #ifndef FF if (argc<9) { cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl; return 1; } #endif #ifdef FF if (argc<7) { cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl; return 1; } #endif int iarg=4; char infname[10000]; char fname[10000]; char outfname[10000]; #ifndef FF iarg=4; #endif #ifdef FF iarg=3; #endif int runmin=atoi(argv[iarg++]); int runmax=atoi(argv[iarg++]); cout << "Run min: " << runmin << endl; cout << "Run max: " << runmax << endl; int nsubpix=4; #ifndef FF nsubpix=atoi(argv[iarg++]); cout << "Subpix: " << nsubpix << endl; #endif float cmin=atof(argv[iarg++]); float cmax=atof(argv[iarg++]); cout << "Energy min: " << cmin << endl; cout << "Energy max: " << cmax << endl; int etabins=1000;//nsubpix*2*100; double etamin=-1, etamax=2; double eta3min=-2, eta3max=2; int quad; double sum, totquad; double sDum[2][2]; double etax, etay, int_x, int_y; double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y; int ok; int f0=-1; int ix, iy, isx, isy; int nframes=0, lastframe=-1; double d_x, d_y, res=5, xx, yy; int nph=0, badph=0, totph=0; FILE *f=NULL; #ifdef DOUBLE_SPH single_photon_hit_double cl(3,3); #endif #ifndef DOUBLE_SPH single_photon_hit cl(3,3); #endif eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax); #ifndef FF cout << "read ff " << argv[2] << endl; sprintf(fname,"%s",argv[2]); interp->readFlatField(fname); interp->prepareInterpolation(ok); #endif #ifdef FF cout << "Will write eta file " << argv[2] << endl; #endif int *img; float *totimg=new float[NC*NR*nsubpix*nsubpix]; for (ix=0; ixcalcQuad(cl.get_cluster(), sum, totquad, sDum); if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && totquad200 && sum<580) { // interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y); #ifndef FF interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y); interp->addToImage(int_x, int_y); #endif #ifdef FF interp->addToFlatField(cl.get_cluster(), etax, etay); #endif if (nph%1000000==0) cout << nph << endl; if (nph%100000000==0) { #ifndef FF interp->writeInterpolatedImage(outfname); #endif #ifdef FF interp->writeFlatField(outfname); #endif } } } fclose(f); #ifdef FF interp->writeFlatField(outfname); #endif #ifndef FF interp->writeInterpolatedImage(outfname); img=interp->getInterpolatedImage(); for (ix=0; ixclearInterpolatedImage(); #endif } else cout << "could not open file " << infname << endl; } #ifndef FF sprintf(outfname,argv[3],11111); WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix); #endif #ifdef FF interp->writeFlatField(outfname); #endif cout << "Filled " << nph << " (/"<< totph <<") " << endl; return 0; }