// *** Macro for drawing plots from Analysis *** //

void psi4160at15GevMomentum1000eventsDrawPlots()
{
/*	{
		TFile *thefile = TFile::Open("/home/alexandros/pandaroot/tutorials/rho/psi4160.root"); // open file with ntuples containing information
		TNtuple *thetuple = (TNtuple *)thefile->Get("nd0"); // get ntuple
		thetuple->Draw("td0m");
	}*/
TFile *thefile = TFile::Open("/home/alexandros/pandaroot/tutorials/rho/psi4160.root"); // open file with ntuples containing information
TNtuple *thetuple = (TNtuple *)thefile->Get("nd0"); // get ntuple
TNtuple *thetuple2 = (TNtuple *)thefile->Get("nantid0"); // get ntuple
Double_t d0tht, d0ev, antid0tht, antid0ev, d0cand, antid0cand, d0pdg, antid0pdg;


Int_t l = 0;
thetuple->SetBranchAddress("ev",&d0ev);
thetuple->SetBranchAddress("cand",&d0cand);
thetuple->SetBranchAddress("d0pdg",&d0pdg);
thetuple->SetBranchAddress("d0tht",&d0tht);

thetuple2->SetBranchAddress("ev",&antid0ev);
thetuple2->SetBranchAddress("cand",&antid0cand);
thetuple2->SetBranchAddress("antid0pdg",&antid0pdg);
thetuple2->SetBranchAddress("antid0tht",&antid0tht);

//TH1D *plot = new TH1D("aaa","aaa", 100, 0, 50);
for(Int_t i=0;i<thetuple2->GetEntries();i++) 
	{
		thetuple2->GetEntry(i);
		//for(Int_t j =0; j<thetuple->GetEntries();j++)
			//{	//Double_t diff = 0;
				l++;
			//	thetuple->GetEntry(j);
			//	if((!(d0ev<antid0ev)&&!(d0ev>antid0ev))&&(!(d0cand<antid0cand)&&!(d0cand>antid0cand)))
	
				//	{cout << " event number for d0 is : " << d0ev << " candidate number is : " << d0cand <<  " pdg number is : " << d0pdg << " theta number is : " << d0tht << endl;		 
					cout << " event number for antid0 is : " << antid0ev << " candidate number is : " << antid0cand << " pdg number is : " << antid0pdg << " theta number is : " << antid0tht << endl;
					//l++;
					///diff = abs(d0tht-antid0tht);
					//cout << " difference is " << diff << endl;					
					//plot->Fill(diff);	
					cout << " common events are : " << l << endl;
					//}		
			//}
	}
//plot->Draw();
}

