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 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.º 3
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.º 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());
      }
   }
}
Exemplo n.º 5
0
void DSelector_kpkm::Init(TTree *locTree)
{
	// USERS: IN THIS FUNCTION, ONLY MODIFY SECTIONS WITH A "USER" OR "EXAMPLE" LABEL. LEAVE THE REST ALONE.

	// The Init() function is called when the selector needs to initialize a new tree or chain.
	// Typically here the branch addresses and branch pointers of the tree will be set.
	// Init() will be called many times when running on PROOF (once per file to be processed).

	//USERS: SET OUTPUT FILE NAME //can be overriden by user in PROOF
	dOutputFileName = "kpkm.root"; //"" for none
	dOutputTreeFileName = "tree_kpkm.root"; //"" for none
	dFlatTreeFileName = "flat_tree_kpkm.root"; //output flat tree (one combo per tree entry), "" for none
	dFlatTreeName = "kpkm_Tree"; //if blank, default name will be chosen

	//Because this function gets called for each TTree in the TChain, we must be careful:
		//We need to re-initialize the tree interface & branch wrappers, but don't want to recreate histograms
	bool locInitializedPriorFlag = dInitializedFlag; //save whether have been initialized previously
	DSelector::Init(locTree); //This must be called to initialize wrappers for each new TTree
	//gDirectory now points to the output file with name dOutputFileName (if any)
	if(locInitializedPriorFlag)
		return; //have already created histograms, etc. below: exit

	Get_ComboWrappers();
	dPreviousRunNumber = 0;

	/*********************************** EXAMPLE USER INITIALIZATION: ANALYSIS ACTIONS **********************************/
	// Define particles of interest for histogramming
        std::deque<Particle_t> MyPhi;
        MyPhi.push_back(KPlus); MyPhi.push_back(KMinus);
        std::deque<Particle_t> MyLambda;
        MyLambda.push_back(KMinus); MyLambda.push_back(Proton);

	// Set up default cut parameters
	dSlope = 1.0;
	dYint = 0.0;

	// Read in parameters from configuration file
	TEnv *env = new TEnv(dOption);
	std::cout << "dOption: " << dOption << std::endl;
	if (!dOption)
		std::cout << "No configuration file provided for TEnv" << std::endl;
	else
	{
		dSlope = env->GetValue("dSlope", dSlope);
		dYint = env->GetValue("dYint", dYint);
		env->PrintEnv();
	}

	//ANALYSIS ACTIONS: //Executed in order if added to dAnalysisActions
	//false/true below: use measured/kinfit data

	// Initial histograms
	dAnalysisActions.push_back(new DHistogramAction_ParticleID(dComboWrapper, false, "Pre-cuts"));
        dAnalysisActions.push_back(new DHistogramAction_ParticleComboKinematics(dComboWrapper, false, "Pre-cuts"));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_pre-cut"));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_pre-cut"));
        dAnalysisActions.push_back(new DHistogramAction_MissingMassSquared(dComboWrapper, false, 1000, -0.1, 0.1, "Pre-cuts"));
        dAnalysisActions.push_back(new DHistogramAction_KinFitResults(dComboWrapper, "Pre-cuts"));

	// Cut on missing mass squared and histogram the invariant mass
        dAnalysisActions.push_back(new DCutAction_MissingMassSquared(dComboWrapper, false, -0.02, 0.02));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_MM2-cut"));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_MM2-cut"));

	// Cut on dEdx and histogram the invariant mass
        dAnalysisActions.push_back(new DCutAction_dEdx(dComboWrapper, false, Proton, SYS_CDC, "dEdx-meas"));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_dEdx-cut"));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_dEdx-cut"));

	// Cut on the PID delta t and histogram the invariant mass
        dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, Proton, SYS_TOF, "p_TOF"));
        dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, Proton, SYS_BCAL, "p_BCAL"));
        dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.0, Proton, SYS_FCAL, "p_FCAL"));
        dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.4, KPlus, SYS_TOF, "Kp_TOF"));
        dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, KPlus, SYS_BCAL, "Kp_BCAL"));
        dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, KPlus, SYS_FCAL, "Kp_FCAL"));
        dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.4, KMinus, SYS_TOF, "Km_TOF"));
        dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, KMinus, SYS_BCAL, "Km_BCAL"));
        dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, KMinus, SYS_FCAL, "Km_FCAL"));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_PID-cuts"));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_PID-cuts"));

	// Histograms
        dAnalysisActions.push_back(new DHistogramAction_BeamEnergy(dComboWrapper, false));
        dAnalysisActions.push_back(new DHistogramAction_ParticleComboKinematics(dComboWrapper, false, "Post_timing"));
        dAnalysisActions.push_back(new DHistogramAction_ParticleID(dComboWrapper, false, "Post_timing"));

	// Chisq comparison cut and histogram the invariant mass
	TF1 *f1 = new TF1("f1", "pol1", 0, 1000);
	f1->SetParameter(0, dYint);
	f1->SetParameter(1, dSlope);
        dAnalysisActions.push_back(new DCutAction_ChiSqOrCL(dComboWrapper, "pippim", true, f1, "Post_timing"));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_chisq-cut"));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_chisq-cut"));

	// Histograms
        dAnalysisActions.push_back(new DHistogramAction_KinFitResults(dComboWrapper,"Post_chisq-cut"));
        dAnalysisActions.push_back(new DHistogramAction_ParticleComboKinematics(dComboWrapper, false, "Post_chisq-cut"));

	// Cut on Chisq or confidence level after performing comparison cut. Histogram the invariant mass
        dAnalysisActions.push_back(new DCutAction_KinFitFOM(dComboWrapper, 1E-10));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_CL-cut"));
        dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_CL-cut"));

	//below: value: +/- N ns, Unknown: All PIDs, SYS_NULL: all timing systems
	//dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, KPlus, SYS_BCAL));

	//INITIALIZE ACTIONS
	//If you create any actions that you want to run manually (i.e. don't add to dAnalysisActions), be sure to initialize them here as well
	Initialize_Actions();

	/******************************** EXAMPLE USER INITIALIZATION: STAND-ALONE HISTOGRAMS *******************************/

	//EXAMPLE MANUAL HISTOGRAMS:
	dHist_MissingMassSquared = new TH1I("MissingMassSquared", ";Missing Mass Squared (GeV/c^{2})^{2}", 600, -0.06, 0.06);
	dHist_BeamEnergy = new TH1I("BeamEnergy", ";Beam Energy (GeV)", 600, 0.0, 12.0);

	/************************** EXAMPLE USER INITIALIZATION: CUSTOM OUTPUT BRANCHES - MAIN TREE *************************/

	//EXAMPLE MAIN TREE CUSTOM BRANCHES (OUTPUT ROOT FILE NAME MUST FIRST BE GIVEN!!!! (ABOVE: TOP)):
	//The type for the branch must be included in the brackets
	//1st function argument is the name of the branch
	//2nd function argument is the name of the branch that contains the size of the array (for fundamentals only)
	/*
	dTreeInterface->Create_Branch_Fundamental<Int_t>("my_int"); //fundamental = char, int, float, double, etc.
	dTreeInterface->Create_Branch_FundamentalArray<Int_t>("my_int_array", "my_int");
	dTreeInterface->Create_Branch_FundamentalArray<Float_t>("my_combo_array", "NumCombos");
	dTreeInterface->Create_Branch_NoSplitTObject<TLorentzVector>("my_p4");
	dTreeInterface->Create_Branch_ClonesArray<TLorentzVector>("my_p4_array");
	*/

	/************************** EXAMPLE USER INITIALIZATION: CUSTOM OUTPUT BRANCHES - FLAT TREE *************************/

	//EXAMPLE FLAT TREE CUSTOM BRANCHES (OUTPUT ROOT FILE NAME MUST FIRST BE GIVEN!!!! (ABOVE: TOP)):
	//The type for the branch must be included in the brackets
	//1st function argument is the name of the branch
	//2nd function argument is the name of the branch that contains the size of the array (for fundamentals only)
	/*
	dFlatTreeInterface->Create_Branch_Fundamental<Int_t>("flat_my_int"); //fundamental = char, int, float, double, etc.
	dFlatTreeInterface->Create_Branch_FundamentalArray<Int_t>("flat_my_int_array", "flat_my_int");
	dFlatTreeInterface->Create_Branch_NoSplitTObject<TLorentzVector>("flat_my_p4");
	dFlatTreeInterface->Create_Branch_ClonesArray<TLorentzVector>("flat_my_p4_array");
	*/

	/************************************* ADVANCED EXAMPLE: CHOOSE BRANCHES TO READ ************************************/

	//TO SAVE PROCESSING TIME
		//If you know you don't need all of the branches/data, but just a subset of it, you can speed things up
		//By default, for each event, the data is retrieved for all branches
		//If you know you only need data for some branches, you can skip grabbing data from the branches you don't need
		//Do this by doing something similar to the commented code below

	//dTreeInterface->Clear_GetEntryBranches(); //now get none
	//dTreeInterface->Register_GetEntryBranch("Proton__P4"); //manually set the branches you want
}
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.º 7
0
void fit(){
  int range = 1e4;

  TFile *f = new TFile("hgrroot.root");
  TCanvas *ca = new TCanvas("ca","ca",0,0,1400,900);
  ca->Divide(4,4);
  TH1F* h[7][4];
  TF1* fu[7][4][2];
  TF1* fus[7][4][2][3];
  double res[7*4];
  double det[7*4];
  double slope[7*4];
  double offset[7*4];
  double resolution =5;
  TEnv* output = new TEnv("corecal.dat");

  for(int d=0;d<7;d++){
    for(int c=0;c<4;c++){
      h[d][c] = (TH1F*)f->Get(Form("htraceen_b%d_c%d_cr%d_d%d",0,9,c,d+1));
      ca->cd(1+c*4);
      //h[d][c]->GetXaxis()->SetRangeUser(100,4000);
      TSpectrum *sp = new TSpectrum(2,resolution);
      sp->SetResolution(resolution);
      Int_t nfound = 0;
      nfound = sp->Search(h[d][c],resolution,"nobackground",0.5);
      Float_t *xpeaks = sp->GetPositionX();
      Float_t *ypeaks = sp->GetPositionY();
//       for(int p=0;p<nfound;p++){
// 	cout << xpeaks[p] << "\t" << ypeaks[p] << endl;
//       }
      if(nfound!=2){
	cout << "Found " << nfound << " peaks in spectrum, too many, aborting" << endl;
	continue;
      }
      h[d][c]->DrawCopy();
      //check if first peak is lower in energy, otherwise swap them
      if(xpeaks[0]>xpeaks[1]){
	Float_t temp = xpeaks[1];
	xpeaks[1] = xpeaks[0];
	xpeaks[0] = temp;
	temp = ypeaks[1];
	ypeaks[1] = ypeaks[0];
	ypeaks[0] = temp;
	
      }

      for(int p=0;p<nfound;p++){
	ca->cd(1+c*4+1+p);
	h[d][c]->GetXaxis()->SetRangeUser(xpeaks[p]-range,xpeaks[p]+range);
	h[d][c]->DrawCopy();
	fu[d][c][p] = new TF1(Form("fcore_d%d_c%d_p%d",d,c,p),fgammagaussbg,xpeaks[p]-range,xpeaks[p]+range,6);
	fu[d][c][p]->SetLineColor(3);
	fu[d][c][p]->SetLineWidth(1);
	fu[d][c][p]->SetParameter(0,0);//bg const
	fu[d][c][p]->SetParameter(1,0);//bg slope
	fu[d][c][p]->SetParameter(2,h[d][c]->Integral(xpeaks[p]-range,xpeaks[p]+range));//norm
	fu[d][c][p]->SetParameter(3,xpeaks[p]);//mean
	fu[d][c][p]->SetParLimits(3,xpeaks[p]-500,xpeaks[p]+500);//mean
	fu[d][c][p]->SetParameter(4,100);//sigma
	fu[d][c][p]->SetParLimits(4,0.001,1000);//sigma
	fu[d][c][p]->SetParameter(5,h[d][c]->GetBinContent(h[d][c]->FindBin(xpeaks[p]-range)));//step
	
	h[d][c]->Fit(fu[d][c][p],"Rqn");
	fu[d][c][p]->Draw("same");


	fus[d][c][p][0] = new TF1(Form("fcore_d%d_c%d_p%d_bg",d,c,p),fgammabg,xpeaks[p]-range,xpeaks[p]+range,6);
	fus[d][c][p][1] = new TF1(Form("fcore_d%d_c%d_p%d_st",d,c,p),fgammastep,xpeaks[p]-range,xpeaks[p]+range,6);
	fus[d][c][p][2] = new TF1(Form("fcore_d%d_c%d_p%d_ga",d,c,p),fgammagaus,xpeaks[p]-range,xpeaks[p]+range,6);
	

	fus[d][c][p][0]->SetLineColor(5);
	fus[d][c][p][1]->SetLineColor(4);
	fus[d][c][p][2]->SetLineColor(2);
	for(int k=0;k<3;k++){
	  fus[d][c][p][k]->SetLineWidth(1);
	  for(int l=0;l<6;l++)
	    fus[d][c][p][k]->SetParameter(l,fu[d][c][p]->GetParameter(l));
	  fus[d][c][p][k]->Draw("same");
	}

      }//peaks
      //res[d*4+c] = 2.35*fu[d][c][1]->GetParameter(4)*(1332.492-1173.228)/(fu[d][c][1]->GetParameter(3)-fu[d][c][0]->GetParameter(3));

      slope[d*4+c] = (1332.492-1173.228)/(fu[d][c][1]->GetParameter(3)-fu[d][c][0]->GetParameter(3));
      offset[d*4+c] = (1332.492+1173.228)-slope[d*4+c]*(fu[d][c][1]->GetParameter(3)+fu[d][c][0]->GetParameter(3));
      offset[d*4+c]*=0.5;
      
      //cout << fu[d][c][0]->GetParameter(3)*slope[d*4+c] + offset[d*4+c] << "\t" << fu[d][c][1]->GetParameter(3)*slope[d*4+c] + offset[d*4+c] << endl;
      
      res[d*4+c] = fu[d][c][1]->GetParameter(2);
      det[d*4+c] = d*5+c;

      output->SetValue(Form("Slope.d%d.c%d",d,c),slope[d*4+c]);
      output->SetValue(Form("Offset.d%d.c%d",d,c),offset[d*4+c]);


      //cout << det[d*4+c] <<"\t" << res[d*4+c] << endl;
      //cout << fu[d][c][0]->GetParameter(4) <<"\t" << fu[d][c][1]->GetParameter(4) << endl;
      //ca->cd(1+c*4+3);
      TPad *p1 = (TPad *)(ca->cd(1+c*4+3)); 
      p1->SetLogy();
      h[d][c]->GetXaxis()->SetRangeUser((int)xpeaks[0]-range,(int)xpeaks[1]+range);
      h[d][c]->DrawCopy();
      for(int p=0;p<nfound;p++){
	fu[d][c][p]->Draw("same");
	for(int k=0;k<3;k++){
	  fus[d][c][p][k]->Draw("same");
	}
      }

    }//crystals
    if(d==0)
      ca->SaveAs("corefits.ps(");
    else
      ca->SaveAs("corefits.ps");
  }//detectors
  output->SaveLevel(kEnvLocal);

  //TGraph *gres = new TGraph(7*4,det,res);
  TGraph *gres = new TGraph(7*4,slope,offset);
  TCanvas *ca2 = new TCanvas("ca2","ca2",0,0,1400,900);
  ca2->cd();
  gres->Draw("AP");
  gres->SetMarkerStyle(20);
  ca2->SaveAs("corefits.ps)");
}
Exemplo n.º 8
0
void KVINDRAReconDataAnalyser::PrintTreeInfos()
{
	// Print informations on currently analysed TTree
	TEnv* treeInfos = GetReconDataTreeInfos();
	if(!treeInfos) return;
	cout << endl << "----------------------------------------------------------------------------------------------------" << endl;
	        cout << "INFORMATIONS ON VERSION OF KALIVEDA USED TO GENERATE FILE:" << endl << endl;
           fDataVersion = treeInfos->GetValue("KVBase::GetKVVersion()","(unknown)");
cout << "version = " << fDataVersion << endl ;
cout << "build date = " << treeInfos->GetValue("KVBase::GetKVBuildDate()","(unknown)")<< endl ;
cout << "source directory = " << treeInfos->GetValue("KVBase::GetKVSourceDir()","(unknown)")<< endl ;
cout << "KVROOT = " << treeInfos->GetValue("KVBase::GetKVRoot()","(unknown)")<< endl ;
cout << "BZR branch name = " << treeInfos->GetValue("KVBase::bzrBranchNick()","(unknown)")<< endl ;
cout << "BZR revision #" << treeInfos->GetValue("KVBase::bzrRevisionNumber()","(unknown)")<< endl ;
cout << "BZR revision ID = " << treeInfos->GetValue("KVBase::bzrRevisionId()","(unknown)")<< endl ;
cout << "BZR revision date = " << treeInfos->GetValue("KVBase::bzrRevisionDate()","(unknown)")<< endl ;
	        cout << endl << "INFORMATIONS ON GENERATION OF FILE:" << endl << endl;
cout << "Generated by : " << treeInfos->GetValue("gSystem->GetUserInfo()->fUser","(unknown)")<< endl ;
cout << "Analysis task : " << treeInfos->GetValue("AnalysisTask","(unknown)")<< endl ;
cout << "Job name : " << treeInfos->GetValue("BatchSystem.JobName","(unknown)")<< endl ;
cout << "Job submitted from : " << treeInfos->GetValue("LaunchDirectory","(unknown)")<< endl ;
cout << "Runs : " << treeInfos->GetValue("Runs","(unknown)")<< endl ;
cout << "Number of events requested : " << treeInfos->GetValue("NbToRead","(unknown)")<< endl ;
	cout << endl << "----------------------------------------------------------------------------------------------------" << endl;

   // if possible, parse fDataVersion into series and release number
   // e.g. if fDataVersion = "1.8.10":
   //     => fDataSeries = "1.8"   fDataReleaseNum = 10
   Int_t a,b,c;
   if(fDataVersion!="(unknown)"){
      if(sscanf(fDataVersion.Data(), "%d.%d.%d", &a, &b, &c) == 3){
         fDataSeries.Form("%d.%d",a,b);
         fDataReleaseNum=c;
      }
   }
   else
   {
      fDataSeries="";
      fDataReleaseNum=-1;
   }
}
Exemplo n.º 9
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();


}