int main(int argc, char *argv[]){ char config_filename[100], filenameX[100], filenameY[100], filenameA[100]; strcpy(config_filename,argv[1]); strcpy(filenameX,argv[2]); strcpy(filenameY,argv[3]); strcpy(filenameA,argv[4]); //long num_steps = atoi(argv[5]); // Initialization config_t config; config.load(config_filename); // load X config.load_x(filenameX); // load Y long num_obs = config.num_obs; double *Y = new double[num_obs]; loadVec(Y,num_obs,filenameY); // load A csrmat_t A; long num_variables = config.num_variables; A.load(num_obs,num_variables,filenameA); // Run RandKaczmarz printf("\n----------------------------"); printf("\nStarting RandKaczmarz ..."); printf("\n----------------------------"); //config.num_steps = num_steps; RandKaczmarz_t RK; RK.init(config); RK.Run(Y,A,config); printf("\n----------------------------"); printf("\nRuntime = %lf s",RK.runtime); printf("\n----------------------------"); RK.save(config); delete [] Y; printf("\n"); }
int main(int argc, char** args){ PetscErrorCode err; PetscViewer fd = NULL; Mat invL1 = NULL, invU1 = NULL, invL2 = NULL, invU2 = NULL, H12 = NULL, H21 = NULL; Vec order = NULL, r = NULL; //, or = NULL; //dimension: n: n1 + n2 Vec seeds = NULL; // Vec r1 = NULL, q1 = NULL, t1_1 = NULL, t1_2 = NULL, t1_3 = NULL, t1_4 = NULL, t1_5 = NULL; // dimension: n1 // Vec r2 = NULL, q2 = NULL, q_tilda = NULL, t2_1 = NULL, t2_2 = NULL, t2_3 = NULL; // dimension: n2 PetscRandom rand; PetscLogDouble tic, toc, total_time, time; PetscInt n, i; PetscMPIInt rank, size; PetscInt seed; PetscScalar c, val; PetscInt QN = 100; // Initialize PETSC and MPI err = PetscInitialize(&argc, &args, (char*) 0, help); CHKERRQ(err); err = MPI_Comm_size(PETSC_COMM_WORLD, &size); CHKERRQ(err); err = MPI_Comm_rank(PETSC_COMM_WORLD, &rank); CHKERRQ(err); err = PetscPrintf(PETSC_COMM_WORLD, "mpi size: %d\n", size); CHKERRQ(err); // Read matrices and an ordering vector err = PetscPrintf(PETSC_COMM_WORLD, "Read inputs (invL1, invU1, invL2, invU2, H12, H21, order)\n"); CHKERRQ(err); err = loadMat("./data/invL1.dat", &invL1, PETSC_COMM_WORLD, MATMPIAIJ, &fd); CHKERRQ(err); err = checkMat("invL1", invL1); CHKERRQ(err); err = loadMat("./data/invU1.dat", &invU1, PETSC_COMM_WORLD, MATMPIAIJ, &fd); CHKERRQ(err); err = checkMat("invU1", invU1); CHKERRQ(err); err = loadMat("./data/invL2.dat", &invL2, PETSC_COMM_WORLD, MATMPIAIJ, &fd); CHKERRQ(err); err = checkMat("invL2", invL2); CHKERRQ(err); err = loadMat("./data/invU2.dat", &invU2, PETSC_COMM_WORLD, MATMPIAIJ, &fd); CHKERRQ(err); err = checkMat("invU2", invU2); CHKERRQ(err); err = loadMat("./data/H12.dat", &H12, PETSC_COMM_WORLD, MATMPIAIJ, &fd); CHKERRQ(err); err = checkMat("H12", H12); CHKERRQ(err); err = loadMat("./data/H21.dat", &H21, PETSC_COMM_WORLD, MATMPIAIJ, &fd); CHKERRQ(err); err = checkMat("H21", H21); CHKERRQ(err); err = loadVec("./data/order.dat", &order, PETSC_COMM_SELF, &fd); CHKERRQ(err); //all processes must have this vector for ordering the result vector. err = checkVec("order", order); CHKERRQ(err); // shift -1 for zero-based index err = VecShift(order, -1); CHKERRQ(err); err = VecGetSize(order, &n); CHKERRQ(err); seed = 5; c = 0.05; err = PetscTime(&tic); CHKERRQ(err); //err = BearQueryMat(seed, c, invL1, invU1, invL2, invU2, H12, H21, order); CHKERRQ(err); //err = PetscTime(&toc); CHKERRQ(err); //time = toc - tic; //err = PetscPrintf(PETSC_COMM_WORLD, "running time: %f sec\n", time); CHKERRQ(err); ///* 100 times querying err = VecCreateSeq(PETSC_COMM_SELF, QN, &seeds); CHKERRQ(err); err = VecSetFromOptions(seeds); CHKERRQ(err); err = PetscRandomCreate(PETSC_COMM_WORLD, &rand); CHKERRQ(err); err = PetscRandomSetSeed(rand, 100); CHKERRQ(err); err = PetscRandomSetInterval(rand, (PetscScalar) 0, (PetscScalar) n); CHKERRQ(err); err = PetscRandomSetFromOptions(rand); CHKERRQ(err); err = VecSetRandom(seeds, rand); CHKERRQ(err); err = PetscRandomDestroy(&rand); CHKERRQ(err); seed = 5; //seed is give by user on one-based index c = 0.05; i = 0; err = VecDuplicate(order, &r); CHKERRQ(err); for(i = 0; i < QN; i++){ err = VecGetValues(seeds, 1, &i, &val); seed = (PetscInt) val; //err = PetscPrintf(PETSC_COMM_SELF, "rank: %d, seed: %d\n", rank, seed); err = PetscTime(&tic); CHKERRQ(err); err = BearQuery(seed, c, invL1, invU1, invL2, invU2, H12, H21, order, r); CHKERRQ(err); err = PetscTime(&toc); CHKERRQ(err); time = toc - tic; err = PetscPrintf(PETSC_COMM_WORLD, "running time: %f sec\n", time); CHKERRQ(err); total_time += time; } err = PetscPrintf(PETSC_COMM_WORLD, "average running time: %f sec\n", total_time/QN); CHKERRQ(err); err = VecDestroy(&r); /* err = MatGetSize(H12, &n1, &n2); CHKERRQ(err); n = n1 + n2; err = PetscPrintf(PETSC_COMM_WORLD, "n1: %d, n2: %d\n", n1, n2); CHKERRQ(err); err = VecCreateMPI(PETSC_COMM_WORLD, PETSC_DECIDE, n, &r); CHKERRQ(err); err = VecCreateMPI(PETSC_COMM_WORLD, PETSC_DECIDE, n1, &q1); CHKERRQ(err); err = VecCreateMPI(PETSC_COMM_WORLD, PETSC_DECIDE, n2, &q2); CHKERRQ(err); err = VecSet(q1, 0); CHKERRQ(err); err = VecSet(q2, 0); CHKERRQ(err); seed = seed - 1; // shift -1 for zero-based index err = VecGetValues(order, 1, &seed, &val); CHKERRQ(err); oseed = (PetscInt) val; err = PetscPrintf(PETSC_COMM_WORLD, "Given seed: %d, Reorered seed: %d (0 ~ n-1)\n", seed, oseed); CHKERRQ(err); if(oseed < n1){ err = VecSetValues(q1, 1, &oseed, &one, INSERT_VALUES); CHKERRQ(err); }else{ oseed = oseed - n1; err = VecSetValues(q2, 1, &oseed, &one, INSERT_VALUES); CHKERRQ(err); //err = printVecSum(q2); } err = VecAssemblyBegin(q1); CHKERRQ(err); err = VecAssemblyBegin(q2); CHKERRQ(err); err = VecAssemblyEnd(q1); CHKERRQ(err); err = VecAssemblyEnd(q2); CHKERRQ(err); err = VecDuplicate(q1, &r1); CHKERRQ(err); err = VecDuplicate(q1, &t1_1); CHKERRQ(err); err = VecDuplicate(q1, &t1_2); CHKERRQ(err); err = VecDuplicate(q1, &t1_3); CHKERRQ(err); err = VecDuplicate(q1, &t1_4); CHKERRQ(err); err = VecDuplicate(q1, &t1_5); CHKERRQ(err); err = VecDuplicate(q2, &r2); CHKERRQ(err); err = VecDuplicate(q2, &q_tilda); CHKERRQ(err); err = VecDuplicate(q2, &t2_1); CHKERRQ(err); err = VecDuplicate(q2, &t2_2); CHKERRQ(err); err = VecDuplicate(q2, &t2_3); CHKERRQ(err); // Start matrix-vec multiplications err = MatMult(invL1, q1, t1_1); CHKERRQ(err); err = MatMult(invU1, t1_1, t1_2); CHKERRQ(err); err = MatMult(H21, t1_2, t2_1); CHKERRQ(err); err = VecAXPBYPCZ(q_tilda, 1.0, -1.0, 0.0, q2, t2_1); CHKERRQ(err); err = MatMult(invL2, q_tilda, t2_2); CHKERRQ(err); err = MatMult(invU2, t2_2, r2); CHKERRQ(err); err = MatMult(H12, r2, t1_3); CHKERRQ(err); err = VecAXPBYPCZ(t1_4, 1.0, -1.0, 0.0, q1, t1_3); CHKERRQ(err); err = MatMult(invL1, t1_4, t1_5); CHKERRQ(err); err = MatMult(invU1, t1_5, r1); CHKERRQ(err); //err = printVecSum(r1); //err = VecView(r2, PETSC_VIEWER_STDOUT_WORLD); // Concatenate r1 and r2 err = VecMerge(r1, r2, r); CHKERRQ(err); err = VecScale(r, c); CHKERRQ(err); //err = VecView(r, PETSC_VIEWER_STDOUT_WORLD); err = VecDuplicate(r, &or); CHKERRQ(err); err = VecReorder(r, order, or); CHKERRQ(err); //err = VecView(or, PETSC_VIEWER_STDOUT_WORLD);*/ // Destory matrices and vectors err = MatDestroy(&invL1); CHKERRQ(err); err = MatDestroy(&invU1); CHKERRQ(err); err = MatDestroy(&invL2); CHKERRQ(err); err = MatDestroy(&invU2); CHKERRQ(err); err = MatDestroy(&H12); CHKERRQ(err); err = MatDestroy(&H21); CHKERRQ(err); err = VecDestroy(&order); CHKERRQ(err); err = VecDestroy(&r); CHKERRQ(err); err = VecDestroy(&seeds); CHKERRQ(err); //err = VecDestroy(&or); CHKERRQ(err); /* err = VecDestroy(&r1); CHKERRQ(err); err = VecDestroy(&q1); CHKERRQ(err); err = VecDestroy(&t1_1); CHKERRQ(err); err = VecDestroy(&t1_2); CHKERRQ(err); err = VecDestroy(&t1_3); CHKERRQ(err); err = VecDestroy(&t1_4); CHKERRQ(err); err = VecDestroy(&t1_5); CHKERRQ(err); err = VecDestroy(&r2); CHKERRQ(err); err = VecDestroy(&q2); CHKERRQ(err); err = VecDestroy(&q_tilda); CHKERRQ(err); err = VecDestroy(&t2_1); CHKERRQ(err); err = VecDestroy(&t2_2); CHKERRQ(err); err = VecDestroy(&t2_3); CHKERRQ(err);*/ // Finalize err = PetscFinalize(); CHKERRQ(err); return 0; }
int plotDYAcceptance(int analysisIs2D, const TString conf, DYTools::TRunMode_t runMode=DYTools::NORMAL_RUN, DYTools::TSystematicsStudy_t systMode=DYTools::NO_SYST, TString rndStudyStr="") { gBenchmark->Start("plotDYAcceptance"); { DYTools::printExecMode(runMode,systMode); const int debug_print=1; if (!DYTools::checkSystMode(systMode,debug_print,9, DYTools::NO_SYST, DYTools::FSR_5plus, DYTools::FSR_5minus, DYTools::FSR_RND_STUDY, DYTools::PU_RND_STUDY, DYTools::PILEUP_5plus, DYTools::PILEUP_5minus, DYTools::NO_REWEIGHT, DYTools::NO_REWEIGHT_FEWZ)) return retCodeError; } // // A note on systematics mode // - FSR_5plus, FSR_5minus should be taken care here // - PU_5plus, PU_5minus are taken care by the eventWeight, through // the PUReweight class if (!DYTools::setup(analysisIs2D)) { std::cout << "failed to initialize the analysis\n"; return retCodeError; } //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== InputFileMgr_t inpMgr; if (!inpMgr.Load(conf)) return retCodeError; // no energy correction for this evaluation inpMgr.clearEnergyScaleTag(); // Construct eventSelector, update mgr and plot directory TString extraTag=rndStudyStr; EventSelector_t evtSelector(inpMgr,runMode,systMode, extraTag,"",EventSelector::_selectDefault); evtSelector.setTriggerActsOnData(false); // Acceptance is generator-level quantity and should not // depend on the pile-up. The flag is disabled. // Correction on May 01, 2014: PU should be applied at all steps EventWeight_t evWeight; if (!evWeight.init(inpMgr.puReweightFlag(),inpMgr.fewzFlag(), systMode,rndStudyStr)) { std::cout << "failed to prepare evWeight\n"; return retCodeError; } std::cout << "evWeight: "; evWeight.PrintDetails(); int useSpecWeight=1; double specWeight=1.0; const double FSRmassDiff=1.0; // FSR_RND_STUDY sets own special weights if (systMode==DYTools::FSR_5plus) { specWeight=1.05; useSpecWeight=1; } else if (systMode==DYTools::FSR_5minus) { specWeight=0.95; useSpecWeight=1; } // Prepare output directory inpMgr.constDir(systMode,1); TString outFileName=inpMgr.correctionFullFileName("acceptance",systMode,0); std::cout << "generated outFileName=<" << outFileName << ">\n"; #ifdef calculate_PreFsrAcc std::cout << dashline; std::cout << "\t\tcalculate_PreFsrAcc is defined\n"; std::cout << dashline; #endif //-------------------------------------------------------------------------------------------------------------- // Main analysis code //============================================================================================================== std::cout << mainpart; // // Set up histograms // // containers to accumulate the events std::vector<TH2D*> hvPass, hvTotal; std::vector<TH2D*> hvFail; #ifdef calculate_PreFsrAcc std::vector<TH2D*> hvPassPreFsr, hvTotalPreFsr; #endif // debug containters std::vector<TH1D*> hMassv; std::vector<TH1D*> hMassBinsv; std::vector<TH1D*> hZpeakv; TH1D *hSelEvents=NULL; // the main result of the macro createBaseH2Vec(hvPass ,"hvPass_" ,inpMgr.mcSampleNames()); createBaseH2Vec(hvTotal,"hvTotal_",inpMgr.mcSampleNames()); createBaseH2Vec(hvFail,"hvFail_",inpMgr.mcSampleNames()); #ifdef calculate_PreFsrAcc createBaseH2Vec(hvPassPreFsr ,"hvPassPreFsr_" ,inpMgr.mcSampleNames()); createBaseH2Vec(hvTotalPreFsr,"hvTotalPreFsr_",inpMgr.mcSampleNames()); #endif // debug distributions: 1GeV bins createAnyH1Vec(hMassv,"hGenMass_",inpMgr.mcSampleNames(),1990,10.,2000.,"#it{M}_{ee} [GeV]","counts/1GeV"); // debug distributions for current mass bin createBaseH1Vec(hMassBinsv,"hGenMassBins_",inpMgr.mcSampleNames()); // debug: accumulate info about the selected events in the samples hSelEvents=createAnyTH1D("hSelEvents","hSelEvents",inpMgr.mcSampleCount(),0,inpMgr.mcSampleCount(),"sampleId","event count"); // collect number of events in the Z-peak createAnyH1Vec(hZpeakv,"hZpeak_",inpMgr.mcSampleNames(),60,60.,120.,"#it{M}_{ee} [GeV]","counts/1GeV"); // // Access samples and fill histograms // AccessOrigNtuples_t accessInfo; // // loop over samples // if (DYTools::processData(runMode)) { double extraWeightFactor=1.0; EventCounterExt_t ecTotal("total"); for (unsigned int isample=0; isample<inpMgr.mcSampleCount(); ++isample) { const CSample_t *mcSample=inpMgr.mcSampleInfo(isample); std::cout << "Processing " << mcSample->getLabel() << "..." << std::endl; std::cout << " of size " << mcSample->size() << "\n"; if (mcSample->size()!=1) { std::cout << "mcSample->size is expected to be 1\n"; return retCodeError; } // accumulate info about processed files EventCounterExt_t ecSample(mcSample->name); for (unsigned int ifile=0; ifile<mcSample->size(); ++ifile) { // Read input file TFile *infile=new TFile(mcSample->getFName(ifile),"read"); if (!infile || !infile->IsOpen()) { TString skimName=inpMgr.convertSkim2Ntuple(mcSample->getFName(ifile)); std::cout << " .. failed. Trying <" << skimName << ">" << std::endl; infile= new TFile(skimName,"read"); } assert(infile->IsOpen()); std::cout << " Reading file <" << mcSample->getFName(ifile) << ">\n"; // Get the TTrees if (!accessInfo.setTree(*infile,"Events",true)) { return retCodeError; } // Find weight for events for this file // The first file in the list comes with weight 1*extraWeightFactor, // all subsequent ones are normalized to xsection and luminosity ULong_t maxEvents = accessInfo.getEntries(); // to match old version package (DYee 7TeV paper), if ((inpMgr.userKeyValueAsInt("USE7TEVMCWEIGHT")==1) && (isample==0) && (ifile==0)) { extraWeightFactor=maxEvents / (inpMgr.totalLumi() * inpMgr.mcSampleInfo(0)->getXsec(ifile)); } //std::cout << "extraWeightFactor=" << extraWeightFactor << ", chk=" << (maxEvents0/inpMgr.mcSampleInfo(0)->getXsec(ifile)) << "\n"; //const double extraWeightFactor=1.0; if (! evWeight.setWeight_and_adjustMaxEvents(maxEvents, inpMgr.totalLumi(), mcSample->getXsec(ifile), extraWeightFactor, inpMgr.selectEventsFlag())) { std::cout << "adjustMaxEvents failed\n"; return retCodeError; } std::cout << "mcSample xsec=" << mcSample->getXsec(ifile) << ", nEntries=" << maxEvents << "\n"; std::cout << " -> sample base weight is " << evWeight.baseWeight() << "\n"; // loop through events EventCounterExt_t ec(Form("%s_file%d",mcSample->name.Data(),ifile)); ec.setIgnoreScale(0); // 1 - count events, 0 - take weight in account // adjust the scale in the counter // if FEWZ weight should be considered, use evWeight.totalWeight() after // the FEWZ weight has been identified (see a line below) ec.setScale(evWeight.baseWeight()); std::cout << "numEntries = " << accessInfo.getEntriesFast() << ", " << maxEvents << " events will be used" << std::endl; for(ULong_t ientry=0; ientry<maxEvents; ientry++) { if (DYTools::isDebugMode(runMode) && (ientry>1000000)) break; // debug option //if (DYTools::isDebugMode(runMode) && (ientry>100)) break; // debug option printProgress(250000," ientry=",ientry,maxEvents); ec.numEvents_inc(); // Load generator level info accessInfo.GetGen(ientry); // If the Z->ll leptons are not electrons, discard this event. // This is needed for signal MC samples such as Madgraph Z->ll // where all 3 lepton flavors are possible if (!accessInfo.genLeptonsAreElectrons()) continue; // Load event info to get nPU accessInfo.GetInfoEntry(ientry); // FSR study correction for weight if (useSpecWeight) { evWeight.setSpecWeightValue(accessInfo,FSRmassDiff,specWeight); if ((systMode==DYTools::FSR_RND_STUDY) && (ientry<100)) { std::cout << "ientry=" << ientry << ", "; evWeight.PrintDetails(); } } // Adjust event weight // .. here "false" = "not data" evWeight.set_PU_and_FEWZ_weights(accessInfo,false); // adjust the scale in the counter to include FEWZ // (and possibly PU) weight //ec.setScale(evWeight.totalWeight()); // accumulate denominator const mithep::TGenInfo *gen= accessInfo.genPtr(); hMassv[isample]->Fill(gen->vmass, evWeight.totalWeight()); hMassBinsv[isample]->Fill(gen->vmass, evWeight.totalWeight()); hvTotal[isample]->Fill(gen->mass, fabs(gen->y), evWeight.totalWeight()); #ifdef calculate_PreFsrAcc hvTotalPreFsr[isample]->Fill(gen->vmass, fabs(gen->vy), evWeight.totalWeight()); #endif int failAcc=0; // check acceptance at Gen PostFSR level if (!evtSelector.inAcceptance(accessInfo)) { hvFail[isample]->Fill(gen->mass, fabs(gen->y), evWeight.totalWeight()); failAcc=1; } #ifdef calculate_PreFsrAcc if (evtSelector.inAcceptancePreFsr(accessInfo)) { hvPassPreFsr[isample]->Fill(gen->vmass, fabs(gen->vy), evWeight.totalWeight()); } #endif if (failAcc) continue; ec.numEventsPassedAcceptance_inc(); // accumulate denominator hvPass[isample]->Fill(gen->mass, fabs(gen->y), evWeight.totalWeight()); hSelEvents->Fill(isample,evWeight.totalWeight()); } // loop over events ec.print(2); // print info about file ecSample.add(ec); // accumulate event counts ecTotal.add(ec); infile->Close(); delete infile; } ecSample.print(2); // print info about sample evtSelector.printCounts(); } ecTotal.print(2); } // if (processData) std::cout << "outFileName=<" << outFileName << ">\n"; if (DYTools::processData(runMode)) { TFile file(outFileName,"recreate"); int res=file.IsOpen(); if (res) res=saveVec(file,hvPass,"accPassDir"); if (res) res=saveVec(file,hvTotal,"accTotalDir"); if (res) res=saveVec(file,hvFail,"accFailDir"); #ifdef calculate_PreFsrAcc if (res) res=saveVec(file,hvPassPreFsr,"accPassPreFsrDir"); if (res) res=saveVec(file,hvTotalPreFsr,"accTotalPreFsrDir"); #endif if (res) res=saveVec(file,hMassv,"mass_1GeV_bins"); if (res) res=saveVec(file,hMassBinsv,"mass_analysis_bins"); if (res) res=saveVec(file,hZpeakv,"mass_Zpeak_1GeV"); if (res) res=saveHisto(file,hSelEvents,"procFileInfo"); if (res) writeBinningArrays(file); file.Close(); if (!res) { std::cout << "error occurred during save to file <" << outFileName << ">\n"; return retCodeError; } } else { TFile file(outFileName,"read"); int res=file.IsOpen(); if (res) res=checkBinningArrays(file); if (res) res=loadVec(file,hvPass,"accPassDir"); if (res) res=loadVec(file,hvTotal,"accTotalDir"); if (res) res=loadVec(file,hvFail,"accFailDir"); #ifdef calculate_PreFsrAcc if (res) res=saveVec(file,hvPassPreFsr,"accPassPreFsrDir"); if (res) res=saveVec(file,hvTotalPreFsr,"accTotalPreFsrDir"); #endif if (res) res=loadVec(file,hMassv,"mass_1GeV_bins"); if (res) res=loadVec(file,hMassBinsv,"mass_analysis_bins"); if (res) res=loadVec(file,hZpeakv,"mass_Zpeak_1GeV"); if (res) res=loadHisto(file,&hSelEvents,"procFileInfo"); file.Close(); if (!res) { std::cout << "error occurred during save to file <" << outFileName << ">\n"; return retCodeError; } } TH2D *hSumPass_BaseH2=createBaseH2("hSumPass_baseH2","hSumPass_baseH2",1); TH2D *hSumTotal_BaseH2=createBaseH2("hSumTotal_baseH2","hSumTotal_baseH2",1); TH2D *hSumFail_BaseH2=createBaseH2("hSumFail_baseH2","hSumFail_baseH2",1); addHistos(hSumPass_BaseH2,hvPass); addHistos(hSumTotal_BaseH2,hvTotal); addHistos(hSumFail_BaseH2,hvFail); TH2D *hAcc_BaseH2 = createBaseH2("hAcceptance_baseH2","hAcc_baseH2",1); // We need the binomial error for the acceptance // eff=Pass/Tot, // (dEff)^2= (1-eff)^2/T^2 (dPass)^2 + eff^2/T^2 (dFail)^2 // (dFail)^2 = (dTot)^2 - (dPass)^2 hAcc_BaseH2->Divide(hSumPass_BaseH2,hSumTotal_BaseH2,1,1,"b"); TH2D *hSumPass=convertBaseH2actual(hSumPass_BaseH2,"hSumPass",1); TH2D *hSumFail=convertBaseH2actual(hSumFail_BaseH2,"hSumFail",1); TH2D *hSumTotal=convertBaseH2actual(hSumTotal_BaseH2,"hSumTotal",1); TH2D *hAcc=Clone(hAcc_BaseH2,"hAcceptance","hAcc"); hAcc->Divide(hSumPass,hSumTotal,1,1,"b"); #ifdef calculate_PreFsrAcc TH2D *hSumPassPreFsr_BaseH2=createBaseH2("hSumPassPreFsr_baseH2","hSumPassPreFsr_baseH2",1); TH2D *hSumTotalPreFsr_BaseH2=createBaseH2("hSumTotalPreFsr_baseH2","hSumTotalPreFsr_baseH2",1); addHistos(hSumPassPreFsr_BaseH2,hvPassPreFsr); addHistos(hSumTotalPreFsr_BaseH2,hvTotalPreFsr); TH2D *hSumPassPreFsr=convertBaseH2actual(hSumPassPreFsr_BaseH2,"hSumPassPreFsr",1); TH2D *hSumTotalPreFsr=convertBaseH2actual(hSumTotalPreFsr_BaseH2,"hSumTotalPreFsr",1); TH2D *hAccPreFsr=Clone(hSumPassPreFsr,"hAccPreFsr","hAccPreFsr"); hAccPreFsr->Divide(hSumPassPreFsr,hSumTotalPreFsr,1,1,"b"); #endif std::cout << dashline; std::cout << dashline; printHisto(hSumPass_BaseH2); printHisto(hSumTotal_BaseH2); printHisto(hAcc_BaseH2); printHisto(hSumPass); printHisto(hSumTotal); printHisto(hAcc); //printHisto(hSumFail); std::cout << dashline; #ifdef calculate_PreFsrAcc std::cout << dashline; printHisto(hSumPassPreFsr); printHisto(hSumTotalPreFsr); printHisto(hAccPreFsr); std::cout << dashline; #endif if (DYTools::processData(runMode)) { TFile file(outFileName,"update"); int res=file.IsOpen(); std::cout << "res=" << res << "\n"; if (res) res=saveHisto(file,hAcc,""); if (res) res=saveHisto(file,hSumPass,""); if (res) res=saveHisto(file,hSumTotal,""); if (res) res=saveHisto(file,hSumFail,""); #ifdef calculate_PreFsrAcc if (res) res=saveHisto(file,hAccPreFsr,""); if (res) res=saveHisto(file,hSumPassPreFsr,""); if (res) res=saveHisto(file,hSumTotalPreFsr,""); #endif file.Close(); if (!res) { std::cout << "error occurred during additional save to file <" << outFileName << ">\n"; return retCodeError; } } //-------------------------------------------------------------------------------------------------------------- // Make plots //============================================================================================================== //-------------------------------------------------------------------------------------------------------------- // Summary print out //============================================================================================================== /* cout << endl; cout << "*" << endl; cout << "* SUMMARY" << endl; cout << "*--------------------------------------------------" << endl; cout << endl; */ //gBenchmark->Show("plotDYAcceptance"); ShowBenchmarkTime("plotDYAcceptance"); return retCodeOk; }