101 TH1::SetDefaultSumw2();
106 TFile *outputFile=
new TFile(
"testUnfold7_histograms.root",
"recreate");
112 TUnfoldBinning *fineBinningRoot,*coarseBinningRoot;
119 TString dir = gSystem->UnixPathName(gSystem->DirName(__FILE__));
120 Int_t error=parser.ParseFile(dir+
"/testUnfold7binning.xml");
122 cout<<
"error="<<error<<
" from TDOMParser\n";
123 cout<<
"==============================================================\n";
124 cout<<
"Maybe the file testUnfold7binning.xml is missing?\n";
125 cout<<
"The content of the file is included in the comments section\n";
126 cout<<
"of this macro \"testUnfold7b.C\"\n";
127 cout<<
"==============================================================\n";
129 TXMLDocument
const *XMLdocument=parser.GetXMLDocument();
131 TUnfoldBinningXML::ImportXML(XMLdocument,
"fine");
133 TUnfoldBinningXML::ImportXML(XMLdocument,
"coarse");
136 fineBinningRoot->Write();
137 coarseBinningRoot->Write();
139 if(fineBinningRoot) {
140 fineBinningRoot->PrintStream(cout);
142 cout<<
"could not read 'detector' binning\n";
144 if(coarseBinningRoot) {
145 coarseBinningRoot->PrintStream(cout);
147 cout<<
"could not read 'generator' binning\n";
150 TUnfoldBinning
const *fineBinning=fineBinningRoot;
151 TUnfoldBinning
const *coarseBinning=coarseBinningRoot;
157 Float_t ptRec[3],ptGen[3],weight;
158 Int_t isTriggered,isSignal;
162 TH1 *histDataRecF=fineBinning->CreateHistogram(
"histDataRecF");
163 TH1 *histDataRecC=coarseBinning->CreateHistogram(
"histDataRecC");
164 TH1 *histDataBgrF=fineBinning->CreateHistogram(
"histDataBgrF");
165 TH1 *histDataBgrC=coarseBinning->CreateHistogram(
"histDataBgrC");
166 TH1 *histDataGen=coarseBinning->CreateHistogram(
"histDataGen");
168 TFile *dataFile=
new TFile(
"testUnfold7_data.root");
169 TTree *dataTree=(TTree *) dataFile->Get(
"data");
172 cout<<
"could not read 'data' tree\n";
175 dataTree->ResetBranchAddresses();
176 dataTree->SetBranchAddress(
"ptrec",ptRec);
179 dataTree->SetBranchAddress(
"istriggered",&isTriggered);
181 dataTree->SetBranchAddress(
"ptgen",ptGen);
182 dataTree->SetBranchAddress(
"issignal",&isSignal);
183 dataTree->SetBranchStatus(
"*",1);
185 cout<<
"loop over data events\n";
187 #define VAR_REC (ptRec[2])
188 #define VAR_GEN (ptGen[2])
190 for(Int_t ievent=0;ievent<dataTree->GetEntriesFast();ievent++) {
191 if(dataTree->GetEntry(ievent)<=0)
break;
194 int binF=fineBinning->GetGlobalBinNumber(VAR_REC);
195 int binC=coarseBinning->GetGlobalBinNumber(VAR_REC);
196 histDataRecF->Fill(binF);
197 histDataRecC->Fill(binC);
199 histDataBgrF->Fill(binF);
200 histDataBgrC->Fill(binC);
205 int binGen=coarseBinning->GetGlobalBinNumber(VAR_GEN);
206 histDataGen->Fill(binGen);
219 TH2 *histMcsigGenRecF=TUnfoldBinning::CreateHistogramOfMigrations
220 (coarseBinning,fineBinning,
"histMcsigGenRecF");
221 TH2 *histMcsigGenRecC=TUnfoldBinning::CreateHistogramOfMigrations
222 (coarseBinning,coarseBinning,
"histMcsigGenRecC");
223 TH1 *histMcsigRecF=fineBinning->CreateHistogram(
"histMcsigRecF");
224 TH1 *histMcsigRecC=coarseBinning->CreateHistogram(
"histMcsigRecC");
225 TH1 *histMcsigGen=coarseBinning->CreateHistogram(
"histMcsigGen");
227 TFile *signalFile=
new TFile(
"testUnfold7_signal.root");
228 TTree *signalTree=(TTree *) signalFile->Get(
"signal");
231 cout<<
"could not read 'signal' tree\n";
234 signalTree->ResetBranchAddresses();
235 signalTree->SetBranchAddress(
"ptrec",&ptRec);
237 signalTree->SetBranchAddress(
"istriggered",&isTriggered);
238 signalTree->SetBranchAddress(
"ptgen",&ptGen);
239 signalTree->SetBranchAddress(
"weight",&weight);
240 signalTree->SetBranchStatus(
"*",1);
242 cout<<
"loop over MC signal events\n";
244 for(Int_t ievent=0;ievent<signalTree->GetEntriesFast();ievent++) {
245 if(signalTree->GetEntry(ievent)<=0)
break;
249 binF=fineBinning->GetGlobalBinNumber(VAR_REC);
250 binC=coarseBinning->GetGlobalBinNumber(VAR_REC);
252 int binGen=coarseBinning->GetGlobalBinNumber(VAR_GEN);
253 histMcsigGenRecF->Fill(binGen,binF,weight);
254 histMcsigGenRecC->Fill(binGen,binC,weight);
255 histMcsigRecF->Fill(binF,weight);
256 histMcsigRecC->Fill(binC,weight);
257 histMcsigGen->Fill(binGen,weight);
265 TH1 *histMcbgrRecF=fineBinning->CreateHistogram(
"histMcbgrRecF");
266 TH1 *histMcbgrRecC=coarseBinning->CreateHistogram(
"histMcbgrRecC");
268 TFile *bgrFile=
new TFile(
"testUnfold7_background.root");
269 TTree *bgrTree=(TTree *) bgrFile->Get(
"background");
272 cout<<
"could not read 'background' tree\n";
275 bgrTree->ResetBranchAddresses();
276 bgrTree->SetBranchAddress(
"ptrec",&ptRec);
278 bgrTree->SetBranchAddress(
"istriggered",&isTriggered);
279 bgrTree->SetBranchAddress(
"weight",&weight);
280 bgrTree->SetBranchStatus(
"*",1);
282 cout<<
"loop over MC background events\n";
284 for(Int_t ievent=0;ievent<bgrTree->GetEntriesFast();ievent++) {
285 if(bgrTree->GetEntry(ievent)<=0)
break;
290 int binF=fineBinning->GetGlobalBinNumber(VAR_REC);
291 int binC=coarseBinning->GetGlobalBinNumber(VAR_REC);
292 histMcbgrRecF->Fill(binF,weight);
293 histMcbgrRecC->Fill(binC,weight);