Exemplo n.º 1
0
prepDataFiles(){
//	TDirectory *theDr = (TDirectory*) myFile->Get("eleIDdir");///denom_pt/fit_eff_plots");
	//theDr->ls();
	int myIndex;	
	
	TSystemDirectory dir(thePath, thePath);
	TSystemFile *file;
	TString fname;
	TIter next(dir.GetListOfFiles());
	while ((file=(TSystemFile*)next())) {
		fname = file->GetName();
		if (fname.BeginsWith("TnP")&& fname.Contains("mc")) {
	
			ofstream myfile;

			TFile *myFile = new TFile(fname);
			TIter nextkey(myFile->GetListOfKeys());
			TKey *key;
			while (key = (TKey*)nextkey()) {
				TString theTypeClasse = key->GetClassName();
				TString theNomClasse = key->GetTitle();
				if ( theTypeClasse == "TDirectoryFile"){
					TDirectory *theDr = (TDirectory*) myFile->Get(theNomClasse);
					TIter nextkey2(theDr->GetListOfKeys());
					TKey *key2;
					while (key2 = (TKey*)nextkey2()) {
						TString theTypeClasse2 = key2->GetClassName();
						TString theNomClasse2 = key2->GetTitle();	
						myfile.open (theNomClasse2+".info");
						if ( theTypeClasse == "TDirectoryFile"){
							cout << "avant " << endl;
							TDirectory *theDr2 = (TDirectory*) myFile->Get(theNomClasse+"/"+theNomClasse2);
							cout << "apres " << endl;
							TIter nextkey3(theDr2->GetListOfKeys());
							TKey *key3;
							while (key3 = (TKey*)nextkey3()) {
								TString theTypeClasse3 = key3->GetClassName();
								TString theNomClasse3 = key3->GetTitle();	
								if ((theNomClasse3.Contains("FromMC"))) {

									TString localClasse3 = theNomClasse3;
									localClasse3.ReplaceAll("__","%");
									cout << "apres " << localClasse3 << endl;
									TObjArray* listBin = localClasse3.Tokenize('%');
									TString first = ((TObjString*)listBin->At(0))->GetString();
									TString second = ((TObjString*)listBin->At(2))->GetString();
									myfile << first;
									myfile << " " << second << " ";
									cout << "coucou la on va récupérer le rooFitResult " << endl;

									RooFitResult *theResults = (RooFitResult*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/"+theNomClasse3+"/fitresults");
									theResults->Print();
									RooArgList theParam = theResults->floatParsFinal();
									int taille = theParam.getSize();
									for (int m = 0 ; m < taille ; m++){
										cout << "m=" << m << endl;
									RooAbsArg *theArg = (RooAbsArg*) theParam.at(m);
									RooAbsReal *theReal = (RooAbsReal*) theArg;
										myfile << theReal->getVal() << " " ;
									}		
															
									myfile << "\n";

								}
							}
						}
						myfile.close();

					}
			
				}
			}
			delete myFile;
		}
	
	}

}
void Plotter(char* name1, char* name2, char* name3, char* name4, char* titlename){

setGraphTDR();

if(name1==NULL){

	printf("\nWarning: ");
	printf("the file ");
	printf(name1);
	printf(" does not exist \n\n");
	return;
	
}

else if(name2==NULL){

	printf("\nWarning: ");
	printf("the file ");
	printf(name2);
	printf(" does not exist \n\n");
	return;
}

else if(name3==NULL){

	printf("\nWarning: ");
	printf("the file ");
	printf(name3);
	printf(" does not exist \n\n");
	return;
}

else if(name4==NULL){

	printf("\nWarning: ");
	printf("the file ");
	printf(name4);
	printf(" does not exist \n\n");
	return;
	
}

else{

	TFile *f1= new TFile(name1);
	TFile *f2= new TFile(name2);
        TFile *f3= new TFile(name3);
        TFile *f4= new TFile(name4);

}

char *hName1 = new char [80];
char *hName2 = new char [80]; 
char *hName3 = new char [80];
char *hName4 = new char [80]; 	
char *filesave = new char[80];
char *filesave1 = new char[80];
char *filesave2 = new char[80];
char *filesave3 = new char[80];
char *filesave4 = new char[80];

f1->cd();
TIter nextkey1( f1->GetListOfKeys() );
TKey *key1;

f2->cd();
TIter nextkey2( f2->GetListOfKeys() );
TKey *key2;

f3->cd();
TIter nextkey3( f3->GetListOfKeys() );
TKey *key3;

f4->cd();
TIter nextkey4( f4->GetListOfKeys() );
TKey *key4;

int i=0;

    while ((key1 = (TKey*)nextkey1())) {

       key2 = (TKey*)nextkey2();
       key3 = (TKey*)nextkey3();
       key4 = (TKey*)nextkey4();

	// read object from source file
	TObject *obj1 = key1->ReadObj();
	TH1D *h1 = (TH1D*)obj1;

	// read object from source file
	TObject *obj2 = key2->ReadObj();
	TH1D *h2 = (TH1D*)obj2;

	// read object from source file
	TObject *obj3 = key3->ReadObj();
	TH1D *h3 = (TH1D*)obj3;

	// read object from source file
	TObject *obj4 = key4->ReadObj();
	TH1D *h4 = (TH1D*)obj4;

	hName1=h1->GetName();
      	hName2=h2->GetName();
       hName3=h3->GetName();
       hName4=h4->GetName();

        // General Style
        
        h1->GetXaxis()->SetTitleOffset(1.6);
        h1->GetYaxis()->SetTitleOffset(1.6);
        h1->GetZaxis()->SetTitleOffset(2.);
        h2->GetXaxis()->SetTitleOffset(1.6);
        h2->GetYaxis()->SetTitleOffset(1.6);
        h2->GetZaxis()->SetTitleOffset(2.);
        h3->GetXaxis()->SetTitleOffset(1.6);
        h3->GetYaxis()->SetTitleOffset(1.6);
        h3->GetZaxis()->SetTitleOffset(2.);
        h4->GetXaxis()->SetTitleOffset(1.6);
        h4->GetYaxis()->SetTitleOffset(1.6);
        h4->GetZaxis()->SetTitleOffset(2.);
        

        sprintf(filesave,"%s%s.png",h1->GetName(),titlename);
        std::string checkLog(obj1->GetName());


   if (h1->GetEntries() != 0 || h2->GetEntries() != 0 || h3->GetEntries() != 0 || h4->GetEntries() != 0){ // Defense

        if (obj1->IsA()->InheritsFrom("TH1") && obj2->IsA()->InheritsFrom("TH1") && obj3->IsA()->InheritsFrom("TH1") && obj4->IsA()->InheritsFrom("TH1")){
        
           TCanvas *togetherlog = new TCanvas("canvasSamelog","canvasSamelog");
           togetherlog->cd();     

           if ( checkLog == "pTJet1wc" || checkLog == "pTJet2wc" || checkLog == "pfetamaxwc" || checkLog == "pfetaminwc" || checkLog == "deltaEtaJetwc" || checkLog == "deltaPhiJetswc" || checkLog == "deltaPtJetswc"  || checkLog == "dijetMasswc" || checkLog == "pfetamaxwc" || checkLog == "pfetaminwc" || checkLog == "deltaEtaJetswc" || checkLog == "deltaPhiJetswc" || checkLog == "deltaPtJetswc"  || checkLog == "dijetMasswc" || checkLog == "pfetamaxwc" || checkLog == "pfetaminwc" || checkLog == "deltaEtaJetswc" || checkLog == "deltaPhiJetswc" || checkLog == "deltaPtJetswc" || checkLog == "RJJwc" || checkLog == "RJJwc"|| checkLog == "trackswc") {
           togetherlog->SetLogy();
           }           


           setGraphTDR();

           h1->SetMarkerStyle(20);
           h1->SetMarkerSize(1);
    
           h2->SetMarkerStyle(20);
           h2->SetMarkerSize(1);
           h2->SetMarkerColor(2);
        
           h3->SetMarkerStyle(20);
           h3->SetMarkerSize(1);
           h3->SetMarkerColor(3);

           h4->SetMarkerStyle(20);
           h4->SetMarkerSize(1);
           h4->SetMarkerColor(4);
           
           leg = new TLegend(0.71,0.89,0.989,0.989);
           leg->SetTextSize(0.020);
           leg->SetFillColor(0);
           gStyle->SetOptStat(0);
           leg->AddEntry(h1,"Pythia6 Z2","p");
           leg->AddEntry(h2,"Exume","p");
           leg->AddEntry(h3,"Pompty","p");
           leg->AddEntry(h4,"Data 2010","p");
                   
           //h1->SetFillColor(1);
           //h1->Sumw2();
           //h1->GetYaxis()->SetTitle("Probability");
           h1->Draw("PE");
           //h1->DrawNormalized("PE");

           //h2->SetFillColor(2);
           //h2->Sumw2();
           //h2->GetYaxis()->SetTitle("Probability");
           h2->Draw("SAMEPE");
           //h2->DrawNormalized("SAMEPE");

           //h3->SetFillColor(3);
           //h3->Sumw2();
           //h3->GetYaxis()->SetTitle("Probability");
           h3->Draw("SAMEPE");
           //h3->DrawNormalized("SAMEPE");
           leg->Draw();

           //h4->SetFillColor(3);
           //h4->Sumw2();
           //h4->GetYaxis()->SetTitle("Probability");
           h4->Draw("SAMEPE");
           //h4->DrawNormalized("SAMEPE");
           leg->Draw();
           
           togetherlog->Update();
           togetherlog->SaveAs(filesave);
           delete togetherlog;

        }

        if (obj1->IsA ()->InheritsFrom ("TH2") && obj2->IsA ()->InheritsFrom ("TH2") && obj3->IsA ()->InheritsFrom ("TH2") && obj4->IsA ()->InheritsFrom ("TH2")){
     

          if ( checkLog == "ETCaloswc" || checkLog == "ETCalosJetsAtTrackerwc" ){

               TCanvas *togetherLego = new TCanvas("canvasLego","canvasLego");
               gStyle->SetOptStat(1);

               h1->SetMarkerSize(0);
               h2->SetMarkerSize(0);
               h3->SetMarkerSize(0);
               h4->SetMarkerSize(0);

               //h1->GetZaxis()->SetTitle("Probability");
               //h2->GetZaxis()->SetTitle("Probability");
               //h3->GetZaxis()->SetTitle("Probability");
               //h4->GetZaxis()->SetTitle("Probability");

               h1->GetYaxis()->SetTitle("log_{10} Castor Signal [fC]");
               h2->GetYaxis()->SetTitle("log_{10} Castor Signal [fC]");
               h3->GetYaxis()->SetTitle("log_{10} Castor Signal [fC]");
               h4->GetYaxis()->SetTitle("log_{10} Castor Signal [fC]");

               togetherLego->cd();
               togetherLego->SetLogy(1);
               //h1->SetLineColor(1);
               h1->SetFillColor(1);
               h1->Draw("LEGO1E0");
               togetherLego->Update();
               sprintf(filesave1,"%s%s-data2010.png",h1->GetName(),titlename);
               togetherLego->SaveAs(filesave1);

               togetherLego->cd();
               togetherLego->SetLogy(1);
               //h2->SetLineColor(2);
               h2->SetFillColor(2);
               h2->Draw("LEGO1E0");
               togetherLego->Update();
               sprintf(filesave2,"%s%s-exume2010.png",h2->GetName(),titlename);
               togetherLego->SaveAs(filesave2);  

               togetherLego->cd();
               togetherLego->SetLogy(1);
               //h3->SetLineColor(3);
               h3->SetFillColor(3);
               h3->Draw("LEGO1E0");
               togetherLego->Update();
               sprintf(filesave3,"%s%s-pompty2010.png",h3->GetName(),titlename);
               togetherLego->SaveAs(filesave3);   

               togetherLego->cd();
               togetherLego->SetLogy(1);
               //h4->SetLineColor(3);
               h4->SetFillColor(4);
               h4->Draw("LEGO1E0");
               togetherLego->Update();
               sprintf(filesave4,"%s%s-pythia62010.png",h4->GetName(),titlename);
               togetherLego->SaveAs(filesave4);           

               delete togetherLego;

          }
        
          else {

          TCanvas *togetherLegoAll = new TCanvas("canvasLegoAll","canvasLegoAll",1200,400);
          togetherLegoAll->Divide(4,1);

          setGraphTDR();
          //setTH2();   
          h1->SetMarkerSize(0);
          h2->SetMarkerSize(0);
          h3->SetMarkerSize(0);
          h4->SetMarkerSize(0);       

          leg2 = new TLegend(0.71,0.89,0.989,0.989);
          leg2->SetTextSize(0.020);
          leg2->SetFillColor(0);
          leg2->AddEntry(h1,"Pythia6 Z2","f");
          leg2->AddEntry(h2,"Exume","f");
          leg2->AddEntry(h3,"Pompty","f");
          leg2->AddEntry(h4,"Data 2010","f");

          //h1->GetZaxis()->SetTitle("Probability");
          //h2->GetZaxis()->SetTitle("Probability");
          //h3->GetZaxis()->SetTitle("Probability");
          //h4->GetZaxis()->SetTitle("Probability");

          h1->GetYaxis()->SetTitle("nHF^{-}");
          h2->GetYaxis()->SetTitle("nHF^{-}");
          h3->GetYaxis()->SetTitle("nHF^{-}");
          h4->GetYaxis()->SetTitle("nHF^{-}");

          togetherLegoAll->cd(1);
          h1->SetFillColor(1);
          h1->Draw("LEGO1E0");

          togetherLegoAll->cd(2);
          h2->SetFillColor(2);
          h2->Draw("LEGO1E0"); 

          togetherLegoAll->cd(3);
          h3->SetFillColor(3);
          h3->Draw("LEGO1E0");

          togetherLegoAll->cd(4);
          h4->SetFillColor(4);
          h4->Draw("LEGO1E0");

          //leg2->Draw();
          togetherLegoAll->Update();
          togetherLegoAll->SaveAs(filesave);
          delete togetherLegoAll;

          }
 
       }

       i++;

   } // if defense
       
  }

printf("\nNumber of Plots: %d\n\n",i);
       

}
Exemplo n.º 3
0
recupTheZpeak(){
//	TDirectory *theDr = (TDirectory*) myFile->Get("eleIDdir");///denom_pt/fit_eff_plots");
	//theDr->ls();
	int myIndex;	
	
	TSystemDirectory dir(thePath, thePath);
	TSystemFile *file;
	TString fname;
	TIter next(dir.GetListOfFiles());
	while ((file=(TSystemFile*)next())) {
		fname = file->GetName();
		if (fname.BeginsWith("TnP")) {
			if (fname.Contains("data")) kind = "data";
			else kind = "mc";
			bool pass = false;
			for (int p = 0 ; p< nbOfIds ; p++){
				if (fname.Contains(thePlotToDraw[p])) {
					pass = true;				 
					theIndex = p;
					break;
				}
			}
			if (!(pass)) continue;
			TFile *myFile = new TFile(fname);
			TIter nextkey(myFile->GetListOfKeys());
			TKey *key;
			while (key = (TKey*)nextkey()) {
				TString theTypeClasse = key->GetClassName();
				TString theNomClasse = key->GetTitle();
				if ( theTypeClasse == "TDirectoryFile"){
					TDirectory *theDr = (TDirectory*) myFile->Get(theNomClasse);
					TIter nextkey2(theDr->GetListOfKeys());
					TKey *key2;
					while (key2 = (TKey*)nextkey2()) {
						TString theTypeClasse2 = key2->GetClassName();
						TString theNomClasse2 = key2->GetTitle();	
						if ( theTypeClasse == "TDirectoryFile"){
							TDirectory *theDr2 = (TDirectory*) myFile->Get(theNomClasse+"/"+theNomClasse2);
							TIter nextkey3(theDr2->GetListOfKeys());
							TKey *key3;
							while (key3 = (TKey*)nextkey3()) {
								TString theTypeClasse3 = key3->GetClassName();
								TString theNomClasse3 = key3->GetTitle();	
								if (((theNomClasse3.Contains("vpvPlusExpo"))||(theNomClasse3.Contains("higgsSF")))&&(!(theNomClasse3.Contains("all")))) {
									TCanvas *theCanvas = (TCanvas*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/"+theNomClasse3+"/fit_canvas");
									theCanvas->Print(outputDir+"/"+kind+"_"+theName[theIndex]+"__"+theNomClasse3+".png");
									
								}
							}
						}

					}
			
				}
			}
			delete myFile;
		}
	
	}

}
void recupThePlots(){
//	TDirectory *theDr = (TDirectory*) myFile->Get("eleIDdir");///denom_pt/fit_eff_plots");
	//theDr->ls();
	cout << "coucou" << theOutFileName << endl;
	
	TFile *myOutFile = new TFile(theOutFileName,"RECREATE");
	
	TSystemDirectory dir(thePath, thePath);
	TSystemFile *file;
	TString fname;
	TIter next(dir.GetListOfFiles());
	while (((file=(TSystemFile*)next()))) {
		fname = file->GetName();
		if ((fname.BeginsWith("TnP"))&&fname.Contains("data")) {
                        cout <<  "--------------------"<< "\n";
                        cout << fname << "\n";
			TFile *myFile = new TFile(fname);
			TIter nextkey(myFile->GetListOfKeys());                   
			TKey *key;
			while ((key = (TKey*)nextkey())) {
                                // cout << key << "\n";
				TString theTypeClasse = key->GetClassName();
				TString theNomClasse = key->GetTitle();
                                   cout << "theTypeClasse:  "<< theTypeClasse << " ,  " << theNomClasse << "\n";
				if ( theTypeClasse == "TDirectoryFile" ){
                                        //    cout << "we are here 1" << "\n";
					TDirectory *theDr = (TDirectory*) myFile->Get(theNomClasse);
					TIter nextkey2(theDr->GetListOfKeys());
					TKey *key2;
					while ((key2 = (TKey*)nextkey2())) {
						TString theTypeClasse2 = key2->GetClassName();
						TString theNomClasse2 = key2->GetTitle();	
						if ( theTypeClasse == "TDirectoryFile" || theTypeClasse == "TGraphAsymmErrors" ){
							TDirectory *theDr2 = (TDirectory*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/fit_eff_plots");
							TIter nextkey3(theDr2->GetListOfKeys());
							TKey *key3;
							while ((key3 = (TKey*)nextkey3())) {
								TString theTypeClasse3 = key3->GetClassName();
								TString theNomClasse3 = key3->GetName();	
				 				cout << "type = " << theTypeClasse3 << " nom = " << theNomClasse3 << endl;
						
								TCanvas *theCanvas = (TCanvas*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/fit_eff_plots/"+theNomClasse3);
								TIter nextObject(theCanvas->GetListOfPrimitives());
								TObject *obj;
								while ((obj = (TObject*)nextObject())) {
									if (obj->InheritsFrom("TGraphAsymmErrors")) {
					        				cout << "histo: " << obj->GetName() << endl;
										myOutFile->cd();
										obj->Write(theNomClasse2+"_"+theNomClasse3);
										myFile->cd();
									}
									if (obj->InheritsFrom("TH2F")) {
										cout << "the TH2F = " << obj->GetName() << endl;
										myOutFile->cd();
										obj->Write(theNomClasse2+"_"+theNomClasse3);
										myFile->cd();
									}
								}
							}
						}

					}
			
				}
			}
			delete myFile;
		}
	
	}
	myOutFile->Close();

}
Exemplo n.º 5
0
void presyst(TString s) {
    TFile * fin = TFile::Open("graphs_"+ s +".root");
    TList * l = fin->GetListOfKeys();
    TCanvas C("C", "C", 3, 58, 1185, 658);
    C.Divide(3,1);
    TGraphAsymmErrors * gra = 0;
    TGraphErrors * gr = 0;
    //Loop for line
    Int_t I = 0;
    TKey *key3;
    TIter nextkey3(fin->GetListOfKeys());
    while ((key3 = (TKey*) nextkey3())) {
        const char *classname = key3->GetClassName();
        TClass *cl = gROOT->GetClass(classname);
        if (!cl) continue;
        if (!cl->InheritsFrom(TGraphAsymmErrors::Class()))
            continue;
        gra = (TGraphAsymmErrors*) fin->Get(key3->GetName());
        C.cd(I + 1);
        gra->Draw("alp");
        I++;
    }
    
    TKey *key;
    TIter nextkey(fin->GetListOfKeys());
    //Loop for stat uncertainty
    Int_t nStat = 0;
    I = 0;
    while ((key = (TKey*) nextkey())) {
        const char *classname = key->GetClassName();
        TClass *cl = gROOT->GetClass(classname);
        if (!cl) continue;
        if (cl->InheritsFrom(TGraphAsymmErrors::Class()))
            continue;
        nStat++;
        gr = (TGraphErrors*) fin->Get(key->GetName());
        gr->SetMarkerColor(kRed);
        gr->SetLineWidth(2);
        gr->SetLineColor(kBlue);
        C.cd(I + 1);
        gr->Draw("p");
        I++;
    }

    //Loop for syst uncertainty
    I = 0;
    TKey *key2;
    TIter nextkey2(fin->GetListOfKeys());

    while ((key2 = (TKey*) nextkey2())) {
        const char *classname = key2->GetClassName();
        TClass *cl = gROOT->GetClass(classname);
        if (!cl) continue;
        if (!cl->InheritsFrom(TGraphAsymmErrors::Class()))
            continue;
        gra = (TGraphAsymmErrors*) fin->Get(key2->GetName());
        gra->SetMarkerColor(kRed);
        gra->SetLineWidth(2);
        gra->SetLineColor(kGreen);
        //        gra->SetLineStyle(kDashed);
        gra->SetMarkerStyle(4);
        C.cd(I + 1);
        gra->Draw("p|>");
        I++;
    }

    C.SaveAs(s + "_figs.gif");
}
Exemplo n.º 6
0
void combinePreFullTests( string rootFullName, string rootPreTest, string rootOutputName)
{

  // open output file 
  TFile *_fileSave = TFile::Open( rootOutputName.c_str(), "new" );
  // open existing files
  TFile * fileFullTest = TFile::Open( rootFullName.c_str(),"read" );  
  TFile * filePreTest = TFile::Open( rootPreTest.c_str(),"read" );

  fileFullTest->cd();
  if( ! fileFullTest ) continue;
  
  TIter nextkey( gDirectory->GetListOfKeys() );
  TKey * key;

  cout << "Copy Subdirectory/histograms from " << fileFullTest->GetName() << endl;
  cout << "into the file: " << _fileSave->GetName() << endl;

  while( ( key = (TKey*)nextkey() ) ) {
    
    TObject * obj = key->ReadObj();
    if (obj->IsA()->InheritsFrom( "TDirectory" )){
      cout << "----- Subdir " << obj->GetName() <<  "  " << obj->GetUniqueID() << endl;
      // create same structure
      _fileSave->mkdir(obj->GetName());
      
      // loop over all histograms in subdirectory
      fileFullTest->cd(obj->GetName());
      TIter nextkey2( gDirectory->GetListOfKeys() );
      TKey * key2;
       
      string objName = obj->GetName(); 
      if (objName.substr(0,3) == "BB2"){
	cout << "for Subdirectory BB2 in file " << fileFullTest->GetName() << " do nothing"  << endl;
      }
      else{
	while( ( key2 = (TKey*)nextkey2() ) ) {
	  _fileSave->cd();	
	  TObject * obj2 = key2->ReadObj();
	  
	  if( obj2->IsA()->InheritsFrom( "TH2D" )) {
	    //cout << "2d histograms " << obj2->GetName() << endl;
	    TH2D * h2 = (TH2D*)obj2;	  
	    _fileSave->cd(obj->GetName());
	    h2->Write();	  
	  }
	  else if ( obj2->IsA()->InheritsFrom( "TH1D" )) {	  
	    //cout << "1d histograms " << obj2->GetName() << endl;
	    TH1D * h1 = (TH1D*)obj2;
	    _fileSave->cd(obj->GetName());
	    h1->Write();	  
	  }	
	}
      } // do not save BB2 from Fulltest but from next file
      // here please save BB2 to final file

    }
    else{
      // store Histograms which are not in a subdirectory HA and HD
      _fileSave->cd();
      if ( obj->IsA()->InheritsFrom( "TH1D" )) {	  
	//cout << "1d histograms " << obj->GetName() << endl;
	TH1D * h1 = (TH1D*)obj;
	_fileSave->cd();
	h1->Write();	  
      }	
      //cout << obj->GetName() <<  " this is a histogram " << endl;
    }

  }

  // Now use BB2 from Pretest and store it in the outputfile _fileSave

  if( ! filePreTest ) continue;

  filePreTest->cd();
  filePreTest->cd("BB2");
  cout << "copy BB2 histograms from file " << filePreTest->GetName() << " into " << _fileSave->GetName() << endl;
 
  TIter nextkey3( gDirectory->GetListOfKeys() );
  TKey * key3;
  while( ( key3 = (TKey*)nextkey3() ) ) {    
    TObject * obj3 = key3->ReadObj();
    if( obj3->IsA()->InheritsFrom( "TH2D" )) {
      //cout << "2d histograms " << obj3->GetName() << endl;
      TH2D * h2 = (TH2D*)obj3;	  
      _fileSave->cd("BB2");
      h2->Write();	  
    }
    else if ( obj3->IsA()->InheritsFrom( "TH1D" )) {	  
      //cout << "1d histograms " << obj3->GetName() << endl;
      TH1D * h1 = (TH1D*)obj3;
      _fileSave->cd("BB2");
      h1->Write();	  
    }
    //cout << "----- " << obj3->GetName() << endl;
  }


  fileFullTest->Close();
  filePreTest->Close();
  _fileSave->Close();

}