Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:07

0001 #include "RecoVertex/BeamSpotProducer/interface/BeamSpotTreeData.h"
0002 #include <TTree.h>
0003 #include <TFile.h>
0004 #include <TString.h>
0005 #include <TList.h>
0006 #include <TSystemFile.h>
0007 #include <TSystemDirectory.h>
0008 #include <iostream>
0009 
0010 using namespace std;
0011 
0012 void NtupleChecker(){
0013   TString path = "/uscms_data/d2/uplegger/CMSSW/CMSSW_3_8_0_pre7/src/RecoVertex/BeamSpotProducer/test/scripts/Ntuples/";
0014   TSystemDirectory sourceDir("fileDir",path); 
0015   TList* fileList = sourceDir.GetListOfFiles(); 
0016   TIter next(fileList);
0017   TSystemFile* fileName;
0018   int fileNumber = 1;
0019   int maxFiles = 1000;
0020   BeamSpotTreeData aData;
0021   while ((fileName = (TSystemFile*)next()) && fileNumber <= maxFiles){
0022     if(TString(fileName->GetName()) == "." || TString(fileName->GetName()) == ".."  ){
0023       continue;
0024     }
0025     TTree* aTree = 0;
0026     TFile file(path+fileName->GetName(),"READ");//STARTUP
0027     cout << "Opening file: " << path+fileName->GetName() << endl;
0028     file.cd();
0029 //    aTree = (TTree*)file.Get("PrimaryVertices");
0030     aTree = (TTree*)file.Get("BeamSpotTree");
0031     cout << (100*fileNumber)/(fileList->GetSize()-2) << "% of files done." << endl;
0032     ++fileNumber;
0033     if(aTree == 0){
0034       cout << "Can't find the tree" << endl;
0035       continue;
0036     }
0037     aData.setBranchAddress(aTree);
0038     for(unsigned int entry=0; entry<aTree->GetEntries(); entry++){
0039       aTree->GetEntry(entry);
0040       cout << aData.getRun() << endl;
0041     }
0042     
0043   }
0044 }