00001 //========================================================== 00002 // 00003 // FileChopper.cxx 00004 // 00005 // Authors: Pedro Ochoa 00006 // 00007 // Written: December 20 2007 00008 // 00009 //=========================================================== 00010 00011 #include <iostream> 00012 #include "MCNNAnalysis/FileChopper.h" 00013 00014 using std::cout; 00015 using std::endl; 00016 00017 FileChopper::FileChopper(){ 00018 00019 tot_entries=0; 00020 chop_size=0; 00021 pieces=0; 00022 remainder=0; 00023 00024 cout << "Caution! Emtpy constructor for FileChopper does not chop ANYTHING" << endl; 00025 00026 chain = new TChain("NtpSt"); 00027 00028 } 00029 00030 FileChopper::FileChopper(const char* fname, Int_t sizeofchop){ 00031 00032 chop_size=sizeofchop; 00033 00034 chain = new TChain("NtpSt"); 00035 00036 Int_t filenum = chain->Add(fname); 00037 tot_entries = chain->GetEntries(); 00038 remainder=tot_entries % chop_size; 00039 pieces= tot_entries/chop_size + (bool)remainder; 00040 00041 cout << "======== FileChopper =================" << endl; 00042 cout << "Added " << filenum << " file(s) to the FileChopper" << endl; 00043 cout << "The file(s) has " << tot_entries << " entries in total" << endl; 00044 cout << "Will divide in " << pieces << " pieces" << endl; 00045 00046 } 00047 00048 FileChopper::~FileChopper(){ 00049 00050 delete chain; 00051 00052 } 00053 00054 //-------------------------------------------------- 00055 Int_t FileChopper::GetTotalPieces(){ 00056 00057 return pieces; 00058 00059 } 00060 //-------------------------------------------------- 00061 Int_t FileChopper::GetSizeOfPiece(Int_t ii){ 00062 00063 Int_t valuetoret=0; 00064 00065 if(ii<pieces-1){ 00066 valuetoret=chop_size; 00067 } else if(ii==pieces-1){ 00068 if(remainder==0){ 00069 valuetoret=chop_size; 00070 } else{ 00071 valuetoret=remainder; 00072 } 00073 } 00074 00075 return valuetoret; 00076 00077 }
1.3.9.1