Exemplo n.º 1
0
void make_all_plot_html(TString file,TString path)
{
  ///
  /// Load up the macros to make sure we can interpret everything
  /// in there!
  ///

  //  gInterpreter->ExecuteMacro ("topd0root_analysis/compile.C");

  ///
  /// Setup
  ///

  TFile *f = new TFile(file);
  TEnv *params = new TEnv ("make_all_plot_html");
  //  params->ReadFile ("topd0root_analysis/macros/make_all_plot_html.params", kEnvChange);
  params->ReadFile ("make_all_plot_html.params", kEnvChange);

  gStyle->SetPalette(1);

  ///
  /// Ok -- we are ready to recursively process this stuff!
  ///

  html_a_directory (f, path, params);
}
Exemplo n.º 2
0
void PublicationHisto(TString config=""){
    //gROOT->SetStyle("Plain"); gROOT->ForceStyle();
    gROOT->ProcessLine(".x /home/aran/.rootlogon.C");
    gStyle->SetPadBottomMargin(.160); // Need this for subscripts
    gStyle->SetPadTopMargin(.08);
    
    TEnv *params = new TEnv("PubHisto");
    params->ReadFile (config, kEnvChange);

    TString type=params->GetValue("Histo.Type", "PublicationHisto");
    if (type != "PublicationHisto"){
	printf(" Must have Histo.Type: PublicationHisto in config file");
	return;
    }
    // Fetch the histos from the different files:
    TString hname=params->GetValue("Histo.Name", "BOGUSNAME");
    TObjArray sameHistos;
    if (hname == "3"){// ok this means we want to add 3 histos
	TString h1=params->GetValue("Histo.1.Name", "BOGUS_H1");
	TString h2=params->GetValue("Histo.2.Name", "BOGUS_H2");
	TString h3=params->GetValue("Histo.3.Name", "BOGUS_H3");
	printf("Adding histos: %s, %s, %s \n",h1.Data(),h2.Data(), h3.Data());
	TObjArray sameHistos = GetThreeSameHistos(h1,h2,h3,params);
    } else {// normal case
	TObjArray sameHistos = GetSameHistos(hname,params);    
    }

    // Plot them:
    printf (" Found %3i histos \n",sameHistos.GetEntriesFast());
    TCanvas *c1 = new TCanvas("c1","PubHist");
    PlotPubHisto(sameHistos,params);
    TString outfile=params->GetValue("Output.File", "dummy.eps");
    c1->SaveAs(outfile.Data());
}
Exemplo n.º 3
0
void readConfigFile (string configFileList, string configFilePath)
{
  // Input stream for data file
  ifstream inFile;       
  // Open input file
  inFile.open (configFileList.c_str(), ios::in);
  
  // If can't open input file, exit the code
  if (!inFile)
    {
      cerr << "ERROR: Can't open input file: " << configFileList << endl;
      exit (1);
    }

  // ROOT configuration file


  while (inFile >> inputType) 
    {

      string configfile=configFilePath + "/" + inputType;

      TEnv *params = new TEnv ("config_file");
      params->ReadFile (configfile.c_str(), kEnvChange);
      
      // Get Root file name
      string rootFileNameNum = params->GetValue ("NormalizedrootfileNum", "file");
      inputRootFileNum.push_back (rootFileNameNum.c_str() ); 

      string rootFileNameDen = params->GetValue ("NormalizedrootfileDen", "file");
      inputRootFileDen.push_back (rootFileNameDen.c_str() );

      // Get process name: data, ttbar, wjets etc.
      string process = params->GetValue ("process", "theprocess"); 
      inputProcess.push_back(process.c_str());

      // Marker Style
      int themarker = params->GetValue("marketStyle", 20);
      inputMarkerStyle.push_back(themarker); 

      // Line Color
      int thecolor = params->GetValue("color" , kRed);
      inputColor.push_back (thecolor);

      // Store TLegend text
      string thelegend = params->GetValue("legend" , "histo");
      inputLegend.push_back (thelegend.c_str());

      // Use collision data in your plots? --> 99% of the time yes...just in case you do not want to
      
      string isSignal = params->GetValue("isSignal", "False");
      inputIsSignal.push_back ( isSignal.c_str() );

      // Output root file name
      HistosOutputRootFile = params->GetValue("outputRootFileHistos", "Histos.root");

    }
  
  inFile.close();
}
Exemplo n.º 4
0
void KVINDRAUpDater::SetPHDs(KVDBRun*)
{
   //If the environment variable
   //   name_of_dataset.INDRADB.PHD:      name_of_file
   //is set, then the corresponding file (which must be in $KVROOT/KVFiles/name_of_dataset)
   //is read and used to set the (Moulton) pulse-height defect parameters of all silicon
   //detectors.

   TString phdfile = gExpDB->GetDBEnv("PHD");

   if (phdfile != "") {
      cout << "--> Setting Si pulse height defect parameters (Moulton)" << endl;

      //get full path to file
      TString path;
      if (KVBase::SearchKVFile(phdfile.Data(), path, gDataSet->GetName())) {
         //read file with a TEnv
         TEnv phds;
         if (phds.ReadFile(path.Data(), kEnvLocal) != 0) {
            Error("SetPHDs", "TEnv::ReadFile != 0, cannot read PHD file");
         }
         //loop over all silicons
         TIter next_si(GetINDRA()->GetListOfSi());
         KVSilicon* si;
         while ((si = (KVSilicon*)next_si())) {
            Int_t group = phds.GetValue(si->GetName(), 0);
            if (group) {
               Double_t p1 = phds.GetValue(Form("Group%d.p1", group), 0.0);
               Double_t p2 = phds.GetValue(Form("Group%d.p2", group), 0.0);
               //set parameters for this detector
               //using si->SetMoultonPHDParameters(Double_t a_1, Double_t a_2, Double_t b_1, Double_t b_2)
               //in our case,
               //   a_1 = 0.0223     a_2 = 0.5682   b_1 = p2  b_2 = p1
               si->SetMoultonPHDParameters(0.0223, 0.5682, p2, p1);
            }
         }
         //set flag in INDRA to say this has been done
         GetINDRA()->PHDSet();
      }
      else {
         Error("SetPHDs", "File %s not found", phdfile.Data());
      }
   }
}
bool L1TStage2Wrapper::fillParameters(const string& parameterFile)
/*****************************************************************/
{
    TEnv params;
    int status = params.ReadFile(parameterFile.c_str(),EEnvLevel(0));
    if(status!=0) 
    {
        cout<<"[ERROR] Cannot read parameter file "<<parameterFile<<"\n"; 
        return false;
    }
    // towers
    m_params.setTowerLsbH       (params.GetValue("towerLsbH"        , 0.5));
    m_params.setTowerLsbE       (params.GetValue("towerLsbE"        , 0.5));
    m_params.setTowerLsbSum     (params.GetValue("towerLsbSum"      , 0.5));
    m_params.setTowerNBitsH     (params.GetValue("towerNBitsH"      , 8));
    m_params.setTowerNBitsE     (params.GetValue("towerNBitsE"      , 8));
    m_params.setTowerNBitsSum   (params.GetValue("towerNBitsSum"    , 9));
    m_params.setTowerNBitsRatio (params.GetValue("towerNBitsRatio"  , 3));
    m_params.setTowerEncoding   (params.GetValue("towerEncoding"    , false));

    // EG
    m_params.setEgLsb                (params.GetValue("egLsb"                      , 0.5));
    m_params.setEgSeedThreshold      (params.GetValue("egSeedThreshold"            , 2.));
    m_params.setEgNeighbourThreshold (params.GetValue("egNeighbourThreshold"       , 1.));
    m_params.setEgHcalThreshold      (params.GetValue("egHcalThreshold"            , 1.));
    m_params.setEgMaxHcalEt          (params.GetValue("egMaxHcalEt"                , 0.));
    m_params.setEgEtToRemoveHECut    (params.GetValue("egEtToRemoveHECut"          , 128.));
    m_params.setEgPUSType            (params.GetValue("egPUSType"               , "None"));

    stringstream egTrimmingLUTFile;
    egTrimmingLUTFile << getenv("CMSSW_BASE") << "/src/" << params.GetValue("egTrimmingLUTFile", "L1Trigger/L1TCalorimeter/data/egTrimmingLUT.txt");
    std::ifstream egTrimmingLUTStream(egTrimmingLUTFile.str());
    if(!egTrimmingLUTStream.is_open())
    {
        cout<<"[ERROR] Cannot open " << egTrimmingLUTFile.str()<<"\n";
        return false;
    }
    std::shared_ptr<l1t::LUT> egTrimmingLUT( new l1t::LUT(egTrimmingLUTStream) );
    m_params.setEgTrimmingLUT(egTrimmingLUT);

    stringstream egCompressShapesLUTFile;
    egCompressShapesLUTFile << getenv("CMSSW_BASE") << "/src/" << params.GetValue("egCompressShapesLUTFile", "L1Trigger/L1TCalorimeter/data/egCompressShapesLUT.txt");
    std::ifstream egCompressShapesLUTStream(egCompressShapesLUTFile.str());
    if(!egCompressShapesLUTStream.is_open())
    {
        cout<<"[ERROR] Cannot open " << egCompressShapesLUTFile.str()<<"\n";
        return false;
    }
    std::shared_ptr<l1t::LUT> egCompressShapesLUT( new l1t::LUT(egCompressShapesLUTStream) );
    m_params.setEgCompressShapesLUT(egCompressShapesLUT);

    stringstream egMaxHOverELUTFile;
    egMaxHOverELUTFile << getenv("CMSSW_BASE") << "/src/" << params.GetValue("egMaxHOverELUTFile", "L1Trigger/L1TCalorimeter/data/egMaxHOverELUT.txt");
    std::ifstream egMaxHOverELUTStream(egMaxHOverELUTFile.str());
    if(!egMaxHOverELUTStream.is_open())
    {
        cout<<"[ERROR] Cannot open " << egMaxHOverELUTFile.str()<<"\n";
        return false;
    }
    std::shared_ptr<l1t::LUT> egMaxHOverELUT( new l1t::LUT(egMaxHOverELUTStream) );
    m_params.setEgMaxHOverELUT(egMaxHOverELUT);

    stringstream egShapeIdLUTFile;
    egShapeIdLUTFile << getenv("CMSSW_BASE") << "/src/" << params.GetValue("egShapeIdLUTFile", "L1Trigger/L1TCalorimeter/data/egShapeIdLUT.txt");
    std::ifstream egShapeIdLUTStream(egShapeIdLUTFile.str());
    if(!egShapeIdLUTStream.is_open())
    {
        cout<<"[ERROR] Cannot open " << egShapeIdLUTFile.str()<<"\n";
        return false;
    }
    std::shared_ptr<l1t::LUT> egShapeIdLUT( new l1t::LUT(egShapeIdLUTStream) );
    m_params.setEgShapeIdLUT(egShapeIdLUT);

    stringstream egIsoLUTFile;
    egIsoLUTFile << getenv("CMSSW_BASE") << "/src/" << params.GetValue("egIsoLUTFile", "L1Trigger/L1TCalorimeter/data/egIsoLUT_PU40bx25.txt");
    std::ifstream egIsoLUTStream(egIsoLUTFile.str());
    if(!egIsoLUTStream.is_open())
    {
        cout<<"[ERROR] Cannot open " << egIsoLUTFile.str()<<"\n";
        return false;
    }
    std::shared_ptr<l1t::LUT> egIsoLUT( new l1t::LUT(egIsoLUTStream) );
    m_params.setEgIsolationLUT(egIsoLUT);

    m_params.setEgIsoAreaNrTowersEta       (params.GetValue("egIsoAreaNrTowersEta"       , 2));
    m_params.setEgIsoAreaNrTowersPhi       (params.GetValue("egIsoAreaNrTowersPhi"       , 4));
    m_params.setEgIsoVetoNrTowersPhi       (params.GetValue("egIsoVetoNrTowersPhi"       , 3));
    //m_params.setEgIsoPUEstTowerGranularity (params.GetValue("egIsoPUEstTowerGranularity" , 1));
    //m_params.setEgIsoMaxEtaAbsForTowerSum  (params.GetValue("egIsoMaxEtaAbsForTowerSum"  , 4));
    //m_params.setEgIsoMaxEtaAbsForIsoSum    (params.GetValue("egIsoMaxEtaAbsForIsoSum"    , 27));
    std::vector<double> egPUSParams(3);
    egPUSParams[0] = params.GetValue("egPUSParams.0" , 1.);
    egPUSParams[1] = params.GetValue("egPUSParams.1" , 4.);
    egPUSParams[2] = params.GetValue("egPUSParams.2" , 27.);
    m_params.setEgPUSParams(egPUSParams);

    stringstream egCalibrationLUTFile;
    egCalibrationLUTFile << getenv("CMSSW_BASE") << "/src/" << params.GetValue("egCalibrationLUTFile", "L1Trigger/L1TCalorimeter/data/egCalibrationLUT.txt");
    std::ifstream egCalibrationLUTStream(egCalibrationLUTFile.str());
    if(!egCalibrationLUTStream.is_open())
    {
        cout<<"[ERROR] Cannot open " << egCalibrationLUTFile.str()<<"\n";
        return false;
    }
    std::shared_ptr<l1t::LUT> egCalibrationLUT( new l1t::LUT(egCalibrationLUTStream) );
    m_params.setEgCalibrationLUT(egCalibrationLUT);

    // Tau
    m_params.setTauLsb                (params.GetValue("tauLsb"                        , 0.5));
    m_params.setTauSeedThreshold      (params.GetValue("tauSeedThreshold"              , 0.));
    m_params.setTauNeighbourThreshold (params.GetValue("tauNeighbourThreshold"         , 0.));
    m_params.setTauIsoPUSType         (params.GetValue("tauIsoPUSType"                 , "None"));

    m_params.setTauIsoAreaNrTowersEta       (params.GetValue("tauIsoAreaNrTowersEta"       , 2));
    m_params.setTauIsoAreaNrTowersPhi       (params.GetValue("tauIsoAreaNrTowersPhi"       , 4));
    m_params.setTauIsoVetoNrTowersPhi       (params.GetValue("tauIsoVetoNrTowersPhi"       , 2));

    std::vector<double> tauPUSParams(3);
    tauPUSParams[0] = params.GetValue("tauPUSParams.0" , 1.);
    tauPUSParams[1] = params.GetValue("tauPUSParams.1" , 4.);
    tauPUSParams[2] = params.GetValue("tauPUSParams.2" , 27.);
    m_params.setTauPUSParams(tauPUSParams);

    stringstream tauIsoLUTFile;
    tauIsoLUTFile << getenv("CMSSW_BASE") << "/src/" << params.GetValue("tauIsoLUTFile", "L1Trigger/L1TCalorimeter/data/tauIsoLUT.txt");
    std::ifstream tauIsoLUTStream(tauIsoLUTFile.str());
    if(!tauIsoLUTStream.is_open())
    {
        cout<<"[ERROR] Cannot open " << tauIsoLUTFile.str()<<"\n";
        return false;
    }
    std::shared_ptr<l1t::LUT> tauIsoLUT( new l1t::LUT(tauIsoLUTStream) );
    m_params.setTauIsolationLUT(tauIsoLUT);

    stringstream tauCalibrationLUTFile;
    tauCalibrationLUTFile<< getenv("CMSSW_BASE") << "/src/" << params.GetValue("tauCalibrationLUTFile", "L1Trigger/L1TCalorimeter/data/tauCalibrationLUT.txt");
    std::ifstream tauCalibrationLUTStream(tauCalibrationLUTFile.str());
    if(!tauCalibrationLUTStream.is_open())
    {
        cout<<"[ERROR] Cannot open " << tauCalibrationLUTFile.str()<<"\n";
        return false;
    }
    std::shared_ptr<l1t::LUT> tauCalibrationLUT( new l1t::LUT(tauCalibrationLUTStream) );
    m_params.setTauCalibrationLUT(tauCalibrationLUT);


    return true;
}
Exemplo n.º 6
0
void KVINDRA::LinkToCodeurs()
{

   // Link detectors with electronic modules
   // for the moment only QDC for Si and ChIo are implemented
   // This information is accessible via KVINDRADetector::GetNumeroCodeur()
   // To be active one has to put in the dataset directory
   // a file name Codeurs.dat containing the name of the file for the concerned type
   // of electronic module
   // for example see INDRA_e613 dataset
   // [dataset name].INDRADB.Codeurs:    ...


   KVFileReader flist;
   TString fp;
   if (!KVBase::SearchKVFile(gDataSet->GetDataSetEnv("INDRADB.Codeurs", ""), fp, gDataSet->GetName())) {
      Warning("LinkToCodeurs", "Fichier %s, inconnu au bataillon", gDataSet->GetDataSetEnv("INDRADB.Codeurs", ""));
      return;
   }

   if (!flist.OpenFileToRead(fp.Data())) {
      //Error("ReadGainList","Error opening file named %s",fp.Data());
      return;
   }
   Info("LinkToCodeurs()", "Reading correspondance Codeur-Detecteur ...");

   TEnv* env = 0;
   KVINDRADetector* idet = 0;
   while (flist.IsOK()) {
      flist.ReadLine(NULL);
      KVString file = flist.GetCurrentLine();
      if (file != "") {
         if (KVBase::SearchKVFile(file.Data(), fp, gDataSet->GetName())) {
            env = new TEnv();
            env->ReadFile(fp.Data(), kEnvAll);
            TEnvRec* rec = 0;
            TObjArray* toks = 0;
            TIter it(env->GetTable());
            while ((rec = (TEnvRec*)it.Next())) {
               if (!strcmp(rec->GetName(), "type")) {
                  Info("LinkToCodeurs", "Module type %s", rec->GetValue());
               }
               else {
                  toks = TString(rec->GetValue()).Tokenize(",");
                  for (Int_t ii = 0; ii < toks->GetEntries(); ii += 1) {
                     idet = (KVINDRADetector*)gIndra->GetDetector(((TObjString*)toks->At(ii))->GetString().Data());
                     if (idet)
                        idet->SetNumeroCodeur(TString(rec->GetName()).Atoi());
                  }
                  delete toks;
               }
            }
            delete env;
         }
      }
   }

   flist.CloseFile();


}