{ gROOT->Reset(); // open the files gStyle-> SetOptStat(1); // TFile* file = new TFile("two_adders_senkrecht_offcenter_run5_500s_26000Ph.root"); TFile* file = new TFile("Probe1.root"); file->cd(); TTree* singlestree = (TTree*)gDirectory->Get("Singles"); TTree* hitstree = (TTree*)gDirectory->Get("Hits"); TTree* opticalsinglestree = (TTree*)gDirectory->Get("OpticalSingles"); // ***************************** // *** hits optical Photons*** // ***************************** Float_t localPosX; Float_t localPosY; Float_t localPosZ; Float_t posZ; Float_t posX; Float_t posY; Float_t sourcePosZ_hits; Float_t sourcePosX_hits; Float_t sourcePosY_hits; Int_t runID_hits; Int_t eventID_hits; Int_t sourceID_hits; Int_t trackID; Int_t parentID; Char_t processName[40]; // ***************************** // *** hard Photons *** // ***************************** Float_t energy; Float_t globalPosX; Float_t globalPosY; Float_t globalPosZ; Float_t sourcePosZ; Float_t sourcePosX; Float_t sourcePosY; Int_t runID; Int_t eventID; Int_t sourceID; // ***************************** // *** Optical Photons *** // ***************************** Float_t energy_optical; Float_t globalPosX_optical; Float_t globalPosY_optical; Float_t globalPosZ_optical; Float_t sourcePosZ_optical; Float_t sourcePosX_optical; Float_t sourcePosY_optical; Int_t runID_optical; Int_t eventID_optical; Int_t sourceID_optical; Float_t sumX=0; Float_t sumY=0; Float_t sumx=0; Float_t sumy=0; Float_t xpos=0; Float_t ypos=0; Float_t x=0; Float_t y=0; Float_t zpos=0; Float_t z=0; Int_t q=0; Int_t p=0; Int_t ih_last=0; hitstree->SetBranchAddress("localPosX",&localPosX); hitstree->SetBranchAddress("localPosY",&localPosY); hitstree->SetBranchAddress("localPosZ",&localPosZ); hitstree->SetBranchAddress("posX",&posX); hitstree->SetBranchAddress("posY",&posY); hitstree->SetBranchAddress("posZ",&posZ); hitstree->SetBranchAddress("sourcePosX",&sourcePosX_hits); hitstree->SetBranchAddress("sourcePosY",&sourcePosY_hits); hitstree->SetBranchAddress("sourcePosZ",&sourcePosZ_hits); hitstree->SetBranchAddress("runID", &runID_hits); hitstree->SetBranchAddress("eventID", &eventID_hits); hitstree->SetBranchAddress("sourceID", &sourceID_hits); hitstree->SetBranchAddress("trackID", &trackID); hitstree->SetBranchAddress("parentID", &parentID); hitstree->SetBranchAddress("processName", &processName); singlestree->SetBranchAddress("globalPosX",&globalPosX); singlestree->SetBranchAddress("globalPosY",&globalPosY); singlestree->SetBranchAddress("globalPosZ",&globalPosZ); singlestree->SetBranchAddress("sourcePosX",&sourcePosX); singlestree->SetBranchAddress("sourcePosY",&sourcePosY); singlestree->SetBranchAddress("sourcePosZ",&sourcePosZ); singlestree->SetBranchAddress("runID", &runID); singlestree->SetBranchAddress("eventID", &eventID); singlestree->SetBranchAddress("sourceID", &sourceID); singlestree->SetBranchAddress("energy", &energy); opticalsinglestree->SetBranchAddress("globalPosX",&globalPosX_optical); opticalsinglestree->SetBranchAddress("globalPosY",&globalPosY_optical); opticalsinglestree->SetBranchAddress("globalPosZ",&globalPosZ_optical); opticalsinglestree->SetBranchAddress("sourcePosX",&sourcePosX_optical); opticalsinglestree->SetBranchAddress("sourcePosY",&sourcePosY_optical); opticalsinglestree->SetBranchAddress("sourcePosZ",&sourcePosZ_optical); opticalsinglestree->SetBranchAddress("runID", &runID_optical); opticalsinglestree->SetBranchAddress("eventID", &eventID_optical); opticalsinglestree->SetBranchAddress("sourceID", &sourceID_optical); opticalsinglestree->SetBranchAddress("energy", &energy_optical); Int_t nhits = hitstree-> GetEntries(); Int_t nsingles = singlestree-> GetEntries(); Int_t nopticalsingles = opticalsinglestree-> GetEntries(); cout << "Number of hard Photons " << nsingles << endl; cout << "Number of optical Photons: " << nhits << endl; TH2F* phHist = new TH2F("y-x Pos. Opticals", "y-x Pos. Opticals", 27, -27, 27, 27, -27, 27); TH1F* phProfY = new TH1F("y Pos. Opticals", "y Pos. Opticals", 27, -27, 27); TH1F* phProfZ = new TH1F("x Pos. Opticals", "x Pos. Opticals", 27, -27, 27); TCanvas* canvas1 = new TCanvas(); //------------------------------------------------------------------------------ Double_t phY[100000], phZ[100000]; Int_t k, i, nph; char s[100], histname[100], histyname[100], histzname[100], graphname[100]; i=0; nph=0; // load data of first gamma singlestree->GetEntry(i); // set the strings for titles and for the file names sprintf(s, "DOI=%5.2fmm x=%5.2fmm y=%5.2fmm t=%5.2f e=%5.2f", globalPosZ, globalPosX, globalPosY, runID, eventID); sprintf(histname, "H_%.2f_%.2f_%.2f.png", globalPosX, globalPosY, globalPosZ); sprintf(graphname, "G_%.2f_%.2f_%.2f.png", globalPosX, globalPosY, globalPosZ); sprintf(histyname, "Y_%.2f_%.2f_%.2f.png", globalPosX, globalPosY, globalPosZ); sprintf(histzname, "Z_%.2f_%.2f_%.2f.png", globalPosX, globalPosY, globalPosZ); //run though all optical photons for (k=0; kGetEntry(k); // if this photon belongs to the actual gamma if (runID_hits <= runID && eventID_hits <= eventID) { if(strcmp(processName,"Transportation")==0){ // fill the histogram with the photon position phHist->Fill(posX, posY); phProfY->Fill(posX); phProfZ->Fill(posY); // store the photon position in the phY phZ arrays // if (nph<100000) // (just for safety, phY and phZ contain max 100000 elements) { phY[nph]=posX; phZ[nph]=posY; } nph++; } } else // if photon belongs to next gamma { if (energy > 0.510) { // Draw the graph with the photon distribution TGraph *phGraph = new TGraph(nph, phY, phZ); phGraph->SetMarkerStyle(6); phGraph->SetTitle(s); phGraph->Draw("AP"); phGraph->GetXaxis()->SetTitle("x"); phGraph->GetYaxis()->SetTitle("y"); phGraph->GetXaxis()->CenterTitle(); phGraph->GetYaxis()->CenterTitle(); canvas1->Print(graphname); phGraph->~TGraph(); // draw the histogram phHist->SetTitle(s); phHist->SetXTitle("x"); phHist->SetYTitle("y"); phHist->Draw("SURF3"); canvas1->Print(histname); phProfY->SetTitle(s) ; phProfY->SetXTitle("x") ; phProfY->Draw("C"); canvas1->Print(histyname); phProfZ->SetTitle(s) ; phProfZ->SetXTitle("y") ; phProfZ->Draw("C"); canvas1->Print (histzname); } phHist->Reset() ; phProfY->Reset() ; phProfZ->Reset() ; // get data of next gamma and fill strings again with the new gamma data i++; singlestree->GetEntry(i); sprintf(s, "DOI=%5.2fmm x=%5.2fmm y=%5.2fmm t=%5.2f e=%5.2f", globalPosZ, globalPosX, globalPosY, runID, eventID); sprintf(histname, "H_%.2f_%.2f_%.2f.png", globalPosX, globalPosY, globalPosZ); sprintf(graphname, "G_%.2f_%.2f_%.2f.png", globalPosX, globalPosY, globalPosZ); sprintf(histyname, "Y_%.2f_%.2f_%.2f.png", globalPosX, globalPosY, globalPosZ); sprintf(histzname, "Z_%.2f_%.2f_%.2f.png", globalPosX, globalPosY, globalPosZ); nph=0; } } }