Bool_t MAPS::initNewRootFile() {
fSave = true;
- if ( checkConf(fPixelsData) ) // TODO FileEvNbInConfig
+ if ( !checkConf(fPixelsData) ) { // TODO FileEvNbInConfig
+ defaultConf();
+ }
+ //-----------------------------------------------
+ //Check and open Data Files
+ int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig);
+ if( checkDataFiles(MaxFiles) )
{
- //-----------------------------------------------
- //Check and open Data Files
- int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig);
- if( checkDataFiles(MaxFiles) )
- 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);
- fHitTree->Branch("pixelthreshold", &fFrameInfo.pixelthreshold[0],"pixelthreshold[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;
- initHistograms();
- cout<<"-----------------------"<<endl;
- cout<<fRootFile<<" recreated!"<<endl;
- cout<<"-----------------------"<<endl;
- return 0;
+ 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);
+ fHitTree->Branch("pixelthreshold", &fFrameInfo.pixelthreshold[0],"pixelthreshold[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);
}
- //-----------------------------------------------
- } sleep(1); // TODO test if removable
+ // Noise TTree
+ fNoiseTree = new TTree("noise", "noise");
+ fDynNoiseTree = fNoiseTree;
+ initHistograms();
+ cout<<"-----------------------"<<endl;
+ cout<<fRootFile<<" recreated!"<<endl;
+ cout<<"-----------------------"<<endl;
+ return 0;
+ }
return 1;
}
}
}
- ifstream inn(fConfigFile, ios::binary);
- if( !inn.good() )
- {
- cout<<"-----------------------"<<endl;
- cout << colorred << "Configuration file not found: " ;
- cout << fConfigFile;
- cout << endlr;
- cout << " -- STOP -- " << endl;
- return true;
- }
+// ifstream inn(fConfigFile, ios::binary);
+// if( !inn.good() )
+// {
+// cout<<"-----------------------"<<endl;
+// cout << colorred << "Configuration file not found: " ;
+// cout << fConfigFile;
+// cout << endlr;
+// return true;
+// }
return false;
//-----------------------------------------------
else
{
cout<<"-----------------------"<<endl;
- cout << "\033[1;31mConfiguration file not found: ";
- cout << fConfigFile;
- cout << endl;
-
- cout << " -- STOP -- " << endl;
+ cout << coloryellow << "Configuration file not found: ";
+ cout << fConfigFile << endlr;
return false;
}
return false;
}
-
bool MAPS::checkConf( Int_t &PixelData ) {
-
+
UInt_t DataSz;
UInt_t NrAdcBoards;
-
- ifstream inn(fConfigFile, ios::binary);
-
+
+ ifstream inn(fConfigFile, ios::binary);
+
if( inn.good() )
{
inn.seekg(0, ios::end);
int End = inn.tellg();
inn.seekg(0, ios::beg);
-
+
char* RAWDATA = new char[End];
- inn.read ( RAWDATA, End);
+ inn.read ( RAWDATA, End);
inn.close();
-
- FileEvNbInConfig = littleEndian32( RAWDATA, 4*3); ///< Event number per file
- FileTotalEvNbInConfig = littleEndian32( RAWDATA, 4*4); ///< Total events in RUN - should be less if RUN was stopped before endl
-// FileTotalEvNbInConfig = 100000000;
- DataSz = littleEndian32( RAWDATA, 4*6); ///< Datas size = BDB_VFAS_RAM_SZ_W32 X Adc number ( VFasRunNb field )
- NrAdcBoards = littleEndian32( RAWDATA, 4*9); ///< Number of Adc boards installed in the system
-
- PixelData = DataSz/4;
+
+ FileEvNbInConfig = littleEndian32( RAWDATA, 4*3); ///< Event number per file
+ FileTotalEvNbInConfig = littleEndian32( RAWDATA, 4*4); ///< Total events in RUN - should be less if RUN was stopped before endl
+ // FileTotalEvNbInConfig = 100000000;
+ DataSz = littleEndian32( RAWDATA, 4*6); ///< Datas size = BDB_VFAS_RAM_SZ_W32 X Adc number ( VFasRunNb field )
+ NrAdcBoards = littleEndian32( RAWDATA, 4*9); ///< Number of Adc boards installed in the system
+
+ PixelData = DataSz/4;
TString System[5] = {"","","USB","","PXI"};
if( fSystem == "" )
{
- if( NrAdcBoards == 1) {
+ if( NrAdcBoards == 1) {
fSystem = "USB";
}
- if( NrAdcBoards == 2) {
+ if( NrAdcBoards == 2) {
fSystem = "USB";
}
- if( NrAdcBoards == 4) {
+ if( NrAdcBoards == 4) {
fSystem = "PXI";
}
}
cout<<"---------"<<endl;
cout<<"System specification ( "<<fSystem<<" ) might be incorrect!"<<endl;
cout<<"Wait 10 sec. to continue: ";
-
+
for(int i=0; i<10; i++)
{
cout<<".";
cout<<endl;
cout<<"---------"<<endl;
}
-
+
delete[] RAWDATA;
-//-----------------------------------------------
+ //-----------------------------------------------
cout<<"-----------------------"<<endl;
cout<<" ==> Check config file ..."<<endl;
cout<<"-----------------------"<<endl;
- cout<<" Config File : "<< fRootFile <<endl;
- cout<<" Events per File : "<<setw(10)<<left<< FileEvNbInConfig <<endl;
- cout<<" Total Events : "<<setw(10)<<left<< FileTotalEvNbInConfig <<" (?)"<<endl;
+ cout<<" Config File : "<< fRootFile <<endl;
+ cout<<" Events per File : "<<setw(10)<<left<< FileEvNbInConfig <<endl;
+ cout<<" Total Events : "<<setw(10)<<left<< FileTotalEvNbInConfig <<" (?)"<<endl;
cout<<" Pixels in Data : "<<fPixelsData<<endl;
cout<<" System found : "<<System[NrAdcBoards]<<endl;
cout<<"-----------------------"<<endl;
-
+
if( fPixelsData<fPixels )
{
cout<<"ERROR -> Number of Pixels defined is bigger than found: "<<fPixels<<" <-> "<<fPixelsData<<endl;
cout<<"-----------------------"<<endl;
return false;
}
-//-----------------------------------------------
-//PARAMETER:
- fF0matrix = new Int_t [fPixelsData]();
- fF1matrix = new Int_t [fPixelsData]();
- fCdsmatrix = new Float_t [fPixelsData]();
- fNoise = new Float_t [fPixelsData]();
- fPedestals = new Float_t [fPixelsData]();
- fHittedPixel= new Int_t [fPixelsData]();
-//-----------------------------------------------
+ //-----------------------------------------------
+ //PARAMETER:
+ fF0matrix = new Int_t [fPixelsData]();
+ fF1matrix = new Int_t [fPixelsData]();
+ fCdsmatrix = new Float_t [fPixelsData]();
+ fNoise = new Float_t [fPixelsData]();
+ fPedestals = new Float_t [fPixelsData]();
+ fHittedPixel= new Int_t [fPixelsData]();
+ //-----------------------------------------------
return true;
}
else
cout << "Configuration file not found: ";
cout << fConfigFile;
cout << endl;
-
- cout << " -- STOP -- " << endl;
return false;
}
}
+bool MAPS::defaultConf( ) {
+ FileEvNbInConfig = 20000; ///< Event number per file
+ FileTotalEvNbInConfig = 10000000;
+ fPixelsData = run->sensorinfocur.columns*run->sensorinfocur.rows;
+//-----------------------------------------------
+ cout<<"-----------------------"<<endl;
+ cout<<" ==> Load default config file ..."<<endl;
+ cout<<"-----------------------"<<endl;
+ cout<<" Config File : default" <<endl;
+ cout<<" Events per File : "<<setw(10)<<left<< FileEvNbInConfig <<endl;
+ cout<<" Total Events : "<<setw(10)<<left<< "?" <<endl;
+ cout<<" Pixels in Data : "<<fPixelsData<<endl;
+ cout<<"-----------------------"<<endl;
+
+//PARAMETER:
+ fF0matrix = new Int_t [fPixelsData]();
+ fF1matrix = new Int_t [fPixelsData]();
+ fCdsmatrix = new Float_t [fPixelsData]();
+ fNoise = new Float_t [fPixelsData]();
+ fPedestals = new Float_t [fPixelsData]();
+ fHittedPixel= new Int_t [fPixelsData]();
+//-----------------------------------------------
+ return true;
+}
+
//####################################################################
bool MAPS::checkDataFiles( Int_t MaxFiles ) {
cout<< "TOTAL FRAMES FOUND: "<<fEventsSum<<endl;
if (FileTotalEvNbInConfig != fEventsSum)
{
- cout<< colorred <<"-----------------------"<<endl;
- cout<<"WARNING: Number of found events not equal to number of events stated in config file! " << FileTotalEvNbInConfig << " != " << fEventsSum << endl;
+ cout<< "-----------------------"<<endl;
+ cout<< coloryellow << "Number of found events not equal to number of events stated in config file! " << FileTotalEvNbInConfig << " != " << fEventsSum << endlr;
cout<<"-----------------------" << endlr;
}
if(!fOk)