]>
Commit | Line | Data |
---|---|---|
03b2fac4 | 1 | /* |
2 | a very basic test macro for processing Pedestal events with AliCaloCalibPedestal | |
3 | (adopted from EMCALLEDda.C macro) | |
4 | Josh Hamblen | |
5 | */ | |
6 | #define AliDebugLevel() -1 | |
7 | ||
8 | void EMCALPEDda(const int runno = 476){ | |
9 | ||
10 | int i, status; | |
11 | ||
12 | /* log start of process */ | |
13 | printf("EMCAL DA started - %s\n",__FILE__); | |
14 | ||
15 | AliCaloCalibPedestal * calibPedestal = new | |
16 | AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal); // pedestal and noise calibration | |
17 | ||
18 | int nevents=0; | |
19 | // Assume we are just interested in the 1st segment, _0.root below for fname* | |
20 | Char_t fname[256]; | |
21 | sprintf(fname, "/local/data/Run_%09d.Seq_1A.Stream_0.root",runno); | |
22 | ||
23 | AliRawReader *rawReader = NULL; | |
24 | rawReader = new AliRawReaderRoot(fname); | |
25 | AliCaloRawStream *in = NULL; | |
26 | in = new AliCaloRawStream(rawReader,"EMCAL"); | |
27 | //in->SetOldRCUFormat(kTRUE); | |
28 | ||
29 | AliRawEventHeaderBase *aliHeader=NULL; | |
30 | int nev=0; | |
31 | /* read until EOF */ | |
32 | while ( rawReader->NextEvent()) { | |
33 | nev++; | |
34 | ||
35 | aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader(); | |
36 | calibPedestal->SetRunNumber( aliHeader->Get("RunNb") ); // just for fun; keep info on last run looked at | |
37 | ||
38 | // select physics and calibration events now (only calibration in future) | |
39 | if ( aliHeader->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent || | |
40 | aliHeader->Get("Type") == AliRawEventHeaderBase::kCalibrationEvent ) { | |
41 | ||
42 | nevents++; | |
43 | if(nevents%1000==0)cout<<"Event "<<nevents<<endl; | |
44 | // Pedestal calibration | |
45 | calibPedestal->ProcessEvent(in); | |
46 | } | |
47 | } // loop over all events in file | |
48 | /* cleanup the reading handles */ | |
49 | delete in; | |
50 | delete rawReader; | |
51 | ||
52 | // | |
53 | // write results/histograms to rootfile | |
54 | // | |
55 | ||
56 | printf ("%d physics/calibration events processed.\n",nevents); | |
57 | ||
58 | // create output histograms and write to file | |
59 | Char_t outname[256]; | |
60 | sprintf(outname, "PED_%09d.root",runno); | |
61 | ||
62 | calibPedestal->SaveHistograms(outname); | |
63 | ||
64 | printf("Wrote %s.\n",outname); | |
65 | ||
66 | // see if we can delete our analysis helper also | |
67 | delete calibPedestal; | |
68 | ||
69 | // | |
70 | // reopen the file that was just made to make the RMS hists | |
71 | // | |
72 | ||
73 | TFile *f=new TFile(outname,"update"); | |
74 | ||
75 | // now take the profile histograms and plot the RMS from them | |
76 | int ncols = hPedlowgain0->GetNbinsX(); | |
77 | int nrows = hPedlowgain0->GetNbinsY(); | |
78 | Double_t rms; | |
79 | ||
80 | TH2F *hPedRMSlowgain0 = new TH2F("hPedRMSlowgain0","Pedestal RMS, low gain, module 0",ncols,0,ncols,nrows,0,nrows); | |
81 | TH2F *hPedRMShighgain0 = new TH2F("hPedRMShighgain0","Pedestal RMS, high gain, module 0",ncols,0,ncols,nrows,0,nrows); | |
82 | TH2F *hSampleRMSlowgain0 = new TH2F("hSampleRMSlowgain0","All Samples RMS, low gain, module 0",ncols,0,ncols,nrows,0,nrows); | |
83 | TH2F *hSampleRMShighgain0 = new TH2F("hSampleRMShighgain0","All Samples RMS, high gain, module 0",ncols,0,ncols,nrows,0,nrows); | |
84 | ||
85 | for (int i=0; i < ncols; i++){ | |
86 | for (int j=0; j < nrows; j++){ | |
87 | ||
88 | rms = hPedlowgain0->GetBinError(i+1,j+1); | |
89 | hPedRMSlowgain0->Fill(i,j,rms); | |
90 | ||
91 | rms = hPedhighgain0->GetBinError(i+1,j+1); | |
92 | hPedRMShighgain0->Fill(i,j,rms); | |
93 | ||
94 | rms = hSamplelowgain0->GetBinError(i+1,j+1); | |
95 | hSampleRMSlowgain0->Fill(i,j,rms); | |
96 | ||
97 | rms = hSamplehighgain0->GetBinError(i+1,j+1); | |
98 | hSampleRMShighgain0->Fill(i,j,rms); | |
99 | } | |
100 | } | |
101 | ||
102 | // write the RMS hists to the file | |
103 | hPedRMSlowgain0->Write(); | |
104 | hPedRMShighgain0->Write(); | |
105 | hSampleRMSlowgain0->Write(); | |
106 | hSampleRMShighgain0->Write(); | |
107 | f->ls(); | |
108 | ||
109 | // now draw the results | |
110 | gStyle->SetOptStat(0); | |
111 | gStyle->SetPalette(1); | |
112 | ||
113 | TCanvas *c1 = new TCanvas("c1","",800,600); | |
114 | c1->Divide(2,2); | |
115 | c1->cd(1); | |
116 | hPedlowgain0->Draw("colz"); | |
117 | c1->cd(2); | |
118 | hPedRMSlowgain0->Draw("colz"); | |
119 | c1->cd(3); | |
120 | hPedhighgain0->Draw("colz"); | |
121 | c1->cd(4); | |
122 | hPedRMShighgain0->Draw("colz"); | |
123 | c1->cd(); | |
124 | ||
125 | TCanvas *c2 = new TCanvas("c2","",800,600); | |
126 | c2->Divide(2,2); | |
127 | c2->cd(1); | |
128 | hSamplelowgain0->Draw("colz"); | |
129 | c2->cd(2); | |
130 | hSampleRMSlowgain0->Draw("colz"); | |
131 | c2->cd(3); | |
132 | hSamplehighgain0->Draw("colz"); | |
133 | c2->cd(4); | |
134 | hSampleRMShighgain0->Draw("colz"); | |
135 | c2->cd(); | |
136 | ||
137 | ||
138 | } |