void generateProfile(modOrigin modelOrigin, modVersion modelVersion, modExtent modelExtent, char *outputDirectory) { printf("Generating model version %f.\n", modelVersion.version); // generate the model grid gridStruct *location = NULL; location = generateModelGrid(modelOrigin,modelExtent); // obtain surface filenames based off version number surfNames surfSubModNames; surfSubModNames = getSurfSubModNames(modelVersion); // determine the depths of each surface for each lat lon point surfaceDepthsGlobal *surfDepsGlob = NULL; location->saveSurfaceDepths = 0; surfDepsGlob = getSurfaceValues(location, surfSubModNames, outputDirectory); // assign values globalDataValues *globDataVals = NULL; globDataVals = assignValues(modelVersion, location, surfSubModNames, surfDepsGlob, outputDirectory); // write profile to file writeIndividualProfile(globDataVals, location, outputDirectory); // free allocated memory free(surfDepsGlob); free(globDataVals); free(location); }
Matrix *readMatrix(char *fileName) { FILE *fp = fopen(fileName, "r"); if (fp == NULL) { fprintf(stderr, "Cannot open file: %s\n", fileName); return NULL; } int ch; int size = 0; while (EOF != (ch = fgetc(fp)) && ch != '\n') { if (ch == ' ') size++; } size++; rewind(fp); size_t buffer_size = 80; char *buffer = malloc(buffer_size * sizeof(char)); Matrix *mat = createMat(size); //read each line and write to matrix. int line_number = 0; while(-1 != getline(&buffer, &buffer_size, fp)) { assignValues(mat, buffer, line_number); line_number++; } fflush(stdout); //close file and clean up buffer fclose(fp); free(buffer); return mat; }
//This controls the process of finding the determinate of a matrix. void theProcess(void) { keyLocationsANDnumbers(); assignValues (); minorCreator(); minorValues(); twoBYtwoValues(); termGrouping(); calculateDeterminate(); }
void recordRecursiveCalls(struct functionCall * array, int exp, int base) { int i, curRes = 1; for(i = exp; i >= 0; i--) { assignValues(array, i, curRes, i+1, exp-i); curRes = curRes*base; } }
void recordRecursiveCalls(struct functionCall * array, int exp, int base) { int i, res = 1, currentValue, recursiveCallNumber; for (i = exp; i >= 0; i--) { currentValue = res; res *= base; recursiveCallNumber = i+1; assignValues(array, i, currentValue, recursiveCallNumber, exp-i); } }
int main(){ // char treeA[]={'1','2','V','3','V','4','V','5','V','6','V','7','V','8','V','9','V','a','V','b','V','c','V','d','V','e','V','f','V','g','V','i','V','j','V','k','V','l','V'}; // char treeB[]={'1','2','H','3','H','4','H','5','H','6','H','7','H','8','H','9','H','a','H','b','H','c','H','d','H','e','H','f','H','g','H','i','H','j','H','k','H','l','H'}; // char treeC[]={'2','1','3','5','4','6','H','7','V','H','V','a','8','V','9','H','c','V','H','g','H','i','b','d','H','k','V','H','f','e','H','V','l','H','V','j','H','V','H'}; // char value[]={'1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','i','j','k','l'}; //double areaNode[]={13.60, 3.69, 16.71, 1.87, 5.29, 2.06, 17.80, 4.35, 16.86, 1.96, 15.19, 11.20, 11.48, 10.61, 19.72, 19.37, 2.64, 7.22, 3.18, 10.35}; //double ratio[]={0.52, 0.30, 0.50, 0.35, 1.15, 0.70, 0.25, 0.55, 0.75, 1.07, 0.36, 1.88, 0.51, 0.25, 0.28, 0.42, 0.56, 0.45, 0.25, 0.45}; vector <double> right, left; vector <double> width, height; vector <char> value, Polish; int size; double area; readin(value, width, height);// reads in values from files Polish.push_back(value[0]); for(int z=1; z<value.size(); z++) { Polish.push_back(value[z]); Polish.push_back('V'); } // for(int y=0; y<Polish.size(); y++) // { // cout<<Polish[y]<<" "; // } node *root=new node;//creates a node for the base of tree root->right=NULL; root->left=NULL; //size=sizeof(treeA)-1; size=Polish.size()-1; createTree(root, size , Polish); //size=sizeof(treeA); size=Polish.size(); assignValues(value, width, height, root); // checkTosee (root); area=areaFunct(right,left, root); cout<<"AREA of A:"<<area; /* size = sizeof(treeB)-1; createTree(root, size, treeB); size=sizeof(treeB); assignValues(value, width, height, root ); area=areaFunct(right,left, root); cout<<"AREA of B:"<<area; size = sizeof(treeC)-1; createTree(root, size, treeC); size=sizeof(treeC); assignValues(value, width, height, root); area=areaFunct(right,left, root); cout<<"AREA of C:"<<area; */ annealingFunc(Polish, value, width,height); return 0; }
void generateSlice(modOrigin modelOrigin, sliceExtent sliceBounds, modVersion modelVersion, char *outputDirectory) { globalDataValues *globDataVals = NULL; surfaceDepthsGlobal *surfDepsGlob = NULL; sliceExtractData *sliceData; sliceData = malloc(sizeof(sliceExtractData)); generateSliceXYpoints(sliceData, modelOrigin, sliceBounds); // generate the model grid gridStruct *location; location = malloc(sizeof(gridStruct)); location->saveSurfaceDepths = 1; int nZ = (sliceBounds.zMax-sliceBounds.zMin)/sliceBounds.resZ; location->nX = sliceData->nPts; location->nY = 1; location->nZ = nZ; // ensure the number of points does not exceed that of the struct preallocation printf("nx: %i, ny: %i, nz: %i.\n", location->nX, location->nY, location->nZ); assert(location->nX<=LON_GRID_DIM_MAX); assert(location->nY<=LAT_GRID_DIM_MAX); assert(location->nZ<=DEP_GRID_DIM_MAX); for(int i = 0; i < sliceData->nPts; i++) { location->Lat[i][0] = sliceData->latPts[i]; location->Lon[i][0] = sliceData->lonPts[i]; } for(int j = 0; j < nZ; j++) { location->Z[j] = -1000*(sliceBounds.zMin + sliceBounds.resZ*(j+0.5)); } // obtain surface filenames based off version number surfNames surfSubModNames; surfSubModNames = getSurfSubModNames(modelVersion); // determine the depths of each surface for each lat lon point surfDepsGlob = getSurfaceValues(location, surfSubModNames, outputDirectory); // assign values globDataVals = assignValues(modelVersion, location, surfSubModNames, surfDepsGlob, outputDirectory); // loop over points and extract values for(int i = 0; i < sliceData->nPts; i++) { for(int k = 0; k < location->nZ; k++) { sliceData->Vp[i][k] = globDataVals->Vp[i][0][k]; sliceData->Vs[i][k] = globDataVals->Vs[i][0][k]; sliceData->Rho[i][k] = globDataVals->Rho[i][0][k]; } } if (sliceBounds.saveSlices == 1) { // generate file for writing FILE *fp2; double currRho, currVp, currVs; static int sliceNumber = 0; sliceNumber += 1; char fName[128]; char sliceDir[128]; sprintf(sliceDir,"%s/Slices",outputDirectory); struct stat st = {0}; if (stat(sliceDir, &st) == -1) { // create output directory and the velocity model mkdir(sliceDir, 0700); } sprintf(fName,"%s/GeneratedSlice%i.txt",sliceDir,sliceNumber); fp2 = fopen(fName,"w"); fprintf(fp2,"Generated slice #%i.\n",sliceNumber); fprintf(fp2,"Slice_Horizontal_Resolution\t%i\n",sliceBounds.resXY); fprintf(fp2,"LatA:\t%lf\n",sliceData->latPts[0]); fprintf(fp2,"LatB:\t%lf\n",sliceData->latPts[sliceData->nPts-1]); fprintf(fp2,"LonA:\t%lf\n",sliceData->lonPts[0]); fprintf(fp2,"LonB:\t%lf\n",sliceData->lonPts[sliceData->nPts-1]); fprintf(fp2,"Lat \t Lon \t Depth \t Vp \t Vs \t Rho\n"); for(int i = 0; i < sliceData->nPts; i++) { for(int m = 0; m < location->nZ; m++) { currVp = sliceData->Vp[i][m]; currRho = sliceData->Rho[i][m]; currVs = sliceData->Vs[i][m]; fprintf(fp2, "%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",sliceData->latPts[i],sliceData->lonPts[i], location->Z[m], currVp, currVs, currRho); } } fclose(fp2); printf("High resolution velocity model slice file save complete.\n"); } free(location); free(sliceData); free(globDataVals); free(surfDepsGlob); }
int main( int argc, char* argv[] ) { DrawTools::setStyle(); TGaxis::SetMaxDigits(3); std::string tag="V0"; std::string runName = ""; if( argc<3 ) { std::cout << "USAGE: ./alignTracking [startTag] [run]" << std::endl; exit(11); } else if(argc>1) { std::string tag_str(argv[1]); tag = tag_str; if(argc>2){ std::string runName_str(argv[2]); runName = runName_str; } } // this is the dir in which the offsets will be saved: std::string constDirName = "Alignment"; system(Form("mkdir -p %s", constDirName.c_str())); std::string constFileName = constDirName+"/offsets_"+tag+".txt"; AlignmentOfficer alignOfficer(constFileName); // TFile* file = TFile::Open("data/run_487.root"); // TFile* file = TFile::Open("data/run_428.root"); //200 GeV // TFile* file = TFile::Open("data/run_407.root"); //150 GeV // TFile* file = TFile::Open("data/run_418.root"); //100 GeV //TFile* file = TFile::Open("data/run_398.root"); //50 GeV // TFile* file = TFile::Open("data/run_455.root"); //20 GeV // TFile* file = TFile::Open("data/run_508.root"); //20 GeV seems to be better than run 455 // TFile* file = TFile::Open("data/run_457.root"); //15 GeV //TFile* file = TFile::Open("data/run_431.root"); //10 GeV // TFile* file = TFile::Open("data/run_273.root"); std::string fileName="dcap://t3se01.psi.ch:22125//pnfs/psi.ch/cms/trivcat/store/user/micheli/rawData/output_run"+runName+".root"; char* hostName = getenv ("HOSTNAME"); TString hostString(hostName); bool isLxplus = hostString.Contains("lxplus"); if(isLxplus) fileName= "xroot://t3se01.psi.ch:1094//store/user/micheli/rawData/output_run" + runName + ".root"; TFile* file = TFile::Open(fileName.c_str()); TTree* tree = (TTree*)file->Get("outputTree"); std::cout<<"Reading run:"<<runName<<std::endl; // Declaration of leaf types UInt_t runNumber; UInt_t spillNumber; UInt_t evtNumber; std::vector<float> *BGOvalues; std::vector<float> *SCINTvalues; std::vector<float> *TDCreco; std::vector<float> *digi_charge_integrated; std::vector<float> *digi_max_amplitude; std::vector<float> *digi_pedestal; std::vector<float> *digi_pedestal_rms; std::vector<float> *digi_time_at_frac30; std::vector<float> *digi_time_at_frac50; std::vector<float> *digi_time_at_max; std::vector<bool> *HODOX1; std::vector<bool> *HODOX2; std::vector<bool> *HODOY1; std::vector<bool> *HODOY2; std::vector<float> *HODOSMALLvalues; Float_t TableX; Float_t TableY; Float_t CeF3HV; Float_t BGOHV; Float_t BeamEnergy; Float_t BeamTilt; Int_t IsPhysics; std::vector<int> *nTdcHits; std::vector<float> *digi_charge_integrated_sub; std::vector<float> *digi_max_amplitude_sub; std::vector<float> *digi_pedestal_sub; std::vector<float> *digi_pedestal_rms_sub; std::vector<float> *digi_charge_integrated_corr2; std::vector<float> *digi_max_amplitude_corr2; // List of branches TBranch *b_runNumber; //! TBranch *b_spillNumber; //! TBranch *b_evtNumber; //! TBranch *b_BGOvalues; //! TBranch *b_SCINTvalues; //! TBranch *b_HODOSMALLvalues; //! TBranch *b_TDCreco; //! TBranch *b_digi_charge_integrated; //! TBranch *b_digi_max_amplitude; //! TBranch *b_digi_pedestal; //! TBranch *b_digi_pedestal_rms; //! TBranch *b_digi_time_at_frac30; //! TBranch *b_digi_time_at_frac50; //! TBranch *b_digi_time_at_max; //! TBranch *b_HODOX1; //! TBranch *b_HODOX2; //! TBranch *b_HODOY1; //! TBranch *b_HODOY2; //! TBranch *b_TableX; //! TBranch *b_TableY; //! TBranch *b_CeF3HV; //! TBranch *b_BGOHV; //! TBranch *b_BeamEnergy; //! TBranch *b_BeamTilt; //! TBranch *b_IsPhysics; //! TBranch *b_nTdcHits; //! TBranch *b_digi_charge_integrated_sub; //! TBranch *b_digi_max_amplitude_sub; //! TBranch *b_digi_pedestal_sub; //! TBranch *b_digi_pedestal_rms_sub; //! TBranch *b_digi_charge_integrated_corr2; //! TBranch *b_digi_max_amplitude_corr2; //! // Set object pointer BGOvalues = 0; SCINTvalues = 0; TDCreco = 0; HODOSMALLvalues = 0; digi_charge_integrated = 0; digi_max_amplitude = 0; digi_pedestal = 0; digi_pedestal_rms = 0; digi_time_at_frac30 = 0; digi_time_at_frac50 = 0; digi_time_at_max = 0; HODOX1 = 0; HODOX2 = 0; HODOY1 = 0; HODOY2 = 0; nTdcHits = 0; digi_charge_integrated_sub = 0; digi_max_amplitude_sub = 0; digi_pedestal_sub = 0; digi_pedestal_rms_sub = 0; digi_charge_integrated_corr2 = 0; digi_max_amplitude_corr2 = 0; //Set Branch Adresses and branch pointers tree->SetBranchAddress("runNumber", &runNumber, &b_runNumber); tree->SetBranchAddress("spillNumber", &spillNumber, &b_spillNumber); tree->SetBranchAddress("evtNumber", &evtNumber, &b_evtNumber); tree->SetBranchAddress("BGOvalues", &BGOvalues, &b_BGOvalues); tree->SetBranchAddress("SCINTvalues", &SCINTvalues, &b_SCINTvalues); tree->SetBranchAddress("HODOSMALLvalues", &HODOSMALLvalues, &b_HODOSMALLvalues); tree->SetBranchAddress("TDCreco", &TDCreco, &b_TDCreco); tree->SetBranchAddress("digi_charge_integrated", &digi_charge_integrated, &b_digi_charge_integrated); tree->SetBranchAddress("digi_max_amplitude", &digi_max_amplitude, &b_digi_max_amplitude); tree->SetBranchAddress("digi_pedestal", &digi_pedestal, &b_digi_pedestal); tree->SetBranchAddress("digi_pedestal_rms", &digi_pedestal_rms, &b_digi_pedestal_rms); tree->SetBranchAddress("digi_time_at_frac30", &digi_time_at_frac30, &b_digi_time_at_frac30); tree->SetBranchAddress("digi_time_at_frac50", &digi_time_at_frac50, &b_digi_time_at_frac50); tree->SetBranchAddress("digi_time_at_max", &digi_time_at_max, &b_digi_time_at_max); tree->SetBranchAddress("HODOX1", &HODOX1, &b_HODOX1); tree->SetBranchAddress("HODOX2", &HODOX2, &b_HODOX2); tree->SetBranchAddress("HODOY1", &HODOY1, &b_HODOY1); tree->SetBranchAddress("HODOY2", &HODOY2, &b_HODOY2); tree->SetBranchAddress("TableX", &TableX, &b_TableX); tree->SetBranchAddress("TableY", &TableY, &b_TableY); tree->SetBranchAddress("CeF3HV", &CeF3HV, &b_CeF3HV); tree->SetBranchAddress("BGOHV", &BGOHV, &b_BGOHV); tree->SetBranchAddress("BeamEnergy", &BeamEnergy, &b_BeamEnergy); tree->SetBranchAddress("BeamTilt", &BeamTilt, &b_BeamTilt); tree->SetBranchAddress("IsPhysics", &IsPhysics, &b_IsPhysics); tree->SetBranchAddress("nTdcHits", &nTdcHits, &b_nTdcHits); tree->SetBranchAddress("digi_charge_integrated_sub", &digi_charge_integrated_sub, &b_digi_charge_integrated_sub); tree->SetBranchAddress("digi_max_amplitude_sub", &digi_max_amplitude_sub, &b_digi_max_amplitude_sub); tree->SetBranchAddress("digi_pedestal_sub", &digi_pedestal_sub, &b_digi_pedestal_sub); tree->SetBranchAddress("digi_pedestal_rms_sub", &digi_pedestal_rms_sub, &b_digi_pedestal_rms_sub); tree->SetBranchAddress("digi_charge_integrated_corr2", &digi_charge_integrated_corr2, &b_digi_charge_integrated_corr2); tree->SetBranchAddress("digi_max_amplitude_corr2", &digi_max_amplitude_corr2, &b_digi_max_amplitude_corr2); int nClusters_hodoX1; int nFibres_hodoX1[HODOX1_CHANNELS]; float pos_hodoX1[HODOX1_CHANNELS]; int nClusters_hodoY1; int nFibres_hodoY1[HODOY1_CHANNELS]; float pos_hodoY1[HODOY1_CHANNELS]; int nClusters_hodoX2; int nFibres_hodoX2[HODOX2_CHANNELS]; float pos_hodoX2[HODOX2_CHANNELS]; int nClusters_hodoY2; int nFibres_hodoY2[HODOY2_CHANNELS]; float pos_hodoY2[HODOY2_CHANNELS]; float wc_x; float wc_y; //int nBins = 80*2*2*2*2; int nBins = 80; // int nBinsWC = 40*5; int nBinsWC = 80; float xMin = -20.; float xMax = 20.; TH1F* h1_wc_y_low = new TH1F("wc_y_low", "", nBinsWC, xMin, xMax); TH1F* h1_wc_y_hi = new TH1F("wc_y_hi" , "", nBinsWC, xMin, xMax); TH1F* h1_wc_x_low = new TH1F("wc_x_low", "", nBinsWC, xMin, xMax); TH1F* h1_wc_x_hi = new TH1F("wc_x_hi" , "", nBinsWC, xMin, xMax); TH1F* h1_hodoY1_low = new TH1F("hodoY1_low", "", nBins, xMin, xMax); TH1F* h1_hodoY1_hi = new TH1F("hodoY1_hi" , "", nBins, xMin, xMax); TH1F* h1_hodoX1_low = new TH1F("hodoX1_low", "", nBins, xMin, xMax); TH1F* h1_hodoX1_hi = new TH1F("hodoX1_hi" , "", nBins, xMin, xMax); TH1F* h1_hodoY2_low = new TH1F("hodoY2_low", "", nBins, xMin, xMax); TH1F* h1_hodoY2_hi = new TH1F("hodoY2_hi" , "", nBins, xMin, xMax); TH1F* h1_hodoX2_low = new TH1F("hodoX2_low", "", nBins, xMin, xMax); TH1F* h1_hodoX2_hi = new TH1F("hodoX2_hi" , "", nBins, xMin, xMax); int nentries = tree->GetEntries(); if(nentries>10000) nentries=10000; for( unsigned iEntry=0; iEntry<nentries; ++iEntry ) { tree->GetEntry(iEntry); if( iEntry % 10000 == 0 ) std::cout << "Entry: " << iEntry << " / " << nentries << std::endl; std::vector<bool> hodoX1_values(HODOX1_CHANNELS, -1.); std::vector<bool> hodoY1_values(HODOY1_CHANNELS, -1.); assignValuesBool( hodoX1_values, *HODOX1, 0. ); assignValuesBool( hodoY1_values, *HODOY1, 0. ); std::vector<bool> hodoX2_values(HODOX2_CHANNELS, -1.); std::vector<bool> hodoY2_values(HODOY2_CHANNELS, -1.); assignValuesBool( hodoX2_values, *HODOX2, 0 ); assignValuesBool( hodoY2_values, *HODOY2, 0 ); std::vector<float> hodoSmallX_values(HODOSMALLX_CHANNELS, -1.); std::vector<float> hodoSmallY_values(HODOSMALLY_CHANNELS, -1.); assignValues( hodoSmallY_values, *HODOSMALLvalues, 0 ); assignValues( hodoSmallX_values, *HODOSMALLvalues, 4 ); // hodo cluster reconstruction int clusterMaxFibres = 4; doHodoReconstructionBool( hodoX1_values , nClusters_hodoX1 , nFibres_hodoX1 , pos_hodoX1 , 0.5, clusterMaxFibres, 0. ); doHodoReconstructionBool( hodoY1_values , nClusters_hodoY1 , nFibres_hodoY1 , pos_hodoY1 , 0.5, clusterMaxFibres, 0. ); doHodoReconstructionBool( hodoX2_values , nClusters_hodoX2 , nFibres_hodoX2 , pos_hodoX2 , 0.5, clusterMaxFibres, 0. ); doHodoReconstructionBool( hodoY2_values , nClusters_hodoY2 , nFibres_hodoY2 , pos_hodoY2 , 0.5, clusterMaxFibres, 0. ); alignOfficer.fix("hodoX1", nClusters_hodoX1, pos_hodoX1); alignOfficer.fix("hodoY1", nClusters_hodoY1, pos_hodoY1); alignOfficer.fix("hodoX2", nClusters_hodoX2, pos_hodoX2); alignOfficer.fix("hodoY2", nClusters_hodoY2, pos_hodoY2); wc_x = TDCreco->at(0); wc_y = TDCreco->at(1); if( runNumber>=170 ) wc_y = -wc_y; // temporary fix wc_x += alignOfficer.getOffset("wc_x"); wc_y += alignOfficer.getOffset("wc_y"); // float hodoSmallY_low = digi_max_amplitude->at(6); // float hodoSmallY_hi = digi_max_amplitude->at(7); //// //float hodoSmallX_low = digi_max_amplitude->at(5); //// //float hodoSmallX_hi = digi_max_amplitude->at(4); // float hodoSmallX_low = digi_max_amplitude->at(4); // float hodoSmallX_hi = digi_max_amplitude->at(5); bool isOctober2015Run= (runNumber > 3900. && runNumber<4600); float hodoSmallY_low = HODOSMALLvalues->at(1); float hodoSmallY_hi = HODOSMALLvalues->at(2); float hodoSmallX_low = HODOSMALLvalues->at(5); float hodoSmallX_hi = HODOSMALLvalues->at(6); if (isOctober2015Run){ hodoSmallY_low = HODOSMALLvalues->at(0); hodoSmallY_hi = HODOSMALLvalues->at(1); hodoSmallX_low = HODOSMALLvalues->at(2); hodoSmallX_hi = HODOSMALLvalues->at(3); } // std::cout<< hodoSmallY_low<<" "<<hodoSmallY_hi<<" "<<hodoSmallX_low<<" "<<hodoSmallX_hi<<std::endl; std::vector<float> pedMeanX,pedMeanY, pedSigmaX, pedSigmaY; if(!isOctober2015Run){ pedMeanY.push_back(141.30); pedMeanY.push_back(152.90); pedMeanX.push_back(139.89); pedMeanX.push_back(151.73); pedSigmaY.push_back(1.25); pedSigmaY.push_back(1.60); pedSigmaX.push_back(1.32); pedSigmaX.push_back(1.31); }else{//ped value for october 2015 run pedMeanY.push_back(212.5); pedMeanY.push_back(202.0); pedMeanX.push_back(218.6);//this channels are not working in these runs.... pedMeanX.push_back(208.0); pedSigmaY.push_back(1.51); pedSigmaY.push_back(1.67); pedSigmaX.push_back(2.04); pedSigmaX.push_back(1.83); } // y low if( hodoSmallY_low>pedMeanY[0]+5*pedSigmaY[0] ) { int posOf2FibClustY1Low = 0; int posOf2FibClustY2Low=0; int nrOf2FibreClustersY1Low = 0; for( int i=0; i<nClusters_hodoY1; ++i ) { if( nFibres_hodoY1[i]==2 ) { ++nrOf2FibreClustersY1Low; posOf2FibClustY1Low= i ;} } //And for Y2 LOW: int nrOf2FibreClustersY2Low = 0; for( int i=0; i<nClusters_hodoY2; ++i ) { if( nFibres_hodoY2[i]==2 ) { ++nrOf2FibreClustersY2Low; posOf2FibClustY2Low=i; } } if((nrOf2FibreClustersY2Low==1||nClusters_hodoY2==1)&& (nrOf2FibreClustersY1Low==1 || nClusters_hodoY1==1) && abs(wc_y) <200 && nTdcHits->at(2)>0 && nTdcHits->at(3)>0 && nTdcHits->at(2)<3 && nTdcHits->at(3)<3 && ( nTdcHits->at(2) + nTdcHits->at(3))<4){ h1_wc_y_low->Fill( wc_y ); h1_hodoY1_low->Fill( pos_hodoY1[posOf2FibClustY1Low] ); h1_hodoY2_low->Fill( pos_hodoY2[posOf2FibClustY2Low] ); } } // y hi if( hodoSmallY_hi>pedMeanY[1]+5*pedSigmaY[1] ) { int posOf2FibClustY1Hi = 0; int posOf2FibClustY2Hi=0; int nrOf2FibreClustersY1Hi = 0; for( int i=0; i<nClusters_hodoY1; ++i ) { if( nFibres_hodoY1[i]==2 ) { ++nrOf2FibreClustersY1Hi; posOf2FibClustY1Hi= i ;} } //And for Y2 HI: int nrOf2FibreClustersY2Hi = 0; for( int i=0; i<nClusters_hodoY2; ++i ) { if( nFibres_hodoY2[i]==2 ) { ++nrOf2FibreClustersY2Hi; posOf2FibClustY2Hi=i; } } if((nrOf2FibreClustersY2Hi==1||nClusters_hodoY2==1)&& (nrOf2FibreClustersY1Hi==1 || nClusters_hodoY1==1) && abs(wc_y) <200 && nTdcHits->at(2)>0 && nTdcHits->at(3)>0 && nTdcHits->at(2)<3 && nTdcHits->at(3)<3 && ( nTdcHits->at(2) + nTdcHits->at(3))<4){ h1_wc_y_hi->Fill( wc_y ); h1_hodoY1_hi->Fill( pos_hodoY1[ posOf2FibClustY1Hi] ); h1_hodoY2_hi->Fill( pos_hodoY2[posOf2FibClustY2Hi] ); } } // x low if( hodoSmallX_low>pedMeanX[0]+5*pedSigmaX[0] ) { int posOf2FibClustX1Low = 0; int posOf2FibClustX2Low=0; int nrOf2FibreClustersX1Low = 0; for( int i=0; i<nClusters_hodoX1; ++i ) { if( nFibres_hodoX1[i]==2 ) { ++nrOf2FibreClustersX1Low; posOf2FibClustX1Low= i ;} } //And for X2 LOW: int nrOf2FibreClustersX2Low = 0; for( int i=0; i<nClusters_hodoX2; ++i ) { if( nFibres_hodoX2[i]==2 ) { ++nrOf2FibreClustersX2Low; posOf2FibClustX2Low=i; } } if((nrOf2FibreClustersX2Low==1||nClusters_hodoX2==1)&& (nrOf2FibreClustersX1Low==1 || nClusters_hodoX1==1) && abs(wc_x)<200 && nTdcHits->at(0)>0 && nTdcHits->at(1)>0 && nTdcHits->at(0)<3 && nTdcHits->at(1)<3 && ( nTdcHits->at(0) + nTdcHits->at(1) )<4){ h1_wc_x_low->Fill( wc_x ); h1_hodoX1_low->Fill( pos_hodoX1[ posOf2FibClustX1Low] ); h1_hodoX2_low->Fill( pos_hodoX2[posOf2FibClustX2Low] ); } } // x hi if( hodoSmallX_hi>pedMeanX[1]+5*pedSigmaX[1] ) { int posOf2FibClustX1Hi = 0; int posOf2FibClustX2Hi=0; int nrOf2FibreClustersX1Hi = 0; for( int i=0; i<nClusters_hodoX1; ++i ) { if( nFibres_hodoX1[i]==2 ) { ++nrOf2FibreClustersX1Hi; posOf2FibClustX1Hi= i ;} } //And for X2 HI: int nrOf2FibreClustersX2Hi = 0; for( int i=0; i<nClusters_hodoX2; ++i ) { if( nFibres_hodoX2[i]==2 ) { ++nrOf2FibreClustersX2Hi; posOf2FibClustX2Hi=i; } } if((nrOf2FibreClustersX2Hi==1||nClusters_hodoX2==1)&& (nrOf2FibreClustersX1Hi==1 || nClusters_hodoX1==1) && abs(wc_x) <200 && nTdcHits->at(0)>0 && nTdcHits->at(1)>0 && nTdcHits->at(0)<3 && nTdcHits->at(1)<3 && ( nTdcHits->at(0) + nTdcHits->at(1) )<4){ h1_wc_x_hi->Fill( wc_x ); h1_hodoX1_hi->Fill( pos_hodoX1[ posOf2FibClustX1Hi] ); h1_hodoX2_hi->Fill( pos_hodoX2[posOf2FibClustX2Hi] ); } } } // for entries std::string outputdir = "AlignmentPlots_"+tag; system( Form("mkdir -p %s", outputdir.c_str())); float offset_wc_y_low = fitAndDraw( outputdir, h1_wc_y_low ); float offset_wc_y_hi = fitAndDraw( outputdir, h1_wc_y_hi ); float offset_wc_x_low = fitAndDraw( outputdir, h1_wc_x_low ); float offset_wc_x_hi = fitAndDraw( outputdir, h1_wc_x_hi ); float offset_hodoY1_low = fitAndDraw( outputdir, h1_hodoY1_low ); float offset_hodoY1_hi = fitAndDraw( outputdir, h1_hodoY1_hi ); float offset_hodoX1_low = fitAndDraw( outputdir, h1_hodoX1_low ); float offset_hodoX1_hi = fitAndDraw( outputdir, h1_hodoX1_hi ); float offset_hodoY2_low = fitAndDraw( outputdir, h1_hodoY2_low ); float offset_hodoY2_hi = fitAndDraw( outputdir, h1_hodoY2_hi ); float offset_hodoX2_low = fitAndDraw( outputdir, h1_hodoX2_low ); float offset_hodoX2_hi = fitAndDraw( outputdir, h1_hodoX2_hi ); float offset_wc_y = 0.5*(offset_wc_y_low +offset_wc_y_hi); float offset_wc_x = 0.5*(offset_wc_x_low +offset_wc_x_hi); float offset_hodoY1 = 0.5*(offset_hodoY1_low+offset_hodoY1_hi); float offset_hodoX1 = 0.5*(offset_hodoX1_low+offset_hodoX1_hi); float offset_hodoY2 = 0.5*(offset_hodoY2_low+offset_hodoY2_hi); float offset_hodoX2 = 0.5*(offset_hodoX2_low+offset_hodoX2_hi); std::cout << "offset_wc_y: " << offset_wc_y << std::endl; std::cout << "offset_wc_x: " << offset_wc_x << std::endl; std::cout << "offset_hodoY1: " << offset_hodoY1 << std::endl; std::cout << "offset_hodoX1: " << offset_hodoX1 << std::endl; std::cout << "offset_hodoY2: " << offset_hodoY2 << std::endl; std::cout << "offset_hodoX2: " << offset_hodoX2 << std::endl; std::string ofsName = constDirName + "/offsets_new.txt"; ofstream ofs(ofsName.c_str()); ofs << "wc_y " << -offset_wc_y << std::endl; ofs << "wc_x " << -offset_wc_x << std::endl; ofs << "hodoY1 " << -offset_hodoY1 << std::endl; ofs << "hodoX1 " << -offset_hodoX1 << std::endl; ofs << "hodoY2 " << -offset_hodoY2 << std::endl; ofs << "hodoX2 " << -offset_hodoX2 << std::endl; ofs.close(); std::cout << "-> Saved offsets in: " << ofsName << std::endl; return 0; }