Пример #1
0
void
dumpToPDF(string inName, string fitName){
  TFile *fin = TFile::Open(inName.c_str(), "read"); assert(fin);


  string outName = inName;
  outName.replace(outName.find(".root"), 5, ".pdf");

  //fitName = "HLT_10LS_delivered_vs_rate_Run190949-191090.root";
  TFile *fFit = TFile::Open(fitName.c_str(), "read"); assert(fFit);

  TCanvas c1;
  c1.Print(Form("%s[", outName.c_str()), "pdf"); //Open .pdf

  //get list of keys
  int nplots = fin->GetNkeys(); 
  int nfits = fFit->GetNkeys(); 
  printf("nplots: %i, nfits: %i\n", nplots, nfits);
  if(nplots != nfits){
    cout<<" PDF output will be wrong since different number of triggers in fit and current run"<<endl;
    abort();
  }
  TList* plots = fin->GetListOfKeys();  
  TList* fits  = fFit->GetListOfKeys();
  for(int i=0; i<nplots; ++i){
    TKey* plot = (TKey*) plots->At(i);
    TKey* fit = (TKey*) fits->At(i);//assume they're in the same order for now

    if(!fin->GetKey(plot->GetName())){
      cout<<"Didn't find "<<plot<<". Removing."<<endl;
      abort();
    }
    if(!fFit->GetKey(fit->GetName())){
      cout<<"Didn't find "<<fit<<". Removing."<<endl;
      abort();
    }
    TCanvas* c = new TCanvas();
    c->Divide(1,2);

    TCanvas* cPlot = (TCanvas*) fin->Get(plot->GetName());
    c->cd(1);
    cPlot->DrawClonePad();

    TCanvas* cFit  = (TCanvas*) fFit->Get(fit->GetName());
    c->cd(2);
    cFit->DrawClonePad();

    string bookmarkName = "Title: ";
    bookmarkName += plot->GetName();

    c->Print(outName.c_str(), bookmarkName.c_str());
  }

  c1.Print(Form("%s]", outName.c_str()), "pdf"); //Close .pdf

}
Пример #2
0
void delay25macro(const int run) {

TFile * f = new TFile(Form("DATA/Run_%i/delay25.root",run));
TCanvas * c = new TCanvas("c","Delay25",1);
TCanvas * g = new TCanvas("g","Empty",1);

c->Divide(3,2);
c->Print(Form("DATA/Run_%i/delay25.ps[",run));

//Go into BPix dir
TDirectory *first_dir = BPix;
first_dir->cd();


//Go into the quadrant dir (BmI, BmO, BpI, BpO)
TList* list = first_dir->GetListOfKeys();
for (int i = 0; i < list->GetSize(); i++) 
{
	TKey *key = dynamic_cast<TKey*>(list->At(i));
	TObject* obj = key->ReadObj();
	if (obj->InheritsFrom("TDirectory")) 
	{
		TDirectory *curr_dir = dynamic_cast<TDirectory*>(obj);
		curr_dir->cd();

		//Go into sector dir
		TList* list1 = curr_dir->GetListOfKeys();
		for (int j = 0; j < list1->GetSize(); j++) 
		{
			TKey *key1 = dynamic_cast<TKey*>(list1->At(j));
			TObject* obj1 = key1->ReadObj();
			if(obj1->InheritsFrom("TDirectory"))
			{
				TDirectory *curr_dir1 = dynamic_cast<TDirectory*>(obj1);
				curr_dir1->cd();

				//Go into portcard dir
				TList* list2 = curr_dir1->GetListOfKeys();
				for (int k = 0; k < list2->GetSize(); k++) 
				{
					TKey *key2 = dynamic_cast<TKey*>(list2->At(k));
					TObject* obj2 = key2->ReadObj();
					if (obj2->InheritsFrom("TDirectory"))
					{
						TDirectory * curr_dir2 = dynamic_cast<TDirectory*>(obj2);
						curr_dir2->cd();
						
						
						//Get canvases
						int pad, counter = 0;
						TList* list3 = curr_dir2->GetListOfKeys();

						for (int k = 0; k < list3->GetSize(); k++) 
						{
							TKey *key3 = dynamic_cast<TKey*>(list3->At(k));
							TObject* obj3 = key3->ReadObj();
							g = (TCanvas *)obj3;
							if (k < 6)
							{
								//cout << "k = " << k << endl;
								pad = k+1;
								//cout << "Drawing to pad " << pad << endl;
							}
							if (k >=6 && k<12)
							{
								//cout << "k = " << k << endl;
								pad = k-5;
								//cout << "Drawing to pad " << pad << endl;
							}
							c->cd(pad);
							g->DrawClonePad();
							if (k == 5 || k == 11) 
							{
								c->Print(Form("DATA/Run_%i/delay25.ps",run));
								if (k == 5)
								{
									c->Clear();
									c->Divide(3,2);
								}
							}
						}
					}
				}
			}
		}
	}
}

c->Print(Form("DATA/Run_%i/delay25.ps]",run));

}