//__________________________________________________________________________ void Plot_JpsiV2_a2_newError() { gROOT->Macro("/Users/eusmartass/Software/utilities/setStyle.C+"); gStyle->SetOptFit(0); // options bool bDoDebug = false; bool bSavePlots = true; const int nptbins = 3; double pts[nptbins+1] = {6.5, 8.0, 10.0, 40.0}; int pt_start = 0; int pt_end = 3; int nPads = pt_end - pt_start; const int nsignals = 3; const char* signals[nsignals] = {"NSig","NPr","Pr"}; const char* legend[nsignals] = {"Inclusive J/#psi","Non-prompt J/#psi", "Prompt J/#psi"}; int signal_start = 0; int signal_end = 3; const int nrapbins = 2; double raps[nrapbins] = {0.0, 2.4}; const int ncentbins = 1; int cts[ncentbins+1] = {10, 60}; int vcts1 = cts[0]; int vcts2 = cts[1]; // phi bins const int nphibins = 4; float dPhiLimits[nphibins+1] = {0.0, TMath::PiOver2()/4, 2*TMath::PiOver2()/4, 3*TMath::PiOver2()/4, 4*TMath::PiOver2()/4}; double dPhiBinCenters[nphibins]; double dPhiBinCentersErr[nphibins]; for(int ibin=0; ibin<nphibins; ibin++) { dPhiBinCenters[ibin] = dPhiLimits[ibin]+dPhiBinWidth/2; dPhiBinCentersErr[ibin] = 0.0; cout<<"bin limits"<< dPhiLimits[ibin] << "\t"<< dPhiLimits[ibin+1]<<"\t"<<dPhiBinCenters[ibin]<<endl; } // inclusive double gYieldP_6580_nsig[nphibins] = {0.7144, 0.6189, 0.6412, 0.5720}; // yield of etHFp for 0 - 10 % double gYieldP_8010_nsig[nphibins] = {0.7267, 0.6793, 0.6196, 0.5209}; // yield of etHFp for 10 - 20 % double gYieldP_1040_nsig[nphibins] = {0.6255, 0.6932, 0.5899, 0.6379}; // yield of etHFp for 20 - 30 % double gYieldM_6580_nsig[nphibins] = {0.7359, 0.6641, 0.5687, 0.5779}; // yield of etHFm for 0 - 10 % double gYieldM_8010_nsig[nphibins] = {0.7465, 0.6629, 0.5406, 0.5964}; // yield of etHFm for 10 - 20 % double gYieldM_1040_nsig[nphibins] = {0.7645, 0.5795, 0.6301, 0.5723}; // yield of etHFm for 20 - 30 % double gYieldP_6580_nsig_err[nphibins] = {0.0478, 0.0439, 0.0434, 0.0419}; // error of etHFp for 0 - 10 % double gYieldP_8010_nsig_err[nphibins] = {0.0459, 0.0446, 0.0422, 0.0383}; // error of etHFp for 10 - 20 % double gYieldP_1040_nsig_err[nphibins] = {0.0399, 0.0420, 0.0388, 0.0403}; // error of etHFp for 20 - 30 % double gYieldM_6580_nsig_err[nphibins] = {0.0477, 0.0450, 0.0418, 0.0417}; // error of etHFm for 0 - 10 % double gYieldM_8010_nsig_err[nphibins] = {0.0475, 0.0444, 0.0405, 0.0423}; // error of etHFm for 10 - 20 % double gYieldM_1040_nsig_err[nphibins] = {0.0449, 0.0395, 0.0410, 0.0395}; // error of etHFm for 20 - 30 % // ------------ prompt double gYieldP_6580_pr[nphibins] = {0.7368, 0.6344, 0.6293, 0.5461}; // yield of etHFp for 0 - 10 % double gYieldP_8010_pr[nphibins] = {0.7525, 0.6752, 0.6059, 0.5129}; // yield of etHFp for 10 - 20 % double gYieldP_1040_pr[nphibins] = {0.6117, 0.7130, 0.5835, 0.6383}; // yield of etHFp for 20 - 30 % double gYieldM_6580_pr[nphibins] = {0.7580, 0.6799, 0.5575, 0.5510}; // yield of etHFm for 0 - 10 % double gYieldM_8010_pr[nphibins] = {0.7726, 0.6586, 0.5284, 0.5869}; // yield of etHFm for 10 - 20 % double gYieldM_1040_pr[nphibins] = {0.7497, 0.5977, 0.6249, 0.5741}; // yield of etHFm for 20 - 30 % //-------- double gYieldP_6580_pr_err[nphibins] = {0.0668, 0.0499, 0.0483, 0.0684}; // error of etHFp for 0 - 10 % double gYieldP_8010_pr_err[nphibins] = {0.0538, 0.0518, 0.0490, 0.0493}; // error of etHFp for 10 - 20 % double gYieldP_1040_pr_err[nphibins] = {0.0435, 0.0483, 0.0430, 0.0452}; // error of etHFp for 20 - 30 % double gYieldM_6580_pr_err[nphibins] = {0.0698, 0.0525, 0.0699, 0.0452}; // error of etHFm for 0 - 10 % double gYieldM_8010_pr_err[nphibins] = {0.0553, 0.0506, 0.0449, 0.0482}; // error of etHFm for 10 - 20 % double gYieldM_1040_pr_err[nphibins] = {0.0539, 0.0486, 0.0470, 0.0449}; // error of etHFm for 20 - 30 % // --------- non-prompt double gYieldP_6580_npr[nphibins] = {0.6187, 0.5526, 0.6921, 0.6830}; // yield of etHFp for 0 - 10 % double gYieldP_8010_npr[nphibins] = {0.6399, 0.6930, 0.6656, 0.5479}; // yield of etHFp for 10 - 20 % double gYieldP_1040_npr[nphibins] = {0.6593, 0.6444, 0.6057, 0.6371}; // yield of etHFp for 20 - 30 % double gYieldM_6580_npr[nphibins] = {0.6404, 0.5959, 0.6169, 0.6933}; // yield of etHFm for 0 - 10 % double gYieldM_8010_npr[nphibins] = {0.6585, 0.6775, 0.5819, 0.6285}; // yield of etHFm for 10 - 20 % double gYieldM_1040_npr[nphibins] = {0.8006, 0.5353, 0.6428, 0.5678}; // yield of etHFm for 20 - 30 % //------------- double gYieldP_6580_npr_err[nphibins] = {0.1014, 0.0900, 0.1008, 0.1174}; // error of etHFp for 0 - 10 % double gYieldP_8010_npr_err[nphibins] = {0.0893, 0.0926, 0.0888, 0.0831}; // error of etHFp for 10 - 20 % double gYieldP_1040_npr_err[nphibins] = {0.0629, 0.0654, 0.0603, 0.0624}; // error of etHFp for 20 - 30 % double gYieldM_6580_npr_err[nphibins] = {0.1052, 0.0967, 0.1060, 0.1033}; // error of etHFm for 0 - 10 % double gYieldM_8010_npr_err[nphibins] = {0.0919, 0.0906, 0.0792, 0.0901}; // error of etHFm for 10 - 20 % double gYieldM_1040_npr_err[nphibins] = {0.0761, 0.0599, 0.0647, 0.0587}; // error of etHFm for 20 - 30 % const int nhf = 2; TGraphErrors *g[nsignals][nptbins][nhf]; double pr[nsignals][nptbins][nhf], ep[nsignals][nptbins][nhf], chi[nsignals][nptbins][nhf], ndf[nsignals][nptbins][nhf]; double gYieldPlus[nptbins]; double gYieldMinus[nptbins]; double gYieldPlus_err[nptbins]; double gYieldMinus_err[nptbins]; for(int iSignal = signal_start; iSignal<signal_end; iSignal++) { const char* chosenSignal = signals[iSignal]; for(int ipt = pt_start; ipt < pt_end; ipt++) { TGraphErrors *pgTempP; TGraphErrors *pgTempM; switch (ipt) { case 0: if (iSignal == 0) { assignArray(gYieldP_6580_nsig,gYieldPlus); assignArray(gYieldM_6580_nsig,gYieldMinus); assignArray(gYieldP_6580_nsig_err,gYieldPlus_err); assignArray(gYieldM_6580_nsig_err,gYieldMinus_err); } else if (iSignal == 1) { assignArray(gYieldP_6580_npr,gYieldPlus); assignArray(gYieldM_6580_npr,gYieldMinus); assignArray(gYieldP_6580_npr_err,gYieldPlus_err); assignArray(gYieldM_6580_npr_err,gYieldMinus_err); } else { assignArray(gYieldP_6580_pr,gYieldPlus); assignArray(gYieldM_6580_pr,gYieldMinus); assignArray(gYieldP_6580_pr_err,gYieldPlus_err); assignArray(gYieldM_6580_pr_err,gYieldMinus_err); } break; case 1: if (iSignal == 0) { assignArray(gYieldP_8010_nsig,gYieldPlus); assignArray(gYieldM_8010_nsig,gYieldMinus); assignArray(gYieldP_8010_nsig_err,gYieldPlus_err); assignArray(gYieldM_8010_nsig_err,gYieldMinus_err); } else if (iSignal == 1) { assignArray(gYieldP_8010_npr,gYieldPlus); assignArray(gYieldM_8010_npr,gYieldMinus); assignArray(gYieldP_8010_npr_err,gYieldPlus_err); assignArray(gYieldM_8010_npr_err,gYieldMinus_err); } else { assignArray(gYieldP_8010_pr,gYieldPlus); assignArray(gYieldM_8010_pr,gYieldMinus); assignArray(gYieldP_8010_pr_err,gYieldPlus_err); assignArray(gYieldM_8010_pr_err,gYieldMinus_err); } break; case 2: if (iSignal == 0) { assignArray(gYieldP_1040_nsig,gYieldPlus); assignArray(gYieldM_1040_nsig,gYieldMinus); assignArray(gYieldP_1040_nsig_err,gYieldPlus_err); assignArray(gYieldM_1040_nsig_err,gYieldMinus_err); } else if (iSignal == 1) { assignArray(gYieldP_1040_npr,gYieldPlus); assignArray(gYieldM_1040_npr,gYieldMinus); assignArray(gYieldP_1040_npr_err,gYieldPlus_err); assignArray(gYieldM_1040_npr_err,gYieldMinus_err); } else { assignArray(gYieldP_1040_pr,gYieldPlus); assignArray(gYieldM_1040_pr,gYieldMinus); assignArray(gYieldP_1040_pr_err,gYieldPlus_err); assignArray(gYieldM_1040_pr_err,gYieldMinus_err); } break; default: cout<< "Wrong pt, please pick something else!"<<endl; }//ipt switch pgTempP = new TGraphErrors(nphibins, dPhiBinCenters, gYieldPlus, dPhiBinCentersErr, gYieldPlus_err); pgTempM = new TGraphErrors(nphibins, dPhiBinCenters, gYieldMinus, dPhiBinCentersErr, gYieldMinus_err); g[iSignal][ipt][0] = pgTempP; g[iSignal][ipt][1] = pgTempM; double cp[4] = {0.0, 0.0, 0.0, 0.0}; double cm[4] = {0.0, 0.0, 0.0, 0.0}; GetV2(g[iSignal][ipt][0], cp); GetV2(g[iSignal][ipt][1], cm); pr[iSignal][ipt][0] = cp[0]; ep[iSignal][ipt][0] = cp[1]; chi[iSignal][ipt][0] = cp[2]; ndf[iSignal][ipt][0] = cp[3]; pr[iSignal][ipt][1] = cm[0]; ep[iSignal][ipt][1] = cm[1]; chi[iSignal][ipt][1] = cm[2]; ndf[iSignal][ipt][1] = cm[3]; }//pt loop // #### Drawing: TLatex *lt1 = new TLatex(); lt1->SetNDC(); lt1->SetTextSize(0.05); // frawing: TCanvas *pc1 = new TCanvas("pc1",Form("pcV2_intPt"),0,0,850,350); TH1F *pp = new TH1F("pp", Form(";| #phi_{J/#psi} - #Psi_{EP} | (rad);#frac{1}{N_{total J/#psi}} #frac{dN}{d#phi} (rad^{-1})"),4,0,TMath::PiOver2()); pp->GetXaxis()->SetLabelSize(20); pp->GetXaxis()->SetLabelFont(43); pp->GetXaxis()->SetTitleSize(18); pp->GetXaxis()->SetTitleFont(43); pp->GetXaxis()->SetTitleOffset(1.2); pp->GetXaxis()->CenterTitle(); pp->GetYaxis()->SetLabelSize(20); pp->GetYaxis()->SetLabelFont(43); pp->GetYaxis()->SetTitleSize(19); pp->GetYaxis()->SetTitleFont(43); pp->GetYaxis()->SetTitleOffset(1.43); pp->GetYaxis()->CenterTitle(); makeMultiPanelCanvas(pc1,nPads,1,0.0,0.0,0.2,0.15,0.02); int ind = 0; for(int ipt = pt_start; ipt < pt_end; ipt++) { if(!g[iSignal][ipt][0]|| !g[iSignal][ipt][1]) { cout<<"No graph! continued !!!!"<<endl; continue; } double vpts1 = pts[ipt]; double vpts2 = pts[ipt+1]; cout<<"Pt bin: "<<vpts1<<"-"<<vpts2<<endl; pc1->cd(ind+1); pp->SetMaximum(1.2); pp->SetMinimum(0.2); pp->Draw(); TGraphErrors *pgP = (TGraphErrors *) g[iSignal][ipt][0]; TGraphErrors *pgM = (TGraphErrors *) g[iSignal][ipt][1]; pgP->SetMarkerStyle(20); pgM->SetMarkerStyle(24); pgP->Draw("pz"); pgM->Draw("pz"); if(ind==0 ) { // drapwing v2 value and chi2 lt1->SetTextSize(0.045); lt1->DrawLatex(0.24,0.23,Form("v_{2}^{etHFp} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][ipt][0], ep[iSignal][ipt][0], chi[iSignal][ipt][0], ndf[iSignal][ipt][0])); lt1->DrawLatex(0.24,0.18,Form("v_{2}^{etHFm} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][ipt][1], ep[iSignal][ipt][1], chi[iSignal][ipt][1], ndf[iSignal][ipt][1])); lt1->SetTextSize(0.055); lt1->DrawLatex(0.24,0.3,Form("%.1f < p_{T} < %.0f GeV/c",vpts1, vpts2)); // pt } else { lt1->SetTextSize(0.05); lt1->DrawLatex(0.05,0.23,Form("v_{2}^{etHFp} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][ipt][0], ep[iSignal][ipt][0], chi[iSignal][ipt][0], ndf[iSignal][ipt][0])); lt1->DrawLatex(0.05,0.18,Form("v_{2}^{etHFm} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][ipt][1], ep[iSignal][ipt][1], chi[iSignal][ipt][1], ndf[iSignal][ipt][1])); lt1->SetTextSize(0.06); if(ind == 1) lt1->DrawLatex(0.05,0.3,Form("%.1f < p_{T} < %.0f GeV/c", vpts1, vpts2)); if(ind > 1) lt1->DrawLatex(0.05,0.3,Form("%.1f < p_{T} < %.0f GeV/c", vpts1, vpts2)); if(ind == 2) { lt1->SetTextSize(0.06); lt1->DrawLatex(0.45,0.8,Form("|y| < %.1f",raps[1])); // rapidity lt1->DrawLatex(0.45,0.73,Form("Cent. %d - %d %%",vcts1, vcts2)); // centrality } if(ind==1) { TLegend *legCent = new TLegend(0.7,0.8,0.95,0.95); legCent->SetFillColor(0); legCent->SetBorderSize(0); legCent->SetTextSize(0.07); legCent->AddEntry(pgP,"etHFp","P"); legCent->AddEntry(pgM,"etHFm","P"); legCent->Draw("same"); } } ind++; }//ipt //_______ stuff to write pc1->cd(1); TLatex *tex1 = new TLatex(0.23,0.93,"CMS Preliminary"); tex1->SetNDC(); tex1->SetTextAlign(13); tex1->SetTextFont(43); tex1->SetTextSize(23); tex1->SetLineWidth(1); tex1->Draw(); TLatex *tex2 = new TLatex(0.23,0.84,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); tex2->SetNDC(); tex2->SetTextAlign(13); tex2->SetTextFont(43); tex2->SetTextSize(18); tex2->SetLineWidth(2); tex2->Draw(); pc1->cd(1); TLatex *tex3 = new TLatex(0.23,0.75,"L_{int} = 150 #mub^{-1}"); tex3->SetNDC(); tex3->SetTextAlign(13); tex3->SetTextFont(43); tex3->SetTextSize(18); tex3->SetLineWidth(2); tex3->Draw(); pc1->cd(3); lt1->SetTextSize(0.06); lt1->DrawLatex(0.05,0.89,Form("%s",legend[iSignal])); // what signal is //_______ if(bSavePlots) { pc1->SaveAs(Form("%s_Jpsi_a2_newErr_Nominal.png",chosenSignal)); pc1->SaveAs(Form("%s_Jpsi_a2_newErr_Nominal.pdf",chosenSignal)); } // pc1->Clear(); cout<<""<<endl; cout<<"%%%%% Category etHFp: "<<signals[iSignal]<<" %%%%%"<<endl; cout<<"| pt. | 6.5-8.0 | 8-10 | 10-40 |"<<endl; cout<<"| v2 |"<<" "<<pr[iSignal][0][0]<<" | "<<pr[iSignal][1][0]<<" | "<<pr[iSignal][2][0]<<" |"<<endl; cout<<"| err |"<<" "<<ep[iSignal][0][0]<<" | "<<ep[iSignal][1][0]<<" | "<<ep[iSignal][2][0]<<" |"<<endl; cout<<"%%%%% Category etHFm: "<<signals[iSignal]<<" %%%%%"<<endl; cout<<"| pt. | 6.5-8.0 | 8-10 | 10-40 |"<<endl; cout<<"| v2 |"<<" "<<pr[iSignal][0][1]<<" | "<<pr[iSignal][1][1]<<" | "<<pr[iSignal][2][1]<<" |"<<endl; cout<<"| err |"<<" "<<ep[iSignal][0][1]<<" | "<<ep[iSignal][1][1]<<" | "<<ep[iSignal][2][1]<<" |"<<endl; }// chose signal }
virtual StaticArray<T>& operator=(const StaticArray<T>& array) { assignArray(array); return *this; }
int main(int argc, char *argv[]) { int all; /*Nombre d'atomes dans pdb*/ int atom; /*Nombre de carbone CA*/ int help_flag = 0; char file_name[500]; char file_eigen[500] = "eigen.dat"; char check_name[500]; char check_eigen[500] = "eigen_t.dat"; int verbose = 0; int mode = 6; float vinit = 1; // Valeur de base float bond_factor = 1; // Facteur pour poid des bond strechcing float angle_factor = 1; // Facteur pour poid des angles double K_phi1 = 1; // Facteurs pour angles dièdres double K_phi3 = 0.5; float init_templaate = 1; float kp_factor = 1; // Facteur pour poid des angles dièdres char inputname[500] ="none"; char matrix_name[500]; int i, j, k, l; int nconn; int lig = 0; int lig_t = 0; float factor = 1.0; for (i = 1;i < argc;i++) { if (strcmp("-i",argv[i]) == 0) {strcpy(file_name,argv[i+1]);--help_flag;} if (strcmp("-t",argv[i]) == 0) {strcpy(check_name,argv[i+1]);--help_flag;} if (strcmp("-init",argv[i]) == 0) {float temp;sscanf(argv[i+1],"%f",&temp);vinit = temp;} if (strcmp("-kr",argv[i]) == 0) {float temp;sscanf(argv[i+1],"%f",&temp);bond_factor = temp;} if (strcmp("-kt",argv[i]) == 0) {float temp;sscanf(argv[i+1],"%f",&temp);angle_factor = temp;} if (strcmp("-kpf",argv[i]) == 0) {float temp;sscanf(argv[i+1],"%f",&temp); kp_factor = temp;} if (strcmp("-m",argv[i]) == 0) {strcpy(matrix_name,argv[i+1]);help_flag = 0;} if (strcmp("-lig",argv[i]) == 0) {lig = 1;} if (strcmp("-ligt",argv[i]) == 0) {lig_t = 1;} if (strcmp("-h",argv[i]) == 0) {help_flag = 1;} if (strcmp("-v",argv[i]) == 0) {verbose = 1;} } if (help_flag == 1) { printf("****************************\nHelp Section\n-i\tFile Input (PDB)\n-o\tOutput Name Motion\n-ieig\tFile Name Eigen\n-v\tVerbose\n-sp\tSuper Node Mode (CA, N, C)\n-m\tMode\n-nm\tNombre de mode\n-lig\tTient compte duligand (sauf HOH)\n-prox\tAffiche la probabilite que deux CA puissent interagir\n-prev\tAffiche les directions principales du mouvement de chaque CA ponderees par leur ecart-type\n****************************\n"); return(0); } //*************************************************** //* * //*Builds a structure contaning information on the initial pdb structure //* * //*************************************************** all = count_atom(file_name); nconn = count_connect(file_name); if (verbose == 1) {printf("Connect:%d\n",nconn);} if (verbose == 1) {printf("Assigning Structure\n\tAll Atom\n");} // Array with all connects int **connect_h=(int **)malloc(nconn*sizeof(int *)); for(i=0;i<nconn;i++) { connect_h[i]=(int *)malloc(6*sizeof(int));} assign_connect(file_name,connect_h); // Assigns all the atoms struct pdb_atom strc_all[all]; atom = build_all_strc(file_name,strc_all); // Retourne le nombre de Node if (atom > 800) {printf("Too much nodes .... To fix, ask [email protected]\n");return(1);} if (verbose == 1) {printf(" Atom:%d\n",all);} check_lig(strc_all,connect_h,nconn,all); // Assigns all Nodes if (verbose == 1) {printf(" CA Structure\n");} if (verbose == 1) {printf(" Node:%d\n",atom);} struct pdb_atom strc_node[atom]; atom = build_cord_CA(strc_all, strc_node,all,lig,connect_h,nconn); if (verbose == 1) {printf(" Assign Node:%d\n",atom);} // Free Connect //for(i=0;i<nconn;i++) {printf("I:%d\n",i);free(connect_h[i]);} //free(connect_h); printf("Check 1\n"); //*************************************************** //* * //*Builds a structure contaning information on the target pdb structure //* * //*************************************************** nconn = 0; int all_t = count_atom(check_name); nconn = count_connect(check_name); if (verbose == 1) {printf("Connect:%d\n",nconn);} if (verbose == 1) {printf("Assigning Structure\n\tAll Atom\n");} // Array with all connects int **connect_t=(int **)malloc(nconn*sizeof(int *)); for(i=0;i<nconn;i++) { connect_t[i]=(int *)malloc(6*sizeof(int));} assign_connect(check_name,connect_t); // Assigns all the atoms struct pdb_atom strc_all_t[all_t]; int atom_t = build_all_strc(check_name,strc_all_t); // Retourne le nombre de Node if (atom_t > 800) {printf("Too much node.... To fix, ask [email protected]\n");return(1);} if (verbose == 1) {printf(" Atom:%d\n",all_t);} check_lig(strc_all_t,connect_t,nconn,all_t); // Assigns all Nodes if (verbose == 1) {printf(" CA Structure\n");} if (verbose == 1) {printf(" Node:%d\n",atom_t);} struct pdb_atom strc_node_t[atom_t]; atom_t = build_cord_CA(strc_all_t, strc_node_t,all_t,lig_t,connect_t,nconn); if (verbose == 1) {printf(" Assign Node:%d\n",atom_t);} printf("Check 2\n"); //*************************************************** //* * //*Aligns both structures * //* * //*************************************************** int align[atom]; int score = node_align(strc_node,atom,strc_node_t,atom_t,align); printf("RMSD:%8.5f Score: %d/%d\n",sqrt(rmsd_no(strc_node,strc_node_t,atom, align)),score,atom); if ((float)score/(float)atom < 0.8) { printf("Low Score... Will try an homemade alignement !!!\n"); score = node_align_onechain(strc_node,atom,strc_node_t,atom_t,align); printf("RMSD:%8.5f Score: %d/%d\n",sqrt(rmsd_no(strc_node,strc_node_t,atom, align)),score,atom); } if ((float)score/(float)atom < 0.8) { printf("Low Score... Will try an homemade alignement !!!\n"); score = node_align_low(strc_node,atom,strc_node_t,atom_t,align); printf("RMSD:%8.5f Score: %d/%d\n",sqrt(rmsd_no(strc_node,strc_node_t,atom, align)),score,atom); } printf("RMSD:%8.5f Score: %d/%d\n",sqrt(rmsd_yes(strc_node,strc_node_t,atom, align,strc_all,all)),score,atom); printf("Check 4\n"); //*************************************************** //* * //*Build hessian matrices * //* * //*************************************************** double **hessian=(double **)malloc(3*atom*sizeof(double *)); // Matrix of the Hessian 1 2 3 (bond, angle, dihedral) for(i=0;i<3*atom;i++) { hessian[i]=(double *)malloc(3*atom*sizeof(double));} for(i=0;i<3*atom;i++)for(j=0;j<(3*atom);j++){hessian[i][j]=0;} gsl_matrix *hess = gsl_matrix_alloc(3*atom,3*atom); gsl_matrix_set_all(hess, 0); gsl_matrix *hess_t = gsl_matrix_alloc(3*atom_t,3*atom_t); gsl_matrix_set_all(hess_t, 0); assign_atom_type(strc_all, all); if (strcmp(inputname,"none") == 0) {} else {assign_lig_type(strc_all, all, inputname);} gsl_matrix *vcon = gsl_matrix_alloc(all,all); gsl_matrix *inter_m = gsl_matrix_alloc(8,8); gsl_matrix *templaate = gsl_matrix_alloc(atom*3, atom*3); gsl_matrix_set_all(templaate,vinit); gsl_matrix_set_all(vcon,0); if (verbose == 1) {printf("Do Vcon !!!\n");} vcon_file_dom(strc_all,vcon,all); if (verbose == 1) {printf("Reading Interaction Matrix %s\n",matrix_name);} load_matrix(inter_m,matrix_name); //write_matrix("vcon_vince.dat", vcon,all,all); if (verbose == 1) {printf("Building templaate\n");} all_interaction(strc_all,all, atom, templaate,lig,vcon,inter_m,strc_node); gsl_matrix_scale (templaate, init_templaate); if (verbose == 1) {printf("Building Hessian\n");} if (verbose == 1) {printf("\tCovalent Bond Potential\n");} build_1st_matrix(strc_node,hessian,atom,bond_factor); if (verbose == 1) {printf("\tAngle Potential\n");} build_2_matrix(strc_node,hessian,atom,angle_factor); if (verbose == 1) {printf("\tDihedral Potential\n");} build_3_matrix(strc_node, hessian,atom,K_phi1/2+K_phi3*9/2,kp_factor); if (verbose == 1) {printf("\tNon Local Interaction Potential\n");} build_4h_matrix(strc_node,hessian,atom,1.0,templaate); if (verbose == 1) {printf("\tAssigning Array\n");} assignArray(hess,hessian,3*atom,3*atom); gsl_matrix_free(vcon); gsl_matrix_free(templaate); double **hessian_t=(double **)malloc(3*atom_t*sizeof(double *)); // Matrix of the Hessian 1 2 3 (bond, angle, dihedral) for(i=0;i<3*atom_t;i++) { hessian_t[i]=(double *)malloc(3*atom_t*sizeof(double));} for(i=0;i<3*atom_t;i++)for(j=0;j<(3*atom_t);j++){hessian_t[i][j]=0;} assign_atom_type(strc_all_t, all_t); if (strcmp(inputname,"none") == 0) {} else {assign_lig_type(strc_all_t, all_t, inputname);} gsl_matrix *vcon_t = gsl_matrix_alloc(all_t,all_t); gsl_matrix *templaate_t = gsl_matrix_alloc(atom_t*3, atom_t*3); gsl_matrix_set_all(templaate_t,vinit); gsl_matrix_set_all(vcon_t,0); if (verbose == 1) {printf("Do Vcon !!!\n");} vcon_file_dom(strc_all_t,vcon_t,all_t); //write_matrix("vcon_vince.dat", vcon,all,all); if (verbose == 1) {printf("Building templaate\n");} all_interaction(strc_all_t,all_t, atom_t, templaate_t,lig,vcon_t,inter_m,strc_node_t); gsl_matrix_scale (templaate_t, init_templaate); if (verbose == 1) {printf("Building Hessian\n");} if (verbose == 1) {printf("\tCovalent Bond Potential\n");} build_1st_matrix(strc_node_t,hessian_t,atom_t,bond_factor); if (verbose == 1) {printf("\tAngle Potential\n");} build_2_matrix(strc_node_t,hessian_t,atom_t,angle_factor); if (verbose == 1) {printf("\tDihedral Potential\n");} build_3_matrix(strc_node_t, hessian_t,atom_t,K_phi1/2+K_phi3*9/2,kp_factor); if (verbose == 1) {printf("\tNon Local Interaction Potential\n");} build_4h_matrix(strc_node_t,hessian_t,atom_t,1.0,templaate_t); if (verbose == 1) {printf("\tAssigning Array\n");} assignArray(hess_t,hessian_t,3*atom_t,3*atom_t); gsl_matrix_free(vcon_t); gsl_matrix_free(templaate_t); printf("Check 5\n"); //*************************************************** //* * //*Build mini hessian matrices * //* * //*************************************************** gsl_matrix *mini_hess = gsl_matrix_alloc(3*score, 3*score); gsl_matrix_set_all(mini_hess, 0); gsl_matrix *mini_hess_t = gsl_matrix_alloc(3*score, 3*score); gsl_matrix_set_all(mini_hess_t, 0); int sup_line = 0; int sup_to_node[score]; for(i = 0; i < atom; i++) { if(align[i] == -1) {continue;} sup_to_node[sup_line] = i; int sup_col = 0; for(j = 0; j < atom; j++) { if(align[j] == -1) {continue;} for(k = 0; k < 3; k++) { for(l = 0; l < 3; l++) { gsl_matrix_set(mini_hess, 3*sup_line + k, 3*sup_col + l, gsl_matrix_get(hess, 3*i + k, 3*j + l)); gsl_matrix_set(mini_hess_t, 3*sup_line + k, 3*sup_col + l, gsl_matrix_get(hess_t, 3*align[i] + k, 3*align[j] + l)); } } sup_col ++; } sup_line++; } gsl_matrix_free(hess); gsl_matrix_free(hess_t); printf("Check 6\n"); gsl_vector *mini_eval = gsl_vector_alloc(3*score); gsl_matrix *mini_evec = gsl_matrix_alloc (3*score,3*score); gsl_vector *mini_eval_t = gsl_vector_alloc(3*score); gsl_matrix *mini_evec_t = gsl_matrix_alloc (3*score,3*score); diagonalyse_matrix(mini_hess,3*score,mini_eval,mini_evec); diagonalyse_matrix(mini_hess_t,3*score,mini_eval_t,mini_evec_t); gsl_matrix_set_all(mini_hess, 0); gsl_matrix_set_all(mini_hess_t, 0); for(i = 0; i < 3*score; i++) { if(gsl_vector_get(mini_eval, i) > 0.0000001) { gsl_vector_set(mini_eval, i, 1.0 / gsl_vector_get(mini_eval, i)); for(j = 0; j < 3*score; j++) { for(k = 0; k < 3*score; k++) { gsl_matrix_set(mini_hess, j, k, gsl_matrix_get(mini_hess, j, k) + gsl_matrix_get(mini_evec, j, i)*gsl_matrix_get(mini_evec, k, i)*gsl_vector_get(mini_eval, i)); } } } } for(i = 0; i < 3*score; i++) { if(gsl_vector_get(mini_eval_t, i) > 0.0000001) { gsl_vector_set(mini_eval_t, i, 1.0 / gsl_vector_get(mini_eval_t, i)); for(j = 0; j < 3*score; j++) { for(k = 0; k < 3*score; k++) { gsl_matrix_set(mini_hess_t, j, k, gsl_matrix_get(mini_hess_t, j, k) + gsl_matrix_get(mini_evec_t, j, i)*gsl_matrix_get(mini_evec_t, k, i)*gsl_vector_get(mini_eval_t, i)); } } } } printf("Check 7\n"); printf("Dynamic distance : %1.10f\n", cmp_gauss(mini_hess, mini_eval, mini_hess_t, mini_eval_t, 3*score)); gsl_matrix_free(mini_hess); gsl_matrix_free(mini_evec); gsl_vector_free(mini_eval); gsl_matrix_free(mini_hess_t); gsl_matrix_free(mini_evec_t); gsl_vector_free(mini_eval_t); free(connect_h); return(1); }
//__________________________________________________________________________ void Plot_JpsiV2_a1_newError() { gROOT->Macro("/Users/eusmartass/Software/utilities/setStyle.C+"); gStyle->SetOptFit(0); // options bool bDoDebug = false; bool bSavePlots = true; const int ncentbins = 4; int cts[ncentbins+1] = {0, 10, 20, 30, 60}; int centrality_start = 0; int centrality_end = 4; int nPads = centrality_end - centrality_start; const int nsignals = 3; const char* signals[nsignals] = {"NSig","NPr","Pr"}; const char* legend[nsignals] = {"Inclusive J/#psi","Non-prompt J/#psi","Prompt J/#psi",}; int signal_start = 0; int signal_end = 3; const int nrapbins = 2; double raps[nrapbins] = {0.0, 2.4}; const int nptbins = 2; double pts[nptbins] = {6.5, 40.0}; int pt_start = 0; int pt_end = 1; // phi bins const int nphibins = 4; float dPhiLimits[nphibins+1] = {0.0, TMath::PiOver2()/4, 2*TMath::PiOver2()/4, 3*TMath::PiOver2()/4, 4*TMath::PiOver2()/4}; double dPhiBinCenters[nphibins]; double dPhiBinCentersErr[nphibins]; for(int ibin=0; ibin<nphibins; ibin++) { dPhiBinCenters[ibin] = dPhiLimits[ibin]+dPhiBinWidth/2; dPhiBinCentersErr[ibin] = 0.0; cout<<"bin limits"<< dPhiLimits[ibin] << "\t"<< dPhiLimits[ibin+1]<<"\t"<<dPhiBinCenters[ibin]<<endl; } // inclusive double gYieldP_0010_nsig[nphibins] = {0.6791, 0.6419, 0.6078, 0.6177}; // yield of etHFp for 0 - 10 % double gYieldP_1020_nsig[nphibins] = {0.6788, 0.6745, 0.6424, 0.5508}; // yield of etHFp for 10 - 20 % double gYieldP_2030_nsig[nphibins] = {0.7705, 0.5811, 0.6172, 0.5776}; // yield of etHFp for 20 - 30 % double gYieldP_3060_nsig[nphibins] = {0.6405, 0.6994, 0.5997, 0.6069}; // yield of etHFp for 30 - 60 % double gYieldM_0010_nsig[nphibins] = {0.6796, 0.6196, 0.6358, 0.6115}; // yield of etHFm for 0 - 10 % double gYieldM_1020_nsig[nphibins] = {0.7550, 0.6097, 0.5786, 0.6032}; // yield of etHFm for 10 - 20 % double gYieldM_2030_nsig[nphibins] = {0.7167, 0.6719, 0.5886, 0.5693}; // yield of etHFm for 20 - 30 % double gYieldM_3060_nsig[nphibins] = {0.7554, 0.6385, 0.5759, 0.5767}; // yield of etHFm for 30 - 60 % double gYieldP_0010_nsig_err[nphibins] = {0.0409, 0.0404, 0.0389, 0.0382}; // error of etHFp for 0 - 10 % double gYieldP_1020_nsig_err[nphibins] = {0.0436, 0.0427, 0.0413, 0.0386}; // error of etHFp for 10 - 20 % double gYieldP_2030_nsig_err[nphibins] = {0.0523, 0.0461, 0.0467, 0.0449}; // error of etHFp for 20 - 30 % double gYieldP_3060_nsig_err[nphibins] = {0.0396, 0.0409, 0.0378, 0.0379}; // error of etHFp for 30 - 60 % double gYieldM_0010_nsig_err[nphibins] = {0.0419, 0.0405, 0.0403, 0.0399}; // error of etHFm for 0 - 10 % double gYieldM_1020_nsig_err[nphibins] = {0.0469, 0.0425, 0.0414, 0.0419}; // error of etHFm for 10 - 20 % double gYieldM_2030_nsig_err[nphibins] = {0.0504, 0.0485, 0.0454, 0.0448}; // error of etHFm for 20 - 30 % double gYieldM_3060_nsig_err[nphibins] = {0.0423, 0.0389, 0.0369, 0.0371}; // error of etHFm for 30 - 60 % // prompt double gYieldP_0010_pr[nphibins] = {0.6533, 0.6450, 0.6174, 0.6307}; // yield of etHFp for 0 - 10 % double gYieldP_1020_pr[nphibins] = {0.6567, 0.6927, 0.6500, 0.5471}; // yield of etHFp for 10 - 20 % double gYieldP_2030_pr[nphibins] = {0.8234, 0.5767, 0.5598, 0.5866}; // yield of etHFp for 20 - 30 % double gYieldP_3060_pr[nphibins] = {0.6453, 0.7071, 0.6158, 0.5782}; // yield of etHFp for 30 - 60 % double gYieldM_0010_pr[nphibins] = {0.6538, 0.6226, 0.6458, 0.6244}; // yield of etHFm for 0 - 10 % double gYieldM_1020_pr[nphibins] = {0.7319, 0.6275, 0.5867, 0.6004}; // yield of etHFm for 10 - 20 % double gYieldM_2030_pr[nphibins] = {0.7665, 0.6673, 0.5342, 0.5785}; // yield of etHFm for 20 - 30 % double gYieldM_3060_pr[nphibins] = {0.7607, 0.6453, 0.5912, 0.5492}; // yield of etHFm for 30 - 60 % double gYieldP_0010_pr_err[nphibins] = {0.0555, 0.0472, 0.0510, 0.0450}; // error of etHFp for 0 - 10 % double gYieldP_1020_pr_err[nphibins] = {0.0525, 0.0511, 0.0516, 0.0513}; // error of etHFp for 10 - 20 % double gYieldP_2030_pr_err[nphibins] = {0.0613, 0.0568, 0.0490, 0.0615}; // error of etHFp for 20 - 30 % double gYieldP_3060_pr_err[nphibins] = {0.0476, 0.0476, 0.0431, 0.0439}; // error of etHFp for 30 - 60 % double gYieldM_0010_pr_err[nphibins] = {0.0465, 0.0492, 0.0482, 0.0463}; // error of etHFm for 0 - 10 % double gYieldM_1020_pr_err[nphibins] = {0.0625, 0.0491, 0.0517, 0.0515}; // error of etHFm for 10 - 20 % double gYieldM_2030_pr_err[nphibins] = {0.0617, 0.0561, 0.0488, 0.0516}; // error of etHFm for 20 - 30 % double gYieldM_3060_pr_err[nphibins] = {0.0504, 0.0443, 0.0465, 0.0419}; // error of etHFm for 30 - 60 % // non-prompt double gYieldP_0010_npr[nphibins] = {0.7498, 0.6333, 0.5816, 0.5818}; // yield of etHFp for 0 - 10 % double gYieldP_1020_npr[nphibins] = {0.7468, 0.6187, 0.6188, 0.5621}; // yield of etHFp for 10 - 20 % double gYieldP_2030_npr[nphibins] = {0.5920, 0.5960, 0.8109, 0.5476}; // yield of etHFp for 20 - 30 % double gYieldP_3060_npr[nphibins] = {0.6239, 0.6727, 0.5437, 0.7062}; // yield of etHFp for 30 - 60 % double gYieldM_0010_npr[nphibins] = {0.7504, 0.6114, 0.6085, 0.5761}; // yield of etHFm for 0 - 10 % double gYieldM_1020_npr[nphibins] = {0.8253, 0.5557, 0.5538, 0.6116}; // yield of etHFm for 10 - 20 % double gYieldM_2030_npr[nphibins] = {0.5493, 0.6875, 0.7714, 0.5383}; // yield of etHFm for 20 - 30 % double gYieldM_3060_npr[nphibins] = {0.7367, 0.6150, 0.5228, 0.6719}; // yield of etHFm for 30 - 60 % //------ double gYieldP_0010_npr_err[nphibins] = {0.0839, 0.0726, 0.0722, 0.0676}; // error of etHFp for 0 - 10 % double gYieldP_1020_npr_err[nphibins] = {0.0873, 0.0797, 0.0819, 0.0832}; // error of etHFp for 10 - 20 % double gYieldP_2030_npr_err[nphibins] = {0.0908, 0.0926, 0.1024, 0.0964}; // error of etHFp for 20 - 30 % double gYieldP_3060_npr_err[nphibins] = {0.0776, 0.0845, 0.0717, 0.0832}; // error of etHFp for 30 - 60 % //----- double gYieldM_0010_npr_err[nphibins] = {0.0771, 0.0724, 0.0719, 0.0678}; // error of etHFm for 0 - 10 % double gYieldM_1020_npr_err[nphibins] = {0.0993, 0.0730, 0.0768, 0.0875}; // error of etHFm for 10 - 20 % double gYieldM_2030_npr_err[nphibins] = {0.0862, 0.1007, 0.0991, 0.0899}; // error of etHFm for 20 - 30 % double gYieldM_3060_npr_err[nphibins] = {0.0880, 0.0779, 0.0717, 0.0793}; // error of etHFm for 30 - 60 % const int nhf = 2; TGraphErrors *g[nsignals][ncentbins][nhf]; double pr[nsignals][ncentbins][nhf], ep[nsignals][ncentbins][nhf], chi[nsignals][ncentbins][nhf], ndf[nsignals][ncentbins][nhf]; double vpts1 = pts[pt_start]; double vpts2 = pts[pt_end]; double gYieldPlus[ncentbins]; double gYieldMinus[ncentbins]; double gYieldPlus_err[ncentbins]; double gYieldMinus_err[ncentbins]; for(int iSignal = signal_start; iSignal<signal_end; iSignal++) { const char* chosenSignal = signals[iSignal]; for(int mcent = centrality_start; mcent < centrality_end; mcent++) { TGraphErrors *pgTempP; TGraphErrors *pgTempM; switch (mcent) { case 0: if (iSignal == 0) { assignArray(gYieldP_0010_nsig,gYieldPlus); assignArray(gYieldM_0010_nsig,gYieldMinus); assignArray(gYieldP_0010_nsig_err,gYieldPlus_err); assignArray(gYieldM_0010_nsig_err,gYieldMinus_err); } else if (iSignal == 1) { assignArray(gYieldP_0010_npr,gYieldPlus); assignArray(gYieldM_0010_npr,gYieldMinus); assignArray(gYieldP_0010_npr_err,gYieldPlus_err); assignArray(gYieldM_0010_npr_err,gYieldMinus_err); } else { assignArray(gYieldP_0010_pr,gYieldPlus); assignArray(gYieldM_0010_pr,gYieldMinus); assignArray(gYieldP_0010_pr_err,gYieldPlus_err); assignArray(gYieldM_0010_pr_err,gYieldMinus_err); } break; case 1: if (iSignal == 0) { assignArray(gYieldP_1020_nsig,gYieldPlus); assignArray(gYieldM_1020_nsig,gYieldMinus); assignArray(gYieldP_1020_nsig_err,gYieldPlus_err); assignArray(gYieldM_1020_nsig_err,gYieldMinus_err); } else if (iSignal == 1) { assignArray(gYieldP_1020_npr,gYieldPlus); assignArray(gYieldM_1020_npr,gYieldMinus); assignArray(gYieldP_1020_npr_err,gYieldPlus_err); assignArray(gYieldM_1020_npr_err,gYieldMinus_err); } else { assignArray(gYieldP_1020_pr,gYieldPlus); assignArray(gYieldM_1020_pr,gYieldMinus); assignArray(gYieldP_1020_pr_err,gYieldPlus_err); assignArray(gYieldM_1020_pr_err,gYieldMinus_err); } break; case 2: if (iSignal == 0) { assignArray(gYieldP_2030_nsig,gYieldPlus); assignArray(gYieldM_2030_nsig,gYieldMinus); assignArray(gYieldP_2030_nsig_err,gYieldPlus_err); assignArray(gYieldM_2030_nsig_err,gYieldMinus_err); } else if (iSignal == 1) { assignArray(gYieldP_2030_npr,gYieldPlus); assignArray(gYieldM_2030_npr,gYieldMinus); assignArray(gYieldP_2030_npr_err,gYieldPlus_err); assignArray(gYieldM_2030_npr_err,gYieldMinus_err); } else { assignArray(gYieldP_2030_pr,gYieldPlus); assignArray(gYieldM_2030_pr,gYieldMinus); assignArray(gYieldP_2030_pr_err,gYieldPlus_err); assignArray(gYieldM_2030_pr_err,gYieldMinus_err); } break; case 3: if (iSignal == 0) { assignArray(gYieldP_3060_nsig,gYieldPlus); assignArray(gYieldM_3060_nsig,gYieldMinus); assignArray(gYieldP_3060_nsig_err,gYieldPlus_err); assignArray(gYieldM_3060_nsig_err,gYieldMinus_err); } else if (iSignal == 1) { assignArray(gYieldP_3060_npr,gYieldPlus); assignArray(gYieldM_3060_npr,gYieldMinus); assignArray(gYieldP_3060_npr_err,gYieldPlus_err); assignArray(gYieldM_3060_npr_err,gYieldMinus_err); } else { assignArray(gYieldP_3060_pr,gYieldPlus); assignArray(gYieldM_3060_pr,gYieldMinus); assignArray(gYieldP_3060_pr_err,gYieldPlus_err); assignArray(gYieldM_3060_pr_err,gYieldMinus_err); } break; default: cout<< "Wrong centrality, please pick something else!"<<endl; }//mcent switch pgTempP = new TGraphErrors(nphibins, dPhiBinCenters, gYieldPlus, dPhiBinCentersErr, gYieldPlus_err); pgTempM = new TGraphErrors(nphibins, dPhiBinCenters, gYieldMinus, dPhiBinCentersErr, gYieldMinus_err); g[iSignal][mcent][0] = pgTempP; g[iSignal][mcent][1] = pgTempM; double cp[4] = {0.0, 0.0, 0.0, 0.0}; double cm[4] = {0.0, 0.0, 0.0, 0.0}; GetV2(g[iSignal][mcent][0], cp); GetV2(g[iSignal][mcent][1], cm); pr[iSignal][mcent][0] = cp[0]; ep[iSignal][mcent][0] = cp[1]; chi[iSignal][mcent][0] = cp[2]; ndf[iSignal][mcent][0] = cp[3]; pr[iSignal][mcent][1] = cm[0]; ep[iSignal][mcent][1] = cm[1]; chi[iSignal][mcent][1] = cm[2]; ndf[iSignal][mcent][1] = cm[3]; }//centrality loop // #### Drawing: TLatex *lt1 = new TLatex(); lt1->SetNDC(); lt1->SetTextSize(0.05); // frawing: TCanvas *pc1 = new TCanvas("pc1",Form("pcV2_intPt"),0,0,1200,350); TH1F *pp = new TH1F("pp", Form(";| #phi_{J/#psi} - #Psi_{EP} | (rad);#frac{1}{N_{total J/#psi}} #frac{dN}{d#phi} (rad^{-1})"),4,0,TMath::PiOver2()); pp->GetXaxis()->SetLabelSize(20); pp->GetXaxis()->SetLabelFont(43); pp->GetXaxis()->SetTitleSize(18); pp->GetXaxis()->SetTitleFont(43); pp->GetXaxis()->SetTitleOffset(1.2); pp->GetXaxis()->CenterTitle(); pp->GetYaxis()->SetLabelSize(20); pp->GetYaxis()->SetLabelFont(43); pp->GetYaxis()->SetTitleSize(19); pp->GetYaxis()->SetTitleFont(43); pp->GetYaxis()->SetTitleOffset(1.43); pp->GetYaxis()->CenterTitle(); makeMultiPanelCanvas(pc1,nPads,1,0.0,0.0,0.2,0.15,0.02); int ind = 0; for(int mcent = centrality_start; mcent < centrality_end; mcent++) { if(!g[iSignal][mcent][0]|| !g[iSignal][mcent][1]) { cout<<"No graph! continued !!!!"<<endl; continue; } int vcts1 = cts[mcent]; int vcts2 = cts[mcent+1]; cout<<"Centrlality bin: "<<vcts1<<"-"<<vcts2<<endl; pc1->cd(ind+1); pp->SetMaximum(1.2); pp->SetMinimum(0.2); pp->Draw(); TGraphErrors *pgP = (TGraphErrors *) g[iSignal][mcent][0]; TGraphErrors *pgM = (TGraphErrors *) g[iSignal][mcent][1]; pgP->SetMarkerStyle(20); pgM->SetMarkerStyle(24); pgP->Draw("pz"); pgM->Draw("pz"); if(ind==0 ) { // drapwing v2 value and chi2 lt1->SetTextSize(0.045); lt1->DrawLatex(0.24,0.23,Form("v_{2}^{etHFp} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][mcent][0], ep[iSignal][mcent][0], chi[iSignal][mcent][0], ndf[iSignal][mcent][0])); lt1->DrawLatex(0.24,0.18,Form("v_{2}^{etHFm} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][mcent][1], ep[iSignal][mcent][1], chi[iSignal][mcent][1], ndf[iSignal][mcent][1])); lt1->SetTextSize(0.055); lt1->DrawLatex(0.24,0.3,Form("Cent. %d - %d %%",vcts1, vcts2)); // centrality } else { lt1->SetTextSize(0.05); lt1->DrawLatex(0.05,0.23,Form("v_{2}^{etHFp} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][mcent][0], ep[iSignal][mcent][0], chi[iSignal][mcent][0], ndf[iSignal][mcent][0])); lt1->DrawLatex(0.05,0.18,Form("v_{2}^{etHFm} = %.2f #pm %.2f (#chi^{2} / ndf = %.2f / %.0f)", pr[iSignal][mcent][1], ep[iSignal][mcent][1], chi[iSignal][mcent][1], ndf[iSignal][mcent][1])); lt1->SetTextSize(0.06); if(ind == 1) lt1->DrawLatex(0.05,0.3,Form("Cent. %d - %d %%",vcts1, vcts2)); if(ind > 1) lt1->DrawLatex(0.05,0.3,Form("Cent. %d - %d %%",vcts1, vcts2)); if(ind == 3) { lt1->SetTextSize(0.06); lt1->DrawLatex(0.45,0.8,Form("|y| < %.1f",raps[1])); // rapidity lt1->DrawLatex(0.45,0.73,Form("%.1f < p_{T} < %.0f GeV/c", vpts1, vpts2)); // pt } if(ind==1) { TLegend *legCent = new TLegend(0.7,0.8,0.95,0.95); legCent->SetFillColor(0); legCent->SetBorderSize(0); legCent->SetTextSize(0.07); legCent->AddEntry(pgP,"etHFp","P"); legCent->AddEntry(pgM,"etHFm","P"); legCent->Draw("same"); } } ind++; }//mcent //_______ stuff to write pc1->cd(1); TLatex *tex1 = new TLatex(0.23,0.93,"CMS Preliminary"); tex1->SetNDC(); tex1->SetTextAlign(13); tex1->SetTextFont(43); tex1->SetTextSize(23); tex1->SetLineWidth(1); tex1->Draw(); TLatex *tex2 = new TLatex(0.23,0.84,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); tex2->SetNDC(); tex2->SetTextAlign(13); tex2->SetTextFont(43); tex2->SetTextSize(18); tex2->SetLineWidth(2); tex2->Draw(); pc1->cd(1); TLatex *tex3 = new TLatex(0.23,0.75,"L_{int} = 150 #mub^{-1}"); tex3->SetNDC(); tex3->SetTextAlign(13); tex3->SetTextFont(43); tex3->SetTextSize(18); tex3->SetLineWidth(2); tex3->Draw(); pc1->cd(4); lt1->SetTextSize(0.06); lt1->DrawLatex(0.05,0.89,Form("%s",legend[iSignal])); // what signal is //_______ if(bSavePlots) { pc1->SaveAs(Form("%s_Jpsi_a1_newErr_Nominal.png",chosenSignal)); pc1->SaveAs(Form("%s_Jpsi_a1_newErr_Nominal.pdf",chosenSignal)); } // pc1->Clear(); cout<<""<<endl; cout<<"%%%%% Category etHFp: "<<signals[iSignal]<<" %%%%%"<<endl; cout<<"| Cent. | 0 - 10 % | 10 - 20 % | 20 - 30 % | 30 - 60 % |"<<endl; cout<<"| v2 |"<<" "<<pr[iSignal][0][0]<<" | "<<pr[iSignal][1][0]<<" | "<<pr[iSignal][2][0]<<" | "<<pr[iSignal][3][0]<<" |"<<endl; cout<<"| err |"<<" "<<ep[iSignal][0][0]<<" | "<<ep[iSignal][1][0]<<" | "<<ep[iSignal][2][0]<<" | "<<ep[iSignal][3][0]<<" |"<<endl; cout<<"%%%%% Category etHFm: "<<signals[iSignal]<<" %%%%%"<<endl; cout<<"| Cent. | 0 - 10 % | 10 - 20 % | 20 - 30 % | 30 - 60 % |"<<endl; cout<<"| v2 |"<<" "<<pr[iSignal][0][1]<<" | "<<pr[iSignal][1][1]<<" | "<<pr[iSignal][2][1]<<" | "<<pr[iSignal][3][1]<<" |"<<endl; cout<<"| err |"<<" "<<ep[iSignal][0][1]<<" | "<<ep[iSignal][1][1]<<" | "<<ep[iSignal][2][1]<<" | "<<ep[iSignal][3][1]<<" |"<<endl; }// chose signal }
int main(int argc, char *argv[]) { int all; /*Number of atoms in the initial PDB*/ int atom; /*Number of initial CAs*/ int all_t; /*Number of atoms in the target PDB*/ int atom_t; /*Number of target CAs*/ int help_flag = 1; char file_name[500]; char matrix_name[500]; char check_name[500]; int print_inter = 0; int print_inter_t = 0; char out_name[500]; char out_name_t[500]; char out_movie[500]; int print_movie = 0; int verbose = 0; float vinit = 1; // Valeur de base float bond_factor = 1; // Facteur pour poid des bond strechcing float angle_factor = 1; // Facteur pour poid des angles double K_phi1 = 1; // Facteurs pour angles dièdres double K_phi3 = 0.5; float init_templaate = 1; float kp_factor = 1; // Facteur pour poid des angles dièdres char inputname[500] ="none"; double beta = 0.000005; int morph = 0; char morph_name[500]; int change_density = 0; int i,j,k,l; int lig = 0; int ligt = 0; int nconn; int print_flag = 0; float ligalign = 0; // Flag/valeur pour aligner seulement les résidus dans un cutoff du ligand, 0, one le fait pas... > 0... le cutoff for (i = 1;i < argc;i++) { if (strcmp("-i",argv[i]) == 0) {strcpy(file_name,argv[i+1]);--help_flag;} if (strcmp("-h",argv[i]) == 0) {help_flag = 1;} if (strcmp("-v",argv[i]) == 0) {verbose = 1;} if (strcmp("-lig",argv[i]) == 0) {lig= 1;} if (strcmp("-ligt",argv[i]) == 0) {ligt= 1;} if (strcmp("-init",argv[i]) == 0) {float temp;sscanf(argv[i+1],"%f",&temp);vinit = temp;} if (strcmp("-kr",argv[i]) == 0) {float temp;sscanf(argv[i+1],"%f",&temp);bond_factor = temp;} if (strcmp("-kt",argv[i]) == 0) {float temp;sscanf(argv[i+1],"%f",&temp);angle_factor = temp;} if (strcmp("-kpf",argv[i]) == 0) {float temp;sscanf(argv[i+1],"%f",&temp); kp_factor = temp;} if (strcmp("-b",argv[i]) == 0) {float temp;sscanf(argv[i+1],"%f",&temp);beta = temp;} if (strcmp("-t",argv[i]) == 0) {strcpy(check_name,argv[i+1]);help_flag = 0;} if (strcmp("-m",argv[i]) == 0) {strcpy(matrix_name,argv[i+1]);help_flag = 0;} if (strcmp("-o",argv[i]) == 0) {strcpy(out_name,argv[i+1]); print_inter = 1;} if (strcmp("-ot",argv[i]) == 0) {strcpy(out_name_t,argv[i+1]); print_inter_t = 1;} if (strcmp("-om",argv[i]) == 0) {strcpy(out_movie,argv[i+1]); print_movie = 1;} if (strcmp("-ligc",argv[i]) == 0) {float temp;sscanf(argv[i+1],"%f",&temp);ligalign = temp;} if (strcmp("-conf",argv[i]) == 0) {change_density = 1;} if (strcmp("-morph",argv[i]) == 0) {strcpy(morph_name,argv[i+1]); morph = 1;} } if (help_flag == 1) { printf("****************************\nHelp Section\n-i\tFile Input (PDB)\n-v\tVerbose\n-w\tWeight Vector\n-t\tInitial Value of template (negative value for random)\n\tIf Load Template, multiply the template\n-lt\tLoad input template\n-sp\tSuper Node Mode (CA, N, C)\n-kt\tPoid de l'angle entre les nodes (1)\n-kr\tPoid de la distance entre les nodes (1)\n-f\tFile to fit\n****************************\n"); return(0); } //*************************************************** //* * //*Builds a structure contaning information on the initial pdb structure //* * //*************************************************** all = count_atom(file_name); nconn = count_connect(file_name); if (verbose == 1) {printf("Connect:%d\n",nconn);} if (verbose == 1) {printf("Assigning Structure\n\tAll Atom\n");} // Array with all connects int **connect_h=(int **)malloc(nconn*sizeof(int *)); for(i=0;i<nconn;i++) { connect_h[i]=(int *)malloc(6*sizeof(int));} assign_connect(file_name,connect_h); // Assigns all the atoms struct pdb_atom strc_all[all]; atom = build_all_strc(file_name,strc_all); // Retourne le nombre de Node if (atom > 800) {printf("Too much nodes .... To fix, ask [email protected]\n");return(1);} if (verbose == 1) {printf(" Atom:%d\n",all);} check_lig(strc_all,connect_h,nconn,all); // Assigns all Nodes if (verbose == 1) {printf(" CA Structure\n");} if (verbose == 1) {printf(" Node:%d\n",atom);} struct pdb_atom strc_node[atom]; atom = build_cord_CA(strc_all, strc_node,all,lig,connect_h,nconn); if (verbose == 1) {printf(" Assign Node:%d\n",atom);} // Free Connect //for(i=0;i<nconn;i++) {printf("I:%d\n",i);free(connect_h[i]);} //free(connect_h); //*************************************************** //* * //*Builds a structure contaning information on the target pdb structure //* * //*************************************************** nconn = 0; all_t = count_atom(check_name); nconn = count_connect(check_name); if (verbose == 1) {printf("Connect:%d\n",nconn);} if (verbose == 1) {printf("Assigning Structure\n\tAll Atom\n");} // Array with all connects int **connect_t=(int **)malloc(nconn*sizeof(int *)); for(i=0;i<nconn;i++) { connect_t[i]=(int *)malloc(6*sizeof(int));} assign_connect(check_name,connect_t); // Assigns all the atoms struct pdb_atom strc_all_t[all_t]; atom_t = build_all_strc(check_name,strc_all_t); // Retourne le nombre de Node if (atom_t > 800) {printf("Too much node.... To fix, ask [email protected]\n");return(1);} if (verbose == 1) {printf(" Atom:%d\n",all_t);} check_lig(strc_all_t,connect_t,nconn,all_t); // Assigns all Nodes if (verbose == 1) {printf(" CA Structure\n");} if (verbose == 1) {printf(" Node:%d\n",atom_t);} struct pdb_atom strc_node_t[atom_t]; atom_t = build_cord_CA(strc_all_t, strc_node_t,all_t,ligt,connect_t,nconn); if (verbose == 1) {printf(" Assign Node:%d\n",atom_t);} //*************************************************** //* * //*Aligns both structures //* * //*************************************************** int align[atom]; int score = node_align(strc_node,atom,strc_node_t,atom_t,align); printf("RMSD:%8.5f Score: %d/%d\n",sqrt(rmsd_no(strc_node,strc_node_t,atom, align)),score,atom); if ((float)score/(float)atom < 0.8) { printf("Low Score... Will try an homemade alignement !!!\n"); score = node_align_onechain(strc_node,atom,strc_node_t,atom_t,align); printf("RMSD:%8.5f Score: %d/%d\n",sqrt(rmsd_no(strc_node,strc_node_t,atom, align)),score,atom); } if ((float)score/(float)atom < 0.8) { printf("Low Score... Will try an homemade alignement !!!\n"); score = node_align_low(strc_node,atom,strc_node_t,atom_t,align); printf("RMSD:%8.5f Score: %d/%d\n",sqrt(rmsd_no(strc_node,strc_node_t,atom, align)),score,atom); } if (ligalign > 0) { score = node_align_lig(strc_node,atom,strc_node_t,atom_t,align,strc_all,all,strc_all_t,all_t,ligalign); printf("RMSD:%8.5f Score: %d/%d\n",sqrt(rmsd_no(strc_node,strc_node_t,atom, align)),score,atom); } printf("RMSD:%8.5f Score: %d/%d\n",sqrt(rmsd_yes(strc_node,strc_node_t,atom, align,strc_all,all)),score,atom); // Build hessians double **hessian=(double **)malloc(3*atom*sizeof(double *)); // Matrix of the Hessian 1 2 3 (bond, angle, dihedral) for(i=0;i<3*atom;i++) { hessian[i]=(double *)malloc(3*atom*sizeof(double));} for(i=0;i<3*atom;i++)for(j=0;j<(3*atom);j++){hessian[i][j]=0;} gsl_matrix *hess = gsl_matrix_alloc(3*atom,3*atom); gsl_matrix_set_all(hess, 0); gsl_matrix *hess_t = gsl_matrix_alloc(3*atom_t,3*atom_t); gsl_matrix_set_all(hess_t, 0); assign_atom_type(strc_all, all); if (strcmp(inputname,"none") == 0) {} else {assign_lig_type(strc_all, all, inputname);} gsl_matrix *vcon = gsl_matrix_alloc(all,all); gsl_matrix *inter_m = gsl_matrix_alloc(8,8); gsl_matrix *templaate = gsl_matrix_alloc(atom*3, atom*3); gsl_matrix_set_all(templaate,vinit); gsl_matrix_set_all(vcon,0); if (verbose == 1) {printf("Do Vcon !!!\n");} vcon_file_dom(strc_all,vcon,all); if (verbose == 1) {printf("Reading Interaction Matrix %s\n",matrix_name);} load_matrix(inter_m,matrix_name); //write_matrix("vcon_vince.dat", vcon,all,all); if (verbose == 1) {printf("Building templaate\n");} all_interaction(strc_all,all, atom, templaate,lig,vcon,inter_m,strc_node); gsl_matrix_scale (templaate, init_templaate); if (verbose == 1) {printf("Building Hessian\n");} if (verbose == 1) {printf("\tCovalent Bond Potential\n");} build_1st_matrix(strc_node,hessian,atom,bond_factor); if (verbose == 1) {printf("\tAngle Potential\n");} build_2_matrix(strc_node,hessian,atom,angle_factor); if (verbose == 1) {printf("\tDihedral Potential\n");} build_3_matrix(strc_node, hessian,atom,K_phi1/2+K_phi3*9/2,kp_factor); if (verbose == 1) {printf("\tNon Local Interaction Potential\n");} build_4h_matrix(strc_node,hessian,atom,1.0,templaate); if (verbose == 1) {printf("\tAssigning Array\n");} assignArray(hess,hessian,3*atom,3*atom); gsl_matrix_free(vcon); gsl_matrix_free(templaate); double **hessian_t=(double **)malloc(3*atom_t*sizeof(double *)); // Matrix of the Hessian 1 2 3 (bond, angle, dihedral) for(i=0;i<3*atom_t;i++) { hessian_t[i]=(double *)malloc(3*atom_t*sizeof(double));} for(i=0;i<3*atom_t;i++)for(j=0;j<(3*atom_t);j++){hessian_t[i][j]=0;} assign_atom_type(strc_all_t, all_t); if (strcmp(inputname,"none") == 0) {} else {assign_lig_type(strc_all_t, all_t, inputname);} gsl_matrix *vcon_t = gsl_matrix_alloc(all_t,all_t); gsl_matrix *templaate_t = gsl_matrix_alloc(atom_t*3, atom_t*3); gsl_matrix_set_all(templaate_t,vinit); gsl_matrix_set_all(vcon_t,0); if (verbose == 1) {printf("Do Vcon !!!\n");} vcon_file_dom(strc_all_t,vcon_t,all_t); //write_matrix("vcon_vince.dat", vcon,all,all); if (verbose == 1) {printf("Building templaate\n");} all_interaction(strc_all_t,all_t, atom_t, templaate_t,lig,vcon_t,inter_m,strc_node_t); gsl_matrix_scale (templaate_t, init_templaate); if (verbose == 1) {printf("Building Hessian\n");} if (verbose == 1) {printf("\tCovalent Bond Potential\n");} build_1st_matrix(strc_node_t,hessian_t,atom_t,bond_factor); if (verbose == 1) {printf("\tAngle Potential\n");} build_2_matrix(strc_node_t,hessian_t,atom_t,angle_factor); if (verbose == 1) {printf("\tDihedral Potential\n");} build_3_matrix(strc_node_t, hessian_t,atom_t,K_phi1/2+K_phi3*9/2,kp_factor); if (verbose == 1) {printf("\tNon Local Interaction Potential\n");} build_4h_matrix(strc_node_t,hessian_t,atom_t,1.0,templaate_t); if (verbose == 1) {printf("\tAssigning Array\n");} assignArray(hess_t,hessian_t,3*atom_t,3*atom_t); gsl_matrix_free(vcon_t); gsl_matrix_free(templaate_t); printf("Check 1\n"); // Build mini-hessians (calculated mini_hess object is equal to mini_hess + mini_hess_t gsl_matrix *mini_hess = gsl_matrix_alloc(3*score, 3*score); gsl_matrix_set_all(mini_hess, 0); gsl_matrix *mini_hess_i = gsl_matrix_alloc(3*score, 3*score); gsl_matrix_set_all(mini_hess_i, 0); gsl_matrix *mini_hess_t = gsl_matrix_alloc(3*score, 3*score); gsl_matrix_set_all(mini_hess_t, 0); int sup_line = 0; int sup_to_node[score]; for(i = 0; i < atom; i++) { if(align[i] == -1) {continue;} sup_to_node[sup_line] = i; int sup_col = 0; for(j = 0; j < atom; j++) { if(align[j] == -1) {continue;} for(k = 0; k < 3; k++) { for(l = 0; l < 3; l++) { gsl_matrix_set(mini_hess_i, 3*sup_line + k, 3*sup_col + l, gsl_matrix_get(hess, 3*i + k, 3*j + l)); gsl_matrix_set(mini_hess, 3*sup_line + k, 3*sup_col + l, gsl_matrix_get(hess, 3*i + k, 3*j + l) + gsl_matrix_get(hess_t, 3*align[i] + k, 3*align[j] + l)); gsl_matrix_set(mini_hess_t, 3*sup_line + k, 3*sup_col + l, gsl_matrix_get(hess_t, 3*align[i] + k, 3*align[j] + l)); } } sup_col ++; } sup_line++; } gsl_matrix_free(hess); gsl_matrix_free(hess_t); printf("Check 2\n"); // Invert mini_hess gsl_vector *eval2 = gsl_vector_alloc(3*score); gsl_matrix *evec2 = gsl_matrix_alloc (3*score,3*score); diagonalyse_matrix(mini_hess, 3*score, eval2, evec2); gsl_matrix_set_all(mini_hess, 0); for(i = 0; i < 3*score; i++) { if(gsl_vector_get(eval2, i) > 0.00001) { for(j = 0; j < 3*score; j++) { for(k = 0; k < 3*score; k++) { gsl_matrix_set(mini_hess, j, k, gsl_matrix_get(mini_hess, j, k) + gsl_matrix_get(evec2, j, i)*gsl_matrix_get(evec2, k, i)/gsl_vector_get(eval2, i)); } } } } gsl_matrix_free(evec2); gsl_vector_free(eval2); printf("Check 3\n"); // Evaluate delta-conf of init to most stable transitionnal conformer and store delta-conf of init to target. gsl_vector *del_conf = gsl_vector_alloc(3*score); gsl_vector_set_all(del_conf, 0); gsl_vector *copy_conf = gsl_vector_alloc(3*score); for(i = 0; i < score; i++) { gsl_vector_set(copy_conf, 3*i, strc_node_t[align[i]].x_cord - strc_node[i].x_cord); gsl_vector_set(copy_conf, 3*i + 1, strc_node_t[align[i]].y_cord - strc_node[i].y_cord); gsl_vector_set(copy_conf, 3*i + 2, strc_node_t[align[i]].z_cord - strc_node[i].z_cord); } for(i = 0; i < 3*score; i++) { for(j = 0; j < 3*score; j++) { gsl_vector_set(del_conf, i, gsl_vector_get(del_conf, i) + gsl_matrix_get(mini_hess_t, i, j)*gsl_vector_get(copy_conf, j)); } } for(i = 0; i < 3*score; i++) { gsl_vector_set(copy_conf, i, gsl_vector_get(del_conf, i)); } gsl_vector_set_all(del_conf, 0); for(i = 0; i < 3*score; i++) { for(j = 0; j < 3*score; j++) { gsl_vector_set(del_conf, i, gsl_vector_get(del_conf, i) + gsl_matrix_get(mini_hess, i, j)*gsl_vector_get(copy_conf, j)); } } for(i = 0; i < score; i++) { gsl_vector_set(copy_conf, 3*i, strc_node_t[align[i]].x_cord - strc_node[i].x_cord); gsl_vector_set(copy_conf, 3*i + 1, strc_node_t[align[i]].y_cord - strc_node[i].y_cord); gsl_vector_set(copy_conf, 3*i + 2, strc_node_t[align[i]].z_cord - strc_node[i].z_cord); } printf("Check 4\n"); // Translate all the nodes (and all its atoms) of both structures to delta-conf of most stable conformer. for(i = 0; i < score; i++) { for(j = 0; j < all; j++) { if(strc_all[j].node == sup_to_node[i]) { strc_all[j].x_cord += gsl_vector_get(del_conf, 3*i); strc_all[j].y_cord += gsl_vector_get(del_conf, 3*i + 1); strc_all[j].z_cord += gsl_vector_get(del_conf, 3*i + 2); } } for(j = 0; j < all_t; j++) { if(strc_all_t[j].node == align[sup_to_node[i]]) { strc_all_t[j].x_cord += gsl_vector_get(del_conf, 3*i) - gsl_vector_get(copy_conf, 3*i); strc_all_t[j].y_cord += gsl_vector_get(del_conf, 3*i + 1) - gsl_vector_get(copy_conf, 3*i + 1); strc_all_t[j].z_cord += gsl_vector_get(del_conf, 3*i + 2) - gsl_vector_get(copy_conf, 3*i + 2); } } } gsl_matrix_free(mini_hess); printf("Check 5\n"); int aligned[atom_t]; for(i = 0; i < atom_t; i++) { aligned[i] = -1; } for(i = 0; i < atom; i++) { if(align[i] != -1) { aligned[align[i]] = 1; } } // Print transition from init if(print_inter == 1) { FILE *out_file; out_file = fopen(out_name, "w"); for (i = 0; i < all; i++) { if(align[strc_all[i].node] != -1) { if (strc_all[i].atom_type == 1) {fprintf(out_file,"ATOM ");} if (strc_all[i].atom_type == 2) {fprintf(out_file,"HETATM");} if (strc_all[i].atom_type == 3) {fprintf(out_file,"HETATM");} fprintf(out_file,"%5.d %s%s %s%4.d%12.3f%8.3f%8.3f 1.00 %2.2f\n", strc_all[i].atom_number, strc_all[i].atom_prot_type, strc_all[i].res_type, strc_all[i].chain, strc_all[i].res_number, strc_all[i].x_cord, strc_all[i].y_cord, strc_all[i].z_cord, strc_all[i].b_factor ); } } fclose(out_file); } printf("Check 6\n"); // Print transition from target if(print_inter_t == 1) { FILE *out_file_t; out_file_t = fopen(out_name_t, "w"); for (i = 0; i < all_t; i++) { if(aligned[strc_all_t[i].node] != -1) { if (strc_all_t[i].atom_type == 1) {fprintf(out_file_t,"ATOM ");} if (strc_all_t[i].atom_type == 2) {fprintf(out_file_t,"HETATM");} if (strc_all_t[i].atom_type == 3) {fprintf(out_file_t,"HETATM");} fprintf(out_file_t,"%5.d %s%s %s%4.d%12.3f%8.3f%8.3f 1.00 %2.2f\n", strc_all_t[i].atom_number, strc_all_t[i].atom_prot_type, strc_all_t[i].res_type, strc_all_t[i].chain, strc_all_t[i].res_number, strc_all_t[i].x_cord, strc_all_t[i].y_cord, strc_all_t[i].z_cord, strc_all_t[i].b_factor ); } } fclose(out_file_t); } printf("Check 7\n"); // Translate all the nodes (and all its atoms) of init structure back to its original conformation. for(i = 0; i < score; i++) { for(j = 0; j < all; j++) { if(strc_all[j].node == sup_to_node[i]) { strc_all[j].x_cord -= gsl_vector_get(del_conf, 3*i); strc_all[j].y_cord -= gsl_vector_get(del_conf, 3*i + 1); strc_all[j].z_cord -= gsl_vector_get(del_conf, 3*i + 2); } } } // Print transition from init to target passing by inter if(print_movie == 1) { FILE *out_file_m; out_file_m = fopen(out_movie, "w"); for(j = 0; j < 30; j++) { fprintf(out_file_m, "Model %1i\n", j + 1); for (i = 0; i < all; i++) { if(align[strc_all[i].node] != -1) { if (strc_all[i].atom_type == 1) {fprintf(out_file_m,"ATOM ");} if (strc_all[i].atom_type == 2) {fprintf(out_file_m,"HETATM");} if (strc_all[i].atom_type == 3) {fprintf(out_file_m,"HETATM");} fprintf(out_file_m,"%5.d %s%s %s%4.d%12.3f%8.3f%8.3f 1.00 %2.2f\n", strc_all[i].atom_number, strc_all[i].atom_prot_type, strc_all[i].res_type, strc_all[i].chain, strc_all[i].res_number, strc_all[i].x_cord, strc_all[i].y_cord, strc_all[i].z_cord, strc_all[i].b_factor ); } } fprintf(out_file_m, "TER\nENDMDL\n\n"); for(i = 0; i < score; i++) { for(k = 0; k < all; k++) { if(strc_all[k].node == sup_to_node[i]) { strc_all[k].x_cord += gsl_vector_get(del_conf, 3*i)/30.0; strc_all[k].y_cord += gsl_vector_get(del_conf, 3*i + 1)/30.0; strc_all[k].z_cord += gsl_vector_get(del_conf, 3*i + 2)/30.0; } } } } for(j = 0; j < 31; j++) { fprintf(out_file_m, "Model %1i\n", j + 31); for (i = 0; i < all_t; i++) { if(aligned[strc_all_t[i].node] != -1) { if (strc_all_t[i].atom_type == 1) {fprintf(out_file_m,"ATOM ");} if (strc_all_t[i].atom_type == 2) {fprintf(out_file_m,"HETATM");} if (strc_all_t[i].atom_type == 3) {fprintf(out_file_m,"HETATM");} fprintf(out_file_m,"%5.d %s%s %s%4.d%12.3f%8.3f%8.3f 1.00 %2.2f\n", strc_all_t[i].atom_number, strc_all_t[i].atom_prot_type, strc_all_t[i].res_type, strc_all_t[i].chain, strc_all_t[i].res_number, strc_all_t[i].x_cord, strc_all_t[i].y_cord, strc_all_t[i].z_cord, strc_all_t[i].b_factor ); } } fprintf(out_file_m, "TER\nENDMDL\n\n"); for(i = 0; i < score; i++) { for(k = 0; k < all_t; k++) { if(strc_all_t[k].node == align[sup_to_node[i]]) { strc_all_t[k].x_cord -= (gsl_vector_get(del_conf, 3*i) - gsl_vector_get(copy_conf, 3*i))/30.0; strc_all_t[k].y_cord -= (gsl_vector_get(del_conf, 3*i + 1) - gsl_vector_get(copy_conf, 3*i + 1))/30.0; strc_all_t[k].z_cord -= (gsl_vector_get(del_conf, 3*i + 2) - gsl_vector_get(copy_conf, 3*i + 2))/30.0; } } } } fclose(out_file_m); } printf("Check 8\n"); // Translate all the nodes (and all its atoms) of init structure back to its original conformation if print_movie == 1 if(print_movie == 1) { for(i = 0; i < score; i++) { for(j = 0; j < all; j++) { if(strc_all[j].node == sup_to_node[i]) { strc_all[j].x_cord -= gsl_vector_get(del_conf, 3*i); strc_all[j].y_cord -= gsl_vector_get(del_conf, 3*i + 1); strc_all[j].z_cord -= gsl_vector_get(del_conf, 3*i + 2); } } } } printf("Check 8.1\n"); // Print transition from init to target by morphing if(morph == 1) { FILE *out_file_morph; out_file_morph = fopen(morph_name, "w"); printf("Check 8.2\n"); for(j = 0; j < 60; j++) { fprintf(out_file_morph, "Model %1i\n", j + 1); for (i = 0; i < all; i++) { if(align[strc_all[i].node] != -1) { if (strc_all[i].atom_type == 1) {fprintf(out_file_morph,"ATOM ");} if (strc_all[i].atom_type == 2) {fprintf(out_file_morph,"HETATM");} if (strc_all[i].atom_type == 3) {fprintf(out_file_morph,"HETATM");} fprintf(out_file_morph,"%5.d %s%s %s%4.d%12.3f%8.3f%8.3f 1.00 %2.2f\n", strc_all[i].atom_number, strc_all[i].atom_prot_type, strc_all[i].res_type, strc_all[i].chain, strc_all[i].res_number, strc_all[i].x_cord, strc_all[i].y_cord, strc_all[i].z_cord, strc_all[i].b_factor ); } } fprintf(out_file_morph, "TER\nENDMDL\n\n"); printf("Check 8.3\n"); for(i = 0; i < score; i++) { for(k = 0; k < all; k++) { if(strc_all[k].node == sup_to_node[i]) { strc_all[k].x_cord += gsl_vector_get(copy_conf, 3*i)/60.0; strc_all[k].y_cord += gsl_vector_get(copy_conf, 3*i + 1)/60.0; strc_all[k].z_cord += gsl_vector_get(copy_conf, 3*i + 2)/60.0; } } } printf("Check 8.4\n"); } fclose(out_file_morph); } printf("Check 9\n"); // Evaluate theoretical delta-G gsl_vector *dummy_conf = gsl_vector_alloc(3*score); gsl_vector_set_all(dummy_conf, 0); gsl_vector *dummy_conf_t = gsl_vector_alloc(3*score); gsl_vector_set_all(dummy_conf_t, 0); for(i = 0; i < 3*score; i++) { for(j = 0; j < 3*score; j++) { gsl_vector_set(dummy_conf, i, gsl_vector_get(dummy_conf, i) + gsl_vector_get(del_conf, j)*gsl_matrix_get(mini_hess_i, j, i)); gsl_vector_set(dummy_conf_t, i, gsl_vector_get(dummy_conf_t, i) + (gsl_vector_get(del_conf, j) - gsl_vector_get(copy_conf, j))*gsl_matrix_get(mini_hess_t, j, i)); } } double energy_ic = 0.0; double energy_tc = 0.0; for(i = 0; i < 3*score; i++) { energy_ic += gsl_vector_get(dummy_conf, i)*gsl_vector_get(del_conf, i); energy_tc += gsl_vector_get(dummy_conf_t, i)*(gsl_vector_get(del_conf, i) - gsl_vector_get(copy_conf, i)); } gsl_vector_free(dummy_conf_t); gsl_vector_free(del_conf); printf("Check 10\n"); if(change_density == 1) { gsl_vector_set_all(dummy_conf, 0); gsl_vector *eval = gsl_vector_alloc(3*score); gsl_vector_set_all(eval, 0); gsl_vector *eval_t = gsl_vector_alloc(3*score); gsl_vector_set_all(eval_t, 0); gsl_matrix *evec = gsl_matrix_alloc (3*score,3*score); gsl_matrix_set_all(evec, 0); gsl_matrix *evec_t = gsl_matrix_alloc (3*score,3*score); gsl_matrix_set_all(evec_t, 0); diagonalyse_matrix(mini_hess_i, 3*score, eval, evec); diagonalyse_matrix(mini_hess_t, 3*score, eval_t, evec_t); gsl_matrix_free(mini_hess_i); gsl_matrix_free(mini_hess_t); gsl_matrix *comb_hess = gsl_matrix_alloc(3*score, 3*score); gsl_matrix_set_all(comb_hess, 0); double entro = 0.0; double entro_t = 0.0; for(i = 0; i < 3*score; i++) { if(gsl_vector_get(eval, i) > 0.00001) { for(j = 0; j < 3*score; j++) { for(k = 0; k < 3*score; k++) { gsl_matrix_set(comb_hess, j, k, gsl_matrix_get(comb_hess, j, k) + gsl_matrix_get(evec, j, i)*gsl_matrix_get(evec, k, i)/gsl_vector_get(eval, i)); } } entro += log(3.141592653589793238462643383279) - log(beta * gsl_vector_get(eval, i)); } if(gsl_vector_get(eval_t, i) > 0.00001) { for(j = 0; j < 3*score; j++) { for(k = 0; k < 3*score; k++) { gsl_matrix_set(comb_hess, j, k, gsl_matrix_get(comb_hess, j, k) + gsl_matrix_get(evec_t, j, i)*gsl_matrix_get(evec_t, k, i)/gsl_vector_get(eval_t, i)); } } entro_t += log(3.141592653589793238462643383279) - log(beta * gsl_vector_get(eval_t, i)); } } gsl_vector_free(eval_t); gsl_matrix_free(evec_t); gsl_vector_set_all(eval, 0); gsl_matrix_set_all(evec, 0); diagonalyse_matrix(comb_hess, 3*score, eval, evec); gsl_matrix_set_all(comb_hess, 0); // double comb_det = 1.0; for(i = 0; i < 3*score; i++) { if(gsl_vector_get(eval, i) > 0.00001) { for(j = 0; j < 3*score; j++) { for(k = 0; k < 3*score; k++) { gsl_matrix_set(comb_hess, j, k, gsl_matrix_get(comb_hess, j, k) + gsl_matrix_get(evec, j, i)*gsl_matrix_get(evec, k, i)/gsl_vector_get(eval, i)); } } // comb_det *= beta / (3.141592653589793238462643383279 * gsl_vector_get(eval, i)); } } for(i = 0; i < 3*score; i++) { for(j = 0; j < 3*score; j++) { gsl_vector_set(dummy_conf, i, gsl_vector_get(dummy_conf, i) + gsl_vector_get(copy_conf, j)*gsl_matrix_get(comb_hess, j, i)); } } double energy_conf = 0.0; for(i = 0; i < 3*score; i++) { energy_conf += gsl_vector_get(dummy_conf, i)*gsl_vector_get(copy_conf, i); } double dummy_energy = 0.0; double prob_conf = 0.0; dummy_energy = -1.0 * beta * energy_conf; prob_conf = exp(dummy_energy); printf("Weighted probability density of exact conformational change at beta = %1.10f : %1.100f\n", beta, prob_conf); printf("Delta-S (target - init) : %1.10f\n", entro_t - entro); printf("Delta-H (target - init) : %1.10f\n", energy_ic - energy_tc); dummy_energy = -310.25 * (entro_t - entro) + energy_ic - energy_tc; printf("Delta-G (target - init) : %1.10f\n", dummy_energy); double K_eq = exp(-1.0 * dummy_energy / (310.25 * 8.3145)); printf("Equilibrium constant (target / init) : %1.10f\n", K_eq); } else { printf("Energy from init to inter : %1.10f\nEnergy from target to inter : %1.10f\nDelta-H (target - init) : %1.10f\n", energy_ic, energy_tc, energy_ic - energy_tc); } gsl_vector_free(copy_conf); gsl_vector_free(dummy_conf); }