initMapsRun( );
} sleep(1); // TODO test if removable
+}
+
+Bool_t MAPS::initNewRootFile() {
if ( checkConf(fPixelsData) ) // TODO FileEvNbInConfig
{
//-----------------------------------------------
int MaxFiles = FileTotalEvNbInConfig/FileEvNbInConfig;
if( checkDataFiles(MaxFiles) )
{
- initSave();
+ fOutputFile = new TFile(fRootFile,"RECREATE");
+ // Hit TTree
+ fHitTree = new TTree("hit", "hit");
+ fHitTree->Branch("frame" , &fFrameInfo.frame , "frame/i" , 32000);
+ fHitTree->Branch("hits" , &fFrameInfo.hits , "hits/i" , 32000);
+ fHitTree->Branch("pixel" , &fFrameInfo.pixel[0] , "pixel[hits]/i" , 32000);
+ for(int i=0; i<25; i++) {
+ fHitTree->Branch( Form("p%i",i+1) , &fFrameInfo.p[i][0] , Form("p%i [hits]/F",i+1) , 32000);
+ }
+ // Noise TTree
+ fNoiseTree = new TTree("noise", "noise");
+ fDynNoiseTree = fNoiseTree;
+ cout<<"-----------------------"<<endl;
+ cout<<fRootFile<<" recreated!"<<endl;
+ cout<<"-----------------------"<<endl;
+ return 0;
}
//-----------------------------------------------
} sleep(1); // TODO test if removable
+ return 1;
+
+}
+
+Bool_t MAPS::initOldRootFile() {
+ fOutputFile = new TFile(fRootFile,"UPDATE");
+ if (fOutputFile->IsZombie())
+ {
+ cout << "Error opening old ROOT file!" << endl;
+ return 1;
+ }
+ fHitTree = (TTree*) fOutputFile->Get("hit");
+ fHitTree->SetBranchAddress("frame" , &fFrameInfo.frame );
+ fHitTree->SetBranchAddress("hits" , &fFrameInfo.hits );
+ fHitTree->SetBranchAddress ("pixel", &fFrameInfo.pixel[0]);
+ for(int i=0; i<25; i++) {
+ fHitTree->SetBranchAddress( Form("p%i",i+1) , &fFrameInfo.p[i][0]);
+ }
+
+ fHitTree = (TTree*) fOutputFile->Get("noise");
+ fDynNoiseTree = fNoiseTree;
+
+ cout<<"-----------------------"<<endl;
+ cout<<fRootFile<<" opened!"<<endl;
+ cout<<"-----------------------"<<endl;
+ return 0;
}
//####################################################################
void MAPS::initMapsRun( ) {
//
fInDir=run->storepathLinux;
- fOutDir = run->storepathLinux; // ouput directory is input directory
+ fOutDir = run->storepathLinux; // default ouput directory is input directory
fRunNumber = run->labbook.runnumber;
fRows = run->sensorinfocurrent.rows;
cout<<" Ordering according to : "<<fOrderCode<<endl;
cout<<" Save/Overwrite data : "<<fSave<<endl;
cout<<" System specified : "<<fSystem<<endl;
- cout<<" Dynamic noise calc : ";
- if (useexponentialdecayingnoisewindow)
- cout << "Modified moving average (MMA)" << endl;
- else
- cout << "Simple moving average (SMA)" << endl;
+
+// loadNoise();
//-----------------------------------------------
unsigned short int vi,vj;
value1[vi][vj] = (vj*16 + (vi & 0xF0) / 16);
}
}
- // TODO remove this part?
- // config ROOT plotting style
- gStyle->SetOptFit(1011);
- gStyle->SetPalette(1);
- gStyle->SetCanvasColor(0);
- gStyle->SetFrameFillColor(10);
- gStyle->SetOptStat(0);
+
+ initHistograms();
//-----------------------------------------------
}
//####################################################################
-void MAPS::initSave() {
- if(fSave )
- {
- fOutputFile = new TFile(fRootFile,"RECREATE");
- // Hit TTree
- fHitTree = new TTree("hit", "hit");
-
- fHitTree->Branch("frame" , &fFrameInfo.frame , "frame/i" , 32000);
- fHitTree->Branch("hits" , &fFrameInfo.hits , "hits/i" , 32000);
- fHitTree->Branch("pixel" , &fFrameInfo.pixel[0] , "pixel[hits]/i" , 32000);
- for(int i=0; i<25; i++) {
- fHitTree->Branch( Form("p%i",i+1) , &fFrameInfo.p[i][0] , Form("p%i [hits]/F",i+1) , 32000);
- }
- // Noise TTree
- fNoiseTree = new TTree("noise", "noise");
- fDynNoiseTree = fNoiseTree;
-//-----------------------------------------------
- hint1 = new TH2F("Hitmulit", "Hit multiplicity", fColumns, 0, fColumns, fRows, 0, fRows);
- hint2 = new TH2F("Pixmulit", "Pix multiplicity", fColumns, 0, fColumns, fRows, 0, fRows);
-
- fdiscriminatedhitmatrix = new TH2F("HittedPixel Discri", "HittedPixel Discri", fColumns, 0, fColumns, fRows, 0, fRows);
- fADCHitmatrix = new TH2F("HittedPixel ADC", "HittedPixel", fColumns, 0, fColumns, fRows, 0, fRows);
-
- hint1->GetXaxis()->SetRangeUser(0, fColumns);
- hint1->GetYaxis()->SetRangeUser(0, fRows);
- hint1->GetXaxis()->SetTitle("column");
- hint1->GetYaxis()->SetTitle("row");
- hint1->GetZaxis()->SetTitle("Signal [ADC]");
-
- hint2->GetXaxis()->SetRangeUser(0, fColumns);
- hint2->GetYaxis()->SetRangeUser(0, fRows);
- hint2->GetXaxis()->SetTitle("column");
- hint2->GetYaxis()->SetTitle("row");
- hint2->GetZaxis()->SetTitle("Signal [ADC]");
-//-----------------------------------------------
- cout<<"-----------------------"<<endl;
- cout<<fRootFile<<" recreated!"<<endl;
- cout<<"-----------------------"<<endl;
- }
+
+void MAPS::initHistograms() {
+ //-----------------------------------------------
+ gStyle->SetOptFit(1011);
+ gStyle->SetPalette(1);
+ gStyle->SetCanvasColor(0);
+ gStyle->SetFrameFillColor(10);
+ gStyle->SetOptStat(0);
+
+ hint1 = new TH2F("Hitmulit", "Hit multiplicity", fColumns, 0, fColumns, fRows, 0, fRows);
+ hint2 = new TH2F("Pixmulit", "Pix multiplicity", fColumns, 0, fColumns, fRows, 0, fRows);
+ fdiscriminatedhitmatrix = new TH2F("HittedPixel Discri", "HittedPixel Discri", fColumns, 0, fColumns, fRows, 0, fRows);
+ fADCHitmatrix = new TH2F("HittedPixel ADC", "HittedPixel", fColumns, 0, fColumns, fRows, 0, fRows);
+
+ hint1->GetXaxis()->SetRangeUser(0, fColumns);
+ hint1->GetYaxis()->SetRangeUser(0, fRows);
+ hint1->GetXaxis()->SetTitle("column");
+ hint1->GetYaxis()->SetTitle("row");
+ hint1->GetZaxis()->SetTitle("Signal [ADC]");
+
+ hint2->GetXaxis()->SetRangeUser(0, fColumns);
+ hint2->GetYaxis()->SetRangeUser(0, fRows);
+ hint2->GetXaxis()->SetTitle("column");
+ hint2->GetYaxis()->SetTitle("row");
+ hint2->GetZaxis()->SetTitle("Signal [ADC]");
+ //-----------------------------------------------
}
+
+
+
//####################################################################
bool MAPS::getFrame(Int_t FrameNumber) {
//####################################################################
// initial Dynamic Noise + Pedestals calculation
bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
+ cout<<" Dynamic noise calc : ";
+ if (useexponentialdecayingnoisewindow)
+ cout << "Modified moving average (MMA)" << endl;
+ else
+ cout << "Simple moving average (SMA)" << endl;
// temporal local variables
/// temporal variable to save second pedestial estimate
Float_t* pixelpedestal2 = new Float_t[fPixels]();
}
//###################################################################
-bool MAPS::loadNoise( TString InDir, Int_t RunNumber, Int_t Matrix) {
+bool MAPS::loadNoise() {
+ loadNoise(fRootFile);
+}
- TString FILENAME = InDir+Form("%i/%i_%i.root",RunNumber,RunNumber,Matrix);
- TFile *f = new TFile(FILENAME,"READ");
+bool MAPS::loadNoise( TString filename) {
+ TFile *f = new TFile(filename,"READ");
if(f->IsZombie())
{
cerr<<"ERROR: loadNoise() failed!"<<endl;
- cerr<<FILENAME<<" not found!"<<endl;
+ cerr<<filename<<" not found!"<<endl;
cerr<<"-----------------------"<<endl;
return false;
exit(-1);
}
else
{
- cout<<"Noise/Pedestals loaded from:"<< FILENAME << "!"<<endl;
TTree *noiseTree = (TNtuple*) f->Get("noise");
Float_t NOISE, PEDESTAL;
noiseTree->SetBranchAddress("pixel" , &PIXEL );
+ cout<<"Noise/Pedestals loaded from:"<< filename << "!"<<endl;
noiseTree->SetBranchAddress("noise" , &NOISE );
noiseTree->SetBranchAddress("pedestal" , &PEDESTAL );
Run::~Run( void)
{
- db->Close();
delete processed;
+ db->Close();
rootfile->Close();
}
{
getVetoPeakPositionFromFe55Run();
}
- setSystemInfo();
+ setSystemSpecificParameters();
generateReadableRunCode();
runexistsinDB = 1;
}
processed = new MAPS(this);
if (!runAllreadyAnalyzed() || force)
{
+ processed->initNewRootFile();
/// progress meter, temporal variable
ULong_t progress_tmp=-1;
/// progress meter
if (progress!=progress_tmp) { print_progress( (((i-start)*100.)/(nframes-1)) ); progress_tmp=progress;}
}
cout << processed->plus << " vs. " << processed->minus << " : " << (processed->plus*1.0)/processed->minus<< endl;
+
// print a dummy file to indicate, that a root file was created once
fstream* fout = new fstream(storepathLinux + "/rootfilecreated",std::ios::out);
*fout << "" << endl;
else
{
cout << "\033[1;33mSkipped analysis of run " << labbook.runnumber << ", I think the root file for this run allready exists.\033[0m" << endl;
+
+ processed->initOldRootFile();
+// TString rootfilepath = storepathLinux + Form ("/RUN_%i_i.root", labbook.runnumber);
+//
+//
+// rootfile = new TFile(rootfilepath);
+// if (!(rootfile->IsZombie()))
+// {
+// runexistsAsRootFile = 1;
+// }
+// else
+// {
+// // if we cannot open the file, print an error messageForm("hist%i",nHistNtuple) and return immediatly
+// cout << "\033[1;31mError: cannot open " << rootfilepath << "\033[0m\n";
+// exit(0);
+// }
}
// binNoise();
// binSeedSumVeto();
-// TString rootfilepath = storepathLinux + Form ("/RUN_%i_i.root", labbook.runnumber);
-// rootfile = new TFile(rootfilepath);
+
// if (!(rootfile->IsZombie()))
// {
// runexistsAsRootFile = 1;
{
processed->InitialDynNoise(100);
processed->getFrame(frame);
-// processed->filterCommonMode();
+ processed->filterCommonMode();
processed->hitana();
processed->plotFrame(frame);
binNoise();
return ss >> result ? result : 0;
}
+
+void Run::setSystemSpecificParameters()
+{
+ // if USB system, threshold = 5, if PXI = 65
+ vetothreshold=labbook.system=="USB"?5:75;
+ setSystemInfo();
+}
+
void Run::setSystemInfo()
{
sensorinfostruct sensorinfoMi34USB;
/// pixel number of seed pixel, position on sensor
UInt_t seedPixel[10000];
/// Array of CLUSTERSIZE * CLUSTERSIZE clusters, seed pixel in the middle
- Float_t pixelcluster[5*5][10000];
+ Float_t pixelcluster[processed->clustersize*processed->clustersize][10000];
+
+ /// collected charge in cluster
+ Float_t pixelSum = 0;
+ Float_t notSeedSum = 0;
for (Int_t framei=0; framei<processed->fHitTree->GetEntries(); framei++) // loop over all frames
{
processed->fHitTree->GetEntry(framei);
// account only frames with less then 10 hits
- cout << processed->fFrameInfo.hits << endl;
-// if (processed->fFrameInfo.hits<10)
-// {
+ if (processed->fFrameInfo.hits<10)
+ {
+ for(Int_t hiti=0; hiti<processed->fFrameInfo.hits;hiti++)
+ {
+ // histogram with the single pixel
+ histogram.Seed->Fill(processed->fFrameInfo.p[12][hiti]);
+
+ // sum histogram
+ pixelSum = 0;
+ notSeedSum = 0;
+ for (Int_t clusteri=0; clusteri<processed->clustersize*processed->clustersize; clusteri++)
+ {
+ pixelSum += processed->fFrameInfo.p[clusteri][hiti];
+ if (clusteri != 12)
+ notSeedSum += processed->fFrameInfo.p[clusteri][hiti];
+ }
+ histogram.Sum->Fill(pixelSum);
+
+ // veto spectrum
+ if (TMath::Abs(notSeedSum) < vetothreshold)
+ histogram.Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel
+ }
+ }
}
}