6 #include "CalibrationHelperFunctions.cxx"
8 void mip_ring_fitter(
const char* file_list=
"",
const char* skimfile=
"mipskimfile.root")
10 gROOT->Macro(
"LoadLogger.C");
11 gROOT->Macro(
"$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
12 gSystem->Load(
"StTpcDb");
13 gSystem->Load(
"StDaqLib");
14 gSystem->Load(
"StDetectorDbMaker");
15 gSystem->Load(
"St_db_Maker");
16 gSystem->Load(
"StDbUtilities");
17 gSystem->Load(
"StEmcRawMaker");
18 gSystem->Load(
"StMcEvent");
19 gSystem->Load(
"StMcEventMaker");
20 gSystem->Load(
"StEmcSimulatorMaker");
21 gSystem->Load(
"StEmcADCtoEMaker");
22 gSystem->Load(
"StEpcMaker");
23 gSystem->Load(
"StDbBroker");
24 gSystem->Load(
"StEEmcUtil");
25 gSystem->Load(
"StAssociationMaker");
26 gSystem->Load(
"StEmcTriggerMaker");
28 gSystem->Load(
"StEmcOfflineCalibrationMaker");
30 const int ntowers=4800;
32 const bool lookForSwaps=
false;
36 cout<<
"input filelist: "<<file_list<<endl;
37 cout<<
"histogram file: "<<skimfile<<endl;
41 TChain* calib_tree =
new TChain(
"calibTree");
42 ifstream filelist(file_list);
46 if(!filelist.good())
break;
48 calib_tree->Add(file);
52 calib_tree->SetBranchAddress(
"event_branch",&myEvent);
56 TH1* ring_histo[nrings];
58 for(
int k=0; k<nrings; k++){
59 sprintf(name,
"ring_histo_%i",k+1);
60 ring_histo[k] =
new TH1D(name,name,250,-50.5,199.5);
64 set<int> track_towers;
65 set<int> excluded_towers;
67 unsigned int nentries = calib_tree->GetEntries();
68 for(
unsigned int i=0; i<nentries; i++){
69 if(i%100000 == 0) cout<<
"processing "<<i<<
" of "<<nentries<<endl;
72 excluded_towers.clear();
74 calib_tree->GetEntry(i);
77 if(TMath::Abs(myEvent->vz[0]) > 30.)
continue;
80 for(
int j=0; j<myEvent->tracks->GetEntries(); j++){
82 int id = mip->tower_id[0];
84 if(track_towers.find(
id) != track_towers.end()){
85 excluded_towers.insert(
id);
88 track_towers.insert(
id);
95 for(
int j=0; j<myEvent->tracks->GetEntries(); j++){
131 double pedsub = mip->tower_adc[0] - mip->tower_pedestal[0];
133 if(mip->p < 1.)
continue;
134 if(mip->tower_status[0] != 1)
continue;
135 if(mip->highest_neighbor > 2.)
continue;
136 if(TMath::Abs(pedsub) < 1.5*mip->tower_pedestal_rms[0])
continue;
137 if(mip->tower_id[0] != mip->tower_id_exit)
continue;
138 if(mip->vertexIndex > 0)
continue;
139 if(excluded_towers.find(mip->tower_id[0]) != excluded_towers.end())
continue;
142 int index = mip->tower_id[0];
143 double eta = helper->getEta(index);
144 if(TMath::Abs(eta) > 0.968) eta += 0.005 * TMath::Abs(eta)/eta;
145 int etaindex = ((TMath::Nint(eta * 1000.0) + 25) / 50 + 19);
146 ring_histo[etaindex]->Fill(pedsub);
151 TFile* output_file =
new TFile(skimfile,
"RECREATE");
153 for(
int k=0; k<nrings;k++) ring_histo[k]->Write();
154 output_file->Close();
227 double peak = f->GetParameter(1);
228 double histo_height = h->GetBinContent(h->GetMaximumBin());
229 if(histo_height == 0) histo_height = 1.;
232 h->SetXTitle(
"ADC/gev*sin(#theta)");
236 TLine *gaussian_peak =
new TLine(peak,0.,peak,histo_height+15);
237 gaussian_peak->SetLineColor(kGreen);
238 gaussian_peak->SetLineWidth(2.0);
239 gaussian_peak->Draw(
"same");
242 char tower_title[100];
243 float eta = (float)((
id - 20) * 2 + 1)/40;
244 sprintf(tower_title,
"eta = %f",eta);
246 title_latex.SetTextSize(0.15);
247 if(!helper->isGoodTower2006(
id)) title_latex.SetTextColor(kRed);
248 title_latex.DrawTextNDC(0.13,0.78,tower_title);
251 TF1 *f2 =
new TF1(tower_title,
"gaus",0.,140.);
252 f2->FixParameter(0,f->GetParameter(0));
253 f2->FixParameter(1,f->GetParameter(1));
254 f2->FixParameter(2,f->GetParameter(2));
255 f2->SetLineWidth(0.6);
260 double background_only_fit(
double *x,
double *par){
261 double par3 = par[0]/1.5;
262 double par4 = par[1] + 10.;
263 double par5 = par[2] * 6.5;
267 double arg1 = (x[0]-par[1])/par[2];
268 double arg2 = (x[0]-par4)/par5;
269 fitval = par[0]*TMath::Exp(-0.5*arg1*arg1) + par3*TMath::Exp(-0.5*arg2*arg2);
275 double fit_function(
double *x,
double *par){
282 double par3 = par[0] / par[3];
283 double par6 = par3/1.5;
284 double par7 = par[4] + 10.;
285 double par8 = par[5] * 6.5;
289 double arg1 = (x[0]-par[1])/par[2];
290 double arg2 = (x[0]-par[4])/par[5];
291 double arg3 = (x[0]-par7)/par8;
292 fitval = par[0]*TMath::Exp(-0.5*arg1*arg1) + par3*TMath::Exp(-0.5*arg2*arg2) + par6*TMath::Exp(-0.5*arg3*arg3);