Пример #1
0
TDirectory* fileDirectory( TDirectory *target, std::string s) 
{
    TDirectory *retval = 0;

    // loop over all keys in this directory
    TIter nextkey(target->GetListOfKeys());
    TKey *key, *oldkey=0;
    while((key = (TKey*)nextkey())) 
    {
	//keep only the highest cycle number for each key
	if (oldkey && !strcmp(oldkey->GetName(),key->GetName())) continue;

	// read object from file
	target->cd();
	TObject *obj = key->ReadObj();
	
	if(obj->IsA()->InheritsFrom(TDirectory::Class())) 
	{
	    // it's a subdirectory
	    //cout << "Found subdirectory " << obj->GetName() << endl;
	    if(strcmp(s.c_str(), obj->GetName()) == 0) return (TDirectory*)obj;
	    
	    if((retval = fileDirectory((TDirectory*)obj, s))) break;
	    
	}
	else break;
    }
    return retval;
}
Пример #2
0
int
main(int argc, const char** argv) {
  CCommandLine arguments;
  arguments.ParseArgumentVector(argc, argv);
  deque<string> sourceFiles;
  string classPathString;
  CFilePath* classDestinationBase = 0;
  bool dependMode = false;

  if (arguments.GetArgumentCount() < 1) {
    SyntaxAbort(arguments.GetCommand());
  }
  for (CCommandLine::ArgumentIteratorType arg = arguments.GetArgumentBegin();
       arg != arguments.GetArgumentEnd(); ++arg) {
    unsigned long optionLength = (*arg).length();
    if (*arg == "-classpath") {
      ++arg;
      if (arg == arguments.GetArgumentEnd()) {
	SyntaxAbort(arguments.GetCommand());
      } else {
	classPathString = *arg;
      }
    } else if (*arg == "-version") {
      cerr << "guavac version " << VERSION << endl;
    } else if (*arg == "-M") {
      dependMode = true;
    } else if (*arg == "-d") {
      ++arg;
      if (arg == arguments.GetArgumentEnd()) {
	SyntaxAbort(arguments.GetCommand());
      } else {
	delete classDestinationBase;
	classDestinationBase = new CFilePath(*arg);
	if (!classDestinationBase->IsDirectory()) {
	  cerr << ">> Invalid destination directory: " << *arg << endl;
	  delete classDestinationBase;
	  classDestinationBase = 0;
	}
      }
    } else if (optionLength > 0 && (*arg)[0] == '-') {
      cerr << ">> Invalid compiler flag: " << *arg << endl;
      SyntaxAbort(arguments.GetCommand());
    } else {
      CFilePath filePath(*arg);
      if (!filePath.IsFile()) {
	cerr << ">> Invalid argument (not a plain file): " << *arg << endl;
	SyntaxAbort(arguments.GetCommand());
      } else if (optionLength < kSourceSuffix.length() ||
		 (*arg).compare(".java",
				optionLength - kSourceSuffix.length()) != 0) {
	cerr << ">> Invalid source file (no .java suffix): " << *arg << endl;
	SyntaxAbort(arguments.GetCommand());
      } else {
	sourceFiles.push_back(*arg);
      }
    }
  }
  if (classPathString.size() == 0) {
    const char* classPathEnvironment = getenv("CLASSPATH");
    if (classPathEnvironment == 0) {
      classPathString = DEFAULT_CLASSPATH;
    } else {
      classPathString = classPathEnvironment;
    }
  }
  if (sourceFiles.size() == 0) {
    cerr << ">> No valid source file names given." << endl;
    exit(1);
  }
  deque<string> classPath;
  if (! ParseClassPath(classPathString, classPath)) {
    cerr << ">> Invalid class path: " << classPathString << endl;
    exit(1);
  }
  bool success = true;
  for (deque<string>::const_iterator sourceIterator = sourceFiles.begin();
       success && !(sourceIterator == sourceFiles.end()); ++sourceIterator) {
    string fileName = *sourceIterator;
    string::size_type lastSlash = fileName.find_last_of('/');
    if (lastSlash == string::npos) {
      lastSlash = 0;
    } else {
      lastSlash++;
    }
    string fileDirectory(fileName, 0, lastSlash);
    CCompiler::ClassList resultClasses;
    deque<string> depends;
    success &= 
      CCompiler::CompileFile(fileName, classPath, resultClasses, depends);
    if (success) {
      if (!dependMode) {
	cout << "Compilation Successful.  Classes/interfaces found:" << endl;
      }
      for (CCompiler::ClassList::iterator i = resultClasses.begin();
	   i != resultClasses.end(); ++i) {
	string className = ::UnicodeToString((*i)->GetShortName());
	string outFileName;
	if (classDestinationBase == 0) {
	  outFileName = fileDirectory + className + ".class";
	} else {
	  outFileName = classDestinationBase->GetString() + "/" +
	    ::UnicodeToString((*i)->GetClassName()) + ".class";
	}
	if (dependMode) {
	  cout << outFileName << ":";
	  for (deque<string>::iterator iter = depends.begin();
	       !(iter == depends.end()); ++iter) {
	    cout << " \\\n        " << *iter;
	  }
	  cout << endl;
	} else if (MakeDirectories(outFileName)) {
	  ofstream outFile;
	  outFile.open(outFileName.c_str(), ios::out | ios::bin | ios::trunc);
	  if (!outFile.is_open()) {
	    cerr << ">> could not open output file " << outFileName << endl;
	  } else {
	    if (!(*i)->IsInner()) {
	      cout << " *  " << className << endl;
	    }
	    (*i)->Compile(outFile);
	    outFile.close();
	  }
	}
      }
    } else {
      cerr << "Compilation Failed" << endl;
    }
    for (CCompiler::ClassList::iterator i = resultClasses.begin();
	 i != resultClasses.end(); ++i) {
      delete *i;
    }
  }
  return success ? 0 : 1;
}
Пример #3
0
void SinglePi(const TString ref_vers, const TString val_vers, bool fastsim){

    //Warning!!! This rootlogon hacks the root color pallate
   setColors();

   TString ref_file = "pi50scan"+ref_vers+"_fullGeom_ECALHCAL_CaloTowers.root";
   TString val_file = "pi50scan"+val_vers+"_fullGeom_ECALHCAL_CaloTowers.root";
      
   TFile f1(ref_file);
   TFile f2(val_file);
   
   // service variables
   //
   //Profiles
   const int Nprof   = 12;

   TProfile* f1_prof[Nprof];
   TProfile* f2_prof[Nprof];

   char labelp[Nprof][64];

   //1D Histos
   const int Nhist1  = 7;

   TH1* f1_hist1[Nhist1];
   TH1* f2_hist1[Nhist1];

   char label1[Nhist1][64];

   //Labels
   //Profiles
   sprintf(labelp[0], "CaloTowersTask_emean_vs_ieta_E1.gif");
   sprintf(labelp[1], "CaloTowersTask_emean_vs_ieta_H1.gif");
   sprintf(labelp[2], "CaloTowersTask_emean_vs_ieta_EH1.gif");

   sprintf(labelp[3], "RecHitsTask_emean_vs_ieta_E.gif");
   sprintf(labelp[4], "RecHitsTask_emean_vs_ieta_H.gif");
   sprintf(labelp[5], "RecHitsTask_emean_vs_ieta_EH.gif");
   if (!fastsim) {
       sprintf(labelp[6], "SimHitsTask_emean_vs_ieta_E.gif");
       sprintf(labelp[7], "SimHitsTask_emean_vs_ieta_H.gif");
       sprintf(labelp[8], "SimHitsTask_emean_vs_ieta_EH.gif");
   }
   sprintf(labelp[9], "RecHitsTask_timing_vs_energy_profile_HB.gif");
   sprintf(labelp[10], "RecHitsTask_timing_vs_energy_profile_HE.gif");
   sprintf(labelp[11], "RecHitsTask_timing_vs_energy_profile_HF.gif");



   //1D Histos
   sprintf(label1[0], "N_calotowers_HB.gif");
   sprintf(label1[1], "N_calotowers_HE.gif");
   sprintf(label1[2], "N_calotowers_HF.gif");
   
   sprintf(label1[3], "RecHits_energy_HB.gif");
   sprintf(label1[4], "RecHits_energy_HE.gif");
   sprintf(label1[5], "RecHits_energy_HO.gif");
   sprintf(label1[6], "RecHits_energy_HF.gif");

   TDirectory *td = fileDirectory(&f1, "CaloTowersTask");
   //f1.cd("DQMData/CaloTowersV/CaloTowersTask");
   //gDirectory->pwd();
   td->pwd();
   f1_prof[0] = (TProfile*)td->Get("emean_vs_ieta_E1");
   f1_prof[1] = (TProfile*)td->Get("emean_vs_ieta_H1");
   f1_prof[2] = (TProfile*)td->Get("emean_vs_ieta_EH1");

   f1_hist1[0] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HB");
   f1_hist1[1] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HE");
   f1_hist1[2] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HF");

   td = fileDirectory(&f1, "HcalRecHitTask");
   //f1.cd("DQMData/HcalRecHitsV/HcalRecHitTask");
   f1_prof[3] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E");
   f1_prof[4] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths");
   f1_prof[5] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH");

   f1_prof[9] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_HB");
   f1_prof[10] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HE");
   f1_prof[11] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HF");

   f1_hist1[3] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HB");
   f1_hist1[4] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HE");
   f1_hist1[5] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HO");
   f1_hist1[6] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HF");   

   if (!fastsim) {
       td = fileDirectory(&f1, "HcalSimHitTask");
       //f1.cd("DQMData/HcalSimHitsV/HcalSimHitTask");
       f1_prof[6] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_E");
       f1_prof[7] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths");
       f1_prof[8] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_EH");
   }

   td = fileDirectory(&f2, "CaloTowersTask");
   //f2.cd("DQMData/CaloTowersV/CaloTowersTask");
   //gDirectory->pwd();
   td->pwd();
   f2_prof[0] = (TProfile*)td->Get("emean_vs_ieta_E1");
   f2_prof[1] = (TProfile*)td->Get("emean_vs_ieta_H1");
   f2_prof[2] = (TProfile*)td->Get("emean_vs_ieta_EH1");

   f2_hist1[0] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HB");
   f2_hist1[1] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HE");
   f2_hist1[2] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HF");

   td = fileDirectory(&f2, "HcalRecHitTask");
   //f2.cd("DQMData/HcalRecHitsV/HcalRecHitTask");
   f2_prof[3] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E");
   f2_prof[4] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths");
   f2_prof[5] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH");

   f2_prof[9] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_HB");
   f2_prof[10] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HE");
   f2_prof[11] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HF"); 

   f2_hist1[3] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HB");
   f2_hist1[4] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HE");
   f2_hist1[5] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HO");
   f2_hist1[6] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HF");

   if (!fastsim) {
       td = fileDirectory(&f2, "HcalSimHitTask");
       //f2.cd("DQMData/HcalSimHitsV/HcalSimHitTask");
       f2_prof[6] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_E");
       f2_prof[7] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths");
       f2_prof[8] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_EH");
   }

   //Profiles
   f1_prof[0]->GetXaxis()->SetTitle("CaloTowers eE (GeV) vs ieta 1 Tower");
   f1_prof[1]->GetXaxis()->SetTitle("CaloTowers hE (GeV) vs ieta 1 Tower");
   f1_prof[2]->GetXaxis()->SetTitle("CaloTowers eE+hE (GeV) vs ieta 1 Tower");
   f1_prof[3]->GetXaxis()->SetTitle("RecHits eE (GeV) vs ieta R = 0.3 Cone");
   f1_prof[4]->GetXaxis()->SetTitle("RecHits hE (GeV) vs ieta R = 0.3 Cone");
   f1_prof[5]->GetXaxis()->SetTitle("RecHits eE+hE (GeV) vs ieta R = 0.3 Cone");
   if (!fastsim) {
     f1_prof[6]->GetXaxis()->SetTitle("SimHits eE (GeV) vs ieta R = 0.3 Cone");
     f1_prof[7]->GetXaxis()->SetTitle("SimHits hE (GeV) vs ieta R = 0.3 Cone");
     f1_prof[8]->GetXaxis()->SetTitle("SimHits eE+hE (GeV) vs ieta R = 0.3 Cone");
   }
   f1_prof[9]->GetXaxis()->SetTitle("HB RecHits timing (ns) vs Energy (GeV)");
   f1_prof[10]->GetXaxis()->SetTitle("HE RecHits timing (ns) vs Energy (GeV)");
   f1_prof[11]->GetXaxis()->SetTitle("HF RecHits timing (ns) vs Energy (GeV)");


   //1D Histos
   f1_hist1[0]->GetXaxis()->SetTitle("Number of HB CaloTowers");
   f1_hist1[1]->GetXaxis()->SetTitle("Number of HE CaloTowers");
   f1_hist1[2]->GetXaxis()->SetTitle("Number of HF CaloTowers");

   f1_hist1[3]->GetXaxis()->SetTitle("HB RecHits energy (GeV)");
   f1_hist1[4]->GetXaxis()->SetTitle("HE RecHits energy (GeV)");
   f1_hist1[5]->GetXaxis()->SetTitle("HO RecHits energy (GeV)");
   f1_hist1[6]->GetXaxis()->SetTitle("HF RecHits energy (GeV)");

   //
   f1_prof[0]->SetMaximum(20.);
   f1_prof[1]->SetMaximum(40.);
   f1_prof[2]->SetMaximum(40.);
   f1_prof[4]->SetMaximum(50.);
   f1_prof[5]->SetMaximum(50.);

   f1_prof[0]->SetMinimum(0.);
   f1_prof[1]->SetMinimum(0.);
   f1_prof[2]->SetMinimum(0.);
   f1_prof[3]->SetMinimum(0.);
   f1_prof[4]->SetMinimum(0.);
   f1_prof[5]->SetMinimum(0.);

   if (!fastsim) {
     f1_prof[6]->SetMinimum(0.);
     f1_prof[7]->SetMinimum(0.);
     f1_prof[8]->SetMinimum(0.);
   }

   f1_prof[9]->GetXaxis()->SetRangeUser(0.,75.);
   f1_prof[10]->GetXaxis()->SetRangeUser(0.,75.);
   f1_prof[11]->GetXaxis()->SetRangeUser(0.,75.);

   /* 
   f1_prof[9]->SetMinimum(0.);
   f1_prof[10]->SetMinimum(0.);
   f1_prof[11]->SetMinimum(0.);
   */



   // f1_hist[2]->GetXaxis()->SetRangeUser(0.,1200.);
   // f1_hist[7]->GetXaxis()->SetRangeUser(0.,160.);
   // hist1->GetXaxis()->SetNdivisions(-21);
   // hist1->GetYaxis()->SetNdivisions(-1003);

   f1_hist1[0]->GetXaxis()->SetRangeUser(0.,100.);
   f2_hist1[0]->GetXaxis()->SetRangeUser(0.,100.);

   f1_hist1[1]->GetXaxis()->SetRangeUser(0.,150.);
   f2_hist1[1]->GetXaxis()->SetRangeUser(0.,150.);

   f1_hist1[2]->GetXaxis()->SetRangeUser(0.,100.);
   f2_hist1[2]->GetXaxis()->SetRangeUser(0.,100.);

   f1_hist1[3]->GetXaxis()->SetRangeUser(0.,100.);
   f2_hist1[3]->GetXaxis()->SetRangeUser(0.,100.);

   f1_hist1[4]->GetXaxis()->SetRangeUser(0.,100.);
   f2_hist1[4]->GetXaxis()->SetRangeUser(0.,100.);

   f1_hist1[5]->GetXaxis()->SetRangeUser(0.,100.);
   f2_hist1[5]->GetXaxis()->SetRangeUser(0.,100.);

   f1_hist1[6]->GetXaxis()->SetRangeUser(0.,100.);
   f2_hist1[6]->GetXaxis()->SetRangeUser(0.,100.);

   f1_hist1[3]->SetMaximum(1.e8);
   f1_hist1[4]->SetMaximum(1.e8);
   f1_hist1[5]->SetMaximum(1.e8);
   f1_hist1[6]->SetMaximum(1.e8);



   //  1D-histo

   for (int i = 0; i < Nhist1; i++){

     TCanvas *myc = new TCanvas("myc","",800,600);
     gStyle->SetOptStat(1111);

     if(i > 2) myc->SetLogy();
     
     f1_hist1[i]->SetStats(kTRUE);   // stat box  
     f2_hist1[i]->SetStats(kTRUE);  

     f1_hist1[i]->SetTitle("");
     f2_hist1[i]->SetTitle("");
     
     f1_hist1[i]->SetLineWidth(2); 
     f2_hist1[i]->SetLineWidth(2); 
     
     // diffferent histo colors and styles
     f1_hist1[i]->SetLineColor(41);
     f1_hist1[i]->SetLineStyle(1); 
     
     f2_hist1[i]->SetLineColor(43);
     f2_hist1[i]->SetLineStyle(2);  
     
     //Set maximum to the larger of the two
     if (f1_hist1[i]->GetMaximum() < f2_hist1[i]->GetMaximum()) f1_hist1[i]->SetMaximum(1.05 * f2_hist1[i]->GetMaximum());

     TLegend *leg = new TLegend(0.2, 0.91, 0.6, 0.99, "","brNDC");

     leg->SetBorderSize(2);
     //  leg->SetFillColor(51); // see new color definition above
     leg->SetFillStyle(1001); //
     leg->AddEntry(f1_hist1[i],"CMSSW_"+ref_vers,"l");
     leg->AddEntry(f2_hist1[i],"CMSSW_"+val_vers,"l");


     TPaveStats *ptstats = new TPaveStats(0.85,0.86,0.98,0.98,"brNDC");
     ptstats->SetTextColor(41);
     f1_hist1[i]->GetListOfFunctions()->Add(ptstats);
     ptstats->SetParent(f1_hist1[i]->GetListOfFunctions());
     TPaveStats *ptstats2 = new TPaveStats(0.85,0.74,0.98,0.86,"brNDC");
     ptstats2->SetTextColor(43);
     f2_hist1[i]->GetListOfFunctions()->Add(ptstats2);
     ptstats2->SetParent(f2_hist1[i]->GetListOfFunctions());
         
     f1_hist1[i]->Draw(""); // "stat"   
     f2_hist1[i]->Draw("histsames");   
     
     leg->Draw();   
     
     myc->SaveAs(label1[i]);

     if(myc) delete myc;
   }     


  //  Profiles
  for (int i = 0; i < Nprof; i++){

    TCanvas *myc = new TCanvas("myc","",800,600);

    bool skipHisto = false;
    if (fastsim && i>=6 && i<=8) skipHisto = true;

    if (!skipHisto) {
      f1_prof[i]->SetStats(kFALSE);   
      f2_prof[i]->SetStats(kFALSE); 
      
      f1_prof[i]->SetTitle("");
      f2_prof[i]->SetTitle("");
      

      f1_prof[i]->SetLineColor(41);
      f1_prof[i]->SetLineStyle(1);     
      f1_prof[i]->SetLineWidth(1); 
      f1_prof[i]->SetMarkerColor(41);
      f1_prof[i]->SetMarkerStyle(21);
      f1_prof[i]->SetMarkerSize(1.0);  
      
      f2_prof[i]->SetLineColor(43);
      f2_prof[i]->SetLineStyle(1);  
      f2_prof[i]->SetLineWidth(1); 
      f2_prof[i]->SetMarkerColor(43);
      f2_prof[i]->SetMarkerStyle(20);
      f2_prof[i]->SetMarkerSize(0.8);  
      
      if(i > 8 ) {
	f1_prof[i]->SetMarkerSize(0.1);
	f2_prof[i]->SetMarkerSize(0.3);  
      }
      
      myc->SetGrid();
      
      if( i <= 8) {
	f1_prof[i]->Draw("histpl");   
	f2_prof[i]->Draw("histplsame"); // esame   
      }
      else {
	f1_prof[i]->Draw("pl");   
	f2_prof[i]->Draw("plsame"); // esame   
      }

      
      TLegend *leg = new TLegend(0.40, 0.91, 0.74, 0.99, "","brNDC");    
      leg->SetBorderSize(2);
      leg->SetFillStyle(1001); 
      leg->AddEntry(f1_prof[i],"CMSSW_"+ref_vers,"pl");
      leg->AddEntry(f2_prof[i],"CMSSW_"+val_vers,"pl");
      
      leg->Draw("");   
     
      myc->SaveAs(labelp[i]);
    }
    if(myc) delete myc;
  }

  TCanvas *myc = new TCanvas("myc","",800,600);

  TProfile* ratio1 = (TProfile*)f2_prof[2]->Clone();
  ratio1->Divide(f1_prof[2]);
  ratio1->SetMaximum(1.2);
  ratio1->SetMinimum(0.8);
  myc->SetGrid();  
  ratio1->Draw("hist pl");

  TLegend *leg = new TLegend(0.20, 0.91, 0.70, 0.99, "","brNDC");
  leg->SetBorderSize(2);
  leg->SetFillStyle(1001);
  leg->AddEntry(ratio1,"CaloTowers scale (pi50) ratio "+val_vers+"/"+ref_vers+" vs ieta","pl");
  leg->Draw("");


  //  f1_prof[2]->Draw();
  myc->SaveAs("Ratio.gif");


   // close ROOT files
   //
   f1.Close() ;  
   f2.Close() ;
   
   return ;  
     
}