LOCA::Abstract::Iterator::IteratorStatus LOCA::Abstract::Iterator::iterate() { LOCA::Abstract::Iterator::StepStatus stepStatus = LOCA::Abstract::Iterator::Successful; LOCA::Abstract::Iterator::StepStatus preStatus; LOCA::Abstract::Iterator::StepStatus compStatus; LOCA::Abstract::Iterator::StepStatus postStatus; iteratorStatus = stop(stepStatus); while (iteratorStatus == LOCA::Abstract::Iterator::NotFinished) { preStatus = preprocess(stepStatus); compStatus = compute(preStatus); postStatus = postprocess(compStatus); stepStatus = computeStepStatus(preStatus, compStatus, postStatus); ++numTotalSteps; if (stepStatus == LOCA::Abstract::Iterator::Successful) ++stepNumber; else ++numFailedSteps; if (iteratorStatus != LOCA::Abstract::Iterator::Failed) iteratorStatus = stop(stepStatus); } return iteratorStatus; }
// Pull data from the input queue, pre- and post-process it. All // tasks must be scheduled for execution in the pre-processing step. This // decision was made to enable user to split larger input tasks into many // smaller tasks. void run_() { while (!terminate_) { try { // Update deferred configuration if (this->configuration_changed_) { // It is safe to change configuration when pre- and post-processing is // not running. this->update_configuration(); } // Preprocess and schedule tasks argument_type task; if (task_queue_.try_pull_front(task) == queue_op_status::success) { std::lock_guard<std::mutex> lk(this->configuration_mtx_); preprocess(task); } // Post-process tasks and signal result std::future<typename context_pool_type::result_type> result; if (executors_.result_queue.try_pull_front(result) == queue_op_status::success) { std::lock_guard<std::mutex> lk(this->configuration_mtx_); result_signal(postprocess(result.get())); } // Maybe we should execute this in two separate threads with conditional // variable for waking up? std::this_thread::sleep_for(std::chrono::microseconds(50)); } catch (...) { this->error(std::current_exception()); } } }
/* * Compute checksum for one file. */ static int sum(const char *fn) { int n; int fd; long long bytes = 0; if (fn == NULL || (fn[0] == '-' && fn[1] == '\0')) fd = 0; else if ((fd = open(fn, O_RDONLY)) < 0) { (void) fprintf(stderr, gettext("cksum: input file \"%s\": "), fn); perror(""); return (1); } filecrc = 0; while ((n = read(fd, (char *)buf, sizeof (buf))) > 0) { bytes += n; filecrc = (*crcfunc) (filecrc, buf, n); if (tflag) totcrc = (*crcfunc) (totcrc, buf, n); } (void) close(fd); totbytes += bytes; (void) printf("%lu", postprocess(filecrc, bytes)); (void) printf("\t%lld", (long long)((bytes + bsize - 1) / bsize)); if (many) { (void) printf("\t%s", (fn[0] == '-' && fn[1] == '\0') ? gettext("[standard input]") : fn); } if (n < 0) (void) fputs(gettext(" [read error]"), stdout); (void) putchar('\n'); return (n == 0 ? 0 : 1); }
void drawDist(const char* infilename, const char* system, Int_t rWrite, Int_t rPerformance) { myOptions(0); gROOT->ForceStyle(); gStyle->SetPalette(1.0); TDatime now; int iDate = now.GetDate(); int iYear=iDate/10000; int iMonth=(iDate%10000)/100; int iDay=iDate%100; char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec"}; char cStamp1[25],cStamp2[25]; sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear); sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear); TFile *f = new TFile(infilename, "read"); // TList *list = (TList*)f->Get("femtolist"); // pseudorapidity vs pt TH2D* ypt =(TH2D*)f->Get(Form("EtaPtcutPass1%stpcM%i",system,0)); int minMultBin = 0; int maxMultBin = 6; double EvMultall = 0; for(int i = minMultBin; i < maxMultBin; i++) { TH1D* yptN =(TH1D*)f->Get(Form("EtaPtcutPass1%stpcM%i",system,i)); ypt->Add(yptN); //delete hEvMult; } TCanvas *c2 = new TCanvas("pseudorapidity vs pt", "pseudorapidity vs pt"); c2->SetGridx(); c2->SetGridy(); c2->SetFillColor(10); ypt->GetXaxis()->SetTitle("#eta"); ypt->GetYaxis()->SetTitle("p_{T}"); ypt->GetXaxis()->SetTitleOffset(1.3); ypt->GetYaxis()->SetTitleOffset(1.3); ypt->GetXaxis()->SetRangeUser(-0.8,0.8); ypt->GetYaxis()->SetRangeUser(0.1,8.); ypt->Draw("colz"); // https://wiki.bnl.gov/eic/index.php/ROOT#Moving_and_resizing_the_palette_axis_of_a_2D_histogram gPad->SetRightMargin( 0.12 ); // The default right margin is 0.1 i.e. 10% of the image width // TPaletteAxis* palette // = dynamic_cast<TPaletteAxis*>( myHistogram.GetListOfFunctions()->FindObject( "palette" ) ); // if( palette ) { // palette->SetX1NDC( 0.86 ); // Start the palette 86 % of the way across the image // palette->SetX1NDC( 0.91 ); // End the palette 91% of the way across the image // gPad->Modified(); // Update with the new position // } // if postprocess(c2,Form("ypt%s",system),rWrite,rPerformance); }
void main(int argc, char **argv) { FILE *fp_in, *fp_out; assert(argc > 2); fp_in = fopen(argv[1], "rt"); fp_out = fopen(argv[2], "wt"); assert(fp_in != NULL); assert(fp_out != NULL); postprocess(fp_in, fp_out); }
int main(int argc, char **argv) { FILE *fp_in, *fp_out; assert(argc > 2); fp_in = fopen(argv[1], "rt"); fp_out = fopen(argv[2], "wt"); assert(fp_in != NULL); assert(fp_out != NULL); if (postprocess(fp_in, fp_out) == OK) { return (0); } return (1); }
void UvdState::processK1(K1 k1) { preprocess(k1.ri.time); if (k1.ri.confidence == 3) { m_recvStats.k1Conf3Lines++; } else { m_recvStats.k1Conf4Lines++; } OccurrenceRecord record; if (m_pendingOccurrences.count(k1.tailNumber) == 0) { record.tailNumber = k1.tailNumber; record.firstTime = k1.ri.time; record.lastTime = k1.ri.time; m_pendingOccurrences[k1.tailNumber] = record; } else { record = m_pendingOccurrences[k1.tailNumber]; if (record.lastTime + 100.0 < k1.ri.time) { // finalize old occurrence lock(); m_occurrences.push_back(record); unlock(); // and replace with new record.tailNumber = k1.tailNumber; record.firstTime = k1.ri.time; record.lastTime = k1.ri.time; } else { record.lastTime = k1.ri.time; } m_pendingOccurrences[k1.tailNumber] = record; } postprocess(k1.ri.time); }
int main(int argc, char** argv) { /* If no args are specified... */ if (argc == 1) { puts(HELP_MSG); return 1; } /* Set defaults */ os_detect(); g_filename = DEFAULT; g_cc = NULL; g_dotnet = NULL; g_verbose = 0; /* Process any options that will effect script processing */ arg_set(argc, argv); if (!preprocess()) return 1; /* chdir() to the directory containing the project script, so that * relative paths may be used in the script */ io_chdir(path_getdir(g_filename)); /* Now run the script */ g_hasScript = script_run(g_filename); if (g_hasScript < 0) { puts("** Script failed to run, ending."); return 1; } /* Process any options that depend on the script output */ arg_reset(); if (!postprocess()) return 1; /* All done */ if (g_hasScript) script_close(); prj_close(); return 0; }
void UvdState::processK2(K2 k2) { preprocess(k2.ri.time); if (k2.ri.confidence == 3) { m_recvStats.k2Conf3Lines++; } else { m_recvStats.k2Conf4Lines++; } lock(); m_points.push_back(k2); unlock(); postprocess(k2.ri.time); }
int main(int argc, char** argv) { std::cout << std::endl << "γ-ray version 0.2" << std::endl << std::endl; try { const rt::configuration_t configuration = configure(argc, argv); const rt::rendering::writer_t write = rt::rendering::make_writer(configuration.output); const rt::scene::instance_t scene = preprocess(configuration); const rt::rendering::image_t image = render(configuration, scene); postprocess(write, image); return EXIT_SUCCESS; } catch (const std::exception& exception) { std::cerr << "Error: " << exception.what() << std::endl; return EXIT_FAILURE; } }
/* * Mainline for cksum. */ int main(int argc, char *argv[]) { int c; int exstat = 0; (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif (void) textdomain(TEXT_DOMAIN); tflag = many = 0; totbytes = totcrc = 0; while ((c = getopt(argc, argv, "")) != -1) { switch (c) { case 't': /* this is non-functional for now */ tflag++; break; default: return (usage()); } } /* Sum from standard input? */ if ((many = optind < argc) == 0) return (sum(NULL)); /* Sum each file argument. */ for (; optind < argc; ++optind) exstat |= sum(argv[optind]); if (tflag) { (void) printf("%lu", postprocess(totcrc, totbytes)); (void) printf(gettext("\t%lld\t Total\n"), (long long)((totbytes + bsize - 1) / bsize)); } return (exstat); }
int vbonode_sread(struct arena* win, struct style* stack) { struct style* sty; struct pinid* pin; struct arena* tmp; struct relation* rel; //say("@vbonode_sread.begin\n"); preprocess(win); rel = win->orel0; while(1) { if(0 == rel)break; if(_win_ == rel->dsttype) { sty = (void*)(rel->srcfoot); pin = (void*)(rel->dstfoot); tmp = (void*)(rel->dstchip); switch(tmp->fmt) { case _aid3d_:aid3d_sread(tmp, pin, win, sty);break; case _mic3d_:mic3d_sread(tmp, pin, win, sty);break; case _cam3d_:cam3d_sread(tmp, pin, win, sty);break; case _lit3d_:lit3d_sread(tmp, pin, win, sty);break; case _bg3d_:bg3d_sread(tmp, pin, win, sty);break; case _fg3d_:fg3d_sread(tmp, pin, win, sty);break; case _ui3d_:ui3d_sread(tmp, pin, win, sty);break; case _xx3d_:xx3d_sread(tmp, pin, win, sty);break; } } rel = samesrcnextdst(rel); } postprocess(win); //say("@vbonode_sread.end\n"); return 0; }
int main() { preprocess(); process(); postprocess(); }
/* * This function reads the given file line by line and executes the rule. * It returns 0 if everything went OK, 1 if there are problems before reading * the file and -1 on error conditions after executing some of the rules. * It will abort reading the file if it encounters any problems. */ static int fileopt(const char *file) { int i, tfd, rc, lineno = 1; struct stat st; FILE *f; char buf[LINE_SIZE]; /* Does the file exist? */ rc = open(file, O_RDONLY); if (rc < 0) { if (errno != ENOENT) { fprintf(stderr,"Error opening %s (%s)\n", file, strerror(errno)); return 1; } fprintf(stderr, "file %s doesn't exist, skipping\n", file); return 0; } tfd = rc; /* Is the file permissions sane? */ if (fstat(tfd, &st) < 0) { fprintf(stderr, "Error fstat'ing %s (%s)\n", file, strerror(errno)); close(tfd); return 1; } if (st.st_uid != 0) { fprintf(stderr, "Error - %s isn't owned by root\n", file); close(tfd); return 1; } if ((st.st_mode & S_IWOTH) == S_IWOTH) { fprintf(stderr, "Error - %s is world writable\n", file); close(tfd); return 1; } if (!S_ISREG(st.st_mode)) { fprintf(stderr, "Error - %s is not a regular file\n", file); close(tfd); return 1; } f = fdopen(tfd, "rm"); if (f == NULL) { fprintf(stderr, "Error - fdopen failed (%s)\n", strerror(errno)); close(tfd); return 1; } /* Read until eof, lineno starts as 1 */ while (get_line(f, buf)) { char *options[NUM_OPTIONS]; char *ptr; int idx=0; /* Weed out blank lines */ while (buf[idx] == ' ') idx++; if (buf[idx] == 0) { lineno++; continue; } preprocess(buf); ptr = strtok(buf, " "); if (ptr == NULL) break; /* allow comments */ if (ptr[0] == '#') { lineno++; continue; } i = 0; options[i++] = "auditctl"; options[i++] = ptr; while( (ptr=strtok(NULL, " ")) && i<NUM_OPTIONS-1 ) { postprocess(ptr); options[i++] = ptr; } options[i] = NULL; /* Parse it */ if (reset_vars()) { fclose(f); return -1; } rc = setopt(i, lineno, options); /* handle reply or send rule */ if (rc != -3) { if (handle_request(rc) == -1) { if (errno != ECONNREFUSED) fprintf(stderr, "There was an error in line %d of %s\n", lineno, file); else { fprintf(stderr, "The audit system is disabled\n"); fclose(f); return 0; } if (ignore == 0) { fclose(f); return -1; } if (continue_error) continue_error = -1; } } lineno++; } fclose(f); return 0; }
void CMPEG2Decoder::assembleFrame(unsigned char *src[], int pf, YV12PICT *dst) { int *qp; #ifdef PROFILING start_timer(); #endif dst->pf = pf; if (pp_mode != 0) { uc* ppptr[3]; if (!(upConv > 0 && chroma_format == 1)) { ppptr[0] = dst->y; ppptr[1] = dst->u; ppptr[2] = dst->v; } else { ppptr[0] = dst->y; ppptr[1] = u422; ppptr[2] = v422; } bool iPPt; if (iPP == 1 || (iPP == -1 && pf == 0)) iPPt = true; else iPPt = false; postprocess(src, this->Coded_Picture_Width, this->Chroma_Width, ppptr, dst->ypitch, dst->uvpitch, this->Coded_Picture_Width, this->Coded_Picture_Height, this->QP, this->mb_width, pp_mode, moderate_h, moderate_v, chroma_format == 1 ? false : true, iPPt); if (upConv > 0 && chroma_format == 1) { if (iCC == 1 || (iCC == -1 && pf == 0)) { conv420to422(ppptr[1],dst->u,0,dst->uvpitch,dst->uvpitch,Coded_Picture_Width,Coded_Picture_Height); conv420to422(ppptr[2],dst->v,0,dst->uvpitch,dst->uvpitch,Coded_Picture_Width,Coded_Picture_Height); } else { conv420to422(ppptr[1],dst->u,1,dst->uvpitch,dst->uvpitch,Coded_Picture_Width,Coded_Picture_Height); conv420to422(ppptr[2],dst->v,1,dst->uvpitch,dst->uvpitch,Coded_Picture_Width,Coded_Picture_Height); } } } else { YV12PICT psrc; psrc.y = src[0]; psrc.u = src[1]; psrc.v = src[2]; psrc.ypitch = psrc.ywidth = Coded_Picture_Width; psrc.uvpitch = psrc.uvwidth = Chroma_Width; psrc.yheight = Coded_Picture_Height; psrc.uvheight = Chroma_Height; if (upConv > 0 && chroma_format == 1) { CopyPlane(psrc.y,psrc.ypitch,dst->y,dst->ypitch,psrc.ywidth,psrc.yheight); if (iCC == 1 || (iCC == -1 && pf == 0)) { conv420to422(psrc.u,dst->u,0,psrc.uvpitch,dst->uvpitch,Coded_Picture_Width,Coded_Picture_Height); conv420to422(psrc.v,dst->v,0,psrc.uvpitch,dst->uvpitch,Coded_Picture_Width,Coded_Picture_Height); } else { conv420to422(psrc.u,dst->u,1,psrc.uvpitch,dst->uvpitch,Coded_Picture_Width,Coded_Picture_Height); conv420to422(psrc.v,dst->v,1,psrc.uvpitch,dst->uvpitch,Coded_Picture_Width,Coded_Picture_Height); } } else CopyAll(&psrc,dst); } // Re-order quant data for display order. if (info == 1 || info == 2 || showQ) { if (picture_coding_type == B_TYPE) qp = auxQP; else qp = backwardQP; } if (info == 1 || info == 2) { __asm emms; int x, y, temp; int quant; minquant = maxquant = qp[0]; avgquant = 0; for(y=0; y<mb_height; ++y) { temp = y*mb_width; for(x=0; x<mb_width; ++x) { quant = qp[x+temp]; if (quant > maxquant) maxquant = quant; if (quant < minquant) minquant = quant; avgquant += quant; } } avgquant = (int)(((float)avgquant/(float)(mb_height*mb_width)) + 0.5f); } if (showQ) { int x, y; for(y=0; y<this->mb_height; y++) { for(x=0;x<this->mb_width; x++) { MBnum(&dst->y[x*16+y*16*dst->ypitch],dst->ypitch,qp[x+y*this->mb_width]); } } } #ifdef PROFILING stop_timer(&tim.post); start_timer(); #endif }
DescInfo * desc_info_load (const char *filename) { FILE *f; DescInfo *info = NULL; DescInfo *first = NULL; char line[512]; char *ID = NULL; unsigned int hash = 0; unsigned int description_len = 0; char description[1024 * 2]; /* Open file. */ f = fopen (filename, "r"); if (f == NULL) return NULL; /* Read file and process each desription entry. */ while (!feof (f)) { fgets (line, sizeof (line), f); if (ID == NULL) { /* This should be the start of a new entry. */ char *end; if (line[0] == '#' || (end = strchr (line, '#')) == NULL) /* Hm... doesn't look like one after all. */ continue; /* Get the entry's ID. */ end[0] = 0; ID = strdup (line); hash = calc_hash (ID); description_len = 0; } else if (line[0] == '#') { /* This should be the end of an entry. */ if (ID == NULL) /* Or maybe not. */ continue; /* * Add entry to list. */ if (info == NULL) { /* This is the first entry. Allocate the first node. */ info = malloc (sizeof (DescInfo)); info->next = NULL; first = info; } else { /* Allocate new node and append it to linked list. */ DescInfo *old; old = info; info = malloc (sizeof (DescInfo)); info->next = NULL; old->next = info; } info->ID = ID; info->hash = hash; ID = NULL; postprocess (description, &description_len); info->description = malloc (description_len + 1); memcpy (info->description, description, description_len); info->description[description_len] = '\0'; } else { /* This should be a line containing the description. * Append line to description. */ size_t len; len = strlen (line); if (description_len + len > sizeof (description)) /* What? The total description is bigger than 2K? Ignore it. */ continue; memcpy (description + description_len, line, len); description_len += len; } } fclose (f); return first; }
void Editor_Export::run () { preprocess (); process (); postprocess (); }
template<class Iterator> void run(Iterator first, Iterator last) { for (Iterator i = first; i != last; i++) generateRoot(*i); postprocess(); }
// infilename - root file with relevant histograms // system - PP,APAP,PP // status - Pass,Fail // rWrite - 0-no,1-png,2-eps // rPerformance - 0-no,1-yes (ALICE logo etc.) // bin: 0 - all, 1- 0:5, 2- 5:10, etc void drawDCA(const char* infilename, const char* system, const char* status, Int_t rWrite, Int_t rPerformance, int isMC, Int_t bin, Int_t ptrange) { myOptions(0); gROOT->ForceStyle(); gStyle->SetPalette(1.0); TDatime now; int iDate = now.GetDate(); int iYear=iDate/10000; int iMonth=(iDate%10000)/100; int iDay=iDate%100; char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec"}; char cStamp1[25],cStamp2[25]; sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear); sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear); TFile *f = new TFile(infilename, "read"); // DCA xy TH2D* DCAxy =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d","Pass", system,0)); if (!bin) { int minMultBin = 0; int maxMultBin = 6; // 8 } else { int minMultBin = bin-1; int maxMultBin = bin; // 8 } // int minMultBin = 0; // int maxMultBin = 0; // 8 double EvMultall = 0; for(int i = minMultBin; i<maxMultBin; i++) { TH2D* DCAxyN = (TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%d",status, system,i)); DCAxy->Add(DCAxyN); cout<<i<<" "<<DCAxyN->GetEntries()<<endl; //delete hEvMult; } if (!isMC) { TCanvas *c2 = new TCanvas("DCA xy prim", "DCA xy prim"); c2->SetGridx(); c2->SetGridy(); c2->SetFillColor(10); c2->SetRightMargin(1.9); c2->SetLogz(); DCAxy->GetXaxis()->SetTitle("DCA_{XY} (cm)"); DCAxy->GetXaxis()->SetRangeUser(-5.0,5.0); DCAxy->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); // DCAxy->GetZaxis()->SetLabelSize(0.05); DCAxy->Draw("colz"); postprocess(c2,Form("DCAxy%s",status),rWrite,rPerformance,system); // TCanvas *c4 = new TCanvas("DCA xy Projection X", "DCA xy Projection X"); // c4->SetGridx(); // c4->SetGridy(); // c4->SetFillColor(10); // c4->SetRightMargin(1.9); // c4->SetLogy(); gStyle->SetOptTitle(1); TCanvas *myCan = new TCanvas("myCan",cStamp1,600,400); myCan->Draw(); myCan->cd(); TPad *myPad = new TPad("myPad", "The pad",0,0,1,1); myPadSetUp(myPad,0.15,0.04,0.04,0.15); myPad->Draw(); myPad->SetLogy(); myPad->cd(); if (ptrange == 0) { TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",1,100); pripp->SetTitle("0.5 < #it{p}_{T} < 3 GeV/#it{c}"); } else if (ptrange == 1) { TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",15,33); pripp->SetTitle("0.5 < #it{p}_{T} < 1 GeV/#it{c}"); } else if (ptrange == 2) { TH1D* pripp = (TH1D*)DCAxy->ProjectionX("zxc1",33,100); pripp->SetTitle("1 < #it{p}_{T} < 3 GeV/#it{c}"); } pripp->SetYTitle("Number of Entries (normalized)"); pripp->GetXaxis()->SetTitleSize(0.068); pripp->GetYaxis()->SetTitleSize(0.068); pripp->GetXaxis()->SetLabelSize(0.058); pripp->GetYaxis()->SetLabelSize(0.058); // pripp->SetLabelSize(0.05); // DCAxy->ProjectionX("asd",50,100)->SetYTitle("Number of Entries"); // DCAxy->ProjectionX("asd",50,100)->SetTitle("1.0 < p_{T} < 2.0 GeV"); // DCAxy->ProjectionX("asd",0,200)->SetTitle(""); // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetNdivisions(8); // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetNdivisions(8); // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetTitleSize(0.05); // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetTitleSize(0.05); // DCAxy->ProjectionX("asd",50,100)->GetXaxis()->SetLabelSize(0.05); // DCAxy->ProjectionX("asd",50,100)->GetYaxis()->SetLabelSize(0.05); pripp->Draw(""); //if (!isMC) { pripp->Scale(1./pripp->Integral()); TFile* fout = new TFile("dca.root","update"); pripp->SetName(Form("dcaxyMC%d",isMC)); pripp->Write(); //} postprocess(myCan,Form("DCAxy%sProX",status),rWrite,rPerformance,system); } else if (isMC) { TH2D* primp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dprim","Pass", system,0)); TH2D* weakp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dweak","Pass", system,0)); TH2D* matp =(TH2D*)f->Get(Form("DCARPtcut%s1%stpcM%dmat","Pass", system,0)); // prim 2D TCanvas *c3prim = new TCanvas("DCA xy primary", "DCA xy primary"); c3prim->SetGridx(); c3prim->SetGridy(); c3prim->SetFillColor(10); c3prim->SetRightMargin(1.9); c3prim->SetLogz(); primp->GetXaxis()->SetTitle("DCA_{XY} (cm)"); primp->GetXaxis()->SetRangeUser(-5.0,5.0); primp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); primp->GetZaxis()->SetLabelSize(0.03); primp->Draw("colz"); postprocess(c3prim,Form("DCAxy%s",status),rWrite,rPerformance,system); // weak 2D TCanvas *c3 = new TCanvas("DCA xy weak", "DCA xy weak"); c3->SetGridx(); c3->SetGridy(); c3->SetFillColor(10); c3->SetRightMargin(1.9); c3->SetLogz(); weakp->GetXaxis()->SetTitle("DCA_{XY} (cm)"); weakp->GetXaxis()->SetRangeUser(-5.0,5.0); weakp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); weakp->GetZaxis()->SetLabelSize(0.03); weakp->Draw("colz"); postprocess(c3,Form("DCAxy%s",status),rWrite,rPerformance,system); // mat 2D TCanvas *c4 = new TCanvas("DCA xy mat", "DCA xy mat"); c4->SetGridx(); c4->SetGridy(); c4->SetFillColor(10); c4->SetRightMargin(1.9); c4->SetLogz(); matp->GetXaxis()->SetTitle("DCA_{XY} (cm)"); matp->GetXaxis()->SetRangeUser(-5.0,5.0); matp->GetYaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); matp->GetZaxis()->SetLabelSize(0.03); matp->Draw("colz"); postprocess(c4,Form("DCAxy%s",status),rWrite,rPerformance,system); // prim proj gStyle->SetOptTitle(1); TCanvas *myCan3prim = new TCanvas("myCan3prim",cStamp1); myCan3prim->Draw(); myCan3prim->cd(); TPad *myPad3prim = new TPad("myPad3prim", "The pad3prim",0,0,1,1); myPadSetUp(myPad3prim,0.15,0.04,0.04,0.15); myPad3prim->Draw(); myPad3prim->SetLogy(); myPad3prim->cd(); TH1D* primpp = (TH1D*)primp->ProjectionX("zxc22",0,100); primpp->Draw(""); cout << primpp->FindBin(-0.1) << endl; cout << primpp->FindBin(0.1) << endl; cout << "primary in cut- " << primpp->Integral(191,211) << endl; cout << "primary all- " << primpp->Integral(1,400) << endl; postprocess(myCan3prim,Form("DCAxy%sProX",status),rWrite,rPerformance,system); // weak proj TCanvas *myCan3 = new TCanvas("myCan3",cStamp1); myCan3->Draw(); myCan3->cd(); TPad *myPad3 = new TPad("myPad3", "The pad3",0,0,1,1); myPadSetUp(myPad3,0.15,0.04,0.04,0.15); myPad3->Draw(); myPad3->SetLogy(); myPad3->cd(); TH1D* weakpp = (TH1D*)weakp->ProjectionX("zxc2",0,100); weakpp->Draw(""); cout << "weak in cut- " << weakpp->Integral(191,211) << endl; cout << "weak all- " << weakpp->Integral(1,400) << endl; postprocess(myCan3,Form("DCAxy%sProX",status),rWrite,rPerformance,system); // mat proj gStyle->SetOptTitle(1); TCanvas *myCan4 = new TCanvas("myCan4",cStamp1); myCan4->Draw(); myCan4->cd(); TPad *myPad4 = new TPad("myPad4", "The pad4",0,0,1,1); myPadSetUp(myPad4,0.15,0.04,0.04,0.15); myPad4->Draw(); myPad4->SetLogy(); myPad4->cd(); TH1D* matpp = (TH1D*)matp->ProjectionX("zxc3",0,100); matpp->Draw(""); cout << "material in cut- " << matpp->Integral(191,211) << endl; cout << "material all- " << matpp->Integral(1,400) << endl; postprocess(myCan4,Form("DCAxy%sProX",status),rWrite,rPerformance,system); cout << "in cut: " << endl; cout << "prim - " << primpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl; cout << "weak - " << weakpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl; cout << "mat - " << matpp->Integral(191,211) / (primpp->Integral(191,211)+weakpp->Integral(191,211)+matpp->Integral(191,211)) << endl; cout << endl << "in cut / all " << endl; cout << "prim - " << primpp->Integral(191,211) / primpp->Integral(1,400) << endl; cout << "weak - " << weakpp->Integral(191,211) / weakpp->Integral(1,400) << endl; cout << "mat - " << matpp->Integral(191,211) / matpp->Integral(1,400) << endl; // _____sum____ TH2D* psum = new TH2D("psum","",400, -2.0, 2.0, 100,0.0,2.0); psum->GetXaxis()->SetTitle("DCA_{xy} (cm)"); psum->GetYaxis()->SetTitle("Number of Entries (normalized)"); psum->GetXaxis()->SetLimits(-2,2); for (int i = 0; i < primp->GetNbinsX(); i++) { for (int j = 0; j < primp->GetNbinsY(); j++) { psum->SetBinContent(i,j,primp->GetBinContent(i,j)+weakp->GetBinContent(i,j)+matp->GetBinContent(i,j)); } } gStyle->SetOptStat(0); TCanvas *cansum = new TCanvas("cansum",cStamp1,600,400); cansum->Draw(); cansum->cd(); TPad *padsum = new TPad("padsum", "The pad4",0,0,1,1); myPadSetUp(padsum,0.15,0.04,0.04,0.15); padsum->Draw(); padsum->SetLogy(); padsum->cd(); // TCanvas* cansum = new TCanvas("cansum","cansum"); // cansum->SetLogy(); //psum->Draw("colz"); TH1D* asd0 = (TH1D*)psum->ProjectionX("zxc",0,100); // asd0->Scale(1./asd0->Integral()); // TFile* fout = new TFile("dca.root","update"); // asd0->SetName(Form("dcaxyMC%d",isMC)); // asd0->Write(); asd0->GetXaxis()->SetTitle("DCA_{xy} (cm)"); asd0->GetYaxis()->SetTitle("Number of Entries (normalized)"); //asd0->SetMaximum(5000); //asd0->SetMinimum(0.00008); asd0->GetXaxis()->SetNdivisions(8); asd0->GetYaxis()->SetNdivisions(8); //asd0->GetYaxis()->SetTitleOffset(1.4); asd0->GetXaxis()->SetTitleSize(0.068); asd0->GetYaxis()->SetTitleSize(0.068); asd0->GetXaxis()->SetLabelSize(0.058); asd0->GetYaxis()->SetLabelSize(0.058); asd0->SetFillColor(kBlack); Double_t norm = asd0->Integral(); //asd0->Scale(1./norm); //asd0->SetMinimum(0.00007); asd0->SetMarkerSize(1.3); asd0->SetMarkerColor(kBlack); asd0->SetMarkerStyle(20); asd0->Draw("pc"); primpp->SetFillColor(kGreen+2); //primpp->Scale(1./norm); primpp->SetMarkerSize(1.3); primpp->SetMarkerColor(kGreen+2); primpp->SetMarkerStyle(20); primpp->Draw("psame"); matpp->SetFillColor(kRed); //matpp->Scale(1./norm); matpp->SetMarkerSize(1.3); matpp->SetMarkerColor(kRed); matpp->SetMarkerStyle(20); matpp->Draw("psame"); weakpp->SetFillColor(kBlue); //weakpp->Scale(1./norm); weakpp->SetMarkerSize(1.3); weakpp->SetMarkerColor(kBlue); weakpp->SetMarkerStyle(20); weakpp->Draw("psame"); // _____endofsum____ TLegend *myLegend = new TLegend(0.6,0.6,0.89,0.89); myLegend->SetFillColor(10); myLegend->SetBorderSize(0); myLegend->AddEntry(asd0,"all","f"); myLegend->AddEntry(primpp,"primary","f"); myLegend->AddEntry(weakpp,"weak decay","f"); myLegend->AddEntry(matpp,"material","f"); //myLegend->Draw("same"); // logo TLatex *sys = new TLatex(0.16,0.91,"AMPT Pb-Pb #sqrt{s_{NN}} = 2.76 TeV"); sys->SetNDC(); sys->SetTextFont(42); sys->SetTextSize(0.05); sys->SetTextColor(kRed+2); sys->Draw(); TDatime now; int iDate = now.GetDate(); int iYear=iDate/10000; int iMonth=(iDate%10000)/100; int iDay=iDate%100; char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec"}; char cStamp1[25],cStamp2[25]; sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear); sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear); TText *date = new TText(0.27,0.5,cStamp2); date->SetNDC(); date->SetTextFont(42); date->SetTextSize(0.04); date->Draw(); // //Acquire canvas proportions // Double_t AliLogo_LowX = 0.27; // Double_t AliLogo_LowY = 0.6; // Double_t AliLogo_Height = 0.22; // //ALICE logo is a png file that is 821x798 pixels->should be wider than a square // Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw(); // TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height); // // myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment ! // myPadSetUp(myPadLogo,0,0,0,0); // myPadLogo->SetFixedAspectRatio(1); // myPadLogo->Draw(); // myPadLogo->cd(); // // TASImage *myAliceLogo = new TASImage("alice_preliminary.eps"); // TASImage *myAliceLogo = new TASImage("alice_performance.eps"); // // TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png"); // myAliceLogo->Draw(); DrawALICELogo(0,0.27,0.55,0.7,0.8); //logo // postprocess(cansum,Form("DCAxyMC%s",status),rWrite,rPerformance,system); cansum->SaveAs("DCAxyMC.png"); cansum->SaveAs("DCAxyMC.eps"); } //__________________________________________________ }
void Editor_Html2Usfm::run () { preprocess (); process (); postprocess (); }
int main(int argc, char *argv[]) { BOOL leftImageHasBeenRead = FALSE; BOOL rightImageHasBeenRead = FALSE; BOOL disparityMapHasBeenRead = FALSE; BOOL do_matching = TRUE; BOOL do_postprocessing = TRUE; int tempCols, tempRows; clock_t time1, time2, time3, time4; char *ptr_ig = NULL; int i; /* Left and right images */ uchar *imgL, *imgR; /* Results after matching the scanlines independently */ uchar *disparity_map1, *depth_discontinuities1; /* Results after postprocessing the first disparity map */ uchar *disparity_map2, *depth_discontinuities2; g_maxdisp = -1; /* Parse command line */ for (i = 1 ; i < argc ; i++) { if (strcmp(argv[i], "-h") == 0) usage(argv[0]); else if (strcmp(argv[i], "-o") == 0) { i++; if (i == argc) error("Missing argument."); setOcclusionPenalty(atoi(argv[i])); } else if (strcmp(argv[i], "-r") == 0) { i++; if (i == argc) error("Missing argument."); setReward(atoi(argv[i])); } else if (strcmp(argv[i], "-d") == 0) { i++; if (i == argc) error("Missing argument."); strcpy(dir_in, argv[i]); } else if (strcmp(argv[i], "-rel") == 0) { i++; if (i == argc) error("Missing argument."); setReliableThreshold(atoi(argv[i])); } else if (strcmp(argv[i], "-alpha") == 0) { i++; if (i == argc) error("Missing argument."); setAlpha(atof(argv[i])); } else if (strcmp(argv[i], "-ma") == 0) { i++; if (i == argc) error("Missing argument."); setMaxAttractionThreshold(atoi(argv[i])); } else if (strcmp(argv[i], "-b") == 0) writeIntermediateResults = TRUE; else if (strcmp(argv[i], "-np") == 0) do_postprocessing = FALSE; else if (strcmp(argv[i], "-jp") == 0) do_matching = FALSE; else if (strcmp(argv[i], "-wpi") == 0) writePostprocessingIntermediateResults = TRUE; else if (!leftImageHasBeenRead) { strcpy(basenameL, argv[i]); leftImageHasBeenRead = TRUE; } else if (strcmp(argv[i], "-ig") == 0) { i++; if (i == argc) error("Missing argument."); strcpy(basename_ig, argv[i]); ptr_ig = (char *) basename_ig; } else if (rightImageHasBeenRead) { g_maxdisp = atoi((argv[i])); g_slop = g_maxdisp + 1; } else if (!rightImageHasBeenRead) { strcpy(basenameR, argv[i]); rightImageHasBeenRead = TRUE; } else if (!disparityMapHasBeenRead) { strcpy(basename_dm_in, argv[i]); disparityMapHasBeenRead = TRUE; } else warning("Unknown argument."); } if (!leftImageHasBeenRead || !rightImageHasBeenRead || (!do_matching && !disparityMapHasBeenRead) || (g_maxdisp == -1) || (g_maxdisp < 14) || (g_maxdisp > 50)) usage(argv[0]); sprintf(fnameL, "%s/%s", dir_in, basenameL); sprintf(fnameR, "%s/%s", dir_in, basenameR); /* Read images (and maybe disparity map and intensity gradients) */ printf("Attempting to read %s and\n" " %s\n", fnameL, fnameR); imgL = pgmReadFile(fnameL, &g_cols, &g_rows); disparity_map1 = malloc(g_rows*g_cols*sizeof(uchar)); if (disparity_map1 == NULL) error("(main) Memory not allocated"); depth_discontinuities1 = malloc(g_rows*g_cols*sizeof(uchar)); if (depth_discontinuities1 == NULL) error("(main) Memory not allocated"); disparity_map2 = malloc(g_rows*g_cols*sizeof(uchar)); if (disparity_map2 == NULL) error("(main) Memory not allocated"); depth_discontinuities2 = malloc(g_rows*g_cols*sizeof(uchar)); if (depth_discontinuities2 == NULL) error("(main) Memory not allocated"); imgR = pgmReadFile(fnameR, &tempCols, &tempRows); if (tempCols != g_cols || tempRows != g_rows) size_error(tempCols, tempRows); printf("Images successfully read. Their size is %3d by %3d\n", g_cols, g_rows); if (!do_matching) { printf("Attempting to read %s\n", basename_dm_in); disparity_map1 = pgmReadFile(basename_dm_in, &tempCols, &tempRows); if (tempCols != g_cols || tempRows != g_rows) size_error(tempCols, tempRows); } printf("Using maximum disparity of %d\n", g_maxdisp); if (do_matching) { time1 = clock(); /* Match scanlines using dynamic programming */ printf("Matching scanlines independently ...\n"); matchScanlines(imgL, imgR, disparity_map1, depth_discontinuities1, ptr_ig); /* Check the time */ time2 = clock(); printf("Done. Independent processing took %4.1f seconds " "of processor time.\n", (((float) time2 - time1)/ CLOCKS_PER_SEC)); } if (do_postprocessing) { time3 = clock(); /* Postprocess disparity map */ printf("Postprocessing disparity map ...\n"); postprocess(imgL, imgR, disparity_map1, disparity_map2, depth_discontinuities2); /* Check the time */ time4 = clock(); printf("Done. Postprocessing took %4.1f seconds of processor time.\n", (((float) time4 - time3)/ CLOCKS_PER_SEC)); } if (do_matching && do_postprocessing) { printf("Total processor time was %4.1f seconds.\n", (((float) time4 - time1)/ CLOCKS_PER_SEC)); } /* Write results */ if (do_matching && writeIntermediateResults) { printf("Writing to %s and %s\n", fname_dm_intermediate, fname_dd_intermediate); pgmWriteFile(fname_dm_intermediate, (unsigned char *) disparity_map1, g_cols, g_rows); pgmWriteFile(fname_dd_intermediate, (unsigned char *) depth_discontinuities1, g_cols, g_rows); } if (do_postprocessing) { printf("Writing to %s and %s\n", fname_dm, fname_dd); pgmWriteFile(fname_dm, (unsigned char *) disparity_map2, g_cols, g_rows); pgmWriteFile(fname_dd, (unsigned char *) depth_discontinuities2, g_cols, g_rows); } printf("\n"); free(imgL); free(imgR); free(disparity_map1); free(depth_discontinuities1); free(disparity_map2); free(depth_discontinuities2); }
int compare(Descr * descr1, Descr *descr2, Score *score, Score *score_hung) { /* descr 1 is db or target, descr2 is query - important in postprocessing*/ int retval, retval1, retval2; int map_ctr, map_ctr_hung, best_ctr; int NX, NY; //NX_eff, NY_eff; Representation X_rep = {0}, Y_rep = {0}; //static Map * map = NULL; Map * map = NULL; //static int map_max = MAP_MAX * 9; int map_max = MAP_MAX * 9; //static int best_max = MAP_MAX; int best_max = MAP_MAX; // static int *map_best = NULL; int *map_best = NULL; // static int NX_allocated = 0, NY_allocated = 0; /* TODO: go back to map lineage description */ int construct_representation(double ** x, int *x_type, int *x_length, int * NX_effective, Descr * descr, int ** represents, int * is_rep_by); int match_clustering(Representation* X_rep, Representation* Y_rep, Map * map, int map_max, int * map_ctr, int * map_best, int best_max, int parent_map); int recursive_map_out(Map * map, int map_ctr, Descr * descr1, Descr * descr2, Protein *protein1, Protein *protein2, int depth); int rec_map_out_for_postproc(Map * map, int map_ctr, Representation *X_rep, Representation *Y_rep, int depth); /****************************************/ /* arrays for immediate consumption */ /****************************************/ /* needs to come first to figure out NX */ rep_initialize(&X_rep, descr1); rep_initialize(&Y_rep, descr2); /****************************************/ /* initialization */ /****************************************/ /* shorthands */ NX = X_rep.N_full; // NX_eff = X_rep.N_compact; NY = Y_rep.N_full; // NY_eff = Y_rep.N_compact; if ((map = init_map(NX, NY, map_max)) == NULL) return 1; map_best = emalloc(map_max * sizeof (int)); if (!map_best) return 1; /****************************************/ /* look for complementary maps */ /****************************************/ map_ctr = 0; map_ctr_hung = 0; retval = 1; Map * map_hung; if ((map_hung = init_map(NX, NY, map_max)) == NULL) return 1; int *map_best_hung = NULL; map_best_hung = emalloc(map_max * sizeof (int)); /* * Structure matching based on secondary structure orientation * Two algorithms used: * - Smith Waterman * - Hungarian */ retval1 = complement_match(&X_rep, &Y_rep, map, map_max, &map_ctr, map_best, best_max, -1); options.sw_score = 0; retval2 = complement_match(&X_rep, &Y_rep, map_hung, map_max, &map_ctr_hung, map_best_hung, best_max, -1); if (retval1 || retval2) { rep_shutdown(&X_rep); rep_shutdown(&Y_rep); // added by Mile clean_map(map, map_max); free(map_best); clean_map(map_hung, map_max); free(map_best_hung); //added by Mile return retval1; } /****************************************/ /* output the best case stats */ /****************************************/ memset(score, 0, sizeof (Score)); memset(score_hung, 0, sizeof (Score)); best_ctr = 0; while (map_best[best_ctr] > -1) { best_ctr++; } // TODO - check cases when hungarian returns score and SW does not if (best_ctr) { assign_score(map, map_best, &X_rep, &Y_rep, score); assign_score(map_hung, map_best_hung, &X_rep, &Y_rep, score_hung); /****************************************/ /* postprocess - find the actual tf */ /* & mapping on the bb level */ /****************************************/ if (options.postprocess) { Protein qry_structure = {0}; Protein tgt_structure = {0}; /* input CA coordinates for the vectors -- for now the input should be a little different if we are expecting to postprocess -- we will use the original pdb */ /* the last arg is 1 in postprocessing */ retval = read_pdb(options.pdbf_qry, options.chain_qry, &qry_structure, 1); if (retval) { fprintf(stderr, "Error reading %s, chain %c; retval %d\n", options.pdbf_qry, options.chain_qry, retval); return 1; } retval = read_pdb(options.pdbf_tgt, options.chain_tgt, &tgt_structure, 1); if (retval) { fprintf(stderr, "Error reading %s, chain %c; retval %d\n", options.pdbf_tgt, options.chain_tgt, retval); return 1; } /* for now, we will just postprocess the best map */ best_ctr = 0; map_ctr = map_best[best_ctr]; int map_ctr_hung = map_best[best_ctr]; postprocess(descr1, &tgt_structure, &X_rep, descr2, &qry_structure, &Y_rep, map + map_ctr, score); postprocess(descr1, &tgt_structure, &X_rep, descr2, &qry_structure, &Y_rep, map_hung + map_ctr_hung, score_hung); rec_map_out_for_postproc(map, map_ctr, &X_rep, &Y_rep, 0); rec_map_out_for_postproc(map_hung, map_ctr_hung, &X_rep, &Y_rep, 0); if(score_hung->total_assigned_score > score->total_assigned_score) { options.score_out = 1; } if (options.verbose) { if (options.score_out == 0){ recursive_map_out(map, map_ctr, descr1, descr2, &qry_structure, & tgt_structure, 0); } else { recursive_map_out(map_hung, map_ctr_hung, descr1, descr2, &qry_structure, & tgt_structure, 0); } } protein_shutdown(&qry_structure); protein_shutdown(&tgt_structure); } else { /****************************************/ /* output the maps */ /****************************************/ if (options.verbose) { best_ctr = 0; while (best_ctr < options.number_maps_out && best_ctr < map_max && (map_ctr = map_best[best_ctr]) > -1 && map[map_best[best_ctr]].z_score < options.z_max_out) { recursive_map_out(map, map_ctr, descr1, descr2, NULL, NULL, 0); best_ctr++; } } // TODO - do something for Hungarian too. Currently without maps } } /* end if best_ctr */ /****************************************/ /* shutting down */ /****************************************/ rep_shutdown(&X_rep); rep_shutdown(&Y_rep); // added by Mile free(map_best); clean_map(map, map_max); clean_map(map_hung, map_max); free(map_best_hung); //added by Mile return 0; }
int main(int argc, char *argv[]) { int i, my_quantum; struct thread_args *targs; pthread_attr_t attr; struct sched_param param; struct timespec ts; sched_policy = SCHED_NORMAL; num_threads = quantum = ppvals = 0; parse_arguments(argc, argv); //print_arguments(); /* set scheduling policy */ if (sched_policy == SCHED_OTHER_RR) { /* priority has no effect -- just use 0 */ param.sched_priority = 0; if ( sched_setscheduler(getpid(), sched_policy, ¶m) == -1) { perror("sched_setscheduler"); exit(1); }; if (quantum_set) { old_quantum = syscall (SYS_other_rr_getquantum); syscall (SYS_other_rr_setquantum, quantum); } my_quantum = syscall (SYS_other_rr_getquantum); printf("other_rr scheduler selected, quantum=%d", my_quantum); if (my_quantum == 0) printf(" (FCFS policy)"); printf("\n"); } else { printf("normal (CFS) scheduler selected\n"); } /* create the buffer */ if ( (val_buf = (char *) malloc(buffer_size)) == NULL ) { printf("error: could not allocate val_buf\n"); exit(1); } total_num_chars = (buffer_size / sizeof(char)); /* create and start each thread */ if ( (threads = malloc(num_threads*sizeof(pthread_t))) == NULL ) { printf("error: could not allocate threads\n"); exit(1); }; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); for (i = 0; i < num_threads; i++) { targs = malloc(sizeof(*targs)); targs->tid = i; targs->prio = prio_array[i]; targs->mychar = (char) (i+START_CHAR); targs->nchars = (total_num_chars / num_threads); pthread_create(&threads[i], &attr, run, (void *)targs); } /* Wait for all threads to complete */ for (i = 0; i < num_threads; i++) { pthread_join(threads[i], NULL); } printf ("\ncompleted %d threads -- processing shared memory segment\n", num_threads); postprocess(); printf("\n"); for ( i = 0 ; i < num_threads; i++ ) { printf("Thread: %d wrote %d %c's\n", i, rec[i], ((char)(i+START_CHAR))); } dump_val_buf(); if (quantum_set) syscall (SYS_other_rr_setquantum, old_quantum); /* Clean up and exit */ pthread_attr_destroy(&attr); pthread_exit (NULL); }
int main (void) { postprocess ("vanilla string"); postprocess ("nospace"); postprocess ("inner space"); postprocess (" leading"); postprocess (" leading"); postprocess ("trailing "); postprocess ("trailing "); postprocess (""); postprocess (" leading&trailing "); postprocess (" leading & trailing "); postprocess (" leading and internal"); postprocess ("internal and trailing "); postprocess (" everything at once "); return 0; }
// Render the project. MasterRenderer::RenderingResult render() { // RenderingResult is initialized to Failed. RenderingResult result; // Perform basic integrity checks on the scene. if (!check_scene()) return result; // Initialize thread-local variables. Spectrum::set_mode(get_spectrum_mode(m_params)); // Reset the frame's render info. m_project.get_frame()->render_info().clear(); try { // Render. m_stopwatch.start(); result.m_status = do_render(); m_stopwatch.measure(); result.m_render_time = m_stopwatch.get_seconds(); // Insert render time into the frame's render info. // Note that the frame entity may have replaced during rendering. ParamArray& render_info = m_project.get_frame()->render_info(); render_info.insert("render_time", result.m_render_time); // Don't proceed further if rendering failed. if (result.m_status != RenderingResult::Succeeded) return result; // Post-process. m_stopwatch.start(); postprocess(result); m_stopwatch.measure(); result.m_post_processing_time = m_stopwatch.get_seconds(); render_info.insert("post_processing_time", result.m_post_processing_time); } catch (const bad_alloc&) { m_renderer_controller->on_rendering_abort(); RENDERER_LOG_ERROR("rendering failed (ran out of memory)."); result.m_status = RenderingResult::Failed; } #ifdef NDEBUG catch (const exception& e) { m_renderer_controller->on_rendering_abort(); RENDERER_LOG_ERROR("rendering failed (%s).", e.what()); result.m_status = RenderingResult::Failed; } catch (...) { m_renderer_controller->on_rendering_abort(); RENDERER_LOG_ERROR("rendering failed (unknown exception)."); result.m_status = RenderingResult::Failed; } #endif return result; }
boost::tuple<size_t, value_type> operator()(const Vec1 &rhs, Vec2 &x) const { boost::tuple<size_t, value_type> cnv = (*solve)(*this, *P, rhs, x); postprocess(rhs, x); return cnv; }
// infilename - root file with relevant histograms // system - PP,APAP,PP // status - Pass,Fail // rWrite - 0-no,1-png,2-eps // rPerformance - 0-no,1-yes (ALICE logo etc.) // bin: 0 - all, 1- 0:5, 2- 5:10, etc void drawPID(const char* infilename, const char* system, const char* status, Int_t rWrite, Int_t rPerformance, Int_t bin) { TFile *f = new TFile(infilename, "read"); // TPC dEdx TH2D* TPCdEdx =(TH2D*)f->Get(Form("TPCdEdxcut%s1%stpcM%i",status, system,0)); if (!bin) { int minMultBin = 0; int maxMultBin = 6; // 8 } else { int minMultBin = bin-1; int maxMultBin = bin; // 8 } double EvMultall = 0; for (int i = minMultBin; i < maxMultBin; i++) { TH2D* TPCdEdxN =(TH2D*)f->Get(Form("TPCdEdxcut%s1%stpcM%i",status,system,i)); TPCdEdx->Add(TPCdEdxN); cout << i << " " << TPCdEdxN->GetEntries() << endl; //delete hEvMult; } TCanvas *c2 = new TCanvas("TPC dEdx", "TPC dEdx"); c2->SetGridx(); c2->SetGridy(); c2->SetFillColor(10); c2->SetRightMargin(1.9); c2->SetLogz(); TPCdEdx->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); TPCdEdx->GetXaxis()->SetRangeUser(0.0,6.0); TPCdEdx->GetYaxis()->SetTitle("dE/dx"); TPCdEdx->GetZaxis()->SetLabelSize(0.03); TPCdEdx->Draw("colz"); // double a1 = -3000.0; double b1 = 1280.0; // double a2 = -312.5; double b2 = 312.5; // double a3 = -200.0; double b3 = 240.0; // TF1 *fa1 = new TF1("fa1","-1800*x+940",0.3,0.4); // fa1->Draw("same"); // TF1 *fa2 = new TF1("fa2","-500.0*x+420.0",0.4,0.6); // fa2->Draw("same"); // TF1 *fa3 = new TF1("fa3","-216.7*x+250.0",0.6,0.9); // fa3->Draw("same"); // TF1 *fa4 = new TF1("fa4","-566.7*x+570.0",0.6,0.75); // fa4->Draw("same"); // TF1 *fa5 = new TF1("fa5","-2076.92*x+1476.15",0.47,0.6); // fa5->Draw("same"); // cout<<TPCdEdx->GetNbinsX()<<endl; // cout<<TPCdEdx->GetNbinsY()<<endl; // for (int ii=0;ii<TPCdEdx->GetNbinsX();ii++){ // for (int jj=0;jj<TPCdEdx->GetNbinsY();jj++){ // cout<<"binX: "<<ii<<endl; // cout<<"binY: "<<jj<<endl; // cout<<"val: "<<TPCdEdx->GetBinContent(ii,jj)<<endl; // } // } // TH1D *py = TPCdEdx->ProjectionY("py", 230, 232); // where firstYbin = 0 and lastYbin = 9 // TCanvas *c22 = new TCanvas("TPC2", "TPC2"); // py->Draw(); postprocess(c2,Form("TPCdEdx%s",status),rWrite,rPerformance,system); // TPC Nsigma TH2D* TPCNsigma =(TH2D*)f->Get(Form("TPCNSigmacut%s1%stpcM%i",status,system,0)); // int minMultBin = 0; // int maxMultBin = 2; double EvMultall = 0; for(int i = minMultBin; i<maxMultBin; i++) { //all TH2D* TPCNsigmaN =(TH2D*)f->Get(Form("TPCNSigmacut%s1%stpcM%i",status,system,i)); TPCNsigma->Add(TPCNsigmaN); //delete hEvMult; } TCanvas *c3 = new TCanvas("TPC Nsigma", "TPC Nsigma"); c3->SetGridx(); c3->SetGridy(); c3->SetFillColor(10); c3->SetRightMargin(1.7); c3->SetLogz(); TPCNsigma->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); TPCNsigma->GetXaxis()->SetRangeUser(0.0,5.0); TPCNsigma->GetYaxis()->SetTitle("number of sigmas"); TPCNsigma->GetZaxis()->SetLabelSize(0.03); TPCNsigma->Draw("colz"); postprocess(c3,Form("TPCNsigma%s",status),rWrite,rPerformance,system); // TOF Nsigma TH2D* TOFNsigma =(TH2D*)f->Get(Form("TOFNSigmacut%s1%stpcM%i",status,system,0)); // int minMultBin = 1; // int maxMultBin = 1; double EvMultall = 0; for(int i = minMultBin; i<maxMultBin; i++) { //all TH2D* TOFNsigmaN =(TH2D*)f->Get(Form("TOFNSigmacut%s1%stpcM%i",status,system,i)); TOFNsigma->Add(TOFNsigmaN); //delete hEvMult; } TCanvas *c4 = new TCanvas("TOF Nsigma", "TOF Nsigma"); c4->SetGridx(); c4->SetGridy(); c4->SetFillColor(10); c4->SetRightMargin(1.7); c4->SetLogz(); TOFNsigma->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); TOFNsigma->GetXaxis()->SetRangeUser(0.0,5.0); TOFNsigma->GetYaxis()->SetTitle("number of sigmas from TOF"); TOFNsigma->GetZaxis()->SetLabelSize(0.03); TOFNsigma->Draw("colz"); postprocess(c4,Form("TOFNsigma%s",status),rWrite,rPerformance,system); // TOF time TH2D* TOFTime =(TH2D*)f->Get(Form("TOFTimecut%s1%stpcM%i",status,system,0)); // int minMultBin = 1; // int maxMultBin = 1; double EvMultall = 0; for(int i = minMultBin; i<maxMultBin; i++) { //all TH2D* TOFTimeN =(TH2D*)f->Get(Form("TOFTimecut%s1%stpcM%i",status,system,i)); TOFTime->Add(TOFTimeN); //delete hEvMult; } TCanvas *c5 = new TCanvas("TOF Time", "TOF Time"); c5->SetGridx(); c5->SetGridy(); c5->SetFillColor(10); c5->SetRightMargin(1.7); c5->SetLogz(); TOFTime->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); TOFTime->GetYaxis()->SetTitle("GetTOFsignal - GetIntegratedTimes"); TOFTime->GetYaxis()->SetTitleOffset(1.3); TOFTime->GetXaxis()->SetRangeUser(0,5); TOFTime->GetYaxis()->SetRangeUser(-7000,7000); // TOFTime->GetZaxis()->SetLabelSize(0.03); TOFTime->Draw("colz"); postprocess(c5,Form("TOFTime%s",status),rWrite,rPerformance,system); // TPC & TOF Nsigma TH2D* TPCTOFNsigma =(TH2D*)f->Get(Form("TPCTOFNSigmacut%s1%stpcM%i",status,system,0)); int minMultBin = 1; int maxMultBin = 1; double EvMultall = 0; for(int i = minMultBin; i<maxMultBin; i++) { //all TH2D* TPCTOFNsigmaN =(TH2D*)f->Get(Form("TPCTOFNSigmacut%s1%stpcM%i",status,system,i)); TOFNsigma->Add(TOFNsigmaN); //delete hEvMult; } TCanvas *c6 = new TCanvas("TOF Nsigma", "TOF Nsigma"); c6->SetGridx(); c6->SetGridy(); c6->SetFillColor(10); c6->SetRightMargin(1.7); c6->SetLogz(); TPCTOFNsigma->GetXaxis()->SetTitle("#it{p}_{T} (GeV/#it{c})"); TPCTOFNsigma->GetXaxis()->SetRangeUser(0.0,5.0); TPCTOFNsigma->GetYaxis()->SetTitle("#sqrt{#frac{n#sigma_{TPC} + n#sigma_{TOF}}{2}}"); TPCTOFNsigma->GetZaxis()->SetLabelSize(0.03); TPCTOFNsigma->Draw("colz"); postprocess(c6,Form("TPCTOFNsigma%s",status),rWrite,rPerformance,system); }
template<class T> void run(const T& t) { generateRoot(t); postprocess(); }