#define fitQunDisplay_cxx // The class definition in fitQunDisplay.h has been generated automatically // by the ROOT utility TTree::MakeSelector(). This class is derived // from the ROOT class TSelector. For more information on the TSelector // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual. // The following methods are defined in this file: // Begin(): called every time a loop on the tree starts, // a convenient place to create your histograms. // SlaveBegin(): called after Begin(), when on PROOF called only on the // slave servers. // Process(): called for each event, in this function you decide what // to read and fill your histograms. // SlaveTerminate: called at the end of the loop on the tree, when on PROOF // called only on the slave servers. // Terminate(): called at the end of the loop on the tree, // a convenient place to draw/fit your histograms. // // To use this file, try the following session on your Tree T: // // Root > T->Process("fitQunDisplay.C") // Root > T->Process("fitQunDisplay.C","some options") // Root > T->Process("fitQunDisplay.C+") // #include #include "fitQunDisplay.h" #include "CherenkovDisplay.h" #include #include #include "THKGamma.h" #include "THKLine.h" #include #include "TEveVector.h" #include using std::cout; using std::endl; void fitQunDisplay::describe_event(int entry) { if(fChain==nullptr)return; cout<AddElement(fitQunResults); TEveScene* UnrolledScene=NULL; TEveSceneList* scenes = gEve->GetScenes(); for (TEveElement::List_i i=scenes->BeginChildren(); i!=scenes->EndChildren(); ++i) { TEveScene* scene=(TEveScene*)(*i); if(!strcmp(scene->GetName(),"Unrolled Event")){ UnrolledScene = scene; break; } } UnrolledScene->AddElement(fitQunResults2D); return kTRUE; } void fitQunDisplay::load_event() { /* Add fitqun results to the Eve event display */ if(fChain==nullptr)return; gEve->GetDefaultGLViewer()->UpdateScene(); for(int se=0;se< fqnse;se++) { TEveElementList* EveSubEvent = new TEveElementList(Form("Sub event %i ",se)); TEveElementList* EveSubEvent2D = new TEveElementList(Form("Sub event %i ",se)); fitQunResults->AddElement(EveSubEvent); fitQunResults2D->AddElement(EveSubEvent2D); for(int PID=1;PID<4;PID++) { if(fq1rpcflg[se][PID]>-1) { float x=fq1rdir[se][PID][0]; float y=fq1rdir[se][PID][1]; float z=fq1rdir[se][PID][2]; float dl=sqrt(x*x+y*y+z*z); float theta =acos(z/dl); float phi =atan2(y,x); TString description=Form("Fitqun %s, sub event %i",HYPO[PID].Data(),se); double pos[3]; pos[0]=fq1rpos[se][PID][0]; pos[1]=fq1rpos[se][PID][1]; pos[2]=fq1rpos[se][PID][2]; addTrack(pos,theta,phi,fq1rmom[se][PID],description,HYPERCOLOUR[PID],MASS[PID],EveSubEvent,EveSubEvent2D); } } if(se == 0) { float x=fqpi0dir1[0][0]; float y=fqpi0dir1[0][1]; float z=fqpi0dir1[0][2]; float dl=sqrt(x*x+y*y+z*z); float theta1 =acos(z/dl); float phi1 =atan2(y,x); x=fqpi0dir2[0][0]; y=fqpi0dir2[0][1]; z=fqpi0dir2[0][2]; dl=sqrt(x*x+y*y+z*z); float theta2=acos(z/dl); float phi2=atan2(y,x); double pos[3]; pos[0]=fqpi0pos[0][0]; pos[1]=fqpi0pos[0][1]; pos[2]=fqpi0pos[0][2]; addPi0(pos,theta1,phi1,fqpi0mom1[0],theta2,phi2,fqpi0mom2[0],EveSubEvent,EveSubEvent2D); } } } void fitQunDisplay::addPi0(double pos[3],double theta1,double phi1,double mom1,double theta2,double phi2,double mom2,TEveElementList* se3d,TEveElementList* se2d ) { THKLine* pi0Track=new THKLine("Fitqun pi0"); pi0Track->SetElementTitle("Fitqun pi0"); pi0Track->SetMainColor(kWhite); pi0Track->SetNextPoint(pos[0],pos[1],pos[2]); pi0Track->SetNextPoint(pos[0]+0.001,pos[1]+0.001,pos[2]+0.001); se3d->AddElement(pi0Track); TString Name("Fitqun Pi0->gamma #1"); THKGamma* gammaTrack=new THKGamma(Name); gammaTrack->Create(Name,kWhite,pos,pScale*mom1,mom1,theta1,phi1); pi0Track->AddElement(gammaTrack); THKCherenkov* cone = new THKCherenkov(Name+" Cherenkov Cone"); THKCherenkov2D* cone2D = new THKCherenkov2D(Name+"Cherenkov cone"); CD.createCherenkov(cone,cone2D,Name,kWhite,mom1,theta1,phi1,0.0,pos,kFALSE); gammaTrack->AddElement(cone); se2d->AddElement(cone2D); Name=TString("Fitqun Pi0->gamma #2"); gammaTrack=new THKGamma(Name); gammaTrack->Create(Name,kWhite,pos,pScale*mom2,mom2,theta2,phi2); cone = new THKCherenkov(Name+"Cherenkov Cone"); cone2D = new THKCherenkov2D(Name+"Cherenkov cone"); CD.createCherenkov(cone,cone2D,Name,kWhite,mom2,theta2,phi2,0.0,pos,kFALSE); gammaTrack->AddElement(cone); se2d->AddElement(cone2D); pi0Track->AddElement(gammaTrack); } void fitQunDisplay::addTrack(double pos[3],double theta,double phi,double Momentum,TString Name,int colour,float Mass,TEveElementList* se3d, TEveElementList* se2d) { if(Momentum<=0)return; THKLine* track=new THKLine(Name); track->Create(Name,colour,pos,pScale*Momentum,Momentum,theta,phi); THKCherenkov* cone = new THKCherenkov(Name+"Cherenkov Cone"); THKCherenkov2D* cone2D = new THKCherenkov2D(Name+"Cherenkov cone"); CD.createCherenkov(cone,cone2D,Name,colour,Momentum,theta,phi,Mass,pos,kFALSE); track->AddElement(cone); se3d->AddElement(track); se2d->AddElement(cone2D); } void fitQunDisplay::CreateTable(HtmlSummary* fgHtmlSummary){ /* Add an html table describing fitqun results */ if(fChain==nullptr)return; HtmlObjTable *table = fgHtmlSummary->AddTable("FitQun results", 8, kTRUE,""); table->SetLabel(0, "Type"); table->SetLabel(1, "Subevent"); table->IsInteger(1); table->SetLabel(2, "Vertex X"); table->SetLabel(3, "Vertex Y"); table->SetLabel(4, "Vertex Z"); table->SetLabel(5, "Momentum "); table->SetLabel(6, "Theta "); table->SetLabel(7, "Phi "); int nused=0; int se; for(se=0;se< fqnse;se++) { for(int PID=1;PID<4;PID++) { if(fq1rpcflg[se][PID]>-1) { float x=fq1rdir[se][PID][0]; float y=fq1rdir[se][PID][1]; float z=fq1rdir[se][PID][2]; float dl=sqrt(x*x+y*y+z*z); float theta =acos(z/dl); float phi =atan2(y,x); TString description=Form("Fitqun %s, sub event %i",HYPO[PID].Data(),se); double pos[3]; pos[0]=fq1rpos[se][PID][0]; pos[1]=fq1rpos[se][PID][1]; pos[2]=fq1rpos[se][PID][2]; addTableRow(table,nused++,se,HYPO[PID],pos,theta,phi,fq1rmom[se][PID]); // if(f1mu_PCflg ==0)addTableRow(table,nused++,se,"muon",f1mu_pos_sub[se],f1mu_theta_sub[se],f1mu_phi_sub[se],f1mu_mom_sub[se]); // if(f1pip_PCflg==0)addTableRow(table,nused++,se,"pi+",f1pip_pos_sub[se],f1pip_theta_sub[se],f1pip_phi_sub[se],f1pip_mom_sub[se]); // if(f1kp_PCflg ==0)addTableRow(table,nused++,se,"Kaon",f1kp_pos_sub[se],f1kp_theta_sub[se],f1kp_phi_sub[se],f1kp_mom_sub[se]); // if(f1p_PCflg ==0)addTableRow(table,nused++,se,"proton",f1p_pos_sub[se],f1p_theta_sub[se],f1p_phi_sub[se],f1p_mom_sub[se]); } } float x=fqpi0dir1[0][0]; float y=fqpi0dir1[0][1]; float z=fqpi0dir1[0][2]; float dl=sqrt(x*x+y*y+z*z); float theta1 =acos(z/dl); float phi1 =atan2(y,x); x=fqpi0dir2[0][0]; y=fqpi0dir2[0][1]; z=fqpi0dir2[0][2]; dl=sqrt(x*x+y*y+z*z); float theta2=acos(z/dl); float phi2=atan2(y,x); double pos[3]; pos[0]=fqpi0pos[0][0]; pos[1]=fqpi0pos[0][1]; pos[2]=fqpi0pos[0][2]; addPi0Rows(table,nused,se,pos,theta1,phi1,fqpi0mom1[0],theta2,phi2,fqpi0mom2[0]); nused+=3; } // int used=0; return; } void fitQunDisplay::addTableRow(HtmlObjTable *table,int used,int subevent,const char* name,Double_t pos[3],Double_t theta,Double_t phi,Double_t mom) { table->SetRowName(used, name); table->SetValue(1,used,subevent); table->SetValue(2,used,pos[0]); table->SetValue(3,used,pos[1]); table->SetValue(4,used,pos[2]); table->SetValue(5,used,mom); table->SetValue(6,used,theta); table->SetValue(7,used,phi); } void fitQunDisplay::addPi0Rows(HtmlObjTable *table,int used,int subevent,double pos[3],double theta1,double phi1,double mom1,double theta2,double phi2,double mom2) { double p1[3]; CherenkovDisplay::polarToCartesian(mom1,theta1,phi1,p1); double p2[3]; CherenkovDisplay::polarToCartesian(mom2,theta2,phi2,p2); double ppi0[3]; ppi0[0]=p1[0]+p1[0]; ppi0[1]=p1[1]+p1[1]; ppi0[2]=p1[2]+p1[2]; double mompi0=-1; double thetapi0=-1; double phipi0=-1; CherenkovDisplay::CartesianToPolar(mompi0,thetapi0,phipi0,ppi0); table->SetRowName(used, "pi0"); table->SetValue(1,used,subevent); table->SetValue(2,used,pos[0]); table->SetValue(3,used,pos[1]); table->SetValue(4,used,pos[2]); table->SetValue(5,used,mompi0); table->SetValue(6,used,thetapi0); table->SetValue(7,used,phipi0); used++; table->SetRowName(used, " -> gamma 1"); table->SetValue(1,used,subevent); table->SetValue(2,used,pos[0]); table->SetValue(3,used,pos[1]); table->SetValue(4,used,pos[2]); table->SetValue(5,used,mom1); table->SetValue(6,used,theta1); table->SetValue(7,used,phi1); used++; table->SetRowName(used, " -> gamma 2"); table->SetValue(1,used,subevent); table->SetValue(2,used,pos[0]); table->SetValue(3,used,pos[1]); table->SetValue(4,used,pos[2]); table->SetValue(5,used,mom2); table->SetValue(6,used,theta2); table->SetValue(7,used,phi2); return; } void fitQunDisplay::Init(TTree *tree) { // The Init() function is called when the selector needs to initialize // a new tree or chain. Typically here the branch addresses and branch // pointers of the tree will be set. // It is normally not necessary to make changes to the generated // code, but the routine can be extended by the user if needed. // Init() will be called many times when running on PROOF // (once per file to be processed). // Set branch addresses and branch pointers fChain = nullptr; if (!tree) return; fChain = tree; fChain->SetMakeClass(1); fChain->SetBranchAddress("cluster_ncand", &cluster_ncand, &b_cluster_ncand); fChain->SetBranchAddress("cluster_tstart", cluster_tstart, &b_cluster_tstart); fChain->SetBranchAddress("cluster_tend", cluster_tend, &b_cluster_tend); fChain->SetBranchAddress("cluster_nhits", cluster_nhits, &b_cluster_nhits); fChain->SetBranchAddress("cluster_totq", cluster_totq, &b_cluster_totq); fChain->SetBranchAddress("cluster_goodflag", cluster_goodflag, &b_cluster_goodflag); fChain->SetBranchAddress("cluster_npeaks", cluster_npeaks, &b_cluster_npeaks); fChain->SetBranchAddress("cluster_ipeak", cluster_ipeak, &b_cluster_ipeak); fChain->SetBranchAddress("cluster_timeofpeak", cluster_timeofpeak, &b_cluster_timeofpeak); fChain->SetBranchAddress("muechk_ncand", muechk_ncand, &b_muechk_ncand); fChain->SetBranchAddress("muechk_toya", muechk_toya, &b_muechk_toya); fChain->SetBranchAddress("muechk_tpeak", muechk_tpeak, &b_muechk_tpeak); fChain->SetBranchAddress("muechk_bg", muechk_bg, &b_muechk_bg); fChain->SetBranchAddress("muechk_mean", muechk_mean, &b_muechk_mean); fChain->SetBranchAddress("muechk_excess", muechk_excess, &b_muechk_excess); fChain->SetBranchAddress("muechk_signif", muechk_signif, &b_muechk_signif); fChain->SetBranchAddress("muechk_icluster", muechk_icluster, &b_muechk_icluster); fChain->SetBranchAddress("trgoff", &trgoff, &b_trgoff); fChain->SetBranchAddress("fqntwnd", &fqntwnd, &b_fqntwnd); fChain->SetBranchAddress("fqtwnd_iclstr", fqtwnd_iclstr, &b_fqtwnd_iclstr); fChain->SetBranchAddress("fqtwnd_npeak", fqtwnd_npeak, &b_fqtwnd_npeak); fChain->SetBranchAddress("fqtwnd_prftt0", fqtwnd_prftt0, &b_fqtwnd_prftt0); fChain->SetBranchAddress("fqtwnd_prftpos", fqtwnd_prftpos, &b_fqtwnd_prftpos); fChain->SetBranchAddress("fqtwnd", fqtwnd, &b_fqtwnd); fChain->SetBranchAddress("fqtwnd_peakt0", fqtwnd_peakt0, &b_fqtwnd_peakt0); fChain->SetBranchAddress("fqtwnd_peakiness", fqtwnd_peakiness, &b_fqtwnd_peakiness); fChain->SetBranchAddress("fqnse", &fqnse, &b_fqnse); fChain->SetBranchAddress("fqitwnd", fqitwnd, &b_fqitwnd); fChain->SetBranchAddress("fqipeak", fqipeak, &b_fqipeak); fChain->SetBranchAddress("fqnhitpmt", fqnhitpmt, &b_fqnhitpmt); fChain->SetBranchAddress("fqtotq", fqtotq, &b_fqtotq); fChain->SetBranchAddress("fq0rtotmu", fq0rtotmu, &b_fq0rtotmu); fChain->SetBranchAddress("fq0rnll", fq0rnll, &b_fq0rnll); fChain->SetBranchAddress("fqn50", fqn50, &b_fqn50); fChain->SetBranchAddress("fqq50", fqq50, &b_fqq50); fChain->SetBranchAddress("fq1rpcflg", fq1rpcflg, &b_fq1rpcflg); fChain->SetBranchAddress("fq1rmom", fq1rmom, &b_fq1rmom); fChain->SetBranchAddress("fq1rt0", fq1rt0, &b_fq1rt0); fChain->SetBranchAddress("fq1rtotmu", fq1rtotmu, &b_fq1rtotmu); fChain->SetBranchAddress("fq1rnll", fq1rnll, &b_fq1rnll); fChain->SetBranchAddress("fq1rpos", fq1rpos, &b_fq1rpos); fChain->SetBranchAddress("fq1rdir", fq1rdir, &b_fq1rdir); fChain->SetBranchAddress("fq1rdconv", fq1rdconv, &b_fq1rdconv); fChain->SetBranchAddress("fq1reloss", fq1reloss, &b_fq1reloss); fChain->SetBranchAddress("fqpi0pcflg", fqpi0pcflg, &b_fqpi0pcflg); fChain->SetBranchAddress("fqpi0mom1", fqpi0mom1, &b_fqpi0mom1); fChain->SetBranchAddress("fqpi0mom2", fqpi0mom2, &b_fqpi0mom2); fChain->SetBranchAddress("fqpi0momtot", fqpi0momtot, &b_fqpi0momtot); fChain->SetBranchAddress("fqpi0dconv1", fqpi0dconv1, &b_fqpi0dconv1); fChain->SetBranchAddress("fqpi0dconv2", fqpi0dconv2, &b_fqpi0dconv2); fChain->SetBranchAddress("fqpi0t0", fqpi0t0, &b_fqpi0t0); fChain->SetBranchAddress("fqpi0totmu", fqpi0totmu, &b_fqpi0totmu); fChain->SetBranchAddress("fqpi0nll", fqpi0nll, &b_fqpi0nll); fChain->SetBranchAddress("fqpi0mass", fqpi0mass, &b_fqpi0mass); fChain->SetBranchAddress("fqpi0photangle", fqpi0photangle, &b_fqpi0photangle); fChain->SetBranchAddress("fqpi0pos", fqpi0pos, &b_fqpi0pos); fChain->SetBranchAddress("fqpi0dir1", fqpi0dir1, &b_fqpi0dir1); fChain->SetBranchAddress("fqpi0dir2", fqpi0dir2, &b_fqpi0dir2); fChain->SetBranchAddress("fqpi0dirtot", fqpi0dirtot, &b_fqpi0dirtot); fChain->SetBranchAddress("fqnmrfit", &fqnmrfit, &b_fqnmrfit); fChain->SetBranchAddress("fqmrifit", fqmrifit, &b_fqmrifit); fChain->SetBranchAddress("fqmrnring", fqmrnring, &b_fqmrnring); fChain->SetBranchAddress("fqmrpcflg", fqmrpcflg, &b_fqmrpcflg); fChain->SetBranchAddress("fqmrnll", fqmrnll, &b_fqmrnll); fChain->SetBranchAddress("fqmrtotmu", fqmrtotmu, &b_fqmrtotmu); fChain->SetBranchAddress("fqmrpid", fqmrpid, &b_fqmrpid); fChain->SetBranchAddress("fqmrmom", fqmrmom, &b_fqmrmom); fChain->SetBranchAddress("fqmrdconv", fqmrdconv, &b_fqmrdconv); fChain->SetBranchAddress("fqmreloss", fqmreloss, &b_fqmreloss); fChain->SetBranchAddress("fqmrt0", fqmrt0, &b_fqmrt0); fChain->SetBranchAddress("fqmrpos", fqmrpos, &b_fqmrpos); fChain->SetBranchAddress("fqmrdir", fqmrdir, &b_fqmrdir); fChain->SetBranchAddress("fqmsnfit", &fqmsnfit, &b_fqmsnfit); fChain->SetBranchAddress("fqmspcflg", fqmspcflg, &b_fqmspcflg); fChain->SetBranchAddress("fqmsnseg", fqmsnseg, &b_fqmsnseg); fChain->SetBranchAddress("fqmspid", fqmspid, &b_fqmspid); fChain->SetBranchAddress("fqmsifit", fqmsifit, &b_fqmsifit); fChain->SetBranchAddress("fqmsimer", fqmsimer, &b_fqmsimer); fChain->SetBranchAddress("fqmstotmu", fqmstotmu, &b_fqmstotmu); fChain->SetBranchAddress("fqmsnll", fqmsnll, &b_fqmsnll); fChain->SetBranchAddress("fqmsmom", fqmsmom, &b_fqmsmom); fChain->SetBranchAddress("fqmseloss", fqmseloss, &b_fqmseloss); fChain->SetBranchAddress("fqmst0", fqmst0, &b_fqmst0); fChain->SetBranchAddress("fqmspos", fqmspos, &b_fqmspos); fChain->SetBranchAddress("fqmsdir", fqmsdir, &b_fqmsdir); fChain->SetBranchAddress("fqtestn1r", &fqtestn1r, &b_fqtestn1r); fChain->SetBranchAddress("fqtest1rstage", fqtest1rstage, &b_fqtest1rstage); fChain->SetBranchAddress("fqtest1rse", fqtest1rse, &b_fqtest1rse); fChain->SetBranchAddress("fqtest1rpid", fqtest1rpid, &b_fqtest1rpid); fChain->SetBranchAddress("fqtest1rpcflg", fqtest1rpcflg, &b_fqtest1rpcflg); fChain->SetBranchAddress("fqtest1rmom", fqtest1rmom, &b_fqtest1rmom); fChain->SetBranchAddress("fqtest1rt0", fqtest1rt0, &b_fqtest1rt0); fChain->SetBranchAddress("fqtest1rtotmu", fqtest1rtotmu, &b_fqtest1rtotmu); fChain->SetBranchAddress("fqtest1rnll", fqtest1rnll, &b_fqtest1rnll); fChain->SetBranchAddress("fqtest1rpos", fqtest1rpos, &b_fqtest1rpos); fChain->SetBranchAddress("fqtest1rdir", fqtest1rdir, &b_fqtest1rdir); fChain->SetBranchAddress("fqtest1rdconv", fqtest1rdconv, &b_fqtest1rdconv); fChain->SetBranchAddress("fqtest1reloss", fqtest1reloss, &b_fqtest1reloss); fChain->SetBranchAddress("fqtestnpi0", &fqtestnpi0, &b_fqtestnpi0); fChain->SetBranchAddress("fqtestpi0stage", fqtestpi0stage, &b_fqtestpi0stage); fChain->SetBranchAddress("fqtestpi0pcflg", fqtestpi0pcflg, &b_fqtestpi0pcflg); fChain->SetBranchAddress("fqtestpi0mom1", fqtestpi0mom1, &b_fqtestpi0mom1); fChain->SetBranchAddress("fqtestpi0mom2", fqtestpi0mom2, &b_fqtestpi0mom2); fChain->SetBranchAddress("fqtestpi0momtot", fqtestpi0momtot, &b_fqtestpi0momtot); fChain->SetBranchAddress("fqtestpi0dconv1", fqtestpi0dconv1, &b_fqtestpi0dconv1); fChain->SetBranchAddress("fqtestpi0dconv2", fqtestpi0dconv2, &b_fqtestpi0dconv2); fChain->SetBranchAddress("fqtestpi0t0", fqtestpi0t0, &b_fqtestpi0t0); fChain->SetBranchAddress("fqtestpi0totmu", fqtestpi0totmu, &b_fqtestpi0totmu); fChain->SetBranchAddress("fqtestpi0nll", fqtestpi0nll, &b_fqtestpi0nll); fChain->SetBranchAddress("fqtestpi0mass", fqtestpi0mass, &b_fqtestpi0mass); fChain->SetBranchAddress("fqtestpi0photangle", fqtestpi0photangle, &b_fqtestpi0photangle); fChain->SetBranchAddress("fqtestpi0pos", fqtestpi0pos, &b_fqtestpi0pos); fChain->SetBranchAddress("fqtestpi0dir1", fqtestpi0dir1, &b_fqtestpi0dir1); fChain->SetBranchAddress("fqtestpi0dir2", fqtestpi0dir2, &b_fqtestpi0dir2); fChain->SetBranchAddress("fqtestpi0dirtot", fqtestpi0dirtot, &b_fqtestpi0dirtot); fChain->SetBranchAddress("ifqver", &ifqver, &b_ifqver); fChain->SetBranchAddress("fqproctime", fqproctime, &b_fqproctime); fChain->SetBranchAddress("nevt", &nevt, &b_nevt); HYPO[0]="gamma"; HYPO[1]="electron"; HYPO[2]="muon"; HYPO[3]="pion"; HYPO[4]="kaon"; HYPO[5]="proton"; HYPO[6]="cone generator"; HYPERCOLOUR[0]= kWhite; HYPERCOLOUR[1]= kYellow; HYPERCOLOUR[2]= kBlue; HYPERCOLOUR[3]= kMagenta; HYPERCOLOUR[4]= kBlue; HYPERCOLOUR[5]= kRed; HYPERCOLOUR[6]= kGreen; MASS[0]=0.0; MASS[1]=0.510998; MASS[2]=113.43; MASS[3]=139.57; MASS[4]=493.677; MASS[5]=938.272; MASS[6]=0; }