File indexing completed on 2025-02-23 09:21:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 void SetLeafAddress(TNtuple* ntuple, const char* name, void* address);
0011
0012 void plot()
0013 {
0014 gROOT->Reset();
0015 gStyle->SetPalette(1);
0016 gROOT->SetStyle("Plain");
0017
0018 TCanvas* c1 = new TCanvas ("c1","",20,20,2000,500);
0019 c1->Divide(4,1);
0020
0021
0022
0023
0024
0025 TFile* f = new TFile("dna.root");
0026
0027 TNtuple* ntuple;
0028 ntuple = (TNtuple*)f->Get("step");
0029 bool rowWise = true;
0030 TBranch* eventBranch = ntuple->FindBranch("row_wise_branch");
0031 if ( ! eventBranch ) rowWise = false;
0032
0033
0034
0035
0036
0037
0038 c1->cd(1);
0039 gStyle->SetOptStat(000000);
0040
0041
0042 ntuple->SetFillStyle(1001);
0043 ntuple->SetFillColor(2);
0044 ntuple->Draw("flagProcess","","B");
0045
0046
0047 ntuple->SetFillStyle(1001);
0048 ntuple->SetFillColor(3);
0049 ntuple->Draw("flagProcess","flagProcess==12||flagProcess==15||flagProcess==22||flagProcess==32||flagProcess==42||flagProcess==52||flagProcess==62","Bsame");
0050
0051
0052 ntuple->SetFillStyle(1001);
0053 ntuple->SetFillColor(4);
0054 ntuple->Draw("flagProcess","flagProcess==11||flagProcess==21||flagProcess==31||flagProcess==41||flagProcess==51||flagProcess==61||flagProcess==110||flagProcess==210||flagProcess==410||flagProcess==510||flagProcess==710||flagProcess==120||flagProcess==220||flagProcess==420||flagProcess==520||flagProcess==720","Bsame");
0055
0056
0057 ntuple->SetFillStyle(1001);
0058 ntuple->SetFillColor(5);
0059 ntuple->Draw("flagProcess","flagProcess==13||flagProcess==23||flagProcess==33||flagProcess==43||flagProcess==53||flagProcess==63||flagProcess==73||flagProcess==130||flagProcess==230||flagProcess==430||flagProcess==530||flagProcess==730","Bsame");
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071 gPad->SetLogy();
0072
0073
0074
0075
0076
0077 c1->cd(2);
0078
0079 ntuple->SetMarkerColor(2);
0080
0081 ntuple->Draw("x:y:z","flagParticle==1");
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091 c1->cd(3);
0092
0093 Double_t flagParticle;
0094 Double_t flagProcess;
0095 Double_t x;
0096 Double_t y;
0097 Double_t z;
0098 Double_t totalEnergyDeposit;
0099 Double_t stepLength;
0100 Double_t kineticEnergyDifference;
0101 Int_t eventID;
0102 Double_t kineticEnergy;
0103 Int_t stepID;
0104 Int_t trackID;
0105 Int_t parentID;
0106 Double_t angle;
0107
0108 if ( ! rowWise ) {
0109 ntuple->SetBranchAddress("flagParticle",&flagParticle);
0110 ntuple->SetBranchAddress("flagProcess",&flagProcess);
0111 ntuple->SetBranchAddress("x",&x);
0112 ntuple->SetBranchAddress("y",&y);
0113 ntuple->SetBranchAddress("z",&z);
0114 ntuple->SetBranchAddress("totalEnergyDeposit",&totalEnergyDeposit);
0115 ntuple->SetBranchAddress("stepLength",&stepLength);
0116 ntuple->SetBranchAddress("kineticEnergyDifference",&kineticEnergyDifference);
0117 ntuple->SetBranchAddress("kineticEnergy",&kineticEnergy);
0118 ntuple->SetBranchAddress("cosTheta",&angle);
0119 ntuple->SetBranchAddress("eventID",&eventID);
0120 ntuple->SetBranchAddress("trackID",&trackID);
0121 ntuple->SetBranchAddress("parentID",&parentID);
0122 ntuple->SetBranchAddress("stepID",&stepID);
0123 }
0124 else {
0125 SetLeafAddress(ntuple, "flagParticle",&flagParticle);
0126 SetLeafAddress(ntuple, "flagProcess",&flagProcess);
0127 SetLeafAddress(ntuple, "x",&x);
0128 SetLeafAddress(ntuple, "y",&y);
0129 SetLeafAddress(ntuple, "z",&z);
0130 SetLeafAddress(ntuple, "totalEnergyDeposit",&totalEnergyDeposit);
0131 SetLeafAddress(ntuple, "stepLength",&stepLength);
0132 SetLeafAddress(ntuple, "kineticEnergyDifference",&kineticEnergyDifference);
0133 SetLeafAddress(ntuple, "kineticEnergy",&kineticEnergy);
0134 SetLeafAddress(ntuple, "cosTheta",&angle);
0135 SetLeafAddress(ntuple, "eventID",&eventID);
0136 SetLeafAddress(ntuple, "trackID",&trackID);
0137 SetLeafAddress(ntuple, "parentID",&parentID);
0138 SetLeafAddress(ntuple, "stepID",&stepID);
0139 }
0140
0141 TH1F* hsolvE = new TH1F ("hsolvE","solvE",100,0,2000);
0142 TH1F* helastE = new TH1F ("helastE","elastE",100,0,2000);
0143 TH1F* hexcitE = new TH1F ("hexcitE","excitE",100,0,2000);
0144 TH1F* hioniE = new TH1F ("hiioniE","ioniE",100,0,2000);
0145 TH1F* hattE = new TH1F ("hattE","attE",100,0,2000);
0146 TH1F* hvibE = new TH1F ("hvibE","vibE",100,0,2000);
0147
0148 for (Int_t j=0;j<ntuple->GetEntries(); j++)
0149 {
0150 ntuple->GetEntry(j);
0151 if (flagProcess==10) hsolvE->Fill(x);
0152 if (flagProcess==11) helastE->Fill(x);
0153 if (flagProcess==12) hexcitE->Fill(x);
0154 if (flagProcess==13) hioniE->Fill(x);
0155 if (flagProcess==14) hattE->Fill(x);
0156 if (flagProcess==15) hvibE->Fill(x);
0157
0158 }
0159
0160 helastE->GetXaxis()->SetTitle("x (nm)");
0161 helastE->SetLineColor(2);
0162
0163 hexcitE->SetLineColor(3);
0164 hioniE->SetLineColor(4);
0165 hattE->SetLineColor(5);
0166 hvibE->SetLineColor(6);
0167 hsolvE->SetLineColor(7);
0168
0169 gPad->SetLogy();
0170
0171 helastE->Draw("");
0172 hexcitE->Draw("SAME");
0173 hioniE->Draw("SAME");
0174 hattE->Draw("SAME");
0175 hvibE->Draw("SAME");
0176 hsolvE->Draw("SAME");
0177
0178
0179
0180
0181
0182 TNtuple* ntuple2;
0183 ntuple2 = (TNtuple*)f->Get("track");
0184 bool rowWise2 = true;
0185 TBranch* eventBranch2 = ntuple2->FindBranch("row_wise_branch");
0186 if ( ! eventBranch2 ) rowWise2 = false;
0187
0188 c1->cd(4);
0189 gStyle->SetOptStat(000000);
0190
0191
0192 ntuple2->SetFillStyle(1001);
0193 ntuple2->SetFillColor(2);
0194 ntuple2->Draw("kineticEnergy","flagParticle==1","B");
0195
0196 gPad->SetLogy();
0197
0198 }
0199
0200 void SetLeafAddress(TNtuple* ntuple, const char* name, void* address) {
0201 TLeaf* leaf = ntuple->FindLeaf(name);
0202 if ( ! leaf ) {
0203 std::cerr << "Error in <SetLeafAddress>: unknown leaf --> " << name << std::endl;
0204 return;
0205 }
0206 leaf->SetAddress(address);
0207 }