diff --git a/Software/ComputePedestals/ComputePedestals.C b/Software/ComputePedestals/ComputePedestals.C index 3bc6417..9115412 100644 --- a/Software/ComputePedestals/ComputePedestals.C +++ b/Software/ComputePedestals/ComputePedestals.C @@ -6,7 +6,7 @@ /* ComputePedestals reads a ROOT file and creates a ROOT file with the following information: - distribution of the ADC counts of each Beetle; -- distribution of the ADC counts of each Beetle channel (hADCx, with x = {0,...,255}; +- distribution of the ADC counts of each Beetle channel (hADCx, with x = {0,...,255}); - mean of the above distribution as a function of the Beetle channel (the pedestal); - RMS of the above distribution as a function of the Beetle channel (the noise); - distribution of the pedestals of each Beetle; @@ -19,13 +19,13 @@ Compile with: -g++ `root-config --glibs --cflags` ComputePedestals.C -o ComputePedestals +make Run with: ./ComputePedestals [input ROOT file] -where [input ROOT file] is the complete path, including the folder and the filename, of the file one wants to process. +where [input ROOT file] is the complete path, including the folder and the filename, of the ROOT file one wants to process. For example: ./ComputePedestals /.../run_xxxxxx_xxxx_xxxx.root @@ -39,14 +39,16 @@ */ #include "../Tools/Lib.C" -#include "../Tools/Par.C" +#include "../Tools/lhcbStyle.C" #include "../Tools/Style.C" +#include "../Tools/Par.C" void ComputePedestals(char *filename, char *externalPath = 0); int main(int argc, char *argv[]) { - dca(); + getLHCbStyle(); + PersonalStyle(); if (argc < 2) { @@ -137,6 +139,13 @@ analysis = string(analysis+"/"+externalPath); string filename_as_string = string(filename); + // Check that the filename provided corresponds to a ROOT file. + int found = filename_as_string.find(".root"); + if (found==string::npos) { + cout << "Error! The filename provided is not associated to a ROOT file." << endl; + return; + } + string filename_as_string_no_path = filename_as_string.substr(filename_as_string.find_last_of('/')+1); string filename_as_string_no_path_no_extension = filename_as_string_no_path.substr(0,filename_as_string_no_path.length()-5); @@ -207,21 +216,17 @@ TFile *output = TFile::Open(analysis+"/ComputePedestals-"+TString(filename_as_string_no_path),"RECREATE"); - - // Open output text file. + // Open output pedestal text file. FILE *output_text = fopen(analysis+"/ComputePedestals-"+TString(filename_as_string_no_path_no_extension)+".dat","w"); TH1F *hADCBeetle1 = new TH1F("hADCBeetle1","",200,400,600); // Modify it. - TPaveStats *sADCBeetle1; - TCanvas *cADCBeetle1 = new TCanvas("cADCBeetle1","",700,700); + TCanvas *cADCBeetle1 = new TCanvas("cADCBeetle1","",400,300); InitHist(hADCBeetle1,"Raw ADC counts on Beetle 1","ADC counts",""); TH1F *hADCBeetle2 = new TH1F("hADCBeetle2","",200,400,600); // Modify it. - TPaveStats *sADCBeetle2; - TCanvas *cADCBeetle2 = new TCanvas("cADCBeetle2","",700,700); + TCanvas *cADCBeetle2 = new TCanvas("cADCBeetle2","",400,300); InitHist(hADCBeetle2,"Raw ADC counts on Beetle 2","ADC counts",""); - // Fill histogram. for (int iEvent=0;iEventGetEntry(iEvent); @@ -235,12 +240,9 @@ } } - sADCBeetle1 = CreateStats(hADCBeetle1,"IUO"); - sADCBeetle2 = CreateStats(hADCBeetle2,"IUO"); - DrawHistStats(cADCBeetle1,hADCBeetle1,sADCBeetle1,"",path_to_figures); - DrawHistStats(cADCBeetle2,hADCBeetle2,sADCBeetle2,"",path_to_figures); - + DrawHist(cADCBeetle1,hADCBeetle1,"",path_to_figures); + DrawHist(cADCBeetle2,hADCBeetle2,"",path_to_figures); // Remove potential outliers. Use the mean and the RMS of the hADCBeetle1 and hADCBeetle2 histograms and exclude everything that is outside 5 times the RMS. double mean1 = hADCBeetle1->GetMean(); @@ -253,7 +255,7 @@ // Fill histograms. TH1F *hADC[N]; - TPaveStats *sADC[N]; + // TPaveStats *sADC[N]; TCanvas *cADC[N]; double pedestal[N]; @@ -261,7 +263,7 @@ for (int ch=0;chSetMinimum(450.); hpedestalvsstrip->SetMaximum(550.); hnoisevsstrip->SetMinimum(0.); - hnoisevsstrip->SetMaximum(50.); + hnoisevsstrip->SetMaximum(70.); - TCanvas *cpedestalvsstrip = new TCanvas("cpedestalvsstrip","",700,700); - TCanvas *cnoisevsstrip = new TCanvas("cnoisevsstrip","",700,700); + TCanvas *cpedestalvsstrip = new TCanvas("cpedestalvsstrip","",400,300); + TCanvas *cnoisevsstrip = new TCanvas("cnoisevsstrip","",400,300); // Style. hpedestalvsstrip->SetFillColor(kAzure); @@ -318,11 +320,11 @@ DrawHist(cnoisevsstrip,hnoisevsstrip,"",path_to_figures); // Distributions of mean and RMS. - TH1F *hpedestalBeetle1 = new TH1F("hpedestalBeetle1","",100,450,550); - TH1F *hnoiseBeetle1 = new TH1F("hnoiseBeetle1","",40,0,20); + TH1F *hpedestalBeetle1 = new TH1F("hpedestalBeetle1","",100,400,600); + TH1F *hnoiseBeetle1 = new TH1F("hnoiseBeetle1","",40,5,15); - TH1F *hpedestalBeetle2 = new TH1F("hpedestalBeetle2","",100,450,550); - TH1F *hnoiseBeetle2 = new TH1F("hnoiseBeetle2","",40,0,20); + TH1F *hpedestalBeetle2 = new TH1F("hpedestalBeetle2","",100,400,600); + TH1F *hnoiseBeetle2 = new TH1F("hnoiseBeetle2","",40,5,15); InitHist(hpedestalBeetle1,"Pedestals","ADC counts",""); InitHist(hnoiseBeetle1,"Noise","ADC counts",""); @@ -340,28 +342,22 @@ hnoiseBeetle2->Fill(noise[ch]); } - TPaveStats *spedestalBeetle1 = CreateStats(hpedestalBeetle1,"IUO"); - TPaveStats *snoiseBeetle1 = CreateStats(hnoiseBeetle1,"IUO"); + TCanvas *cpedestalBeetle1 = new TCanvas("cpedestalBeetle1","",400,300); + TCanvas *cnoiseBeetle1 = new TCanvas("cnoiseBeetle1","",400,300); - TPaveStats *spedestalBeetle2 = CreateStats(hpedestalBeetle2,"IUO"); - TPaveStats *snoiseBeetle2 = CreateStats(hnoiseBeetle2,"IUO"); + TCanvas *cpedestalBeetle2 = new TCanvas("cpedestalBeetle2","",400,300); + TCanvas *cnoiseBeetle2 = new TCanvas("cnoiseBeetle2","",400,300); - TCanvas *cpedestalBeetle1 = new TCanvas("cpedestalBeetle1","",700,700); - TCanvas *cnoiseBeetle1 = new TCanvas("cnoiseBeetle1","",700,700); - - TCanvas *cpedestalBeetle2 = new TCanvas("cpedestalBeetle2","",700,700); - TCanvas *cnoiseBeetle2 = new TCanvas("cnoiseBeetle2","",700,700); - - DrawHistStats(cpedestalBeetle1,hpedestalBeetle1,spedestalBeetle1,"",path_to_figures); - DrawHistStats(cnoiseBeetle1,hnoiseBeetle1,snoiseBeetle1,"",path_to_figures); + DrawHist(cpedestalBeetle1,hpedestalBeetle1,"",path_to_figures); + DrawHist(cnoiseBeetle1,hnoiseBeetle1,"",path_to_figures); - DrawHistStats(cpedestalBeetle2,hpedestalBeetle2,spedestalBeetle2,"",path_to_figures); - DrawHistStats(cnoiseBeetle2,hnoiseBeetle2,snoiseBeetle2,"",path_to_figures); + DrawHist(cpedestalBeetle2,hpedestalBeetle2,"",path_to_figures); + DrawHist(cnoiseBeetle2,hnoiseBeetle2,"",path_to_figures); - // Write output text file. + // Write output pedestal text file. for (int ch=0;ch Ped, the pedestals calculated by ComputePedestals; +- std::vector ADCProcessed, one per event (ADC after pedestal subtraction); +- distribution of the ADC counts of each Beetle (TH1F *hADCBeetle1 and TH1F *hADCBeetle2, before pedestal subtraction, and TH1F *hADCPedSubBeetle1 and TH1F *hADCPedSubBeetle2, after pedestal subtraction); +- distribution of the ADC counts of each Beetle channel (TH1F *hADC[N], before pedestal subtraction, and TH1F *hADCPedSub[N], after pedestal subtraction); +- ADC counts as a function of the Beetle channel (event-by-event, displayed only for one particular event, TH1F *hADCvsStripBeetle1 and TH1F *hADCvsStripBeetle2, before pedestal subtraction, and TH1F *hADCPedSubvsStripBeetle1 and TH1F *hADCPedSubvsStripBeetle2, after pedestal subtraction). + +Compile with: + +make + +Run with: + +./ProcessRawData [input ROOT file] [input text file (pedestals)] [additional folder] + +where: +- [input ROOT file] is the complete path, including the folder and the filename, of the ROOT file one wants to process; +- [input text file (pedestals)] is the complete path, including the folder and the filename, of the text file one wants to get the pedestals from; +- [additional folder] is the optional additional folder where the output will be saved. +*/ + +#include "../Tools/Lib.C" +#include "../Tools/lhcbStyle.C" +#include "../Tools/Style.C" +#include "../Tools/Par.C" + +void ProcessRawData(char *filename, char *filenamePed, char *externalPath=0); + +int main(int argc, char *argv[]) +{ + getLHCbStyle(); + PersonalStyle(); + + if ((argc ==2) && (string(argv[1]) == "--info")) + { + cout << "**************************************************" << endl; + + cout << "Some comments." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else if (argc < 3) + { + cout << "**************************************************" << endl; + + cout << "Error! Input file or pedestal file missing..." << endl; + cout << "Please use the following format:" << endl; + cout << "./ProcessRawData [1] [2] [3]" << endl; + cout << "with:" << endl; + cout << "[1] = Input ROOT file, complete path;" << endl; + cout << "[2] = Input text file (pedestals), complete path;" << endl; + cout << "[3] = Additional folder, optional." << endl; + cout << "Type ./ProcessRawData --info for more information." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else + { + cout << "File to process: " << argv[1] << endl; + cout << "Pedestal file: " << argv[2] << endl; + if (argc == 3) + ProcessRawData(argv[1],argv[2]); + else if (argc == 4) + ProcessRawData(argv[1],argv[2],argv[3]); + else + { + cout << "Error! Too many arguments given..." << endl; + + return 0; + } + + return 0; + } +} + +void ProcessRawData(char *filename, char *filenamePed, char *externalPath) +{ + cout << "**************************************************" << endl; + cout << "Processing raw data..." << endl; + cout << "**************************************************" << endl; + + // Do not comment this line. + gROOT->ProcessLine("#include "); + + // Do some fanciness to get the directory right. + string analysis = "/home/hep/flionett/TestStand/AnalysisResults"; + if (externalPath!=0) + analysis = string(analysis+"/"+externalPath); + + string filename_as_string = string(filename); + // Check that the filename provided corresponds to a ROOT file. + int found = filename_as_string.find(".root"); + if (found==string::npos) { + cout << "Error! The filename provided is not associated to a ROOT file." << endl; + return; + } + + string filename_as_string_no_path = filename_as_string.substr(filename_as_string.find_last_of('/')+1); + string filename_as_string_no_path_no_extension = filename_as_string_no_path.substr(0,filename_as_string_no_path.length()-5); + + // Create a folder named AnalysisResults. Do not worry, nothing bad is going to happen if the folder already exists. + string path_to_make = "mkdir -p "+analysis; + system(path_to_make.c_str()); + cout << "Setting output to: " << path_to_make << endl; + + // Create a folder named Figures inside the folder named AnalysisResults. + string path_to_make_figures = "mkdir "+analysis+"/Figures"; + system(path_to_make_figures.c_str()); + path_to_make_figures = "mkdir "+analysis+"/Figures"+"/ProcessRawData"; + system(path_to_make_figures.c_str()); + path_to_make_figures = "mkdir "+analysis+"/Figures"+"/ProcessRawData"+"/"+filename_as_string_no_path_no_extension; + system(path_to_make_figures.c_str()); + cout << "Setting figures to: " << path_to_make_figures << endl; + + TString path_to_figures = (string(path_to_make_figures)).substr((string(path_to_make_figures)).find_last_of(' ')+1); + + // Open input data ROOT file. + TFile *input = TFile::Open(TString(filename)); + + int NEvents; + + std::vector *ADC = 0; + + TBranch *b_NEvents = 0; + + TBranch *b_ADC = 0; + + // Get info from trees. + TTree *Header = (TTree *)input->Get("Header"); + int EventsHeader = Header->GetEntries(); + if (EventsHeader != 1) + { + cout << "Error! The ROOT file has been corrupted..." << endl; + + return ; + } + else + { + Header->SetBranchAddress("NEvents",&NEvents,&b_NEvents); + + Header->GetEntry(); + + cout << "Number of events: " << NEvents << endl; + } + + // Get info from trees. + TTree *EventInfo = (TTree *)input->Get("EventInfo"); + int EventsEventInfo = EventInfo->GetEntries(); + if (EventsEventInfo != NEvents) + { + cout << "Error! The ROOT file has been corrupted..." << endl; + + return; + } + else + { + EventInfo->SetBranchAddress("ADC",&ADC,&b_ADC); + } + + // Open input pedestal text file. + FILE *inputText = fopen(TString(filenamePed),"r"); + + // Read pedestals. + double ped[N]; + + for (int iChannel=0; iChannel Ped; + + InputFilename = string(filename); + PedFilename = string(filenamePed); + + for (int iChannel=0; iChannelCloneTree(0); + HeaderProcessed->Branch("InputFilename",&InputFilename); + HeaderProcessed->Branch("PedFilename",&PedFilename); + HeaderProcessed->Branch("Ped",&Ped); + HeaderProcessed->Fill(); + + // Show the distributions for one particular event. + int sample = 970; // Modify it. + + // Copy the EventInfo tree to the output data ROOT file and add some more information. + std::vector ADCProcessed; // Raw ADC - pedestal. + + TTree *EventInfoProcessed = EventInfo->CloneTree(0); + EventInfoProcessed->Branch("ADCProcessed",&ADCProcessed); + + // Distribution of the ADC counts of each Beetle (TH1F *hADCBeetle1 and TH1F *hADCBeetle2, before pedestal subtraction, and TH1F *hADCPedSubBeetle1 and TH1F *hADCPedSubBeetle2, after pedestal subtraction); + + TH1F *hADCBeetle1 = new TH1F("hADCBeetle1","",200,200,800); // Modify it. + TCanvas *cADCBeetle1 = new TCanvas("cADCBeetle1","",400,300); + InitHist(hADCBeetle1,"Raw ADC counts on Beetle 1","ADC counts",""); + + TH1F *hADCPedSubBeetle1 = new TH1F("hADCPedSubBeetle1","",200,-200,200); // Modify it. + TCanvas *cADCPedSubBeetle1 = new TCanvas("cADCPedSubBeetle1","",400,300); + InitHist(hADCPedSubBeetle1,"Pedestal subtracted ADC counts on Beetle 1","ADC counts",""); + + TH1F *hADCBeetle2 = new TH1F("hADCBeetle2","",200,200,800); // Modify it. + TCanvas *cADCBeetle2 = new TCanvas("cADCBeetle2","",400,300); + InitHist(hADCBeetle2,"Raw ADC counts on Beetle 2","ADC counts",""); + + TH1F *hADCPedSubBeetle2 = new TH1F("hADCPedSubBeetle2","",200,-200,200); // Modify it. + TCanvas *cADCPedSubBeetle2 = new TCanvas("cADCPedSubBeetle2","",400,300); + InitHist(hADCPedSubBeetle2,"Pedestal subtracted ADC counts on Beetle 2","ADC counts",""); + + // Distribution of the ADC counts of each Beetle channel (TH1F *hADC[N], before pedestal subtraction, and TH1F *hADCPedSub[N], after pedestal subtraction); + + TH1F *hADC[N]; + TCanvas *cADC[N]; + + TH1F *hADCPedSub[N]; + TCanvas *cADCPedSub[N]; + + for (int iChannel=0;iChannelSetFillColor(kAzure); + hADCPedSubvsStripBeetle1->SetFillColor(kAzure); + hADCvsStripBeetle1->SetMinimum(-1200); + hADCvsStripBeetle1->SetMaximum(1200); + hADCPedSubvsStripBeetle1->SetMinimum(-400); + hADCPedSubvsStripBeetle1->SetMaximum(400); + + // Style and range for Beetle 2 plots. + hADCvsStripBeetle2->SetFillColor(kRed); + hADCPedSubvsStripBeetle2->SetFillColor(kRed); + hADCvsStripBeetle2->SetMinimum(-1200); + hADCvsStripBeetle2->SetMaximum(1200); + hADCPedSubvsStripBeetle2->SetMinimum(-400); + hADCPedSubvsStripBeetle2->SetMaximum(400); + + // Fill histograms. + for (int iEvent=0;iEvent0) + { + ADCProcessed.clear(); + } + + EventInfo->GetEntry(iEvent); + + // Fill histograms. + for (int iChannel=0;iChannelat(iChannel) > 1024.) + cout << "Error! ADC counts of Beetle channel " << iChannel << ": " << ADC->at(iChannel) << endl; + + ADCProcessed.push_back(ADC->at(iChannel)-ped[iChannel]); + + if ((iChannel>=0) && (iChannelFill(ADC->at(iChannel)); + hADCPedSubBeetle1->Fill(ADC->at(iChannel)-ped[iChannel]); + if (iEvent == sample) { + hADCvsStripBeetle1->Fill(iChannel,ADC->at(iChannel)); + hADCPedSubvsStripBeetle1->Fill(iChannel,ADC->at(iChannel)-ped[iChannel]); + } + } + else if ((iChannel>=NBeetle) && (iChannelFill(ADC->at(iChannel)); + hADCPedSubBeetle2->Fill(ADC->at(iChannel)-ped[iChannel]); + if (iEvent == sample) { + hADCvsStripBeetle2->Fill(iChannel,ADC->at(iChannel)); + hADCPedSubvsStripBeetle2->Fill(iChannel,ADC->at(iChannel)-ped[iChannel]); + } + } + + hADC[iChannel]->Fill(ADC->at(iChannel)); + hADCPedSub[iChannel]->Fill(ADC->at(iChannel)-ped[iChannel]); + } + + EventInfoProcessed->Fill(); + } + + DrawHist(cADCBeetle1,hADCBeetle1,"",path_to_figures); + DrawHist(cADCPedSubBeetle1,hADCPedSubBeetle1,"",path_to_figures); + + DrawHist(cADCBeetle2,hADCBeetle2,"",path_to_figures); + DrawHist(cADCPedSubBeetle2,hADCPedSubBeetle2,"",path_to_figures); + + DrawHist(cADCvsStripBeetle1,hADCvsStripBeetle1,"",path_to_figures); + DrawHist(cADCPedSubvsStripBeetle1,hADCPedSubvsStripBeetle1,"",path_to_figures); + + DrawHist(cADCvsStripBeetle2,hADCvsStripBeetle2,"",path_to_figures); + DrawHist(cADCPedSubvsStripBeetle2,hADCPedSubvsStripBeetle2,"",path_to_figures); + + // Write output ROOT file. + output->Write(); + + // Close input and output ROOT files. + input->Close(); + output->Close(); + + return; +} diff --git a/Software/TbNtupleMaker/TbNtupleMaker.C b/Software/TbNtupleMaker/TbNtupleMaker.C index b12a438..43ca158 100755 --- a/Software/TbNtupleMaker/TbNtupleMaker.C +++ b/Software/TbNtupleMaker/TbNtupleMaker.C @@ -1,9 +1,18 @@ //************************************************ // Author: Federica Lionetto, Adam Davis, Biplab Dey, Paolo Gandini -// Created on: 07/30/2014 +// Created on: 30/07/2014 //************************************************ /* +IMPORTANT + +I cannot display std::vector PedByGain, std::vector NoiseByGain, and std::vector Gain in the ROOT file that is created by TbNtupleMaker. +Further investigation is needed in order to understand if the format is fine or not. +*/ + + + +/* TbNtupleMaker reads an Alibava file and creates a ROOT file (same filename) with the following information: - int NEvents, the number of events read from the header of the Alibava file; - int RunType, the run type; @@ -13,7 +22,7 @@ - TH1F histo_PedByGain("histo_PedByGain","histo_PedByGain",N,0,N-1); - TH1F histo_NoiseByGain("histo_NoiseByGain","histo_NoiseByGain",N,0,N-1); - TH1F histo_Gain("histo_Gain","histo_Gain",N,0,N-1); -- string Date = a->date(), the date read from the header of the Alibava file; +- string Date, the date read from the header of the Alibava file; - std::vector ADC, the raw ADC counts, one per event; - double TDCTime, the TDC time (meaningful only in radioactive source runs), one per event; - double Temp, the temperature, one per event; @@ -43,7 +52,7 @@ */ //************************************************ -// Types: +// Run types: // 1 = calibration run // 2 = laser synchronization run // 3 = laser run @@ -107,7 +116,7 @@ cout << "- TH1F histo_PedByGain;" << endl; cout << "- TH1F histo_NoiseByGain;" << endl; cout << "- TH1F histo_Gain;" << endl; - cout << "- string Date = a->date(), the date read from the header of the Alibava file;" << endl; + cout << "- string Date, the date read from the header of the Alibava file;" << endl; cout << "- std::vector ADC, the raw ADC counts, one per event;" << endl; cout << "- double TDCTime, the TDC time (meaningful only in radioactive source runs), one per event;" << endl; cout << "- double Temp, the temperature, one per event;" << endl; @@ -193,27 +202,7 @@ TH1F histo_PedByGain("histo_PedByGain","histo_PedByGain",N,0,N); TH1F histo_NoiseByGain("histo_NoiseByGain","histo_NoiseByGain",N,0,N); TH1F histo_Gain("histo_Gain","histo_Gain",N,0,N); - TH1F histo_Signal20("histo_Signal20","Signal calculated by Alibava > 20, distribution over the strips",N,0,N); - TH1F histo_Signal40("histo_Signal40","Signal calculated by Alibava > 40, distribution over the strips",N,0,N); - TH1F histo_Signal60("histo_Signal60","Signal calculated by Alibava > 60, distribution over the strips",N,0,N); - TH1F histo_TDC("histo_TDC","TDC distribution, ADC > 40",50,0,50); - string Date = a->date(); - - /////// vito - TH1D** ADC_ch = new TH1D*[256]; - TH2D* ADCvsEv = new TH2D("ADCvsEv_%d", - "ADCvsEv_%d", - 1e5, -0.5, 99999.5, - 200, 399.5, 600.5 ); - - for(int i=0; i<256; i++){ - - ADC_ch[i] = new TH1D(Form("ADC_ch_%d", i), - Form("ADC_ch_%d", i), - 1024, -0.5, 1023.5 ); - - } - + string Date; // Allocate only necessary space. PedByGain.reserve(N); @@ -240,29 +229,32 @@ cout << "Number of events in the Alibava file: " << NEvents << endl; RunType = a->type(); + cout << "Run type of the Alibava file: " << RunType << endl; + for(int iChannel=0; iChannelget_gain(iChannel); PedByGain[iChannel]=a->ped(iChannel); NoiseByGain[iChannel] = a->noise(iChannel); - histo_Gain.SetBinContent(iChannel+1,a->get_gain(iChannel)); + Gain[iChannel]= a->get_gain(iChannel); histo_PedByGain.SetBinContent(iChannel+1,a->ped(iChannel)); histo_NoiseByGain.SetBinContent(iChannel+1,a->noise(iChannel)); + histo_Gain.SetBinContent(iChannel+1,a->get_gain(iChannel)); } + Date = a->date(); + cout << "Date of the Alibava file: " << Date << endl; + Header->Fill(); + cout << "Information in the header:" << endl; Header->Print(); - cout << "**************************************************" << endl; - cout << "Date from Alibava file: " << Date <Branch("n",&n); EventInfo->Branch("ADC",&ADC); EventInfo->Branch("TDCTime",&TDCTime); EventInfo->Branch("Temp",&Temp); + EventInfo->Branch("n",&n); // Loop over events. for (int iEvent=0; iEventdata(jChannel)-PedByGain[jChannel]>20) histo_Signal20.Fill(jChannel); - if(a->data(jChannel)-PedByGain[jChannel]>40) histo_Signal40.Fill(jChannel); - if(a->data(jChannel)-PedByGain[jChannel]>60) histo_Signal60.Fill(jChannel); ADC.push_back(a->data(jChannel)); - ADC_ch[jChannel]->Fill( a->data(jChannel) ); - if(jChannel==200) ADCvsEv->Fill( iEvent, a->data(jChannel) ); - } - n = iEvent+1; TDCTime =a->time(); - for(int t=0; t40) {histo_TDC.Fill(TDCTime,1); break;} Temp = a->temp(); + n = iEvent+1; EventInfo->Fill(); } @@ -294,12 +278,10 @@ // Close Alibava file. a->close(); - // Write and close ROOT file. - for(int i=0; i<256; i++) - ADC_ch[i]->Write(); - ADCvsEv->Write(); - + // Write ROOT file. output->Write(); + + // Close ROOT file. output->Close(); return; diff --git a/Software/Tools/Lib.C b/Software/Tools/Lib.C index cb09c0f..d015d1c 100644 --- a/Software/Tools/Lib.C +++ b/Software/Tools/Lib.C @@ -16,11 +16,13 @@ #include "TCanvas.h" #include "TFile.h" #include "TF1.h" +#include "TGaxis.h" #include "TGraph.h" #include "TGraphErrors.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" +#include "TLatex.h" #include "TLegend.h" #include "TLine.h" #include "TLorentzVector.h" diff --git a/Software/Tools/Par.C b/Software/Tools/Par.C index 61f46b9..f762785 100644 --- a/Software/Tools/Par.C +++ b/Software/Tools/Par.C @@ -17,4 +17,7 @@ // Number of Beetle channels per chip. const int NBeetle = 128; +// Number of Beetle channels to skip to find the next connected Beetle channel + 1. If Beetle channel 0 and Beeetle channel 4 are connected, NSkip = 4. +const int NSkip = 4; + #endif diff --git a/Software/Tools/Style.C b/Software/Tools/Style.C index d2c4aa1..cfbd494 100644 --- a/Software/Tools/Style.C +++ b/Software/Tools/Style.C @@ -12,6 +12,7 @@ #define __STYLE_C_INCLUDED__ #include "Lib.C" +#include "lhcbStyle.C" //************************************************ // @@ -20,6 +21,8 @@ void dca(); +void PersonalStyle(); + void InitHist(TH1 *hist, TString title = "", TString x = "", TString y = ""); void InitHist2(TH2 *hist, TString title = "", TString x = "", TString y = "", TString z = ""); @@ -176,14 +179,22 @@ gSystem->ProcessEvents(); } +// PersonalStyle modifies the official LHCb style. +void PersonalStyle() { + TStyle *style = getLHCbStyle(); + style->SetOptStat("emruo"); + style->SetTitleOffset(1.05,"Y"); + // TGaxis::SetMaxDigits(3); + + return; +} + // InitHist defines some attributes of the "hist" histogram: the title "title" and the x-axis and y-axis labels "x" and "y". void InitHist(TH1 *hist, TString title, TString x, TString y) { - hist->UseCurrentStyle(); - gStyle->SetTitleFontSize(0.1); hist->SetTitle(title); hist->GetXaxis()->SetTitle(x); if (y == "") - hist->GetYaxis()->SetTitle(Form("Events / %g",hist->GetBinWidth(1))); + hist->GetYaxis()->SetTitle(Form("Entries / %g",hist->GetBinWidth(1))); else hist->GetYaxis()->SetTitle(y); @@ -192,13 +203,11 @@ // InitHist2 defines some attributes of the "hist" histogram: the title "title" and the x-axis, y-axis, and z-axis labels "x", "y", and "z". void InitHist2(TH2 *hist, TString title, TString x, TString y, TString z) { - hist->UseCurrentStyle(); - gStyle->SetTitleFontSize(0.1); hist->SetTitle(title); hist->GetXaxis()->SetTitle(x); hist->GetYaxis()->SetTitle(y); if (z == "") - hist->GetZaxis()->SetTitle(Form("Events / (%g*%g)",hist->GetXaxis()->GetBinWidth(1),hist->GetYaxis()->GetBinWidth(1))); + hist->GetZaxis()->SetTitle(Form("Entries / (%g*%g)",hist->GetXaxis()->GetBinWidth(1),hist->GetYaxis()->GetBinWidth(1))); else hist->GetZaxis()->SetTitle(z); @@ -370,8 +379,6 @@ // InitGraph defines some attributes of the "graph" graph: the title "title" and the x-axis and y-axis labels "x" and "y". void InitGraph(TGraph *graph, TString title, TString x, TString y) { - graph->UseCurrentStyle(); - gStyle->SetTitleFontSize(0.1); graph->SetTitle(title); graph->GetXaxis()->SetTitle(x); graph->GetYaxis()->SetTitle(y); diff --git a/Software/Tools/lhcbStyle.C b/Software/Tools/lhcbStyle.C new file mode 100644 index 0000000..f19e35c --- /dev/null +++ b/Software/Tools/lhcbStyle.C @@ -0,0 +1,206 @@ +// Header guard. +#ifndef __LHCBSTYLE_C_INCLUDED__ +#define __LHCBSTYLE_C_INCLUDED__ + +#include "Lib.C" + +// all users - please change the name of this file to lhcbStyle.C +// Commits to lhcbdocs svn of .C files are not allowed +TStyle *getLHCbStyle(); + +TStyle *getLHCbStyle() +{ + + // define names for colours + Int_t black = 1; + Int_t red = 2; + Int_t green = 3; + Int_t blue = 4; + Int_t yellow = 5; + Int_t magenta= 6; + Int_t cyan = 7; + Int_t purple = 9; + + +//////////////////////////////////////////////////////////////////// +// PURPOSE: +// +// This macro defines a standard style for (black-and-white) +// "publication quality" LHCb ROOT plots. +// +// USAGE: +// +// Include the lines +// gROOT->ProcessLine(".L lhcbstyle.C"); +// lhcbStyle(); +// at the beginning of your root macro. +// +// Example usage is given in myPlot.C +// +// COMMENTS: +// +// Font: +// +// The font is chosen to be 132, this is Times New Roman (like the text of +// your document) with precision 2. +// +// "Landscape histograms": +// +// The style here is designed for more or less square plots. +// For longer histograms, or canvas with many pads, adjustements are needed. +// For instance, for a canvas with 1x5 histograms: +// TCanvas* c1 = new TCanvas("c1", "L0 muons", 600, 800); +// c1->Divide(1,5); +// Adaptions like the following will be needed: +// gStyle->SetTickLength(0.05,"x"); +// gStyle->SetTickLength(0.01,"y"); +// gStyle->SetLabelSize(0.15,"x"); +// gStyle->SetLabelSize(0.1,"y"); +// gStyle->SetStatW(0.15); +// gStyle->SetStatH(0.5); +// +// Authors: Thomas Schietinger, Andrew Powell, Chris Parkes, Niels Tuning +// Maintained by Editorial board member (currently Niels) +/////////////////////////////////////////////////////////////////// + + // Use times new roman, precision 2 + Int_t lhcbFont = 132; // Old LHCb style: 62; + // Line thickness + Double_t lhcbWidth = 2.00; // Old LHCb style: 3.00; + // Text size + Double_t lhcbTSize = 0.06; + + // use plain black on white colors + gROOT->SetStyle("Plain"); + TStyle *lhcbStyle= new TStyle("lhcbStyle","LHCb plots style"); + + //lhcbStyle->SetErrorX(0); // don't suppress the error bar along X + + lhcbStyle->SetFillColor(1); + lhcbStyle->SetFillStyle(1001); // solid + lhcbStyle->SetFrameFillColor(0); + lhcbStyle->SetFrameBorderMode(0); + lhcbStyle->SetPadBorderMode(0); + lhcbStyle->SetPadColor(0); + lhcbStyle->SetCanvasBorderMode(0); + lhcbStyle->SetCanvasColor(0); + lhcbStyle->SetStatColor(0); + lhcbStyle->SetLegendBorderSize(0); + lhcbStyle->SetLegendFont(132); + + // If you want the usual gradient palette (blue -> red) + lhcbStyle->SetPalette(1); + // If you want colors that correspond to gray scale in black and white: + int colors[8] = {0,5,7,3,6,2,4,1}; + lhcbStyle->SetPalette(8,colors); + + // set the paper & margin sizes + lhcbStyle->SetPaperSize(20,26); + lhcbStyle->SetPadTopMargin(0.05); + lhcbStyle->SetPadRightMargin(0.05); // increase for colz plots + lhcbStyle->SetPadBottomMargin(0.16); + lhcbStyle->SetPadLeftMargin(0.14); + + // use large fonts + lhcbStyle->SetTextFont(lhcbFont); + lhcbStyle->SetTextSize(lhcbTSize); + lhcbStyle->SetLabelFont(lhcbFont,"x"); + lhcbStyle->SetLabelFont(lhcbFont,"y"); + lhcbStyle->SetLabelFont(lhcbFont,"z"); + lhcbStyle->SetLabelSize(lhcbTSize,"x"); + lhcbStyle->SetLabelSize(lhcbTSize,"y"); + lhcbStyle->SetLabelSize(lhcbTSize,"z"); + lhcbStyle->SetTitleFont(lhcbFont); + lhcbStyle->SetTitleFont(lhcbFont,"x"); + lhcbStyle->SetTitleFont(lhcbFont,"y"); + lhcbStyle->SetTitleFont(lhcbFont,"z"); + lhcbStyle->SetTitleSize(1.2*lhcbTSize,"x"); + lhcbStyle->SetTitleSize(1.2*lhcbTSize,"y"); + lhcbStyle->SetTitleSize(1.2*lhcbTSize,"z"); + + // use medium bold lines and thick markers + lhcbStyle->SetLineWidth(lhcbWidth); + lhcbStyle->SetFrameLineWidth(lhcbWidth); + lhcbStyle->SetHistLineWidth(lhcbWidth); + lhcbStyle->SetFuncWidth(lhcbWidth); + lhcbStyle->SetGridWidth(lhcbWidth); + lhcbStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes + lhcbStyle->SetMarkerStyle(20); + lhcbStyle->SetMarkerSize(1.0); + + // label offsets + lhcbStyle->SetLabelOffset(0.010,"X"); + lhcbStyle->SetLabelOffset(0.010,"Y"); + + // by default, do not display histogram decorations: + lhcbStyle->SetOptStat(0); + // lhcbStyle->SetOptStat("emr"); // show only nent -e , mean - m , rms -r + // full opts at http://root.cern.ch/root/html/TStyle.html#TStyle:SetOptStat + lhcbStyle->SetStatFormat("6.3g"); // specified as c printf options + lhcbStyle->SetOptTitle(0); + lhcbStyle->SetOptFit(0); + //lhcbStyle->SetOptFit(1011); // order is probability, Chi2, errors, parameters + //titles + lhcbStyle->SetTitleOffset(0.95,"X"); + lhcbStyle->SetTitleOffset(0.95,"Y"); + lhcbStyle->SetTitleOffset(1.2,"Z"); + lhcbStyle->SetTitleFillColor(0); + lhcbStyle->SetTitleStyle(0); + lhcbStyle->SetTitleBorderSize(0); + lhcbStyle->SetTitleFont(lhcbFont,"title"); + lhcbStyle->SetTitleX(0.0); + lhcbStyle->SetTitleY(1.0); + lhcbStyle->SetTitleW(1.0); + lhcbStyle->SetTitleH(0.05); + + // look of the statistics box: + lhcbStyle->SetStatBorderSize(0); + lhcbStyle->SetStatFont(lhcbFont); + lhcbStyle->SetStatFontSize(0.05); + lhcbStyle->SetStatX(0.9); + lhcbStyle->SetStatY(0.9); + lhcbStyle->SetStatW(0.25); + lhcbStyle->SetStatH(0.15); + + // put tick marks on top and RHS of plots + lhcbStyle->SetPadTickX(1); + lhcbStyle->SetPadTickY(1); + + // histogram divisions: only 5 in x to avoid label overlaps + lhcbStyle->SetNdivisions(505,"x"); + lhcbStyle->SetNdivisions(510,"y"); + + gROOT->SetStyle("lhcbStyle"); + gROOT->ForceStyle(); + + // add LHCb label + TPaveText *lhcbName = new TPaveText(gStyle->GetPadLeftMargin() + 0.05, + 0.87 - gStyle->GetPadTopMargin(), + gStyle->GetPadLeftMargin() + 0.20, + 0.95 - gStyle->GetPadTopMargin(), + "BRNDC"); + lhcbName->AddText("LHCb"); + lhcbName->SetFillColor(0); + lhcbName->SetTextAlign(12); + lhcbName->SetBorderSize(0); + + TText *lhcbLabel = new TText(); + lhcbLabel->SetTextFont(lhcbFont); + lhcbLabel->SetTextColor(1); + lhcbLabel->SetTextSize(lhcbTSize); + lhcbLabel->SetTextAlign(12); + + TLatex *lhcbLatex = new TLatex(); + lhcbLatex->SetTextFont(lhcbFont); + lhcbLatex->SetTextColor(1); + lhcbLatex->SetTextSize(lhcbTSize); + lhcbLatex->SetTextAlign(12); + + cout << "-------------------------" << endl; + cout << "Set LHCb Style - Feb 2012" << endl; + cout << "-------------------------" << endl; + + return lhcbStyle; +} + +#endif