/**
* @file ChargeSpektrum.c
- * @brief Use brief, otherwise the index won't have a brief explanation.
+ * @brief This is the main program, it manages the user input and creats classes of type Run.c
*
- * Detailed explanation.
+ * The main program reads in and interprets the user input, and organizes it. Each runnumber is used
+ * to create classes of type "Run.c".
+ *
+ * Modify this file to enable/disable plots and data outputs.
*
*
*/
void ChargeSpektrum(TString runnumber = "")
{
-#include "SetStyle.c"
cout << endl << endl;
if (gROOT->IsBatch())
isBatch = kTRUE;
-
+
numberRuns=0;
std::vector<int> runList;
std::vector<Bool_t> runListForceAnalysis;
std::vector<TString> runListCustomTitle;
std::vector<TString> sumuprunList; // not used yet, add runs to each other, combine statistics
- if (runnumber.Length() > 0)
- {
- if (runnumber.Contains("-")) {
- TObjArray* runarray = runnumber.Tokenize("-");
- if (runarray->GetEntries()==2)
- {
- TObjString* tempstrobj;
- tempstrobj=static_cast<TObjString*>(runarray->At(0));
- if (tempstrobj->GetString().Length()>0)
- {
- Int_t tempintstart = tempstrobj->GetString().Atoi();
- tempstrobj=static_cast<TObjString*>(runarray->At(1));
- if (tempstrobj->GetString().Length()>0)
- {
- Int_t tempintend = tempstrobj->GetString().Atoi();
- if (tempintend-tempintstart > 0)
- {
- for (Int_t i=tempintstart; i <= tempintend; i++)
- {
- runList.push_back(i);
- runListForceAnalysis.push_back(kFALSE);
- numberRuns++;
- }
- }
- else
- cout << coloryellow << "Invalid run number range "<< colorreset << colorwhite << tempintstart << " till " << tempintend << endlr;
- }
- else
- cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempstrobj->GetString() << endlr;
-
- }
- else
- cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempstrobj->GetString() << endlr;
- }
- else
- {
- cout << endl << colorred << "Given parameters have wrong format, please enter integer run numbers devided by '" << colorreset << colorwhite << "," << colorreset << colorred << " or 2 runnumbers devided by " << colorreset << colorwhite << "-" << colorreset << colorred << "' and surrounded by '" << colorreset << colorwhite << "\"" << colorreset << colorred << "'." << endlr;
- cout << "For example run: " << colorwhite << "root -l 'ChargeSpektrum.c+(\"342815,342816\")'" << endl;
- exit(1);
- }
-
- } else {
- TObjArray* runarray = runnumber.Tokenize(","); // seperate run numbers by ','
- if (runarray->GetEntries()>0)
- {
- TObjString* tempstrobj;
- for (Int_t i=0; i < runarray->GetEntries(); i++)
- {
- tempstrobj=static_cast<TObjString*>(runarray->At(i));
- if (tempstrobj->GetString().Length()>0)
- {
- TString sumrunsstr = "";
- TObjArray* sumrunarray = tempstrobj->GetString().Tokenize("+");
- TObjString* sumuprunsstrobj;
- for (Int_t j=0; j < sumrunarray->GetEntries(); j++)
- {
- sumuprunsstrobj=static_cast<TObjString*>(sumrunarray->At(j));
- TString currunnumberstr = sumuprunsstrobj->GetString();
- Int_t tempint = currunnumberstr.Atoi();
- if (tempint > 0)
- {
- runList.push_back(tempint);
- if (currunnumberstr.Contains("!"))
- runListForceAnalysis.push_back(kTRUE);
- else
- runListForceAnalysis.push_back(kFALSE);
- if (currunnumberstr.Contains("=")) {
- cout << colorcyan << currunnumberstr << endlr;
- runListCustomTitle.push_back(currunnumberstr(currunnumberstr.Index('=')+1,currunnumberstr.Length()-currunnumberstr.Index('=')-1));
- } else {
- runListCustomTitle.push_back("");
- }
- sumrunsstr.Append(Form("%d,",tempint));
- numberRuns++;
- }
- else
- cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempint << endlr;
- }
- sumuprunList.push_back(sumrunsstr);
- }
- else
- cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempstrobj->GetString() << endlr;
- }
- }
- else
- {
- cout << endl << colorred << "Given parameters have wrong format, please enter integer run numbers devided by '" << colorreset << colorwhite << "," << colorreset << colorred << "' and surrounded by '" << colorreset << colorwhite << "\"" << colorreset << colorred << "'." << endlr;
- cout << "For example run: " << colorwhite << "root -l 'ChargeSpektrum.c+(\"342815,342816\")'" << endl;
- exit(1);
- }
- }
- }
- else
- {
- /// number of runs to be analyzed, number of lines read by @c ReadRunList()
- ReadRunList(&runList);
- }
+
+ #include "SetStyle.c"
+ InterpreteUserInput(runnumber, &runList, &runListForceAnalysis, &runListCustomTitle, &sumuprunList);
+
runs = new Run*[numberRuns];
cout << "Found " << numberRuns << " run(s) in 'runlist.txt' or given as parameters." << endl;
//runs[runi]->setFixedThresholdValueElectrons(1440);
//runs[runi]->setNoisethresholdborderADU(30);
-// runs[runi]->analyzeFrame(57826);
-// runs[runi]->analyzeFrame(57827);
-// runs[runi]->analyzeFrame(983603);
+// runs[runi]->analyzeFrame(1000);
// creates or opens .root file, can analyze the RAW data
if (runListForceAnalysis.size() >= (unsigned)runi+1)
// runs[runi]->compareHistogramClassVector.push_back(runs[runi]->histogramthreshold->calibrated);
// runs[runi]->compareHistogramClassVector.push_back(runs[runi]->histogramfixedthreshold);
// runs[runi]->plotCompareHistograms();
-// runs[runi]->plotAllHistograms(runs[runi]->histogramthreshold);
- compareHistogramClassVector.push_back(runs[runi]->histogramthreshold->normalized);
- compareHistogramVector.push_back(runs[runi]->histogramthreshold->normalized->calibrated->Seed);
- compareHistogramVector2.push_back(runs[runi]->histogramthreshold->normalized->Seed);
+ runs[runi]->plotAllHistograms(runs[runi]->histogram);
+ compareHistogramClassVector.push_back(runs[runi]->histogram->normalized);
+// compareHistogramVector.push_back(runs[runi]->histogramthreshold->normalized->calibrated->Seed);
+// compareHistogramVector2.push_back(runs[runi]->histogramthreshold->normalized->Seed);
//compareHistogramClassVector.push_back(runs[runi]->histogram);
// runs[runi]->plot1DHistogram(runs[runi]->histogramthreshold, runs[runi]->histogramthreshold->Veto, "gaus");
- runs[runi]->plot1DHistogram(runs[runi]->histogramthreshold, runs[runi]->histogramthreshold->normalized->Sum, "gaus", 1);
- runs[runi]->plot1DHistogram(runs[runi]->histogramthreshold, runs[runi]->histogramthreshold->normalized->Veto, "GaussTail", 1);
- // compareHistogramVector.push_back(runs[runi]->histogramthreshold->calibrated->normalized->Veto);
+// runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Sum, "gaus", 1);
+// runs[runi]->plot1DHistogram(runs[runi]->histogramthreshold, runs[runi]->histogramthreshold->Veto, "GaussTail", 1);
+ // compareHistogramVector.push_back(runs[runi]->histogramthreshold->calibrated->normalized->Veto);
+// runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Seed, "landau", 1);
runs[runi]->writeAllHistogramsToFile();
}
//cout << runs[runi]->histogram
// runs[3]->setLabel("HR18, P13, 5.0 V");
printSummaryTable(&compareHistogramClassVector);
// CompareHistograms(&compareHistogramVector);
-CompareHistograms(&compareHistogramVector2);
+// CompareHistograms(&compareHistogramVector2);
plotAllRuns(&compareHistogramClassVector);
// plotAllRuns(&compareHistogramClassVector2);
// plotAllRuns(&compareHistogramClassVector3);
Int_t* ReadRunList();
Int_t ReadRunList(std::vector<int>*);
+void InterpreteUserInput(TString, std::vector<int>*, std::vector<Bool_t>*, std::vector<Bool_t>*, std::vector<Bool_t>*);
Bool_t plotAllRuns();
Bool_t plotAllRuns(vector<HistogramType*>*);
/** @brief A function to plot TH1F histograms of different runs into one file
exit(1);
}
+void InterpreteUserInput(TString runnumber, std::vector<int> *runList, std::vector<Bool_t> *runListForceAnalysis, std::vector<TString> *runListCustomTitle, std::vector<TString> *sumuprunList)
+{
+ if (runnumber.Length() > 0)
+ {
+ if (runnumber.Contains("-")) {
+ TObjArray* runarray = runnumber.Tokenize("-");
+ if (runarray->GetEntries()==2)
+ {
+ TObjString* tempstrobj;
+ tempstrobj=static_cast<TObjString*>(runarray->At(0));
+ if (tempstrobj->GetString().Length()>0)
+ {
+ Int_t tempintstart = tempstrobj->GetString().Atoi();
+ tempstrobj=static_cast<TObjString*>(runarray->At(1));
+ if (tempstrobj->GetString().Length()>0)
+ {
+ Int_t tempintend = tempstrobj->GetString().Atoi();
+ if (tempintend-tempintstart > 0)
+ {
+ for (Int_t i=tempintstart; i <= tempintend; i++)
+ {
+ runList->push_back(i);
+ runListForceAnalysis->push_back(kFALSE);
+ numberRuns++;
+ }
+ }
+ else
+ cout << coloryellow << "Invalid run number range "<< colorreset << colorwhite << tempintstart << " till " << tempintend << endlr;
+ }
+ else
+ cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempstrobj->GetString() << endlr;
+
+ }
+ else
+ cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempstrobj->GetString() << endlr;
+ }
+ else
+ {
+ cout << endl << colorred << "Given parameters have wrong format, please enter integer run numbers devided by '" << colorreset << colorwhite << "," << colorreset << colorred << " or 2 runnumbers devided by " << colorreset << colorwhite << "-" << colorreset << colorred << "' and surrounded by '" << colorreset << colorwhite << "\"" << colorreset << colorred << "'." << endlr;
+ cout << "For example run: " << colorwhite << "root -l 'ChargeSpektrum.c+(\"342815,342816\")'" << endl;
+ exit(1);
+ }
+
+ } else {
+ TObjArray* runarray = runnumber.Tokenize(","); // seperate run numbers by ','
+ if (runarray->GetEntries()>0)
+ {
+ TObjString* tempstrobj;
+ for (Int_t i=0; i < runarray->GetEntries(); i++)
+ {
+ tempstrobj=static_cast<TObjString*>(runarray->At(i));
+ if (tempstrobj->GetString().Length()>0)
+ {
+ TString sumrunsstr = "";
+ TObjArray* sumrunarray = tempstrobj->GetString().Tokenize("+");
+ TObjString* sumuprunsstrobj;
+ for (Int_t j=0; j < sumrunarray->GetEntries(); j++)
+ {
+ sumuprunsstrobj=static_cast<TObjString*>(sumrunarray->At(j));
+ TString currunnumberstr = sumuprunsstrobj->GetString();
+ Int_t tempint = currunnumberstr.Atoi();
+ if (tempint > 0)
+ {
+ runList->push_back(tempint);
+ if (currunnumberstr.Contains("!"))
+ runListForceAnalysis->push_back(kTRUE);
+ else
+ runListForceAnalysis->push_back(kFALSE);
+ if (currunnumberstr.Contains("=")) {
+ cout << colorcyan << currunnumberstr << endlr;
+ runListCustomTitle->push_back(currunnumberstr(currunnumberstr.Index('=')+1,currunnumberstr.Length()-currunnumberstr.Index('=')-1));
+ } else {
+ runListCustomTitle->push_back("");
+ }
+ sumrunsstr.Append(Form("%d,",tempint));
+ numberRuns++;
+ }
+ else
+ cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempint << endlr;
+ }
+ sumuprunList->push_back(sumrunsstr);
+ }
+ else
+ cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempstrobj->GetString() << endlr;
+ }
+ }
+ else
+ {
+ cout << endl << colorred << "Given parameters have wrong format, please enter integer run numbers devided by '" << colorreset << colorwhite << "," << colorreset << colorred << "' and surrounded by '" << colorreset << colorwhite << "\"" << colorreset << colorred << "'." << endlr;
+ cout << "For example run: " << colorwhite << "root -l 'ChargeSpektrum.c+(\"342815,342816\")'" << endl;
+ exit(1);
+ }
+ }
+ }
+ else
+ {
+ /// number of runs to be analyzed, number of lines read by @c ReadRunList()
+ ReadRunList(runList);
+ }
+}
+
+
Int_t ReadRunList(std::vector<int>* runlist)
{
std::ifstream file("runlist.txt");
}
PEDESTAL = PEDESTAL/Frames;
+ cout << colorcyan << "Pedestal :" << PEDESTAL << endlr;
for(UInt_t j=0; j<Frames; j++)
{
}
NOISE = TMath::Sqrt(NOISE/(Frames-1));
+ cout << colorcyan << "NOISE :" << NOISE << endlr;
fNoise[i] = NOISE;
fPedestals[i] = PEDESTAL;
// cout<<fCdsmatrix[i]<<",";
}
- // cout<<fFrameNumber<<":________:"<<cdsMatrixSum<<endl;
- // debugStream<>(fCdsmatrix, fPixels, fColumns, 2, 20);
- // cout<<"Pedestals"<<endl;
- // debugStream<>(fPedestals, fPixels, fColumns, 2, 20);
+// cout<<fFrameNumber<<":________:"<<cdsMatrixSum<<endl;
+// debugStream<>(fCdsmatrix, fPixels, fColumns, 2, 20);
+// cout<<"Pedestals"<<endl;
+// debugStream<>(fPedestals, fPixels, fColumns, 2, 20);
for(Int_t i=0; i<fPixels; i++)
{
cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fPedestals[i]);
}
}
}
- // cout<<"Hitted pixel discriminator matrix:"<<endl;
- // debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
+// cout<<"Hitted pixel discriminator matrix:"<<endl;
+// debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
fHittedPixel[rechargePixellist[rechargingpixeli]] = -4;
}
}
}
-
+// if ( B < 10) CHANCE=0; // TODO remove me, buggy column 3 in Mi19, triing to ommit dirty?
+
}
}
}
- // cout<<"Hitted pixel discriminator matrix:"<<endl;
- // debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
+// cout<<"Hitted pixel discriminator matrix:"<<endl;
+// debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
if (bordercluster)
fHittedPixel[Hitlist[hit]] = -2;
else
// {
// cout<<"Charge"<<chargesumincluster4<<"must bigger than NOISE"<<noisesumincluster4*6.0<<endl;
// debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
- // for(Int_t row=0; row<5; row++)
- // {
- // for(Int_t column=0; column<5; column++)
- // {
- // std::cout.width(10);
- // std::cout << std::fixed;
- // std::cout << std::left << std::setprecision(2) << pixelchargeincluster[row*5+column];
- // }
- // cout << endl;
- // }
- // cout << endl;
+ // Uncomment below to see hot cluster and their charge
+// for(Int_t row=0; row<5; row++)
+// {
+// for(Int_t column=0; column<5; column++)
+// {
+// std::cout.width(10);
+// std::cout << std::fixed;
+// std::cout << std::left << std::setprecision(2) << pixelchargeincluster[row*5+column];
+// }
+// cout << endl;
+// }
+// cout << "Charge sum: " << chargesumincluster << endl;
+// cout << endl;
// debugStream<>(cdsmatrixCorrPed, fPixels, fColumns, 1, 10);
// }
+
fHits++;
}
{
fdiscriminatedhitmatrix->SetBinContent(i%fColumns, (int)(i/fColumns), fHittedPixel[i]);
fADCHitmatrix->SetBinContent(i%fColumns, (int)(i/fColumns), fCdsmatrix[i]);
- // cout<<"HITHERE"<<i<<":"<<fHittedPixel[i]<<";"<<fCdsmatrix[i]<<endl;
}
}
}
else {
cout <<endl <<endl << colorwhite << "---------------- FRAME " << fFrameNumber << " ----------------" << colorreset << endl << endl;
+ cout<<"F0 matrix:"<<endl;
+ debugStream<>(fF0matrix, fPixels/fColumns, fColumns, 0, 39);
+ cout<<"F1 matrix:"<<endl;
+ debugStream<>(fF1matrix, fPixels/fColumns, fColumns, 0, 39);
+
cout<<"CDS matrix:"<<endl;
- debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 39);
+ debugStream<>(fCdsmatrix, fPixels/fColumns, fColumns, 0, 39);
Float_t cdsmatrixCorrPed[fPixels];
for(Int_t i=0; i<fPixels; i++)
{
cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fPedestals[i]);
}
cout<<"CDS matrix minus pedestals:"<<endl;
- debugStream<>(cdsmatrixCorrPed, fPixels, fColumns, 0, 10);
- // cout<<fCdsmatrix[0]<<","<<fCdsmatrix[1]<<","<<fCdsmatrix[2]<<","<<fCdsmatrix[3]<<","<<fCdsmatrix[4]<<","<<fCdsmatrix[5]<<","<<fCdsmatrix[6]<<endl;
+ debugStream<>(cdsmatrixCorrPed, fPixels/fColumns, fColumns, 0, 10);
+// cout<<fCdsmatrix[0]<<","<<fCdsmatrix[1]<<","<<fCdsmatrix[2]<<","<<fCdsmatrix[3]<<","<<fCdsmatrix[4]<<","<<fCdsmatrix[5]<<","<<fCdsmatrix[6]<<endl;
cout<<"Hitted pixel discriminator matrix:"<<endl;
- debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
+ debugStream<>(fHittedPixel, fPixels/fColumns, fColumns, 1, 1);
TCanvas* cm1 = new TCanvas(Form("Frame %d",FrameNumber),Form("Frame %d",FrameNumber),50,100,1200,800);
cm1->Divide(2,3);
TH2F *h1 = new TH2F("CDS matrix", "CDS matrix", fColumns, 0, fColumns, fRows, 0, fRows);
TH2F *h2 = new TH2F("Frame 0 matrix", "Frame 0 matrix", fColumns, 0, fColumns, fRows, 0, fRows);
TH2F *h3 = new TH2F("Frame 1 matrix", "Frame 1 matrix", fColumns, 0, fColumns, fRows, 0, fRows);
+ TH2F *h6 = new TH2F("CDS matrix - Pedestial", "CDS matrix - Pedestial", fColumns, 0, fColumns, fRows, 0, fRows);
TH1F *h4 = new TH1F("Frame 0 histo", "Frame 0 histo", 2*16384, -16384, 16384);
TH1F *h5 = new TH1F("Frame 1 histo", "Frame 1 histo", 2*16384, -16384, 16384);
Int_t column;
Int_t row;
- Float_t F0,F1,CDS;
+ Float_t F0,F1,CDS,CDSminusPed;
for(Int_t i=0; i<fPixels; i++)
{
column = i%fColumns;
CDS = fCdsmatrix[i];
+ CDSminusPed = cdsmatrixCorrPed[i];
F0 = fF0matrix[i];
F1 = fF1matrix[i];
h3->Fill(column,row,F1);
h4->Fill(F0);
h5->Fill(F1);
+ h6->Fill(column,row,CDSminusPed);
}
cm1->cd(1);
- h1->Draw("colz");
- h1->GetXaxis()->SetTitle("column");
- h1->GetYaxis()->SetTitle("row");
- h1->GetZaxis()->SetTitle("Signal [ADC]");
+ h6->Draw("colz");
+ h6->GetXaxis()->SetTitle("column");
+ h6->GetYaxis()->SetTitle("row");
+ h6->GetZaxis()->SetTitle("Signal [ADC]");
cm1->cd(2);
- h1->Draw("surf2z");
- h1->GetXaxis()->SetTitle("column");
- h1->GetYaxis()->SetTitle("row");
- h1->GetZaxis()->SetTitle("Signal [ADC]");
+ h6->Draw("surf2z");
+ h6->GetXaxis()->SetTitle("column");
+ h6->GetYaxis()->SetTitle("row");
+ h6->GetZaxis()->SetTitle("Signal [ADC]");
cm1->cd(3);
h2->Draw("surf2z");
systemparam systemparamPegasus (2800,2800/2,20,10,100);
systemparam systemparamPXI (800*16,800,75,150,150);
systemparam systemparamFSBB (2800,2800/4,25,10,100);
+ systemparam systemparamUSBMi19 (400/*maxbin*/,400/1/*nbins*/, 25/*vetothreshold*/, 10/*maxbinnoise*/, 100/*nbinsnoise*/);
if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi34") )
cursystemparam = systemparamUSB;
else if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("FSBB") )
cursystemparam = systemparamPXI;
else if (labbook.system.EqualTo("Pegasus")) // && labbook.chipGen.EqualTo("34") )
cursystemparam = systemparamPegasus;
+ if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi19") )
+ cursystemparam = systemparamUSBMi19;
+ else if (labbook.system.EqualTo("USB")) // && labbook.chipGen.EqualTo("34") )
+ cursystemparam = systemparamUSB;
setSensorInSystemParam();
}
sensorinfostruct sensorinfoMi34PXI( 16, /* rows */ 64 /* columns */ );
sensorinfostruct sensorinfoPegasus( 8, 56 );
sensorinfostruct sensorinfoFSBB( 4, 416 );
+ sensorinfostruct sensorinfoMi19USB( 192, /* rows */ 192 /* columns */ );
if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi34") )
cursensorinfo=sensorinfoMi34USB;
cursensorinfo=sensorinfoMi34PXI;
else if (labbook.system.EqualTo("Pegasus")) // && labbook.chipGen.EqualTo("34") )
cursensorinfo=sensorinfoPegasus;
+ else if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi19") )
+ cursensorinfo=sensorinfoMi19USB;
}
void Run::setMatrixSpecificParameters()
processed->InitialDynNoise();
int start = 0;
int nframes = processed->GetNumberFrames();
- // for(int i=0; i<1000;i++) // TODO remove 100000 run 342272
+// for(int i=0; i<10000;i++) // TODO remove 100000 run 342272
for(int i=0; i<nframes;i++) // TODO remove 100000 run 342272
{
// cout << "getframe " << i << endl;
{
processed->fHitTree->GetEntry(framei);
// account only frames with less then 10 hits
- if (processed->fFrameInfo.hits<(unsigned int)10)
+// cout << colorcyan << processed->fFrameInfo.hits << endlr;
+// if (processed->fFrameInfo.hits<(unsigned int)10)
{
for(Int_t hiti=0; (unsigned int)hiti<processed->fFrameInfo.hits;hiti++)
{
// histogram with the single pixel
histogram->Seed->Fill(processed->fFrameInfo.p[12][hiti]);
+// cout << colorcyan << "filled seed" << endlr;
// sum histogram
pixelSum = 0;
}
if (histogramfixedthreshold != 0) {
- cout << colorred << "NOT NULL! " << endlr;
if (processed->fFrameInfo.pixelfixedthreshold[hiti]>0)
{
histogramfixedthreshold->numberofhits++;