當前位置: 首頁>>代碼示例>>C++>>正文


C++ TList::GetEntries方法代碼示例

本文整理匯總了C++中TList::GetEntries方法的典型用法代碼示例。如果您正苦於以下問題:C++ TList::GetEntries方法的具體用法?C++ TList::GetEntries怎麽用?C++ TList::GetEntries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TList的用法示例。


在下文中一共展示了TList::GetEntries方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: cmpLRD

void cmpLRD(TFile* f1, TFile* f2, const char* dName, const char* patt = 0, unsigned int logmod=0, unsigned int dOpt=1){
  //  std::cout<<"cmpLRD In "<< dName<<std::endl;
  TDirectory* td = gROOT->GetDirectory(dName);
  if (td){
    TList* tkl = td->GetListOfKeys();
    unsigned int tklSize = tkl->GetEntries();
    //    std::cout<<"\t size "<<tklSize<<std::endl;
    for (unsigned int iK=0; iK< tklSize; ++iK){
      //      std::cout<<"at "<<iK<<"\t " <<tkl->At(iK)->GetName()<<std::endl;
      if (TClass(((TKey*)tkl->At(iK))->GetClassName()).InheritsFrom("TDirectory")){
	TDirectory* tdc = (TDirectory*)((TKey*)tkl->At(iK))->ReadObj();
	if (tdc ==0) continue;
	TString tdcPFull(tdc->GetPath());
	TString pRel(tdcPFull.Tokenize(":")->At(1)->GetName());
	//	std::cout<<tdcPFull.Data()<<std::endl;
	
	//now execute compare 
	//	if(pRel.Index("/SiStrip/")>=0) continue; //this takes a huge time in alcareco and is irrelevant
	///DQMData/Run 1/Btag
	if (patt==0 || (patt!=0 && pRel.Index(patt)>=0)){
	  //	  std::cout<<"Comparing in " <<pRel.Data()<<std::endl;
	  compareInDir(f1, f2, pRel.Data(),logmod,dOpt);
	}
	cmpLRD(f1, f2, tdcPFull.Data(), patt,logmod,dOpt);
      }
    }
  }
}
開發者ID:HuguesBrun,項目名稱:cms-bot,代碼行數:28,代碼來源:compareValHists.C

示例2: SelectPad

void
Pick(Int_t canvas_index)
{
  TObject *o;
  TCanvas* c = ((TCanvas*) gROOT->GetListOfCanvases()->At(canvas_index));
  c->cd();
  // std::cout << "______PICKED______\n\t" 
  // 	  << c->GetName() << " canvas_index=" << canvas_index << std::endl;
  //  ((TCanvas*) gROOT->GetListOfCanvases()->At(canvas_index))->cd();
  

  TList *ll = toolcanvas->GetListOfPrimitives();
  // std::cout << ll->GetEntries() << std::endl;
  for (Int_t ii=ll->GetEntries()-1; ii>=0; ii--)
    {
      o = ll->At(ii);
      // std::cout << ii << " removing " << ll->At(ii)->GetName() << std::endl;
      ll->Remove(o);
    }

  toolcanvas->cd();
  toolcanvas->SetWindowSize(toolw-28, toolh-8);
  //  toolcanvas->SetCanvasSize(toolw, toolh);
  pt->Draw();
  toolcanvas->Modified();
  toolcanvas->Update();
  canvas = ((TCanvas*) gROOT->GetListOfCanvases()->At(canvas_index));
  //Enlarge();
  SelectPad();
}
開發者ID:jrtomps,項目名稱:phdwork,代碼行數:30,代碼來源:DoubleClickEnlarge.C

示例3: Terminate

void rdphi::Terminate()
{
//cout << "total event: " << NevtAll << "rejected: " << rejected_events << endl; 

  TFile *f = new TFile("output.root","RECREATE");

  //Write output Histograms
  TList *tl = GetOutputList();
  int l = tl->GetEntries();
  for ( int i = 0 ; i < l ; i++ )
  {
    TObject *o = tl->At(i);

    if ( o->InheritsFrom("TH1") )
    {
      cout << "TresChorros: Saving Histogram: "
          << "  Class: " << o->ClassName()  
          << "  Name: "<< o->GetName() 
          << "  Title: " << o->GetTitle()
          << " " 
          << endl << flush;
      o->Write();
    }
    }
  f->Flush();
  f->Close();  

}
開發者ID:affablelochan,項目名稱:DataAnalysis,代碼行數:28,代碼來源:rdphi_v1.C

示例4: TObjArray

void
SelectPad()
{
  notDeleted = kTRUE;

  toolcanvas->cd();
  // Clear buttons from toolcanvas
  TObject *o;
  TList *ll = toolcanvas->GetListOfPrimitives();
  for (Int_t ii=ll->GetEntries()-1; ii>=0; ii--)
    {
      o = ll->At(ii);
      ll->Remove(o);
    }

  Double_t buttonheight = 50;
  TList *li = canvas->GetListOfPrimitives();
  Int_t nentries = li->GetEntries();

  if (nentries==1)
    return;

  toolcanvas->SetWindowSize(toolw,(nentries+1)*buttonheight);
  toolcanvas->Modified();
  toolcanvas->Update();

  pt->SetY1NDC(1.0-1.0/(nentries+1));
  pt->Draw();

  toolcanvas->Update();


  //  toolcanvas->cd();
  if (b) {delete b;}
  
  Int_t count=0;
  b = new TObjArray(nentries);
  for (Int_t i=0; i<nentries; i++)
    {
      b->Add(new TButton(Form("pad%i",i+1),Form("Enlarge(%i);",i),0,(1-(count+1.)/(nentries+1)),1,(1-(count+2.)/(nentries+1))));
      b->At(i)->Draw();
      count++;
    }
  toolcanvas->Modified();
  toolcanvas->Update();
  //  if (display) {display->Modified(); display->Update();}
}
開發者ID:jrtomps,項目名稱:phdwork,代碼行數:47,代碼來源:DoubleClickEnlarge.C

示例5: MakeCutLog

void MakeCutLog(const char *inputRootFile = "AnalysisResults",const char *path = "./", const char* outputDir="./Output/"){

  fstream outputFile(Form("%sCutSelection.log",outputDir),ios::out);
  if(!outputFile.is_open()){
    cout<<"Problem opening file"<<endl;
    return;
  }

  //  Char_t filename_input1[200] = (Form("%s%s",path,input1));	
  TString filename = Form("%s%s.root",path,inputRootFile);	
  TFile f(filename.Data());  

  TList *directories = f.GetListOfKeys(); // get the list of directories in the file
  
  for(Int_t entFile=0;entFile<directories->GetEntries();entFile++){

    TObject * o = f.Get(directories->At(entFile)->GetName()); // get the object in the base directory

    if(TString(o->IsA()->GetName())=="TDirectoryFile"){ // means that this is a directory (PWGGA......)
      
      TDirectory *pwg4dir =(TDirectory*)o;
 
      TString baseDirName = pwg4dir->GetName();
      
      TString reconstructionFlagString = ""; // this is for new scheme where also the flags are coded in numbers in the PWGGA.... name

      if(baseDirName.Length()>31){
	reconstructionFlagString = baseDirName(baseDirName.Index("GammaConversion_")+16,8);
      }
      
      TList *pwg4list = pwg4dir->GetListOfKeys(); // list of the yeys inside the base directory

      for(Int_t entHist=0;entHist<pwg4list->GetEntries();entHist++){
	TString name = pwg4list->At(entHist)->GetName();

	if(name.Contains("container")==0){ // does not try to read the container (get errors if tried)
	  TObject * oHist = pwg4dir->Get(pwg4list->At(entHist)->GetName()); // get the object 
	  
	  if(TString(oHist->IsA()->GetName())=="TList"){ // check if the object is a TList
	    
	    TString listname = oHist->GetName();
	    cout<<"Reading: "<<listname.Data()<<endl;
	    
	    TString cutString = listname(listname.Index("_")+1,listname.Length()) + "\n";// get the Cut string from the name


	    outputFile << cutString.Data();
	  }
	}
      }
    }
  }
  outputFile.close();
}
開發者ID:ktf,項目名稱:AliPhysics,代碼行數:54,代碼來源:MakeCutLog.C

示例6: saveSummaryLoop

void RootWImage::saveSummaryLoop(TPad* basePad, std::string baseName, TFile* myTargetFile) {
  TList* aList;
  TObject* anObject;
  TPad* myPad;
  std::string myClass;
  std::string myName;

  TNamed* aNamed;

  // TSystemFile* aFile;
  // string aFileName;
  // string aFileNameTail;
  // TFile* myRootFile;

  aList = basePad->GetListOfPrimitives();
  for (int i=0; i<aList->GetEntries(); ++i) {
    anObject = aList->At(i);
    myClass = anObject->ClassName();
    if (myClass=="TPad") { // Go one step inside
      myPad = (TPad*) anObject;
      saveSummaryLoop(myPad, baseName, myTargetFile);
    } else if (
	       (myClass=="TProfile") ||
	       (myClass=="TGraph") ||
	       (myClass=="TH1D") ||
	       (myClass=="TH2C") ||
	       (myClass=="TH2D") ||
	       (myClass=="THStack") 
	       ) {
      aNamed = (TNamed*) anObject;
      myTargetFile->cd();
      myName = Form("%s.%s", baseName.c_str(), aNamed->GetName());
      myName = RootWeb::cleanUpObjectName(myName);
      aNamed->SetName(myName.c_str());
      aNamed->Write();
    } else if (
	       (myClass=="TEllipse") ||
	       (myClass=="TFrame") ||
	       (myClass=="TLatex") ||
	       (myClass=="TLegend") ||
	       (myClass=="TLine") ||
	       (myClass=="TPaveText") ||
	       (myClass=="TPolyLine") ||
	       (myClass=="TText") 
	       ) {
    } else {
      std::cerr << Form("Unhandled class %s", myClass.c_str()) << std::endl;
    }
  }
}
開發者ID:Deepali-Garg,項目名稱:Ph2_ACF,代碼行數:50,代碼來源:rootweb.cpp

示例7: PrintLegend

// A macro to print out a TLegend - can be considered a smarter TLegend::ls().
// If no TLegend pointer is passed, it loops over the TLegends drawn on current TPad.
void PrintLegend(TLegend *leg=0) {
  if ( leg==0 ) {
    if (gROOT->GetListOfCanvases()->GetEntries()==0) return;
    TList *padprim = gPad->GetListOfPrimitives();
    for (int i=0; i<padprim->GetEntries(); i++) {
      TObject *myobj = gROOT->FindObject(padprim->At(i)->GetName());
      if ( myobj != 0 && myobj->InheritsFrom("TLegend") )
	PrintLegend((TLegend*)myobj); }
    return;
  }
  TList *ents = leg->GetListOfPrimitives();
  for (int i=0; i<ents->GetEntries(); i++) {
    TLegendEntry *le = (TLegendEntry*)ents->At(i);
    TString s( le->GetLabel() );
    TObject *obj = le->GetObject();
    if (!obj) continue;  // if no object, this can be the title line, so skip
    TString color = "???";
    if ( obj->InheritsFrom("TH1") )
      color = gROOT->GetListOfColors()->At(((TH1*)obj)->GetLineColor())->GetName();
    cout << "Item ";  cout.width(2); cout.fill('0'); cout << i << " plotted in ";
    cout.width(7); cout.fill(' '); cout << color << " : " << s << endl;
  }
  //leg->ls();
}
開發者ID:daivdoux,項目名稱:ROOTmacros,代碼行數:26,代碼來源:LegendTools.C

示例8: namesMatchingClass

///////////////////////////////
// Return matching key names
SEXP namesMatchingClass(SEXP fileForHists, SEXP directoryR, SEXP classTypeR)
{
  TFile* f = checkForFileForHistsWrapper(fileForHists);

  const char* oldDirectory = setFileDirectory(f, directoryR);

  // Get the class type
	std::string classType = CHAR( STRING_ELT(classTypeR, 0) );
  
  // Keep track of the ones we want
  std::vector<const char*> names;
  std::vector<int> cycles;
  
  // Loop over keys in this directory -- pull out names and cycles for classes
  // that match the ones we want.
  TList* l = gDirectory->GetListOfKeys();
  for ( unsigned int i = 0; i < l->GetEntries(); ++i ) {
    TKey* k = (TKey*) l->At(i);
    if ( strcmp( k->GetClassName(), classType.c_str() ) == 0 ) {
      names.push_back( k->GetName() );
      cycles.push_back( k->GetCycle() );
    }
  }

  // Now we loop over the vectors to get the list of names
  SEXP rNames;
  PROTECT( rNames = NEW_CHARACTER( names.size() ) );

  for ( unsigned int i = 0; i < names.size(); ++i ) {
    // Form the string
    char buf[BUFSIZE];
    snprintf(buf, BUFSIZE, "%s;%d", names[i], cycles[i]);
    
    // Save this away
    SET_STRING_ELT( rNames, i, mkChar( buf ) );
  }

  UNPROTECT(1);

  // Restore the old directory
  if ( ! f->cd(oldDirectory) ) {
    error("namesMatchingClass: cd to old directory failed");
  }
  
  return rNames;
}
開發者ID:lyonsquark,項目名稱:RootTreeToR,代碼行數:48,代碼來源:fileForHistsWrapper.cpp

示例9: ClearSelection

void KVNameValueList::ClearSelection(TRegexp& sel)
{
   // Remove from list all parameters whose name matches the regular expression
   // Examples:
   //  remove all parameters starting with "toto": TRegexp sel("^toto")
   //  remove all parameters with "toto" in name:  TRegexp sel("toto")

   TList toBeRemoved;
   Int_t np1 = GetNpar();
   for (Int_t ii = 0; ii < np1; ii += 1) {
      TString name = GetParameter(ii)->GetName();
      if (name.Contains(sel)) toBeRemoved.Add(new TNamed(name.Data(), ""));
   }
   if (toBeRemoved.GetEntries()) {
      TIter next(&toBeRemoved);
      TNamed* tbr;
      while ((tbr = (TNamed*)next())) RemoveParameter(tbr->GetName());
      toBeRemoved.Delete();
   }
}
開發者ID:FableQuentin,項目名稱:kaliveda,代碼行數:20,代碼來源:KVNameValueList.cpp

示例10: AnalyzeClipping

void AnalyzeClipping(TString inputWaveName = "sum trigger input ch5 960mV",
TString outputWaveName = "sum trigger output ch5 - 2V clip - 960mV input", 
Double_t inputDelay = 1.1E-8, Double_t lowerCut = 16E-9, Double_t upperCut = 23E-9,
const char *inFile = "Data.root",const char *WaveformsFile = "Waveforms.root") {
	
	//try to access data file and in case of failure return
	if(gSystem->AccessPathName(inFile,kFileExists)) {
		cout << "Error: file " << inFile << " does not exsist. Run .x DataParse.C to create it" << endl;
		return;
	}

	TFile *f = TFile::Open(inFile);
	TFolder *dataSet;
	
	TString dataFolderS = "SumTriggerBoardData";
	dataFolderS.Append(";1");

	dataSet = (TFolder*)f->Get(dataFolderS);
	
	cout << dataSet << endl;

	cout << dataSet->GetName() << endl;
	
	Int_t nScope = 150; // number of measurements done by the scope evey time
	
	//try to access waveforms file and in case of failure return
	if(gSystem->AccessPathName(WaveformsFile,kFileExists)) {
		cout << "Error: file " << WaveformsFile << " does not exsist. Run .x WaveformsFileMaker.C to create it" << endl;
		return;
	}
	
	TFile *f = TFile::Open(WaveformsFile);
	TList *listOfKeys = f->GetListOfKeys();
	Int_t numberOfKeys = listOfKeys->GetEntries();
	TList *listOfGraphs = new TList();
	
	// if the waveform file name begins with the string "comparator" it goes in this list
	TList *listOfCompWaves = new TList();
	// if the waveform file name begins with the string "sum output" it goes in this list
	TList *listOfAdderWaves = new TList();

	for(Int_t i = 0; i < numberOfKeys; i++) {
		TString *keyName = new TString(listOfKeys->At(i)->GetName());
		TTree *tree = (TTree*)f->Get(keyName->Data());
		Float_t x = 0;
		Float_t y = 0;
		tree->SetBranchAddress("x",&x);
		tree->SetBranchAddress("y",&y);
		Int_t nentries = tree->GetEntries();

		TString *gName = new TString(keyName->Data());
		gName->Append(" graph");
		TGraphErrors *gWave = new TGraphErrors(nentries);
		gWave->SetName(gName->Data());
		gWave->SetTitle(gName->Data());
		gWave->GetXaxis()->SetTitle("Time");
		gWave->GetYaxis()->SetTitle("Voltage");

		for (Int_t j = 0; j < nentries; j++) {
			tree->GetEntry(j);
			gWave->SetPoint(j,x,y);
		}

		listOfGraphs->Add(gWave);
	}
	
	// Global variables
	
	Double_t *xInput, *xOutput, *yInput, *yOutput;
	
	// V input 960 mV
	
	TString path = "Clipping/Output width analysis/Channel 5/V input 960mV/";
	
	TGraphErrors *gClip960mV = TBGraphErrors(dataSet,path,"V clip","Output FWHM",1,nScope);
	
	gClip960mV->SetMarkerStyle(20);
	gClip960mV->SetMarkerSize(0.8);
	gClip960mV->GetXaxis()->SetTitle("V clipping (mV)");
	gClip960mV->GetYaxis()->SetTitle("Output FWHM (ns)");
	
	TCanvas *cClip960mV = new TCanvas("cClip960mV","Output FWHM in function of V clipping",800,600);
	gClip960mV->Draw("APEL");
	
	// Expected output FWHM
	
	TGraphErrors *gInput960mV = listOfGraphs->FindObject("sum trigger input ch5 960mV graph");
	
	Double_t *xClip = gClip960mV->GetX();
	Int_t nClip = gClip960mV->GetN();
	cout << "nClip = " << nClip << endl;
	Long64_t graphPoints = gInput960mV->GetN();
	yInput = gInput960mV->GetY();
	xInput = gInput960mV->GetX();
	
	vector<double> xFirst(nClip);
	vector<double> xLast(nClip);
	Double_t half;
	
	Int_t flag = 0;
//.........這裏部分代碼省略.........
開發者ID:matteodepalo,項目名稱:sum-trigger-board,代碼行數:101,代碼來源:AnalyzeClipping.C

示例11: addhistoEmc

void addhistoEmc(const char* list="list.txt", char *newname=0)
{
    // Add histograms from a set of files listed in file list
    // and write the result into a new file.

    char SumName[20];

    if (!newname) {
        sprintf(SumName,"Sum_All_Emc.root");
        newname=SumName;
        printf("\n  === Default output file name is %s ===\n",newname);
    }

    TFile *f=NULL;
    TH1F* hst[5][64][56];
    TH1F* hadd=NULL;
    char hnam[80];
    char htit[80];
    TList* hlist = 0;

    char fpath[80];
    int ifscanf=0;
    Int_t ifile=0;

    for(Int_t iMod=0; iMod<5; iMod++) {
        for(Int_t iX=0; iX<64; iX++) {
            for(Int_t iZ=0; iZ<56; iZ++) {
                sprintf(hnam,"%d_%d_%d",iMod,iX,iZ);
                sprintf(htit,"Two-gamma inv. mass for mod %d, cell (%d,%d)",iMod,iX,iZ);
                hst[iMod][iX][iZ] = new TH1F(hnam,htit,100,0.,300.);
            }
        }
    }

    TH1F*  hmgg = new TH1F("hmgg","2-cluster invariant mass",100,0.,300.);

    FILE* fd = fopen(list,"r");
    while( ifscanf = fscanf(fd,"%s",fpath) != EOF) {
        f=new TFile(fpath);
        hlist = (TList*)f->Get("histos");

        for(Int_t iList=0; iList<hlist->GetEntries(); iList++) {
            hadd = (TH1F*)hlist->At(iList);
            const char* str = hadd->GetName();
            int md,X,Z;
            if (sscanf(str,"%d_%d_%d",&md,&X,&Z)) {
                hst[md][X][Z]->Add(hadd);
                //printf("Added hst[%d][%d][%d]\n",md,X,Z);
            }
            else {
                printf("Trying to add histogram %s to hmgg.\n",hadd->GetName());
                hmgg->Add(hadd);
            }
        }

        printf("Deleting list..\n");
        hlist->Delete();
        printf("OK!\n");
        ifile++;

        printf("File %s processed.\n",fpath);
        if(f) delete f;
    }

    printf("%d processed.\n",ifile);

    TFile outfile(newname,"recreate");

    for(Int_t iMod=0; iMod<5; iMod++) {
        for(Int_t iX=0; iX<64; iX++) {
            for(Int_t iZ=0; iZ<56; iZ++) {
                if(hst[iMod][iX][iZ]->GetEntries()) hst[iMod][iX][iZ]->Print();
                hst[iMod][iX][iZ]->Write();
            }
        }
    }

    hmgg->Write();
    outfile.Close();
}
開發者ID:brettviren,項目名稱:ORKA-ILCRoot,代碼行數:80,代碼來源:addhistoEmc.C

示例12: add_periods

void add_periods(const char *newname, const char *perioddir)
{
	int i, j, K, N, L;
	char str[1024];
	TList *keys;
	TFile *fIn;
	TFile *f0;
	TSystemFile *fSys;
	char prefix[128];
	char *ptr;
	TNamed *obj;
	TH1D *h;
	TH1D *hist[MAXHIST];
	
	TSystemDirectory *dir = new TSystemDirectory("MyDir", perioddir);
	TList *files = dir->GetListOfFiles();
	if (!files) {
		printf("%s - nothing to do(files)\n", perioddir);
		delete dir;
		return;
	}
	N = files->GetEntries() - 2;
	if (N <= 1) {
		printf("%s - nothing to do\n", perioddir);
		delete dir;
		return;
	}
	
	TFile *fNew = new TFile(newname, "RECREATE");
	if (!fNew->IsOpen()) {
	    delete dir;
	    delete files;
	    return;
	}
	
	fSys = (TSystemFile *) files->At(2);
	if (!fSys) {
		printf("Can not open the first file\n");
		delete dir;
		delete files;
		return;
	}
	sprintf(str, "%s/%s", perioddir, fSys->GetName());
	f0 = new TFile(str);
	if (!f0->IsOpen()) {
		printf("Can not open the first file\n");
		delete dir;
		delete files;
		return;
	}
	keys = f0->GetListOfKeys();
	K = keys->GetEntries();
	if (K <= 0) {
		printf("Nothing to do: K=0\n");
		delete dir;
		delete files;
		return;
	}
	L = 0;
	for (j=0; j<K; j++) {
		obj = (TNamed *) keys->At(j);
		if (!obj) continue;
		obj = (TNamed *) f0->Get(obj->GetName());
		if (!obj) continue;
		if (strcmp(obj->ClassName(), "TH1D")) continue;
		hist[L] = (TH1D *)obj;
		L++;
	}
	if (!L) {
		printf("Nothing to do: L=0\n");
		f0->Close();
		delete dir;
		delete files;
		return;
	}
	
	for (i=1; i<N; i++) {
		fSys = (TSystemFile *) files->At(i+2);	// skip . and ..
		if (!fSys) continue;
		sprintf(str, "%s/%s", perioddir, fSys->GetName());
		fIn = new TFile(str);
		if (!fIn->IsOpen()) continue;
		for (j=0; j<L; j++) {
			h = (TH1D *) fIn->Get(hist[j]->GetName());
			if (!h) continue;
			hist[j]->Add(h);
		}
//		printf("%s\n", fSys->GetName());
		fIn->Close();
	}

	fNew->cd();
	for (j=0; j<L; j++) hist[j]->Write();
	fNew->Close();
	
	f0->Close();
	delete files;
	delete dir;
}
開發者ID:lab305itep,項目名稱:digi,代碼行數:99,代碼來源:add_periods.C

示例13: MakePlots

void MakePlots(TString filename, float zmax=30, int nSmooth=10, TString opt="", TString energy="8TeV", TString lumi=""){
  TString outDir=filename; outDir.Remove(outDir.Last('/')); outDir+="/img/"+opt;
  //outDir="tmp/k5b/";
  //std::map<TString, TH2F *> deltaNLL_map;
  
  /*------------------------------ Plotto */
  TCanvas *c = new TCanvas("c","c");
  
  TFile f_in(filename, "read");
  if(f_in.IsZombie()){
    std::cerr << "File opening error: " << filename << std::endl;
    return;
  }
  
  TList *KeyList = f_in.GetListOfKeys();
  std::cout << KeyList->GetEntries() << std::endl;
  for(int i =0; i <  KeyList->GetEntries(); i++){
    c->Clear();
    TKey *key = (TKey *)KeyList->At(i);
    if(TString(key->GetClassName())!="RooDataSet") continue;
    RooDataSet *dataset = (RooDataSet *) key->ReadObj();
    if(dataset==NULL){
      std::cerr << "[WARNING] No dataset for " << key->GetName() << "\t" << key->GetTitle() << std::endl;
      continue;
    }
    TString constTermName = dataset->GetName();
    TString alphaName=constTermName; alphaName.ReplaceAll("constTerm","alpha");

    if(constTermName.Contains("absEta_1_1.4442-gold")) continue;
    if(constTermName.Contains("rho") || constTermName.Contains("phi")) continue;
        if(constTermName.Contains("scale")) continue;
    TTree *tree = dataset2tree(dataset);
    TGraphErrors bestFit_ = bestFit(tree, alphaName, constTermName);
    //    TString binning="(241,-0.0005,0.2405,60,0.00025,0.03025)"; 
    TString binning="(241,-0.0005,0.2405,301,-0.00005,0.03005)"; 
    
    TH2F *hist = prof2d(tree, constTermName, alphaName, "nll", binning, true,nSmooth, opt);
//     std::cout << "Bin width = " << hist->GetXaxis()->GetBinWidth(10) << "\t" << hist->GetYaxis()->GetBinWidth(10) << std::endl; 
//     std::cout << "Bin 1 center = " << hist->GetXaxis()->GetBinCenter(1) << "\t" << hist->GetYaxis()->GetBinCenter(1) << std::endl; 
//     std::cout << "Bin 10 center = " << hist->GetXaxis()->GetBinCenter(10) << "\t" << hist->GetYaxis()->GetBinCenter(10) << std::endl; 
//     return;
    hist->Draw("colz");
    hist->GetZaxis()->SetRangeUser(0,zmax);
    hist->GetXaxis()->SetRangeUser(0,0.15);
    hist->GetYaxis()->SetRangeUser(0,0.018);

    hist->GetXaxis()->SetTitle("#Delta S");
    hist->GetYaxis()->SetTitle("#Delta C");

    Int_t iBinX, iBinY;
    Double_t x,y;
    hist->GetBinWithContent2(0.0002,iBinX,iBinY,1,-1,1,-1,0.0000001);
    x= hist->GetXaxis()->GetBinCenter(iBinX);
    y= hist->GetYaxis()->GetBinCenter(iBinY);
    std::cout << "Best Fit: " << x << "\t" << y << std::endl;
    TGraph nllBestFit(1,&x,&y);

    TString fileName=outDir+"/"+constTermName;
    fileName+="-"; fileName+=nSmooth;
    
    nllBestFit.SetMarkerStyle(3);
    nllBestFit.SetMarkerColor(kRed);
    nllBestFit.Draw("P same");

    std::cout << fileName << std::endl;
    ofstream fout(fileName+".dat", ios_base::app);
    fout << constTermName << "\t" << x << "\t" << y << std::endl;


    c->SaveAs(fileName+".png");
    c->SaveAs(fileName+".eps");
    if(fileName.Contains("constTerm")) c->SaveAs(fileName+".C");

    fileName+="-zoom";
    hist->GetZaxis()->SetRangeUser(0,1);
    //hist->GetXaxis()->SetRangeUser(0.00,0.12);
    //hist->GetYaxis()->SetRangeUser(0,0.005);
    c->SaveAs(fileName+".png");
    c->SaveAs(fileName+".eps");


//     hist->SaveAs(outDir+"/deltaNLL-"+constTermName+".root");
//     hist->Draw("colz");
//     bestFit_.Draw("P same");
//     bestFit_.SetMarkerSize(2);


    
//     nllBestFit.SetMarkerStyle(3);
//     nllBestFit.SetMarkerColor(kRed);
//     TList* contour68 = contourFromTH2(hist, 0.68);

//     hist->Draw("colz");
//     hist->GetZaxis()->SetRangeUser(0,zmax);
//     //bestFit_.Draw("P same");
//     nllBestFit.Draw("P same");
//     //contour68->Draw("same");
    delete hist;
    RooAbsPdf *histPdf = NULL;
    if(!opt.Contains("keys")){
//.........這裏部分代碼省略.........
開發者ID:J-C-Wright,項目名稱:ECALELF,代碼行數:101,代碼來源:mcmcDraw.C

示例14: addn2

void addn2() {

  // open existing f1:

  char* fn[99];
  int ni;

  // SR90 maps, mod D003

  ni = -1;
  ni++; fn[ni] = "SR90-map-00a.root";
  ni++; fn[ni] = "SR90-map-00b.root";
  ni++; fn[ni] = "SR90-map-01a.root";
  ni++; fn[ni] = "SR90-map-01b.root";
  ni++; fn[ni] = "SR90-map-02.root";
  ni++; fn[ni] = "SR90-map-03.root";
  ni++; fn[ni] = "SR90-map-05a.root";
  ni++; fn[ni] = "SR90-map-05b.root";
  ni++; fn[ni] = "SR90-map-07a.root";
  ni++; fn[ni] = "SR90-map-07b.root";
  ni++; fn[ni] = "SR90-map-07c.root";
  ni++; fn[ni] = "SR90-map-07d.root";

  // direct X-rays 9.4.2014 module D0003

  ni = -1;
  ni++; fn[ni] = "X-ray-20-modtd40000.root";
  ni++; fn[ni] = "X-ray-20-vthr60-modtd1000.root";
  ni++; fn[ni] = "X-ray-27-vthr60-modtd1000.root";
  ni++; fn[ni] = "X-ray-35-modtd40000.root";
  ni++; fn[ni] = "X-ray-35-vthr60-close-modtd65000.root";
  ni++; fn[ni] = "X-ray-35-vthr60-midpos-0p1mA-modtd10000.root";
  ni++; fn[ni] = "X-ray-35-vthr60-midpos-halfcur-modtd40000.root";
  ni++; fn[ni] = "X-ray-35-vthr60-modtd40000.root";

  int nmax = ni;

  TFile f1(fn[0]);

  if( f1.IsZombie() ) {
    cout << "Error opening " << fn[0] << endl;
    return;
  }
  cout << "opened " << fn[0] << endl;

  //--------------------------------------------------------------------
  // create f0:

  TFile f0("fileA.root", "RECREATE");
  cout << "created ";
  gDirectory->pwd();

  /*
  TFile options:  
  NEW or CREATE   create a new file and open it for writing,
                  if the file already exists the file is
                  not opened.
  RECREATE        create a new file, if the file already
                  exists it will be overwritten.
  UPDATE          open an existing file for writing.
                  if no file exists, it is created.
  READ            open an existing file for reading (default).
  NET             used by derived remote file access
                  classes, not a user callable option
  WEB             used by derived remote http access
                  class, not a user callable option
  "" (default), READ is assumed.
  */

  //--------------------------------------------------------------------
  // copy f1 to f0:

  f1.cd();

  cout << "keys:\n";
  f1.GetListOfKeys()->Print();

  cout << "pwd: ";
  f1.pwd();

  cout << "ls: \n";
  f1.ls();

  // f1 has sub-dir:

  cout << "First: " << f1.GetListOfKeys()->First()->GetName() << endl;
  cout << "First: " << f1.GetListOfKeys()->First()->ClassName() << endl;
  char* dir1 = f1.GetListOfKeys()->First()->GetName();
  cout << "cd to " << dir1 << endl;
  f1.cd( dir1 );
  cout << "we are in ";
  gDirectory->pwd();

  gDirectory->ReadAll(); // load histos

  TList * lst = gDirectory->GetList();
  cout << lst->GetName() << endl;
  cout << lst->GetTitle() << endl;
  cout << "size    " << lst->GetSize() << endl;
  cout << "entries " << lst->GetEntries() << endl;
//.........這裏部分代碼省略.........
開發者ID:andreavargas,項目名稱:Psi46testDesy,代碼行數:101,代碼來源:addn2.C

示例15: AnaPi0Select

void AnaPi0Select(const char* dataset="minbias_LHC09a4_81040_81050.xml")
{
    
    gSystem->Load("libTree");
    gSystem->Load("libGeom");
    gSystem->Load("libVMC");
    gSystem->Load("libPhysics");

    //load analysis framework
    gSystem->Load("libANALYSIS");
    gSystem->Load("libANALYSISalice"); //AliAnalysisTaskSE

    //Set local DB for PHOS
    gROOT->ProcessLine(".! tar xzvf PHOS.tgz") ;
    AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
    AliCDBManager::Instance()->SetSpecificStorage("PHOS/*","local://./");

    // A task can be compiled dynamically with AClic
    gROOT->LoadMacro("AliAnalysisTaskPi0CalibSelection.cxx+g");

    // Connect to alien
    TString token = gSystem->Getenv("GRID_TOKEN") ;
    if ( token == "OK" ) 
     TGrid::Connect("alien://");
    else 
     AliInfo("You are not connected to the GRID") ; 

    // Create the chain
    TChain* chain = new TChain("esdTree");
    TGridCollection * collection = dynamic_cast<TGridCollection*>(TAlienCollection::Open(dataset));
   
    TAlienResult* result = collection->GetGridResult("",0 ,0);
    TList* rawFileList = result->GetFileInfoList();

    for (Int_t counter=0 ; counter < rawFileList->GetEntries() ; counter++) {
     TFileInfo * fi =  static_cast<TFileInfo*>(rawFileList->At(counter)) ; 
     const char * rawFile = fi->GetCurrentUrl()->GetUrl() ;  
     printf("Processing %s\n", rawFile) ;
     chain->Add(rawFile);
     printf("Chain: %d entries.\n",chain->GetEntries()); 
    }

    // Make the analysis manager
    AliAnalysisManager *mgr = new AliAnalysisManager("Pi0CalibSelect","Pi0CalibSelection");

    // ESD input handler
    AliESDInputHandler* esdH = new AliESDInputHandler();
    mgr->SetInputEventHandler(esdH);

    // Debug level
    mgr->SetDebugLevel(10);

    // Add task
    AliAnalysisTaskPi0CalibSelection *task = new AliAnalysisTaskPi0CalibSelection("Pi0CalibSelection");
    task->SetClusterMinEnergy(0.4);
    mgr->AddTask(task);

    // Create containers for input/output
    AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
    AliAnalysisDataContainer *coutput = mgr->CreateContainer("histos",TList::Class(),AliAnalysisManager::kOutputContainer,"histos.root");

    // Connect input/output
    mgr->ConnectInput(task, 0, cinput);
    mgr->ConnectOutput(task, 1, coutput);

    if (mgr->InitAnalysis()) {
	     mgr->PrintStatus();
	     mgr->StartAnalysis("local", chain);
    }

}
開發者ID:ktf,項目名稱:AliRoot,代碼行數:71,代碼來源:AnaPi0Select.C


注:本文中的TList::GetEntries方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。