/******************************************************************** Bad Chunks Checking code, 15th April 2013 --- This version is a bit more "automatized" in that you give it a dataset string as a parameter and it spits out appropriately named text files. Some small customization for each usage case (output directory, in the first lines of the function below) may still be needed when being used in general. --- Also note: the code expects to find an "output" directory to store text files with summaries. If it does not exist, please create it or also chang the path! ********************************************************************/ #include #include #include "TFile.h" #include "TTree.h" #include "TString.h" using namespace std; int ProcessBadChunks02(TString lDataset ){ //Path to output files: change as needed TString lFileName = "/Volumes/MyPassport/work/download/badchunk/"; lFileName.Append(lDataset.Data()); lFileName.Append(".root"); //Print out "I'm alive" cout<<"----------------------------------------------------"<IsOpen()) { cout<<"File not found!"<FindObjectAny("fTree"); if (!ftree) { cout<<"File doesn't contain fTree!"<GetEntries()<SetBranchAddress("fRunNumber" ,&llRunNumber ); ftree->SetBranchAddress("fFileName" , &llFileName ); ftree->SetBranchAddress("fNTracks" ,&llNTracks ); ftree->SetBranchAddress("fNGlobalTracks" ,&llNGlobalTracks ); //Output ostreams: text files with chunk location, good and bad //Save by default to "output" directory TString lGoodName = "output/GoodChunks-"; lGoodName.Append(lDataset.Data()); lGoodName.Append(".txt"); TString lBadName = "output/BadChunks-"; lBadName.Append(lDataset.Data()); lBadName.Append(".txt"); TString lReport = "output/Datasetreport-"; lReport.Append(lDataset.Data()); lReport.Append(".txt"); filebuf fbgood; fbgood.open (lGoodName,ios::out); ostream osgood(&fbgood); filebuf fbbad; fbbad.open (lBadName,ios::out); ostream osbad(&fbbad); filebuf fbreport; fbreport.open (lReport,ios::out); ostream osreport(&fbreport); //Main Tree Loop Long_t lProcessedChunks = 0; Long_t lProcessedChunksGood = 0; Long_t lProcessedChunksBad = 0; Long_t lTracks = 0; Long_t lGlobalTracks = 0; TString *lChunkName = new TString(); //First Chunk entry ftree->GetEntry(0); *lChunkName = *llFileName; cout<<"TEST "<Data() <<", track = "<Data() << endl; for(Long_t iEvent = 1; iEventGetEntries(); iEvent++){ ftree->GetEntry(iEvent); if( !llFileName->EqualTo(*lChunkName) ){ lProcessedChunks++; //Change Chunk if( lTracks > 0 && lGlobalTracks ==0){ //Candidate bad chunk found! cout<<"BAD CHUNK at "<Data() <<", track = "<Data()< Processed "< 0 && lGlobalTracks ==0){ //Candidate bad chunk found! cout<<"BAD CHUNK at "<Data()<Data() <Data()< Good chunks saved to \"goodguys.txt\""< Bad chunks saved to \"badguys.txt\""<