Attachment 'CreateDataBackground.C'

Download

   1 #include "WIMP_functions.C"
   2 
   3 #include <fstream>
   4 #include "TFile.h"
   5 #include "TProfile.h"
   6 
   7 
   8 
   9 
  10 void CreateDataBackground(){
  11 
  12 
  13   // ####### PARAMETERS
  14 
  15   
  16   double lumi = 500.0;
  17   double Pe = 0.0;
  18   double Pp = 0.0;
  19   
  20   double cos_cut = 0.995;
  21 
  22 
  23   TFile* f;
  24   char filename[256];
  25   char name[256];
  26   char obj_title[256];
  27 
  28 
  29   // #########################################################################
  30   // #########################################################################
  31   // ##################   BACKGROUND DATA TEMPLATES ######################
  32   // #########################################################################
  33   
  34   //##################### OUTPUTFILES #####################
  35   TFile* f_data_bg[11];
  36   TH1D* h_data_bg_E[11];
  37   
  38    for (int m(0); m < 11 ; m++){
  39     if (m == 0) {
  40       Pe = 0.0;
  41       Pp = 0.0;
  42     }
  43     if (m == 1) {
  44       Pe = 0.8;
  45       Pp = 0.0;
  46     }
  47     if (m == 2) {
  48       Pe = 0.8;
  49       Pp = -0.3;
  50     }
  51     if (m == 3) {
  52       Pe = 0.8;
  53       Pp = -0.5; //usual -0.6
  54     }
  55     if (m == 4) {
  56       Pe = -0.8;
  57       Pp = 0.0;
  58     }
  59     if (m == 5) {
  60       Pe = -0.8;
  61       Pp = 0.3;
  62     }
  63     if (m == 6) {
  64       Pe = -0.8;
  65       Pp = 0.6;
  66     }
  67     if (m == 7) {
  68       Pe = 0.8;
  69       Pp = 0.3;
  70     }
  71     if (m == 8) {
  72       Pe = -0.8;
  73       Pp = -0.3;
  74     }
  75     if (m == 9) {
  76       Pe = 0.8;
  77       Pp = 0.6;
  78     }
  79     if (m == 10) {
  80       Pe = 0.8;
  81       Pp = -0.6;
  82     }
  83   
  84    
  85     sprintf(filename,"../data/Templates_Andrii/temp/Data_Background_Pe%.1f_Pp%.1f_Lumi%.0f.root",Pe,Pp,lumi);
  86     f_data_bg[m] = new TFile(filename,"RECREATE");
  87       
  88     sprintf(obj_title,"Background_Pe%.1f_Pp%.1f_Lumi%.0f",Pe,Pp,lumi);
  89     h_data_bg_E[m] = new TH1D(obj_title,"Background;E [GeV]; Entries",300,0.0,300.0);
  90     h_data_bg_E[m]->Sumw2();
  91   }
  92   
  93  
  94   // ################ CREATE BACKGROUND TEMPLATES ############
  95     
  96   ifstream txtfile("../steeringfiles/ILD00_Data_RootFiles.txt");
  97    
  98     
  99   while (!txtfile.eof()){
 100     txtfile.getline(name,256,'\n');
 101     printf("%s\n",name);
 102     f = new TFile(name,"OPEN");
 103     if (f->IsZombie()) continue;
 104       
 105     // ********** GET BACKGROUND DATA TREES
 106       
 107     TTree* tree = (TTree*)f->Get("Tree");
 108     TTree* seltree = (TTree*)f->Get("SelPhotonTree");
 109     TTree* globaltree = (TTree*)f->Get("GlobalParameters");
 110     LoadTree(tree);
 111     LoadSelPhotonTree(seltree);
 112     LoadGlobalTree(globaltree);
 113     
 114     globaltree->GetEntry(0);
 115     
 116     double factor = (double)NumberOfEventsInFile/NumberOfEventsInRun;
 117     // ********** LOOP OVER ENTRIES
 118        
 119      int n_entries = seltree->GetEntries();
 120     //	n_entries =1;
 121     //n_entries = (int)n_entries/1000;
 122 
 123     for (int j(0); j < n_entries; j++){
 124       if (j%10000 == 0) printf("event %i\n",j);
 125       tree->GetEntry(j);
 126       seltree->GetEntry(j);
 127       // MCLumi_Run = MCLumi_Run*factor;
 128       for (int m(0); m < 11 ; m++){
 129 	if (m == 0) {
 130   	  Pe = 0.0;
 131   	  Pp = 0.0;
 132   	}
 133   	if (m == 1) {
 134   	  Pe = 0.8;
 135   	  Pp = 0.0;
 136   	}
 137   	if (m == 2) {
 138   	  Pe = 0.8;
 139   	  Pp = -0.3;
 140   	}
 141   	if (m == 3) {
 142   	  Pe = 0.8;
 143   	  Pp = -0.5; // usual -0.6
 144   	}
 145   	if (m == 4) {
 146   	  Pe = -0.8;
 147   	  Pp = 0.0;
 148   	}
 149   	if (m == 5) {
 150   	  Pe = -0.8;
 151   	  Pp = 0.3;
 152   	}
 153   	if (m == 6) {
 154   	  Pe = -0.8;
 155   	  Pp = 0.6;
 156   	}
 157 	if (m == 7) {
 158 	  Pe = 0.8;
 159 	  Pp = 0.3;
 160 	}
 161 	if (m == 8) {
 162 	  Pe = -0.8;
 163 	  Pp = -0.3;
 164 	}
 165 	if (m == 9) {
 166 	  Pe = 0.8;
 167 	  Pp = 0.6;
 168 	}
 169 	if (m == 10) {
 170 	  Pe = 0.8;
 171 	  Pp = -0.6;
 172 	}
 173  	
 174  	CreatePolarisationWeights(Pe,Pp);
 175  	//  	double weight = GetEventWeight(lumi, P_e, P_p)*EventWeight;
 176    	double weight = GetEventWeight(lumi, MCLumi_Run, P_e, P_p)*EventWeight;
 177    	h_data_bg_E[m]->Fill(SelPhoton_energy[0],weight);
 178 //	cout<<"EventWeight = "<<EventWeight<<"| Weight = "<<weight<<"| Photon_energy = "<<SelPhoton_energy[0]<<"| Pe = "<<Pe <<"| Pp = "<<Pp<<endl;
 179       }
 180     }
 181     delete f;
 182   }
 183   
 184   //  #########  ADD BHABHA EXPECTATION HISTOGRAM
 185     char polstate[128];
 186     char histoname[128];
 187     TFile* f_bhabha = new TFile("../data/Templates/BhabhaBackground.root","OPEN");
 188     
 189     for ( int m(0); m < 11; m++){
 190       switch(m){
 191       case 0:
 192         sprintf(polstate,"p0p0");
 193         break;
 194       case 1:
 195         sprintf(polstate,"p8p0");
 196         break;
 197       case 2:
 198         sprintf(polstate,"p8m3");
 199         break;
 200       case 3:
 201         sprintf(polstate,"p8m6");
 202         break;
 203       case 4:
 204         sprintf(polstate,"m8p0");
 205         break;
 206       case 5:
 207         sprintf(polstate,"m8p3");
 208         break;
 209       case 6:
 210         sprintf(polstate,"m8p6");
 211         break;
 212       default: 
 213         sprintf(polstate,"p0p0");
 214       }
 215       sprintf(histoname,"Bhabha_E_Lumi50_%s",polstate);
 216       TH1D* h_bhabha_E = (TH1D*)f_bhabha->Get(histoname);
 217       h_data_bg_E[m]->Add(h_bhabha_E,lumi/50.0); 
 218       
 219     }
 220     
 221   for ( int m(0); m < 11; m++){
 222     f_data_bg[m]->cd();
 223     h_data_bg_E[m]->Write();
 224     f_data_bg[m]->Close();
 225   }
 226     f_bhabha->Close();
 227     
 228   // ###### FOR COMPARISON, STORE PARAMETRISED BACKGROUND
 229   // TFile* f_full_bg = new TFile("../data/Templates/ParametrisedBackground.root","OPEN");
 230   // sprintf(polstate,"m830");  
 231   // sprintf(obj_title,"Background_E_Modeled_Lumi50_%s",polstate);
 232   // TH1D* h_full_bg_template = (TH1D*)f_full_bg->Get(obj_title);
 233   // h_full_bg_template->Scale(lumi/50.0);
 234 
 235 
 236 
 237   return;  
 238 }   
 239  

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.