int main() { int n; clock_t t1, t2; float tms; printf("\nn = "); scanf("%d", &n); while (n < 0) { printf("\nn mora biti prirodan broj veci od ili jednak 0!\n\nn = "); scanf("%d", &n); } t1 = clock(); dinam(n); t2 = clock(); tms = 1000 * (t2 - t1) / CLOCKS_PER_SEC; printf("\ndinamicki: %fms\n", tms); t1 = clock(); ana(n); t2 = clock(); tms = 1000 * (t2 - t1) / CLOCKS_PER_SEC; printf("\nanaliticki: %fms\n", tms); t1 = clock(); rec(n); t2 = clock(); tms = 1000 * (t2 - t1) / CLOCKS_PER_SEC; printf("\nrekurzivni: %fms\n", tms); return 0; }
int allting(int* kommunikationsform, std::string kommunikationsformer) { if (*kommunikationsform > 3 || kommunikationsformer == "kompensering") return 6365; int kommunikationsport = *kommunikationsform + 1; std::string* kompis = new std::string("komplettering"); int* komplementering = ana(kommunikationsport, kompis); std::string konditionering("konjunktiv"); std::string* konfigurering = adressbuss(&kommunikationsport, konditionering); std::string* konkretisering = new std::string("kontant"); std::string konservering = amortering(kommunikationsport, konkretisering); std::string* kontra = new std::string("konung"); int* kontring = anskaffning(kommunikationsport, kontra); std::string konvertering("kopiering"); std::string* kopia = alfa(&kommunikationsport, konvertering); std::string* kopp = new std::string("korg"); std::string koppling = antagligen(kommunikationsport, kopp); int korp(24731); return korp; } // allting
std::string alltigenom(int jordskorpa, std::string* jordyta) { if (jordskorpa > 3 || *jordyta == "ju") return "jude"; int jovisst = jordskorpa + 1; std::string* jul = new std::string("julkorv"); int* julklapp = alls(jovisst, jul); std::string juristlag("juste"); int just = alltnog(&jovisst, juristlag); std::string* justering = new std::string("kajuta"); int* k = anskaffning(jovisst, justering); std::string* kaka = new std::string("kalk"); int* kalibrering = ana(jovisst, kaka); std::string* kalv = new std::string("kan"); int* kamera = allmoge(jovisst, kalv); std::string kanske("kapitalvara"); std::string* kapitalt = angivning(&jovisst, kanske); std::string kapning("karakterisering"); int kappa = allena(&jovisst, kapning); std::string* karakteristika = new std::string("karm"); std::string karl = almanacka(jovisst, karakteristika); std::string karmstol("karta"); return karmstol; } // alltigenom
Bool findplay(Play *p, Rack *r) { /* Find the best possible play given rack 'r', * store it in 'p', return whether or not one * was found. */ Word w; wordclear(&w); p->score = -1; if(firstmove) { /* just find the biggest scoring word, * don't worry too much about where to put it. */ ana(root, &w, r, p); p->pos = CENTRE; } else cmove(p,r); return p->score >= 0; }
UINT ServerThreadProc(LPVOID pParam) { CSocketAddress saClient; CMyHttpBlockSocket sConnect; CListBox* pList=(CListBox*)pParam; //缓存区 char* buffer=new char[SERVERMAXBUF]; char headers[500], request1[MAXLINELENGTH], request2[MAXLINELENGTH]; //连接错误返回到浏览的信息 char hdrErr[]= "HTTP/1.0 404 对象没有找到\r\n" "Server: MySocket Server\r\n" "Content-Type: text/html\r\n" "Accept-Ranges: bytes\r\n" "Content-Length: 66\r\n\r\n" "<html><h1><body>HTTP/1.0 404 对象没有找到</h1></body></html>\r\n"; //连接正确时返回的信息 char hdrFmt[]= "HTTP/1.0 200 OK\r\n" "Server: MySocket Server\r\n" "Date: %s\r\n" "Content-Type: text/html\r\n" "Accept-Ranges: bytes\r\n" "Content-Length: %d\r\n"; //默认的页面--default HTML page char CustomHtml[]= "<html>\r\n" "<head>\r\n" "<title></title>\r\n" "</head>\r\n" "<body>\r\n" "<p align=\"center\">欢迎访问我的主页</p>\r\n" "<h3 align=\"center\"><a href=\"Default.htm\">快乐天地</a></h3>\r\n" "<p>结束</p>\r\n" "<p> </p>\r\n" "</body></html>\r\n\r\n"; CString strGmtNow= CTime::GetCurrentTime().FormatGmt("%a, %d %b %Y %H:%M:%S GMT"); int nBytesSent=0; CFile* pFile=NULL; char* pToken1; char* pToken2; char* pData = NULL; char StringSeparates[64] = { 0 }; int nStringSeparates = 0; try { //开始侦听连接请求 if(!g_sListen.Accept(sConnect, saClient)) { //在应用程序关闭时的处理 g_bListening=FALSE; delete [] buffer; return 0; } //连接数增加一个 g_nConnection++; //开始另一个服务器线程 AfxBeginThread(ServerThreadProc, pParam, THREAD_PRIORITY_NORMAL); //从客户端(浏览器)读取请求 sConnect.ReadHttpHeaderLine(request1, MAXLINELENGTH, 10); //记录请求 LogRequest(pParam, request1, saClient); //解析请求并作相应的处理 if(Parse(request1, &pToken1, &pToken2)) { //浏览器GET方式 if(!stricmp(pToken1, "GET")) { do { //读取请求的剩余部分 sConnect.ReadHttpHeaderLine(request2, MAXLINELENGTH, 10); } while(strcmp(request2, "\r\n")); if(!stricmp(pToken2, "/custom"))// || !stricmp(pToken2, "/")) { //发送默认的页面--default HTML page wsprintf(headers, hdrFmt, (const char*) strGmtNow, strlen(CustomHtml)); strcat(headers, "\r\n"); sConnect.Write(headers, strlen(headers), 10); sConnect.Write(CustomHtml, strlen(CustomHtml), 10); } else if(strchr(pToken2, '?')) { //CGI请求 //该HTTP服务器还不能对CGI请求作出响应 //也不能调用相应的ISAPI的DLL(动态连接库) } else { //文件处理 //注意对服务器目录的设定 //获得文件在服务器上的路径 if((pFile=OpenFile(pToken2))!=NULL) { //文件打开 CFileStatus fileStatus; pFile->GetStatus(fileStatus); CString strGmtMod=fileStatus.m_mtime.FormatGmt("%a, %d %b %Y %H:%M:%S GMT"); char hdrModified[50]; wsprintf(hdrModified, "Last-Modified: %s\r\n\r\n", (const char*) strGmtMod); DWORD dwLength=pFile->GetLength(); wsprintf(headers, hdrFmt, (const char*) strGmtNow, dwLength); strcat(headers, hdrModified); nBytesSent=sConnect.Write(headers, strlen(headers), 10); //传送的文件应该是在某一个时间之后被修改过的 //因此文件的时间应该是小于该设定时间 nBytesSent=0; DWORD dwBytesRead=0; UINT uBytesToRead; //将文件以5k的大小为单位发送,避免内存分配错误 while(dwBytesRead < dwLength) { uBytesToRead=min(SERVERMAXBUF, dwLength-dwBytesRead); VERIFY(pFile->Read(buffer, uBytesToRead)==uBytesToRead); nBytesSent+=sConnect.Write(buffer, uBytesToRead, 10); dwBytesRead+=uBytesToRead; } pFile->Close(); } else { //向浏览器发送“出错信息” nBytesSent=sConnect.Write(hdrErr, strlen(hdrErr), 10); } } } else if(!stricmp(pToken1, "POST")) { int nDataSize = 0; //浏览器POST方式 do { //读取请求的剩余部分 sConnect.ReadHttpHeaderLine(request2, MAXLINELENGTH, 10); char *p = strstr(request2, "Content-Length: "); if (NULL != p) { char *Size = p + 16; nDataSize = atoi(Size); } char *psp = strstr(request2, "boundary"); if (NULL != psp) { psp+=9; for (int i = 0; '\r' != *psp && i < 64; ++i, ++psp) { StringSeparates[i] = *psp; nStringSeparates++; } } } while(strcmp(request2, "\r\n")); // sConnect.ReadHttpHeaderLine(request2, MAXLINELENGTH, 10); // sConnect.ReadHttpHeaderLine(request2, MAXLINELENGTH, 10); // sConnect.ReadHttpHeaderLine(request2, MAXLINELENGTH, 10); pData = new char[nDataSize]; sConnect.ReadHttpResponse(pData, nDataSize, 10); LogRequest(pParam, request2, saClient); //向浏览器发送“出错信息” //nBytesSent=sConnect.Write(hdrErr, strlen(hdrErr), 10); nBytesSent = sConnect.Write(hdrFmt, strlen(hdrFmt), 10); // CHttpDataAnalyse ana(pData, nDataSize); ana.SetStringSeparates(StringSeparates, nStringSeparates); if (ana.Analyse()) { TRACE("ok"); } } else { //其它的请求方式 } } else { //错误的请求 } //关闭套接字 sConnect.Close(); // } catch(CMyBlockSocketException* pe) { //错误处理 LogBlockingSocketException(pParam, "服务器:", pe); pe->Delete(); } delete [] buffer; if(pFile) delete pFile; if (NULL != pData) { delete pData; pData = NULL; } return 0; }
int main(int ac, char *av[]) { { int pos = 0; for(int index = 0;av[0][index];++index) if(av[0][index] == '\\' || av[0][index] == '/') pos = index; program_base = std::string(&(av[0][0]),&(av[0][0])+pos+1); } if(ac > 2) { { std::cout << "DSI Studio " << __DATE__ << ", Fang-Cheng Yeh" << std::endl; // options for general options po::options_description desc("reconstruction options"); desc.add_options() ("help", "help message") ("action", po::value<std::string>(), "rec:diffusion reconstruction trk:fiber tracking") ("source", po::value<std::string>(), "assign the .src or .fib file name") ; po::variables_map vm; po::store(po::command_line_parser(ac, av).options(desc).allow_unregistered().run(),vm); if (vm.count("help")) { std::cout << "example: perform reconstruction" << std::endl; std::cout << " --action=rec --source=test.src.gz --method=4 " << std::endl; std::cout << "options:" << std::endl; rec(0,0); std::cout << "example: perform fiber tracking" << std::endl; std::cout << " --action=trk --source=test.src.gz.fib.gz --method=0 --fiber_count=5000" << std::endl; std::cout << "options:" << std::endl; trk(0,0); return 1; } if (!vm.count("action") || !vm.count("source")) { std::cout << "invalid command, use --help for more detail" << std::endl; return 1; } if(vm["action"].as<std::string>() == std::string("rec")) return rec(ac,av); if(vm["action"].as<std::string>() == std::string("trk")) return trk(ac,av); if(vm["action"].as<std::string>() == std::string("src")) return src(ac,av); if(vm["action"].as<std::string>() == std::string("ana")) return ana(ac,av); } return 1; } QApplication::setStyle(new QCleanlooksStyle); QApplication a(ac,av); a.setOrganizationName("LabSolver"); a.setApplicationName("DSI Studio"); QFont font; font.setFamily(QString::fromUtf8("Arial")); a.setFont(font); if(!load_fa_template()) return -1; MainWindow w; w.setFont(font); w.showMaximized(); w.setWindowTitle(QString("DSI Studio ") + __DATE__ + " build"); return a.exec(); }
int main(int ac, char *av[]) { if(ac > 2) { std::auto_ptr<QCoreApplication> cmd; { for (int i = 1; i < ac; ++i) if (std::string(av[i]) == std::string("--action=cnt") || std::string(av[i]) == std::string("--action=vis")) { cmd.reset(new QApplication(ac, av)); std::cout << "Starting GUI-based command line interface." << std::endl; break; } if(!cmd.get()) cmd.reset(new QCoreApplication(ac, av)); } cmd->setOrganizationName("LabSolver"); cmd->setApplicationName("DSI Studio"); try { std::cout << "DSI Studio " << __DATE__ << ", Fang-Cheng Yeh" << std::endl; // options for general options po::options_description desc("reconstruction options"); desc.add_options() ("help", "help message") ("action", po::value<std::string>(), "rec:diffusion reconstruction trk:fiber tracking") ("source", po::value<std::string>(), "assign the .src or .fib file name") ; po::variables_map vm; po::store(po::command_line_parser(ac, av).options(desc).allow_unregistered().run(),vm); if (vm.count("help")) { std::cout << "example: perform reconstruction" << std::endl; std::cout << " --action=rec --source=test.src.gz --method=4 " << std::endl; std::cout << "example: perform fiber tracking" << std::endl; std::cout << " --action=trk --source=test.src.gz.fib.gz --method=0 --fiber_count=5000" << std::endl; return 1; } if (!vm.count("action") || !vm.count("source")) { std::cout << "invalid command, use --help for more detail" << std::endl; return 1; } if(vm["action"].as<std::string>() == std::string("rec")) return rec(ac,av); if(vm["action"].as<std::string>() == std::string("trk")) return trk(ac,av); if(vm["action"].as<std::string>() == std::string("src")) return src(ac,av); if(vm["action"].as<std::string>() == std::string("ana")) return ana(ac,av); if(vm["action"].as<std::string>() == std::string("exp")) return exp(ac,av); if(vm["action"].as<std::string>() == std::string("atl")) return atl(ac,av); if(vm["action"].as<std::string>() == std::string("cnt")) return cnt(ac,av); if(vm["action"].as<std::string>() == std::string("vis")) return vis(ac,av); std::cout << "invalid command, use --help for more detail" << std::endl; return 1; } catch(const std::exception& e ) { std::cout << e.what() << std::endl; } catch(...) { std::cout << "unknown error occured" << std::endl; } return 1; } QApplication a(ac,av); a.setOrganizationName("LabSolver"); a.setApplicationName("DSI Studio"); QFont font; font.setFamily(QString::fromUtf8("Arial")); a.setFont(font); // load template if(!fa_template_imp.load_from_file()) { QMessageBox::information(0,"Error","Cannot find HCP488_QA.nii.gz in file directory",0); return false; } // load atlas load_atlas(); MainWindow w; w.setFont(font); w.show(); w.setWindowTitle(QString("DSI Studio ") + __DATE__ + " build"); return a.exec(); }
//_____________________________________________________________________________ void FnormMacro( const char* filename="../LHC15g.MuMu.1.root", const char* associatedSimFileName="", const char* associatedSimFileName2="", const char* beamYear="PbPb2011",const int DebugLevel =0) { // //_____ FNorm // analysis.ComputeIntFnormFromCounters("",kFALSE); // //_____ AliAnalysisMuMu ana(filename,associatedSimFileName,associatedSimFileName2,beamYear); AliLog::SetGlobalDebugLevel(DebugLevel); if (!ana.OC() || !ana.CC()) { AliError("No mergeable/counter collection. Consider Upgrade()"); return ; } else { cout << " ================================================================ " << endl; cout << " Compute Mean Fnorm From Counters " << endl; cout << " ================================================================ " << endl; } // Get configuration settings TObjArray* eventTypeArray = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kEventSelectionList,IsSimulation()); TObjArray* triggerMuonArray = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kDimuonTriggerList,IsSimulation()); TObjArray* triggerMBArray = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kMinbiasTriggerList,IsSimulation()); TObjArray* centralityArray = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kCentralitySelectionList, IsSimulation()); // Iterator for loops TIter nextTriggerMuon(triggerMuonArray); TIter nextTriggerMB(triggerMBArray); TIter nextEventType(eventTypeArray); TIter nextCentrality(centralityArray); // Strings TObjString* striggerMuon; TObjString* striggerMB; TObjString* seventType; TObjString* scentrality; //Pointers on histo TH1*h(0x0); TH1*h1(0x0); TH1*h2(0x0); Double_t FNormOverStat(0.); Double_t FNormTotError(0.); Double_t FNormTotErrorInverse(0.); Double_t FNormTotErrorSys(0.); Double_t Norm(1.); Int_t n =0; //counter nextEventType.Reset(); // Loop on each envenType (see MuMuConfig) //============================================================================== while ( ( seventType = static_cast<TObjString*>(nextEventType())) ) { AliDebug(1,Form("EVENTTYPE %s",seventType->String().Data())); nextTriggerMuon.Reset(); // Loop on each Muon trigger (see MuMuConfig) //============================================================================== while ( ( striggerMuon = static_cast<TObjString*>(nextTriggerMuon())) ) { AliDebug(1,Form("-MUON TRIGGER %s",striggerMuon->String().Data())); nextTriggerMB.Reset(); // Loop on each MB trigger (not the ones in MuMuConfig but the ones set) //============================================================================== while ( ( striggerMB = static_cast<TObjString*>(nextTriggerMB())) ) { AliDebug(1,Form("-- MB PAIRCUT %s",striggerMB->String().Data())); nextCentrality.Reset(); // Loop on each centrality //============================================================================== while ( ( scentrality = static_cast<TObjString*>(nextCentrality()) ) ) { TString id(Form("/FNORM-%s/%s/%s/PbPb",striggerMuon->String().Data(),seventType->String().Data(),scentrality->String().Data())); // Path where are saved histos in the mergeable collection h = OC()->Histo(id.Data(),Form("hFNormIntVSrun_%s",striggerMB->String().Data())); if (!h) { AliDebug(1,Form("Can't get histo %s/hFNormIntVSrun_%s",id.Data(),striggerMB->String().Data())); continue; } h1 = OC()->Histo(id.Data(),Form("hFNormInt_%s",striggerMB->String().Data())); if (!h1) { AliDebug(1,Form("Can't get histo %s/hFNormInt_%s",id.Data(),striggerMB->String().Data())); continue; } h2 = OC()->Histo(id.Data(),Form("hFNormIntSys_%s",striggerMB->String().Data())); if (!h2) { AliDebug(1,Form("Can't get histo %s/hFNormIntSys_%s",id.Data(),striggerMB->String().Data())); continue; } cout << Form("Fnorm from %s/%s added",id.Data(),h1->GetName()) << endl; cout << Form("Fnorm from %s/%s added",id.Data(),h2->GetName()) << endl; // Normalise with respect to centrality if (scentrality->String().Contains("V0M_00.00_90.00")) { Norm = 1.; FNormOverStat = FNormOverStat + (Norm*h1->GetBinContent(1)) /(TMath::Power(Norm *h1->GetBinError(1),2.)); FNormTotError = FNormTotError + 1./(TMath::Power(Norm*h1->GetBinError(1),2.)); FNormTotErrorInverse = FNormTotErrorInverse + 1./(TMath::Power(Norm*h1->GetBinError(1),-2.)); FNormTotErrorSys = FNormTotErrorSys + 1./(TMath::Power(Norm*h2->GetBinContent(1),2.)); cout <<"--- Quantities from histogram : " << endl; cout <<" - Norm = " << Norm << endl; cout <<" - FNormHisto = " << h1->GetBinContent(1) << endl; cout <<" - FNormHistoError = " << h1->GetBinError(1) << endl; cout <<" - FNormHistoSys = " << h2->GetBinContent(1) << endl; cout <<"--- Quantities (normalized) from histogram: " << endl; cout <<" - FNormHisto = " << Norm*h1->GetBinContent(1) << endl; cout <<" - FNormHistoError = " << Norm*h1->GetBinError(1) << endl; cout <<" - FNormHistoSys = " << Norm*h2->GetBinContent(1) << endl; cout <<"--- After addition : " << endl; cout <<" - FNormOverStat = " << FNormOverStat << endl; cout <<" - FNormTotError = " << FNormTotError << endl; cout <<" - FNormTotErrorInverse = " << FNormTotErrorInverse << endl; cout <<" - FNormTotErrorSys = " << FNormTotErrorSys << endl; } else if (scentrality->String().Contains("V0M_10.00_50.00")) { Norm = (1./0.4)*0.445*0.9; FNormOverStat = FNormOverStat + (Norm*h1->GetBinContent(1)) /(TMath::Power(Norm *h1->GetBinError(1),2.)); FNormTotError = FNormTotError + 1./(TMath::Power(Norm*h1->GetBinError(1),2.)); FNormTotErrorInverse = FNormTotErrorInverse + 1./(TMath::Power(Norm*h1->GetBinError(1),-2.)); FNormTotErrorSys = FNormTotErrorSys + 1./(TMath::Power(Norm*h2->GetBinContent(1),2.)); cout <<"--- Quantities from histogram : " << endl; cout <<" - Norm = " << Norm << endl; cout <<" - FNormHisto = " << h1->GetBinContent(1) << endl; cout <<" - FNormHistoError = " << h1->GetBinError(1) << endl; cout <<" - FNormHistoSys = " << h2->GetBinContent(1) << endl; cout <<"--- Quantities (normalized) from histogram: " << endl; cout <<" - FNormHisto = " << Norm*h1->GetBinContent(1) << endl; cout <<" - FNormHistoError = " << Norm*h1->GetBinError(1) << endl; cout <<" - FNormHistoSys = " << Norm*h2->GetBinContent(1) << endl; cout <<"--- After addition : " << endl; cout <<" - FNormOverStat = " << FNormOverStat << endl; cout <<" - FNormTotError = " << FNormTotError << endl; cout <<" - FNormTotErrorInverse = " << FNormTotErrorInverse << endl; cout <<" - FNormTotErrorSys = " << FNormTotErrorSys << endl; } else if (scentrality->String().Contains("V0M_00.00_07.50")) { Norm = (1./0.075)*0.443*0.9; FNormOverStat = FNormOverStat + (Norm*h1->GetBinContent(1)) /(TMath::Power(Norm *h1->GetBinError(1),2.)); FNormTotError = FNormTotError + 1./(TMath::Power(Norm*h1->GetBinError(1),2.)); FNormTotErrorInverse = FNormTotErrorInverse + 1./(TMath::Power(Norm*h1->GetBinError(1),-2.)); FNormTotErrorSys = FNormTotErrorSys + 1./(TMath::Power(Norm*h2->GetBinContent(1),2.)); cout <<"--- Quantities from histogram : " << endl; cout <<" - Norm = " << Norm << endl; cout <<" - FNormHisto = " << h1->GetBinContent(1) << endl; cout <<" - FNormHistoError = " << h1->GetBinError(1) << endl; cout <<" - FNormHistoSys = " << h2->GetBinContent(1) << endl; cout <<"--- Quantities (normalized) from histogram: " << endl; cout <<" - FNormHisto = " << Norm*h1->GetBinContent(1) << endl; cout <<" - FNormHistoError = " << Norm*h1->GetBinError(1) << endl; cout <<" - FNormHistoSys = " << Norm*h2->GetBinContent(1) << endl; cout <<"--- After addition : " << endl; cout <<" - FNormOverStat = " << FNormOverStat << endl; cout <<" - FNormTotError = " << FNormTotError << endl; cout <<" - FNormTotErrorInverse = " << FNormTotErrorInverse << endl; cout <<" - FNormTotErrorSys = " << FNormTotErrorSys << endl; } else { AliError("Check this method for centrality selection !"); return; } n++; } } } } cout << "Mean FNorm computed from " << n <<" results = " << FNormOverStat/FNormTotError << " +/- " << TMath::Sqrt(FNormTotErrorInverse) << " (stat) +/-" << TMath::Sqrt(FNormTotErrorSys) << " (sys) " <<endl; delete triggerMuonArray ; delete triggerMBArray ; delete eventTypeArray ; delete centralityArray ; }
void mlpHiggs(Int_t ntrain=100) { // Example of a Multi Layer Perceptron // For a LEP search for invisible Higgs boson, a neural network // was used to separate the signal from the background passing // some selection cuts. Here is a simplified version of this network, // taking into account only WW events. //Author: Christophe Delaere if (!gROOT->GetClass("TMultiLayerPerceptron")) { gSystem->Load("libMLP"); } // Prepare inputs // The 2 trees are merged into one, and a "type" branch, // equal to 1 for the signal and 0 for the background is added. const char *fname = "mlpHiggs.root"; TFile *input = 0; if (!gSystem->AccessPathName(fname)) { input = TFile::Open(fname); } else { printf("accessing %s file from http://root.cern.ch/files\n",fname); input = TFile::Open(Form("http://root.cern.ch/files/%s",fname)); } if (!input) return; TTree *signal = (TTree *) input->Get("sig_filtered"); TTree *background = (TTree *) input->Get("bg_filtered"); TTree *simu = new TTree("MonteCarlo", "Filtered Monte Carlo Events"); Float_t ptsumf, qelep, nch, msumf, minvis, acopl, acolin; Int_t type; signal->SetBranchAddress("ptsumf", &ptsumf); signal->SetBranchAddress("qelep", &qelep); signal->SetBranchAddress("nch", &nch); signal->SetBranchAddress("msumf", &msumf); signal->SetBranchAddress("minvis", &minvis); signal->SetBranchAddress("acopl", &acopl); signal->SetBranchAddress("acolin", &acolin); background->SetBranchAddress("ptsumf", &ptsumf); background->SetBranchAddress("qelep", &qelep); background->SetBranchAddress("nch", &nch); background->SetBranchAddress("msumf", &msumf); background->SetBranchAddress("minvis", &minvis); background->SetBranchAddress("acopl", &acopl); background->SetBranchAddress("acolin", &acolin); simu->Branch("ptsumf", &ptsumf, "ptsumf/F"); simu->Branch("qelep", &qelep, "qelep/F"); simu->Branch("nch", &nch, "nch/F"); simu->Branch("msumf", &msumf, "msumf/F"); simu->Branch("minvis", &minvis, "minvis/F"); simu->Branch("acopl", &acopl, "acopl/F"); simu->Branch("acolin", &acolin, "acolin/F"); simu->Branch("type", &type, "type/I"); type = 1; Int_t i; for (i = 0; i < signal->GetEntries(); i++) { signal->GetEntry(i); simu->Fill(); } type = 0; for (i = 0; i < background->GetEntries(); i++) { background->GetEntry(i); simu->Fill(); } // Build and train the NN ptsumf is used as a weight since we are primarly // interested by high pt events. // The datasets used here are the same as the default ones. TMultiLayerPerceptron *mlp = new TMultiLayerPerceptron("@msumf,@ptsumf,@acolin:5:3:type", "ptsumf",simu,"Entry$%2","(Entry$+1)%2"); mlp->Train(ntrain, "text,graph,update=10"); mlp->Export("test","python"); // Use TMLPAnalyzer to see what it looks for TCanvas* mlpa_canvas = new TCanvas("mlpa_canvas","Network analysis"); mlpa_canvas->Divide(2,2); TMLPAnalyzer ana(mlp); // Initialisation ana.GatherInformations(); // output to the console ana.CheckNetwork(); mlpa_canvas->cd(1); // shows how each variable influences the network ana.DrawDInputs(); mlpa_canvas->cd(2); // shows the network structure mlp->Draw(); mlpa_canvas->cd(3); // draws the resulting network ana.DrawNetwork(0,"type==1","type==0"); mlpa_canvas->cd(4); // Use the NN to plot the results for each sample // This will give approx. the same result as DrawNetwork. // All entries are used, while DrawNetwork focuses on // the test sample. Also the xaxis range is manually set. TH1F *bg = new TH1F("bgh", "NN output", 50, -.5, 1.5); TH1F *sig = new TH1F("sigh", "NN output", 50, -.5, 1.5); bg->SetDirectory(0); sig->SetDirectory(0); Double_t params[4]; for (i = 0; i < background->GetEntries(); i++) { background->GetEntry(i); params[0] = msumf; params[1] = ptsumf; params[2] = acolin; params[3] = acopl; bg->Fill(mlp->Evaluate(0, params)); } for (i = 0; i < signal->GetEntries(); i++) { signal->GetEntry(i); params[0] = msumf; params[1] = ptsumf; params[2] = acolin; params[3] = acopl; sig->Fill(mlp->Evaluate(0,params)); } bg->SetLineColor(kBlue); bg->SetFillStyle(3008); bg->SetFillColor(kBlue); sig->SetLineColor(kRed); sig->SetFillStyle(3003); sig->SetFillColor(kRed); bg->SetStats(0); sig->SetStats(0); bg->Draw(); sig->Draw("same"); TLegend *legend = new TLegend(.75, .80, .95, .95); legend->AddEntry(bg, "Background (WW)"); legend->AddEntry(sig, "Signal (Higgs)"); legend->Draw(); mlpa_canvas->cd(0); delete input; }