Attachment 'CalibrateData.C'

Download

   1 # include "GlobalVariables.C"
   2 
   3 void CalibrateData(){
   4 
   5   printf("Calibrate Data\n");
   6   // ####### OPEN PROCESSED FILE, GET TREES
   7   char line[500];
   8   string filename;
   9 
  10   FILE* file = fopen("../steeringfiles/ILD00_Processed_RootFiles.txt","r");
  11   while(fscanf(file,"%s\n",line) != EOF) {
  12 
  13     filename = line;
  14     printf("%s\n",filename.c_str());
  15 
  16     TFile* f_in = new TFile(filename.c_str(),"OPEN");
  17     TTree* tree = (TTree*)f_in->Get("Tree");
  18     TTree* preproctree = (TTree*)f_in->Get("ProcTree");
  19     TTree* globaltree = (TTree*)f_in->Get("GlobalParameters");
  20     TTree* xsectree = 0;
  21     TTree* bcaltree = 0;
  22 
  23     LoadTree(tree);
  24     LoadPreProcTree(preproctree);
  25     LoadGlobalTree(globaltree);
  26     if (f_in->Get("XSecTree")){
  27       xsectree = (TTree*)f_in->Get("XSecTree");
  28       LoadXSecTree(xsectree);
  29     }
  30 
  31     if (f_in->Get("BcalTree")){
  32       bcaltree = (TTree*)f_in->Get("BcalTree");
  33       LoadBcalTree(bcaltree);
  34     }
  35 
  36 
  37 
  38     // ######## CREATE CALIBRATED FILE, CREATE TREES
  39 
  40     string newname = (filename.substr(filename.find("ILD"))).insert(6,"Calibrated_");
  41     newname.insert(0,"../data/Calibrated/");
  42  
  43     TFile* f_out = new TFile(newname.c_str(),"RECREATE");
  44     TTree* calibratedtree = new TTree("CalibratedTree","CalibratedTree");
  45     SetCalibratedTreeBranches(calibratedtree);
  46 
  47 
  48     cout << tree->GetEntries() << endl;
  49     TTree* out_tree = tree->CloneTree();
  50 
  51     TTree* out_globaltree = globaltree->CloneTree();
  52 
  53     TTree* out_xsectree = 0;
  54     TTree* out_bcaltree = 0;
  55 
  56 
  57 
  58     if(xsectree){
  59       out_xsectree = xsectree->CloneTree();
  60     }
  61 
  62     if(bcaltree){
  63       out_bcaltree = bcaltree->CloneTree();
  64     }
  65   
  66 
  67     // ########## LOAD CALIBRATION FUNCTION
  68 
  69     TFile* f_cal = new TFile("../data/Auxiliary/Energycalibration.root","OPEN");
  70     TH1D* h_cal = (TH1D*)f_cal->Get("ErecEgen_Cos");
  71     TF1* func_cal = (TF1*)h_cal->GetFunction("EnergyCalibration_Func");
  72 
  73  
  74     // ########### CALIBRATE PROCESSED RECOS
  75 
  76     int nEntries = preproctree->GetEntries();
  77     //nEntries = 1e4;
  78     for (int i(0); i < nEntries; i++){
  79 
  80  
  81       preproctree->GetEntry(i);
  82       nCalibratedRecos = 0;
  83       for (int j(0); j < nProcessedRecos; j++){
  84 
  85 	if (ProcessedReco_type[j] == 22){
  86 	  double cos =  TMath::Abs(ProcessedReco_cosTheta[j]);
  87 	  double cali_factor = func_cal->Eval(cos);
  88 	  //cout << cos << "  "<<cali_factor<< endl;
  89 	  CalibratedReco_energy[nCalibratedRecos] = ProcessedReco_energy[j]/cali_factor;
  90 	  CalibratedReco_px[nCalibratedRecos] = ProcessedReco_px[j]/cali_factor;
  91 	  CalibratedReco_py[nCalibratedRecos] = ProcessedReco_py[j]/cali_factor;
  92 	  CalibratedReco_pz[nCalibratedRecos] = ProcessedReco_pz[j]/cali_factor;
  93 	  CalibratedReco_absP[nCalibratedRecos] = ProcessedReco_absP[j]/cali_factor;
  94 	}
  95 
  96 	else{
  97 	  CalibratedReco_energy[nCalibratedRecos] = ProcessedReco_energy[j];
  98 	  CalibratedReco_px[nCalibratedRecos] = ProcessedReco_px[j];
  99 	  CalibratedReco_py[nCalibratedRecos] = ProcessedReco_py[j];
 100 	  CalibratedReco_pz[nCalibratedRecos] = ProcessedReco_pz[j];
 101 	  CalibratedReco_absP[nCalibratedRecos] = ProcessedReco_absP[j];
 102 	}
 103 
 104 	CalibratedReco_isBCal[nCalibratedRecos] = ProcessedReco_isBCal[j];
 105 	CalibratedReco_id[nCalibratedRecos] = ProcessedReco_id[j];
 106 	CalibratedReco_type[nCalibratedRecos] = ProcessedReco_type[j];
 107 	CalibratedReco_mass[nCalibratedRecos] = ProcessedReco_mass[j];
 108 	CalibratedReco_charge[nCalibratedRecos] = ProcessedReco_charge[j];
 109 	CalibratedReco_position_x[nCalibratedRecos] = ProcessedReco_position_x[j];
 110 	CalibratedReco_position_y[nCalibratedRecos] = ProcessedReco_position_x[j];
 111 	CalibratedReco_position_z[nCalibratedRecos] = ProcessedReco_position_z[j];
 112 	CalibratedReco_cosTheta[nCalibratedRecos] = ProcessedReco_cosTheta[j];
 113 	CalibratedReco_phi[nCalibratedRecos] = ProcessedReco_phi[j];
 114 	CalibratedToRecoId[nCalibratedRecos] = ProcessedToRecoId[j];
 115 	CalibratedRecoRelatedToId[nCalibratedRecos] = ProcessedRecoRelatedToId[j];
 116 	CalibratedRecoRelationWeight[nCalibratedRecos] = ProcessedRecoRelationWeight[j];
 117 	nCalibratedRecos++;
 118       }
 119       calibratedtree->Fill();
 120     }
 121 
 122     // ########### WRITE CALIBRATED FILE
 123 
 124 
 125     f_out->cd();
 126     out_tree->Write();
 127     out_globaltree->Write();
 128     if (xsectree){
 129       out_xsectree->Write();
 130     }
 131 
 132     if (bcaltree){
 133       out_bcaltree->Write();
 134     }
 135     calibratedtree->Write();
 136     f_out->Close();
 137     
 138     f_in->Close();
 139   }
 140   gROOT->ProcessLine(".q");
 141   return;
 142 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2012-01-30 13:28:08, 4.3 KB) [[attachment:CalibrateData.C]]
  • [get | view] (2012-01-30 13:27:40, 12.0 KB) [[attachment:CalibrationFunctions.C]]
  • [get | view] (2014-06-20 09:25:03, 5.2 KB) [[attachment:CreateDataBackground.C]]
  • [get | view] (2014-06-20 09:21:28, 22.3 KB) [[attachment:CreateDataForSignalAndBackground.C]]
  • [get | view] (2014-06-20 09:24:20, 0.2 KB) [[attachment:CreateDataForSignalAndBackground.py]]
  • [get | view] (2012-01-30 12:32:43, 12.0 KB) [[attachment:FindMergeAngle.C]]
  • [get | view] (2012-01-30 13:22:33, 9.8 KB) [[attachment:PreprocessData.C]]
  • [get | view] (2012-01-30 13:51:59, 16.8 KB) [[attachment:Selection.C]]
  • [get | view] (2014-06-20 09:26:52, 13.2 KB) [[attachment:TSysLimit_searches.C]]
  • [get | view] (2014-06-20 09:28:25, 14.9 KB) [[attachment:TSysLimit_searches_onebin.C]]
  • [get | view] (2014-06-20 09:25:07, 12.9 KB) [[attachment:WIMP_functions.C]]
  • [get | view] (2014-06-20 12:52:10, 1.3 KB) [[attachment:runLambdaSearch.sh]]
  • [get | view] (2014-06-20 12:52:16, 0.2 KB) [[attachment:submitter.sh]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.