1 #include <calobase/TowerInfoDefs.h>
21 R__LOAD_LIBRARY(libcalo_io.so)
23 namespace myAnalysis {
25 void init(
const string& inputFile =
"data/LEDTowerBuilder.root");
27 void finalize(
const string &outputFile=
"output/test.root");
79 input = TFile::Open(inputFile.c_str());
111 "adc vs Time Sample; Time Sample; adc",
118 vector<Float_t>*
time = 0;
119 vector<Float_t>*
ADC = 0;
120 vector<Float_t>* ped = 0;
121 vector<Int_t>* chan = 0;
122 vector<vector<Float_t>>* waveforms = 0;
124 led_tree->SetBranchAddress(
"time",&time);
125 led_tree->SetBranchAddress(
"adc",&ADC);
126 led_tree->SetBranchAddress(
"ped",&ped);
127 led_tree->SetBranchAddress(
"chan",&chan);
128 led_tree->SetBranchAddress(
"waveforms",&waveforms);
133 Int_t counter_event[24576] = {0};
135 Int_t events_max = 100;
137 if(
i%100 == 0) cout <<
"Progress: " <<
i*100./nevents <<
" %" << endl;
141 UInt_t nchannels = time->size();
144 for(UInt_t
j = 0;
j < nchannels; ++
j) {
145 Float_t time_val = time->at(
j);
146 Float_t ADC_val = ADC->at(
j);
147 Float_t ped_val = ped->at(
j);
149 if(channel >= 24576) {
150 cout <<
"invalid channel number: " << channel <<
", event: " <<
i << endl;
158 Int_t time_bin =
hTime->FindBin(time_val);
159 Int_t ADC_bin =
hADC->FindBin(ADC_val);
160 Int_t ped_bin =
hPed->FindBin(ped_val);
161 Int_t channel_bin =
hChannels->FindBin(channel);
163 for (UInt_t sample = 0; sample <
time_bins; ++sample) {
164 Float_t adc_val = waveforms->at(
j).at(sample);
169 if(counter_event[channel] < events_max) {
181 hTime->Fill(time_val);
212 cout <<
"events processed: " << nevents << endl;
213 cout <<
"max channels per event: " <<
channels_max << endl;
215 cout <<
"ADC_min: " <<
ADC_min <<
" ADC_max: " <<
ADC_max << endl;
216 cout <<
"adc_min: " <<
adc_min <<
" adc_max: " <<
adc_max << endl;
217 cout <<
"ped_min: " <<
ped_min <<
" ped_max: " <<
ped_max << endl;
221 TFile
output(outputFile.c_str(),
"recreate");
251 output.mkdir(
"adcVsTime");
254 if(
h2->GetEntries())
h2->Write();
263 for (UInt_t
i = 0;
i < 1536; ++
i) {
268 cout <<
"channel: " <<
i <<
", etabin: " << etabin <<
", phibin: " << phibin << endl;
272 void read_LEDs(
const string &inputFile=
"data/LEDTowerBuilder.root",
273 const string &outputFile=
"output/test.root",
284 int main(
int argc,
char* argv[]) {
285 if(argc < 1 || argc > 4){
286 cout <<
"usage: ./bin/read-LEDs inputFile outputFile events" << endl;
287 cout <<
"inputFile: Location of LEDTowerBuilder.root. Default = data/LEDTowerBuilder.root." << endl;
288 cout <<
"outputFile: output root file. Default = output/test.root." << endl;
289 cout <<
"events: Number of events to analyze. Default = 0 (meaning all events)." << endl;
293 string input =
"data/LEDTowerBuilder.root";
294 string output =
"output/test.root";
304 events = atoi(argv[3]);
309 cout <<
"done" << endl;