]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/totEt/macros/emEt/PlotSecondariesCorr.C
updating calculation of secondary correction to include making latex tables for analy...
[u/mrichter/AliRoot.git] / PWGLF / totEt / macros / emEt / PlotSecondariesCorr.C
1 void SetStyles(TH1 *histo,int marker, int color, char *name){
2   //histo->Sumw2();
3   histo->SetMarkerStyle(marker);
4   histo->SetMarkerColor(color);
5   histo->SetLineColor(color);
6   histo->SetName(name);
7   //histo->GetXaxis()->SetTitle(xtitle);
8   //histo->GetYaxis()->SetTitle(ytitle);
9 }
10 Int_t colors[] = {0,TColor::kRed, TColor::kOrange, TColor::kGreen+3, TColor::kBlue, TColor::kBlack, 
11                     TColor::kRed, TColor::kOrange, TColor::kGreen+3, TColor::kBlue, TColor::kBlack, 
12                     TColor::kRed, TColor::kOrange, TColor::kGreen+3, TColor::kBlue, TColor::kBlack, 
13                     TColor::kRed, TColor::kOrange, TColor::kGreen+3, TColor::kBlue, TColor::kBlack};
14 Int_t markers[] = {20,21,22,23,33, 24,25,26,32,27, 20,21,22,23,33, 24,25,26,32,27};
15
16 Float_t nSecondariesTrMultScaledSim[] = {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};
17 Float_t nSecondariesTrMultScaledData[] = {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};
18 Float_t nSecondariesClMultScaledSim[] = {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};
19 Float_t nSecondariesClMultScaledData[] = {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};
20 Float_t nSecondariesShortTrMultScaledSim[] = {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};
21 Float_t nSecondariesShortTrMultScaledData[] = {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};
22 Float_t nSecondariesShortClMultScaledSim[] = {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};
23 Float_t nSecondariesShortClMultScaledData[] = {0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};
24 void WriteLatex();
25 Float_t secondaryCorrEmcal[20] = {0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0};
26 Float_t secondaryCorrPhos[20] = {0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0};
27 Float_t secondaryErrorEmcal[20] = {0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0};
28 Float_t secondaryErrorPhos[20] = {0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0};
29
30 void PlotSecondariesCorr(TString filename = "rootFiles/LHC11a10a_bis/Et.ESD.simPbPb.EMCal.LHC11a10a_bis.Run139465.root",TString datafilename = "rootFiles/LHC10hPass2/Et.ESD.realPbPb.EMCal.LHC10hPass2.Run139465.root", Bool_t effCorr = kTRUE){
31     TString detector = "";
32   gStyle->SetOptTitle(0);
33   gStyle->SetOptStat(0);
34   gStyle->SetOptFit(0);
35
36     if(filename.Contains("EMC")){
37       detector = "Emcal";
38     }
39     else{
40       detector = "Phos";
41     }
42     TString tag = "";
43     if(!effCorr) tag = "NoEffCorr";
44
45     TString outname1 = "/tmp/SecondariesVsTrMult"+detector+".eps";
46     TString outname3 = "/tmp/SecondariesVsTrMultRatio"+detector+".png";
47     TString outname2 = "/tmp/SecondariesVsClMult"+detector+".eps";
48     ofstream myfile;
49     TString textfilename = "Secondaries"+detector+tag+".dat";
50     myfile.open (textfilename.Data());
51     ofstream myfile2;
52     TString textfilename2 = "Secondaries"+detector+tag+"Short.dat";
53     myfile2.open (textfilename2.Data());
54
55     TFile *fdata = TFile::Open(datafilename, "READ");
56     TList *ldata = dynamic_cast<TList*>(fdata->Get("out1"));
57     TH3F *fHistCentVsNchVsNclData = ldata->FindObject("fHistCentVsNchVsNclReco");
58     fHistCentVsNchVsNclData->SetName("fHistCentVsNchVsNclRecoData");
59
60     TFile *f = TFile::Open(filename, "READ");
61     TList *l = dynamic_cast<TList*>(f->Get("out1"));
62     TH2F *fHistSecondariesVsNch;
63     TH2F *fHistSecondariesVsNcl;
64     TH2F *fHistSecondariesOutOfAccEffCorrVsNch;
65     TH2F *fHistSecondariesDetectorCoverEffCorrVsNch;
66     if(effCorr){
67       fHistSecondariesVsNch =(TH2F *) l->FindObject("fHistSecondariesEffCorrVsNch");
68       fHistSecondariesVsNcl =(TH2F *) l->FindObject("fHistSecondariesEffCorrVsNcl");
69       fHistSecondariesOutOfAccEffCorrVsNch =(TH2F *) l->FindObject("fHistSecondariesOutOfAccEffCorrVsNch");
70       fHistSecondariesDetectorCoverEffCorrVsNch =(TH2F *) l->FindObject("fHistSecondariesDetectorCoverEffCorrVsNch");
71     }
72     else{
73       fHistSecondariesVsNch =(TH2F *) l->FindObject("fHistSecondariesVsNch");
74       fHistSecondariesVsNcl =(TH2F *) l->FindObject("fHistSecondariesVsNcl");
75       fHistSecondariesOutOfAccEffCorrVsNch =(TH2F *) l->FindObject("fHistSecondariesOutOfAccEffCorrVsNch");
76       fHistSecondariesDetectorCoverEffCorrVsNch =(TH2F *) l->FindObject("fHistSecondariesDetectorCoverEffCorrVsNch");
77     }
78     TH3F *fHistCentVsNchVsNcl = l->FindObject("fHistCentVsNchVsNcl");
79
80     TCanvas *c1 = new TCanvas("c1","Secondaries vs N_{ch}",600,400);
81     c1->SetTopMargin(0.02);
82     c1->SetRightMargin(0.02);
83     c1->SetBorderSize(0);
84     c1->SetFillColor(0);
85     c1->SetFillColor(0);
86     c1->SetBorderMode(0);
87     c1->SetFrameFillColor(0);
88     c1->SetFrameBorderMode(0);
89     c1->SetLogz();
90     //fHistSecondariesVsNch->GetXaxis()->SetRange(1,fHistSecondariesVsNch->GetXaxis()->FindBin(10.0));
91     fHistSecondariesVsNch->Draw("colz");
92     TH1D *prof1 = fHistSecondariesVsNch->ProfileX("prof1");
93     prof1->Draw("same");
94     TCanvas *c1a = new TCanvas("c1a","In detector cover and out of acceptance",600,400);
95     c1a->SetTopMargin(0.02);
96     c1a->SetRightMargin(0.02);
97     c1a->SetBottomMargin(0.153226);
98     c1a->SetBorderSize(0);
99     c1a->SetFillColor(0);
100     c1a->SetFillColor(0);
101     c1a->SetBorderMode(0);
102     c1a->SetFrameFillColor(0);
103     c1a->SetFrameBorderMode(0);
104     TH1D *profNCh = fHistSecondariesVsNch->ProfileY("profNCh");
105     profNCh->Draw("");
106     TH1D *profNChOutOfAcc = fHistSecondariesOutOfAccEffCorrVsNch->ProfileY("profNChOutOfAcc");
107     TH1D *profNChDetCover = fHistSecondariesDetectorCoverEffCorrVsNch->ProfileY("profNChDetCover");
108     //profNChDetCover->Draw("same");
109     //profNChOutOfAcc->Draw("same");
110     cout<<"Max "<<profNChDetCover->GetMaximum()<<" "<<profNChOutOfAcc->GetMaximum()<<" "<<profNCh->GetMaximum()<<endl;
111     profNChDetCover->SetLineColor(TColor::kRed);
112     profNChOutOfAcc->SetLineColor(TColor::kGreen+3);
113     profNCh->GetXaxis()->SetTitle("N_{Ch}");
114     profNCh->GetYaxis()->SetTitle("E_{T}^{Secondaries}");
115     profNCh->GetXaxis()->SetLabelSize(0.06);
116     profNCh->GetXaxis()->SetTitleSize(0.06);
117     profNCh->GetYaxis()->SetLabelSize(0.06);
118     profNCh->GetYaxis()->SetTitleSize(0.06);
119     profNCh->GetYaxis()->SetTitleOffset(0.6);
120     TLatex *texDet = new TLatex(50,6,detector.Data());
121     texDet->SetTextSize(0.0752688);
122     texDet->Draw();
123     c1a->SaveAs(outname1.Data());
124     TCanvas *c1b = new TCanvas("c1b","Fraction in detector cover, out of acceptance",600,400);
125     c1b->SetTopMargin(0.02);
126     c1b->SetRightMargin(0.02);
127     c1b->SetBottomMargin(0.153226);
128     c1b->SetBorderSize(0);
129     c1b->SetFillColor(0);
130     c1b->SetFillColor(0);
131     c1b->SetBorderMode(0);
132     c1b->SetFrameFillColor(0);
133     c1b->SetFrameBorderMode(0);
134 //     profNCh->Draw("");
135 //     profNChDetCover->Draw("same")
136 //       profNChOutOfAcc->Draw("same");
137     TH1D *profNChDetCoverRatio = profNChDetCover->Clone("profNChDetCoverRatio");
138     TH1D *profNChOutOfAccRatio = profNChOutOfAcc->Clone("profNChOutOfAccRatio");
139     profNChDetCoverRatio->Divide(profNCh);
140     profNChOutOfAccRatio->Divide(profNCh);
141     profNChDetCoverRatio->Draw("l");
142     profNChOutOfAccRatio->Draw("same l");
143     int rebin = 4;
144     profNChDetCoverRatio->Rebin(rebin);
145     profNChOutOfAccRatio->Rebin(rebin);
146     profNChDetCoverRatio->Scale(1.0/rebin);
147     profNChOutOfAccRatio->Scale(1.0/rebin);
148     profNChDetCoverRatio->SetMaximum(0.2);
149     c1b->SaveAs(outname3.Data());
150
151     TCanvas *c2 = new TCanvas("c2","Secondaries vs NCl",600,400);
152     c2->SetTopMargin(0.02);
153     c2->SetRightMargin(0.02);
154     c2->SetBorderSize(0);
155     c2->SetFillColor(0);
156     c2->SetFillColor(0);
157     c2->SetBorderMode(0);
158     c2->SetFrameFillColor(0);
159     c2->SetFrameBorderMode(0);
160     c2->SetLogz();
161     fHistSecondariesVsNcl->Draw("colz");
162     //fHistSecondariesVsNcl->GetXaxis()->SetRange(1,fHistSecondariesVsNcl->GetXaxis()->FindBin(10.0));
163     TH1D *prof1 = fHistSecondariesVsNcl->ProfileX("prof2");
164     prof1->Draw("same");
165     TCanvas *c2a = new TCanvas("c2a","average secondaries vs NCl",600,400);
166     c2a->SetTopMargin(0.02);
167     c2a->SetRightMargin(0.02);
168     c2a->SetBottomMargin(0.153226);
169     c2a->SetBorderSize(0);
170     c2a->SetFillColor(0);
171     c2a->SetFillColor(0);
172     c2a->SetBorderMode(0);
173     c2a->SetFrameFillColor(0);
174     c2a->SetFrameBorderMode(0);
175     TH1D *profNCl = fHistSecondariesVsNcl->ProfileY("profNCl");
176     profNCl->Draw("same");
177     profNCl->GetXaxis()->SetTitle("N_{Cl}");
178     profNCl->GetYaxis()->SetTitle("E_{T}^{Secondaries}");
179     profNCl->GetXaxis()->SetLabelSize(0.06);
180     profNCl->GetXaxis()->SetTitleSize(0.06);
181     profNCl->GetYaxis()->SetLabelSize(0.06);
182     profNCl->GetYaxis()->SetTitleSize(0.06);
183     profNCl->GetYaxis()->SetTitleOffset(0.6);
184     texDet->Draw();
185     c2a->SaveAs(outname2.Data());
186
187     TObjArray trackmultiplicity(20);
188     TObjArray clustermultiplicity(20);
189     TObjArray trackmultiplicityData(20);
190     TObjArray clustermultiplicityData(20);
191     int nbinsChMult = fHistCentVsNchVsNcl->GetYaxis()->GetNbins();
192     int nbinsClMult = fHistCentVsNchVsNcl->GetZaxis()->GetNbins();
193     fHistCentVsNchVsNcl->GetXaxis()->SetTitle("Cent Bin");
194     fHistCentVsNchVsNcl->GetYaxis()->SetTitle("N_{tr}");
195     fHistCentVsNchVsNcl->GetZaxis()->SetTitle("N_{cl}");
196     for(int cb=0;cb<20;cb++){
197       //x axis is centrality
198       //y axis is charged track multiplicity
199       //z axis is cluster multiplicity
200       fHistCentVsNchVsNcl->GetXaxis()->SetRange(cb+1,cb+1);
201       trackmultiplicity[cb] = fHistCentVsNchVsNcl->Project3D("y");
202       clustermultiplicity[cb] = fHistCentVsNchVsNcl->Project3D("z");
203       SetStyles((TH1*)trackmultiplicity[cb],markers[cb],colors[cb],Form("tr%i",cb));
204       SetStyles((TH1*)clustermultiplicity[cb],markers[cb],colors[cb],Form("cl%i",cb));
205       fHistCentVsNchVsNclData->GetXaxis()->SetRange(cb+1,cb+1);
206       trackmultiplicityData[cb] = fHistCentVsNchVsNclData->Project3D("y");
207       clustermultiplicityData[cb] = fHistCentVsNchVsNclData->Project3D("z");
208       SetStyles((TH1*)trackmultiplicityData[cb],markers[cb],colors[cb],Form("tr%i",cb));
209       SetStyles((TH1*)clustermultiplicityData[cb],markers[cb],colors[cb],Form("cl%i",cb));
210     }
211     TCanvas *c3 = new TCanvas("c3","<E_{T}> Neutral Removed",600,400);
212     c3->SetTopMargin(0.02);
213     c3->SetRightMargin(0.02);
214     c3->SetBorderSize(0);
215     c3->SetFillColor(0);
216     c3->SetFillColor(0);
217     c3->SetBorderMode(0);
218     c3->SetFrameFillColor(0);
219     c3->SetFrameBorderMode(0);
220     c3->SetLogy();
221     ((TH1*)trackmultiplicity[0])->Draw();
222     for(int cb=1;cb<20;cb++){
223 //       cout<<"cb "<<cb<<" tr "<< ((TH1*)trackmultiplicity[cb])->GetMean();
224 //       cout<<" cluster "<< ((TH1*)clustermultiplicity[cb])->GetMean()<<endl;
225       ((TH1*)trackmultiplicity[cb])->Draw("same");
226     }
227     TCanvas *c4 = new TCanvas("c4","<E_{T}> Neutral Removed",600,400);
228     c4->SetTopMargin(0.02);
229     c4->SetRightMargin(0.02);
230     c4->SetBorderSize(0);
231     c4->SetFillColor(0);
232     c4->SetFillColor(0);
233     c4->SetBorderMode(0);
234     c4->SetFrameFillColor(0);
235     c4->SetFrameBorderMode(0);
236     c4->SetLogy();
237     ((TH1*)clustermultiplicity[0])->Draw();
238     for(int cb=1;cb<20;cb++){
239 //       cout<<"cb "<<cb<<" "<< ((TH1*)trackmultiplicity[cb])->GetMean()<<endl;
240       ((TH1*)clustermultiplicity[cb])->Draw("same");
241     }
242     cout<<" Sim cluster track data cluster track "<<endl;
243       //for fewer centrality bins
244     int currentShortCB = 0;
245     Float_t neventsShort[] = {0,0,0,0};
246     //profNCh, profNCl
247     for(int cb=0;cb<19;cb++){
248
249       int nbins = ((TH1*)clustermultiplicity[cb])->GetNbinsX();
250       Float_t nevents = 0.0;
251       for(int binn = 1;binn<=nbins;binn++){
252         float neventsBinn = ((TH1*)clustermultiplicity[cb])->GetBinContent(binn);
253         float mult= ((TH1*)clustermultiplicity[cb])->GetBinCenter(binn);
254         float meanet = profNCl->GetBinContent(profNCl->FindBin(mult));
255         nSecondariesClMultScaledSim[cb] += neventsBinn*meanet;
256         nevents +=neventsBinn;
257         nSecondariesShortClMultScaledSim[currentShortCB] += neventsBinn*meanet;
258         neventsShort[0] +=neventsBinn;
259       }
260       if(nevents>0) nSecondariesClMultScaledSim[cb] = nSecondariesClMultScaledSim[cb]/nevents;
261
262
263
264       nbins = ((TH1*)trackmultiplicity[cb])->GetNbinsX();
265       nevents = 0.0;
266       for(int binn = 1;binn<=nbins;binn++){
267         float neventsBinn = ((TH1*)trackmultiplicity[cb])->GetBinContent(binn);
268         float mult= ((TH1*)trackmultiplicity[cb])->GetBinCenter(binn);
269         float meanet = profNCh->GetBinContent(profNCh->FindBin(mult));
270         nSecondariesTrMultScaledSim[cb] += neventsBinn*meanet;
271         nevents +=neventsBinn;
272         nSecondariesShortTrMultScaledSim[currentShortCB] += neventsBinn*meanet;
273         neventsShort[1] +=neventsBinn;
274       }
275       if(nevents>0) nSecondariesTrMultScaledSim[cb] = nSecondariesTrMultScaledSim[cb]/nevents;
276
277       nbins = ((TH1*)clustermultiplicity[cb])->GetNbinsX();
278       nevents = 0.0;
279       float meanmult = 0.0;
280       //cout<<"Data cluster scaled  = (";
281       for(int binn = 1;binn<=nbins;binn++){
282         float neventsBinn = ((TH1*)clustermultiplicity[cb])->GetBinContent(binn);
283         float mult= ((TH1*)clustermultiplicity[cb])->GetBinCenter(binn);
284         float meanet = profNCl->GetBinContent(profNCl->FindBin(mult));
285         nSecondariesClMultScaledData[cb] += neventsBinn*meanet;
286         meanmult += neventsBinn*mult;
287         nevents +=neventsBinn;
288         //if(neventsBinn>0) cout<<"("<<mult<<") "<<neventsBinn<<"*"<<meanet<<"+";
289         nSecondariesShortClMultScaledData[currentShortCB] += neventsBinn*meanet;
290         neventsShort[2] +=neventsBinn;
291       }
292       if(nevents>0) meanmult = meanmult/nevents;
293       //nSecondariesClMultScaledData[cb] = nSecondariesClMultScaledData[cb]/nevents;
294       //cout<<")/"<<nevents<<endl;
295       //cout<<"cb "<<cb<<" = "<<nSecondariesClMultScaledData[cb]<<"/"<<nevents;
296       if(nevents>0) nSecondariesClMultScaledData[cb] = nSecondariesClMultScaledData[cb]/nevents;//<<" = ";
297       //cout<<" " << nSecondariesClMultScaledData[cb];
298       //cout<<" mean "<<((TH1*)clustermultiplicityData[cb])->GetMean()<<" mean2 "<<meanmult<<" mean method "<< profNCl->GetBinContent(profNCl->FindBin(meanmult));
299       //cout<<" mean method "<< profNCl->GetBinContent(profNCl->FindBin(((TH1*)trackmultiplicityData[cb])->GetMean()));
300       //cout<<endl;
301
302       nbins = ((TH1*)trackmultiplicity[cb])->GetNbinsX();
303       nevents = 0.0;
304       for(int binn = 1;binn<=nbins;binn++){
305         float neventsBinn = ((TH1*)trackmultiplicityData[cb])->GetBinContent(binn);
306         float mult= ((TH1*)trackmultiplicityData[cb])->GetBinCenter(binn);
307         float meanet = profNCh->GetBinContent(profNCh->FindBin(mult));
308         nSecondariesTrMultScaledData[cb] += neventsBinn*meanet;
309         nevents +=neventsBinn;
310         nSecondariesShortTrMultScaledData[currentShortCB] += neventsBinn*meanet;
311         neventsShort[3] +=neventsBinn;
312       }
313
314 //       cout<<"cb "<<cb<<" = "<<nSecondariesTrMultScaledData[cb]<<"/"<<nevents;
315       if(nevents>0) nSecondariesTrMultScaledData[cb] = nSecondariesTrMultScaledData[cb]/nevents;
316 //       cout<<" " << nSecondariesTrMultScaledData[cb];
317 //       cout<<" mean "<<((TH1*)trackmultiplicityData[cb])->GetMean()<<" mean method "<< profNCh->GetBinContent(profNCh->FindBin(((TH1*)trackmultiplicityData[cb])->GetMean()));
318 //       cout<<endl<<endl;
319
320
321       float meanSim = ( nSecondariesTrMultScaledSim[cb] +  nSecondariesClMultScaledSim[cb] ) /2.0;
322       float errSim =  TMath::Abs( nSecondariesTrMultScaledSim[cb] -  nSecondariesClMultScaledSim[cb] ) /2.0;
323       float mean = ( nSecondariesTrMultScaledData[cb] +  nSecondariesClMultScaledData[cb] ) /2.0;
324       float err =  TMath::Abs( nSecondariesTrMultScaledData[cb] -  nSecondariesClMultScaledData[cb] ) /2.0;
325       myfile<<Form("%2.3f %2.3f",mean,err)<<endl;
326
327       cout<<"cb "<<cb<<" ET from secondaries "<< nSecondariesClMultScaledSim[cb];// <<endl;
328       cout<<" "<< nSecondariesTrMultScaledSim[cb];
329       cout<<" "<<meanSim << "+/-"<<errSim;
330       cout<<" "<< nSecondariesClMultScaledData[cb];
331       cout<<" "<< nSecondariesTrMultScaledData[cb];
332       cout<<" "<<mean << "+/-"<<err;
333       cout<<endl;
334
335       //return;
336       if(cb<2 || (cb+1)%2==0){//For combined bins, 
337         if(neventsShort[0]>0)nSecondariesShortClMultScaledSim[currentShortCB] = nSecondariesShortClMultScaledSim[currentShortCB]/neventsShort[0];
338         if(neventsShort[1]>0)nSecondariesShortTrMultScaledSim[currentShortCB] = nSecondariesShortTrMultScaledSim[currentShortCB]/neventsShort[1];
339         if(neventsShort[2]>0)nSecondariesShortClMultScaledData[currentShortCB] = nSecondariesShortClMultScaledData[currentShortCB]/neventsShort[2];
340         if(neventsShort[3]>0)nSecondariesShortTrMultScaledData[currentShortCB] = nSecondariesShortTrMultScaledData[currentShortCB]/neventsShort[3];
341         cout<<"cb Short "<<currentShortCB<<" ET from secondaries "<< nSecondariesShortClMultScaledSim[currentShortCB];// <<endl;
342         cout<<" "<< nSecondariesShortTrMultScaledSim[currentShortCB];
343
344         meanSim = ( nSecondariesShortTrMultScaledSim[currentShortCB] +  nSecondariesShortClMultScaledSim[currentShortCB] ) /2.0;
345         errSim =  TMath::Abs( nSecondariesShortTrMultScaledSim[currentShortCB] -  nSecondariesShortClMultScaledSim[currentShortCB] ) /2.0;
346         cout<<" "<<meanSim << "+/-"<<errSim;
347
348         cout<<" "<< nSecondariesShortClMultScaledData[currentShortCB];
349         cout<<" "<< nSecondariesShortTrMultScaledData[currentShortCB];
350
351         for(int k=0;k<4;k++){neventsShort[k] = 0;}
352
353         mean = ( nSecondariesShortTrMultScaledData[currentShortCB] +  nSecondariesShortClMultScaledData[currentShortCB] ) /2.0;
354         err =  TMath::Abs( nSecondariesShortTrMultScaledData[currentShortCB] -  nSecondariesShortClMultScaledData[currentShortCB] ) /2.0;
355         myfile2<<Form("%2.3f %2.3f",mean,err)<<endl;
356         //myfile2<<mean<<" "<<err<<endl;
357         cout<<" "<<mean << "+/-"<<err;
358         cout<<endl;
359
360         currentShortCB++;
361         cout<<"cb "<<cb<<" incrementing short CB "<<currentShortCB<<endl<<endl;
362       }
363
364     }
365     myfile.close();
366     myfile2.close();
367
368     WriteLatex();
369 }
370
371 void WriteLatex(){
372   TString detector = "Emcal";
373     string inline;
374     TString secondaryInfileName = "Secondaries"+detector+".dat";
375     ifstream mysecondaryfile3 (secondaryInfileName.Data());
376     Float_t value = 0;
377     Float_t error = 0;
378     Int_t i=0;
379     if (mysecondaryfile3.is_open()){
380       while ( mysecondaryfile3.good() )
381         {
382           getline (mysecondaryfile3,inline);
383           istringstream tmp(inline);
384           tmp >> value;
385           tmp >> error;
386           if(i<20){
387             secondaryCorrEmcal[i] = value;
388             secondaryErrorEmcal[i] = error;
389           }
390           i++;
391         }
392         mysecondaryfile3.close();
393     }
394
395     detector = "Phos";
396     secondaryInfileName = "Secondaries"+detector+".dat";
397     ifstream mysecondaryfile4 (secondaryInfileName.Data());
398     Float_t value = 0;
399     Float_t error = 0;
400     Int_t i=0;
401     if (mysecondaryfile4.is_open()){
402       while ( mysecondaryfile4.good() )
403         {
404           getline (mysecondaryfile4,inline);
405           istringstream tmp(inline);
406           tmp >> value;
407           tmp >> error;
408           if(i<20){
409             secondaryCorrPhos[i] = value;
410             secondaryErrorPhos[i] = error;
411           }
412           i++;
413         }
414         mysecondaryfile4.close();
415     }
416     ofstream myfile3;
417     myfile3.open ("Secondaries.tex");
418
419     for(int i=0;i<20;i++){
420       TString line = Form("%i-%i & %2.3f $\\pm$ %2.3f & %2.3f $\\pm$ %2.3f \\\\",i*5,(i+1)*5,secondaryCorrPhos[i],secondaryErrorPhos[i],secondaryCorrEmcal[i],secondaryErrorEmcal[i]);
421       myfile3<<line.Data()<<endl;
422     }
423     myfile3.close();
424
425
426 }