void TBDataParser::OnCharacters(const char *characters) { if(_currentElement != NULL && !strcmp(_currentElement->Data(),"vector")) { TString *string = new TString(characters); TObjArray *values = string->Tokenize(", "); for(Int_t i = 0; i < values->GetEntries(); i++) { TObjString *object = (TObjString *) values->At(i); TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", ""); if(value.IsFloat()) { _vector->Fill(value.Atof()); } } if(_vectorsStack->GetEntries() == 1) { _motherVecEntries = _vector->GetEntries(); } else if(_currentMethod != NULL && !strcmp(_currentMethod->Data(),"all")) { for(Int_t i = 1; i < _motherVecEntries; i++) { TObjString *object = (TObjString *) values->First(); TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", ""); if(value.IsFloat()) _vector->Fill(value.Atof()); } } values->Delete(); } }
Double_t CalcLednicR(Double_t zr, Double_t zt, Double_t v) { TString cmd = Form("echo '%0.5f,%0.5f,%0.5f'", zr, zt, v); cmd+= " | ./lednic_input.exe"; Printf("%s", cmd.Data()); cmd = gSystem->GetFromPipe(cmd.Data()); if (!cmd.IsFloat()) { Printf("Problem with program 'lednic_input.exe'"); return 0; } return cmd.Atof(); }
//void main_makePlots() int main(int argc, char* argv[]) { // Output filenames options - for creation of a log file and a histogram file in the given directory TString dir = "control_plots/"; TString tst = fileTimeStamp(); TString pfx = "_plots_"; TString sfx = "_NO_MET_CUT"; // Process input if(argc<3) { cout << "\n ERROR: Please enter a decay chain, dataset, and (optional) a max number of events.\n" << endl; return 1; } TString decayChain = argv[1]; TString dataset = argv[2]; TString maxEventsStr = "" ; if(argc>=4) { maxEventsStr = argv[3]; if(!maxEventsStr.IsFloat()) { cout << "\n ERROR: Please enter the number of events you want to process for your third option" "\n (or nothing if you want to process them all).\n" << endl; return 1; } } if(decayChain!="Zuu" && decayChain!="Zee" && decayChain!="Zttuu" && decayChain!="Zttee") { cout << "\n ERROR: Please specify one of the following decay chains for your first option: Zuu, Zee, Zttuu, Zttee\n" << endl; return 1; } // Open files and map trees TFile* f_input; if (dataset == "muon" ) f_input = TFile::Open(fn_muon ); else if(dataset == "elec" ) f_input = TFile::Open(fn_elec ); else if(dataset == "dy" ) f_input = TFile::Open(fn_dy ); else if(dataset == "dy1j" ) f_input = TFile::Open(fn_dy1j ); else if(dataset == "ww" ) f_input = TFile::Open(fn_ww ); else if(dataset == "wz" ) f_input = TFile::Open(fn_wz ); else if(dataset == "zz" ) f_input = TFile::Open(fn_zz ); else if(dataset == "tthad" ) f_input = TFile::Open(fn_tthad ); else if(dataset == "ttlep" ) f_input = TFile::Open(fn_ttlep ); else if(dataset == "ttsemi" ) f_input = TFile::Open(fn_ttsemi ); else if(dataset == "t_s" ) f_input = TFile::Open(fn_t_s ); else if(dataset == "t_t" ) f_input = TFile::Open(fn_t_t ); else if(dataset == "t_tw" ) f_input = TFile::Open(fn_t_tw ); else if(dataset == "tbar_s" ) f_input = TFile::Open(fn_tbar_s ); else if(dataset == "tbar_t" ) f_input = TFile::Open(fn_tbar_t ); else if(dataset == "tbar_tw" ) f_input = TFile::Open(fn_tbar_tw); else { cout << "\n ERROR: Please specify one of the following datasets for your second option:" "\n muon, elec, dy, dy1j, ww, wz, zz, tthad, ttlep, ttsemi, t(bar)_(s/t/tw)\n" << endl; return 1; } // If tau tau decays specified on a non-dy set. if( (decayChain=="Zttuu" || decayChain=="Zttee") && (dataset!="dy" && dataset!="dy1j")) { cout << "\n ERROR: Tau decay split only valid for DY datasets\n" << endl; return 1; } TTree* t_input = (TTree*)f_input->Get("tree"); // Create an instance of the ZCControlPlotMaker and input options ZCControlPlotMaker *plotMaker = new ZCControlPlotMaker(); TString outputFileName = dir+tst+pfx+decayChain+"_"+dataset+sfx; TString options = decayChain; if(dataset!="muon" && dataset!="elec") options+=",sim"; if(dataset=="dy") options+=",dy"; // Process tree and save output if(maxEventsStr!="") t_input->Process(plotMaker, options, maxEventsStr.Atoi() ); else t_input->Process(plotMaker, options ); cout << plotMaker->saveOutputToFile(outputFileName) << endl; return 0; }
int main(int argc,char *argv[]) { string usage = "\nCNVnator "; #ifdef CNVNATOR_VERSION usage += CNVNATOR_VERSION; #else usage += "v???"; #endif usage += "\n\nUsage:\n"; usage += argv[0]; usage += " -root out.root [-genome name] [-chrom 1 2 ...] -tree file1.bam ...\n"; usage += argv[0]; usage += " -root out.root [-genome name] [-chrom 1 2 ...] -merge file1.root ...\n"; usage += argv[0]; usage += " -root file.root [-genome name] [-chrom 1 2 ...] [-d dir] -his bin_size\n"; usage += argv[0]; usage += " -root file.root [-chrom 1 2 ...] -stat bin_size\n"; usage += argv[0]; usage += " -root file.root -eval bin_size\n"; usage += argv[0]; usage += " -root file.root [-chrom 1 2 ...] -partition bin_size [-ngc]\n"; // usage += argv[0]; //usage += " -root file.root [-chrom 1 2 ...] -spartition bin_size [-gc]\n"; usage += argv[0]; usage += " -root file.root [-chrom 1 2 ...] -call bin_size [-ngc]\n"; usage += argv[0]; usage += " -root file.root -genotype bin_size [-ngc]\n"; usage += argv[0]; usage += " -root file.root -view bin_size [-ngc]\n"; usage += argv[0]; usage += " -pe file1.bam ... -qual val(20) -over val(0.8) [-f file]\n"; usage += "\n"; usage += "Valid genomes (-genome option) are: NCBI36, hg18, GRCh37, hg19\n"; if (argc < 2) { cerr<<"Not enough parameters."<<endl; cerr<<usage<<endl; return 0; } #ifdef USE_YEPPP YepStatus yepStatus = yepLibrary_Init(); if (yepStatus != YepStatusOk) { cerr<<"Yeppp library initialization failed with status "<<yepStatus<<"."<<endl; return 1; } #endif static const int OPT_TREE = 0x00001; static const int OPT_MERGE = 0x00002; static const int OPT_HIS = 0x00004; static const int OPT_HISMERGE = 0x00008; static const int OPT_STAT = 0x00010; static const int OPT_PARTITION = 0x00020; static const int OPT_EPARTITION = 0x00040; static const int OPT_CALL = 0x00080; static const int OPT_VIEW = 0x00100; static const int OPT_GENOTYPE = 0x00200; static const int OPT_EVAL = 0x00400; static const int OPT_PE = 0x00800; static const int OPT_PANEL = 0x01000; static const int OPT_FIT = 0x02000; static const int OPT_SPARTITION = 0x04000; static const int OPT_HIS_NEW = 0x08000; static const int OPT_AGGREGATE = 0x10000; // tree, merge, his, stat, partition, spartition, call, view, genotype int max_opts = 10000, n_opts = 0, opts[max_opts], bins[max_opts], gbin = 0; for (int i = 0;i < n_opts;i++) bins[i] = 0; bool useGCcorr = true,useATcorr = false; bool forUnique = false,relaxCalling = false; string out_root_file(""),call_file(""),group_name(""); string chroms[1000],data_files[100000],root_files[100000] = {""},dir = "."; int n_chroms = 0,n_files = 0,n_root_files = 0,range = 128, qual = 20; double over = 0.8; Genome *genome = NULL; int index = 1; while (index < argc) { string option = argv[index++]; if (option == "-tree" || option == "-merge" || option == "-pe") { if (option == "-tree") opts[n_opts++] = OPT_TREE; if (option == "-merge") opts[n_opts++] = OPT_MERGE; if (option == "-pe") opts[n_opts++] = OPT_PE; while (index < argc && argv[index][0] != '-') if (strlen(argv[index++]) > 0) data_files[n_files++] = argv[index - 1]; } else if (option == "-his" || option == "-his_new" || option == "-hismerge" || option == "-stat" || option == "-eval" || option == "-partition" || option == "-spartition" || option == "-epartition" || option == "-call" || option == "-view" || option == "-genotype" || option == "-aggregate") { int bs = 0; if (index < argc && argv[index][0] != '-') { TString tmp = argv[index++]; if (!tmp.IsDigit()) { cerr<<"Bin size must be integer for option '"<<option<<"'."<<endl; cerr<<usage<<endl; return 0; } bs = tmp.Atoi(); } if (option == "-his") opts[n_opts] = OPT_HIS; if (option == "-hismerge") opts[n_opts] = OPT_HISMERGE; if (option == "-stat") opts[n_opts] = OPT_STAT; if (option == "-partition") opts[n_opts] = OPT_PARTITION; if (option == "-epartition") opts[n_opts] = OPT_EPARTITION; if (option == "-spartition") opts[n_opts] = OPT_SPARTITION; if (option == "-call") opts[n_opts] = OPT_CALL; if (option == "-view") opts[n_opts] = OPT_VIEW; if (option == "-genotype") opts[n_opts] = OPT_GENOTYPE; if (option == "-his_new") opts[n_opts] = OPT_HIS_NEW; if (option == "-eval") opts[n_opts] = OPT_EVAL; if (option == "-aggregate") opts[n_opts] = OPT_AGGREGATE; bins[n_opts++] = bs; } else if (option == "-panel") { opts[n_opts++] = OPT_PANEL; } else if (option == "-fit") { opts[n_opts++] = OPT_FIT; if (index < argc && argv[index][0] != '-') group_name = argv[index++]; else { cout<<"Please provide name of a sample group."<<endl; return 0; } } else if (option == "-outroot") { if (index < argc && argv[index][0] != '-') out_root_file = argv[index++]; else { cout<<"Please provide new root-file name."<<endl; return 0; } } else if (option == "-root") { while (index < argc && argv[index][0] != '-') if (strlen(argv[index++]) > 0) root_files[n_root_files++] = argv[index - 1]; if (n_root_files == 0) { cerr<<"Please provide root-file name."<<endl; cerr<<usage<<endl; return 0; } } else if (option == "-outroot") { if (index < argc && argv[index][0] != '-') out_root_file = argv[index++]; else { cout<<"Please provide new root-file name."<<endl; return 0; } } else if (option == "-chrom") { while (index < argc && argv[index][0] != '-') chroms[n_chroms++] = argv[index++]; if (n_chroms == 0) { cerr<<"Provide chromosome names."<<endl; cerr<<usage<<endl; return 0; } } else if (option == "-ngc") { useGCcorr = false; } else if (option == "-at") { useATcorr = true; } else if (option == "-genome") { if (index < argc) genome = Genome::get(argv[index++]); } else if (option == "-d") { if (index < argc && argv[index][0] != '-') dir = argv[index++]; else cerr<<"No directory is given."<<endl; } else if (option == "-qual") { if (index >= argc || argv[index][0] == '-') { cerr<<"No quality value is provided."<<endl; cerr<<usage<<endl; return 0; } TString tmp = argv[index++]; if (!tmp.IsDigit()) { cerr<<"Quality value must be integer."<<endl; cerr<<usage<<endl; return 0; } qual = tmp.Atoi(); } else if (option == "-over") { if (index >= argc || argv[index][0] == '-') { cerr<<"No fraction of overlap is provided."<<endl; cerr<<usage<<endl; return 0; } TString tmp = argv[index++]; if (!tmp.IsFloat()) { cerr<<"Fraction of overlap must be number."<<endl; cerr<<usage<<endl; return 0; } over = tmp.Atof(); } else if (option == "-f") { if (index >= argc || argv[index][0] == '-') { cerr<<"No file name is provided."<<endl; cerr<<usage<<endl; return 0; } call_file = argv[index++]; } else if (option == "-unique") { forUnique = true; } else if (option == "-range") { range = atoi(argv[index++]); } else if (option == "-relax") { relaxCalling = true; } else if (option[0] == '-') { cerr<<"Unknown option '"<<option<<"'.\n"<<endl; } } if (out_root_file.length() <= 0) out_root_file = root_files[0]; if (out_root_file.length() <= 0) cerr<<"WARNING: no name of root-file provided."<<endl; for (int o = 0;o < n_opts;o++) { int option = opts[o]; int bin = bins[o]; if (bin <= 0) bin = gbin; if (option == OPT_TREE) { // tree HisMaker maker(out_root_file,genome); maker.setDataDir(dir); maker.produceTrees(chroms,n_chroms,data_files,n_files,forUnique); } if (option == OPT_MERGE) { // merge HisMaker maker(out_root_file,genome); maker.mergeTrees(chroms,n_chroms,data_files,n_files); } if (option == OPT_HIS || option == OPT_HISMERGE) { // his HisMaker maker(out_root_file,bin,useGCcorr,genome); maker.setDataDir(dir); maker.produceHistograms(chroms,n_chroms,root_files,n_root_files,false); if (option == OPT_HISMERGE) maker.produceHistograms(chroms,n_chroms,root_files,n_root_files,true); } if (option == OPT_STAT) { // stat HisMaker maker(out_root_file,bin,useGCcorr,genome); maker.stat(chroms,n_chroms,useATcorr); } if (option == OPT_PARTITION) { // partition HisMaker maker(out_root_file,bin,useGCcorr,genome); maker.partition(chroms,n_chroms,false,useATcorr,useGCcorr,false,range); } if (option == OPT_EPARTITION) { // exome partition HisMaker maker(out_root_file,bin,useGCcorr,genome); maker.partition(chroms,n_chroms,false,useATcorr,useGCcorr,true,range); } if (option == OPT_CALL) { // call HisMaker maker(out_root_file,bin,useGCcorr,genome); maker.callSVs(chroms,n_chroms,useATcorr,useGCcorr,relaxCalling); } if (option == OPT_VIEW) { // view HisMaker maker(out_root_file,bin,useGCcorr,genome); TApplication theApp("App",0,0); maker.view(root_files,n_root_files,useATcorr,useGCcorr); theApp.Run(); } if (option == OPT_GENOTYPE) { // genotype HisMaker maker(out_root_file,bin,useGCcorr,genome); TApplication theApp("App",0,0); maker.genotype(root_files,n_root_files,useATcorr,useGCcorr); theApp.Run(); } if (option == OPT_EVAL) { // eval HisMaker maker(out_root_file,bin,useGCcorr,genome); maker.eval(root_files,n_root_files,useATcorr,useGCcorr); } if (option == OPT_PE) { // pe HisMaker maker("null",genome); if (call_file.length() > 0) maker.pe_for_file(call_file,data_files,n_files,over,qual); else { TApplication theApp("App",0,0); maker.pe(data_files,n_files,over,qual); theApp.Run(); } } if (option == OPT_SPARTITION) { // spartition HisMaker maker(out_root_file,bin,useGCcorr,genome); maker.partition(chroms,n_chroms,true,useATcorr,useGCcorr,false,range); } if (option == OPT_HIS_NEW) { // his_new HisMaker maker(out_root_file,bin,useGCcorr,genome); maker.setDataDir(dir); maker.produceHistogramsNew(chroms,n_chroms); } // EXOnator options if (option == OPT_PANEL) { // panel EXOnator exonator(out_root_file); exonator.makeTables(); } if (option == OPT_FIT) { // fit EXOnator exonator(out_root_file); exonator.fit(group_name); } if (option == OPT_AGGREGATE) { // aggregate HisMaker maker(out_root_file,bin,useGCcorr,genome); maker.setDataDir(dir); maker.aggregate(root_files,n_root_files,chroms,n_chroms); } } return 0; }
void DrawMLPoutputMovie( TFile* file, const TString& methodType, const TString& methodTitle ) { gROOT->SetBatch( 1 ); // define Canvas layout here! const Int_t width = 600; // size of canvas // this defines how many canvases we need TCanvas* c = 0; Float_t nrms = 4; Float_t xmin = -1.2; Float_t xmax = 1.2; Float_t ymin = 0; Float_t ymax = 0; Float_t maxMult = 6.0; Int_t countCanvas = 0; Bool_t first = kTRUE; TString dirname = methodType + "/" + methodTitle + "/" + "EpochMonitoring"; TDirectory *epochDir = (TDirectory*)file->Get( dirname ); if (!epochDir) { cout << "Big troubles: could not find directory \"" << dirname << "\"" << endl; exit(1); } // now read all evolution histograms TIter keyItTit(epochDir->GetListOfKeys()); TKey *titkeyTit; while ((titkeyTit = (TKey*)keyItTit())) { if (!gROOT->GetClass(titkeyTit->GetClassName())->InheritsFrom("TH1F")) continue; TString name = titkeyTit->GetName(); if (!name.BeginsWith("convergencetest___")) continue; if (!name.Contains("_train_")) continue; // only for training so far if (name.EndsWith( "_B")) continue; // must be signal histogram if (!name.EndsWith( "_S")) { cout << "Big troubles with histogram: " << name << " -> should end with _S" << endl; exit(1); } // create canvas countCanvas++; TString ctitle = Form("TMVA response %s",methodTitle.Data()); c = new TCanvas( Form("canvas%d", countCanvas), ctitle, 0, 0, width, (Int_t)width*0.78 ); TH1F* sig = (TH1F*)titkeyTit->ReadObj(); sig->SetTitle( Form("TMVA response for classifier: %s", methodTitle.Data()) ); TString dataType = (name.Contains("_train_") ? "(training sample)" : "(test sample)"); // find background TString nbn = sig->GetName(); nbn[nbn.Length()-1] = 'B'; TH1F* bgd = dynamic_cast<TH1F*>(epochDir->Get( nbn )); if (bgd == 0) { cout << "Big troubles with histogram: " << bgd << " -> cannot find!" << endl; exit(1); } cout << "sig = " << sig->GetName() << endl; cout << "bgd = " << bgd->GetName() << endl; // set the histogram style TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd ); // normalise both signal and background TMVAGlob::NormalizeHists( sig, bgd ); // set only first time, then same for all plots if (first) { if (xmin == 0 && xmax == 0) { xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(), bgd->GetMean() - nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmin() ); xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(), bgd->GetMean() + nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmax() ); } ymin = 0; ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult; first = kFALSE; } // build a frame Int_t nb = 100; TString hFrameName(TString("frame") + methodTitle); TObject *o = gROOT->FindObject(hFrameName); if(o) delete o; TH2F* frame = new TH2F( hFrameName, sig->GetTitle(), nb, xmin, xmax, nb, ymin, ymax ); frame->GetXaxis()->SetTitle( methodTitle + " response" ); frame->GetYaxis()->SetTitle("(1/N) dN^{ }/^{ }dx"); TMVAGlob::SetFrameStyle( frame ); // find epoch number (4th token) TObjArray* tokens = name.Tokenize("_"); TString es = ((TObjString*)tokens->At(4))->GetString(); if (!es.IsFloat()) { cout << "Big troubles in epoch parsing: \"" << es << "\" is not float" << endl; exit(1); } Int_t epoch = es.Atoi(); // eventually: draw the frame frame->Draw(); c->GetPad(0)->SetLeftMargin( 0.105 ); frame->GetYaxis()->SetTitleOffset( 1.2 ); // Draw legend TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12, c->GetLeftMargin() + 0.5, 1 - c->GetTopMargin() ); legend->SetFillStyle( 1 ); legend->AddEntry(sig,TString("Signal ") + dataType, "F"); legend->AddEntry(bgd,TString("Background ") + dataType, "F"); legend->SetBorderSize(1); legend->SetMargin( 0.15 ); legend->Draw("same"); TText* t = new TText(); t->SetTextSize( 0.04 ); t->SetTextColor( 1 ); t->SetTextAlign( 31 ); t->DrawTextNDC( 1 - c->GetRightMargin(), 1 - c->GetTopMargin() + 0.015, Form( "Epoch: %i", epoch) ); // overlay signal and background histograms sig->Draw("samehist"); bgd->Draw("samehist"); // save to file TString dirname = "movieplots"; TString foutname = dirname + "/" + name; foutname.Resize( foutname.Length()-2 ); foutname.ReplaceAll("convergencetest___",""); foutname += ".gif"; cout << "storing file: " << foutname << endl; c->Update(); c->Print(foutname); } }