6 void mip_histogram_maker(
const char* file_list=
"",
const char* skimfile=
"mipskimfile.root")
8 gROOT->Macro(
"LoadLogger.C");
9 gROOT->Macro(
"loadMuDst.C");
10 gSystem->Load(
"StTpcDb");
11 gSystem->Load(
"StDaqLib");
12 gSystem->Load(
"StDetectorDbMaker");
13 gSystem->Load(
"St_db_Maker");
14 gSystem->Load(
"StDbUtilities");
15 gSystem->Load(
"StEmcRawMaker");
16 gSystem->Load(
"StMcEvent");
17 gSystem->Load(
"StMcEventMaker");
18 gSystem->Load(
"StEmcSimulatorMaker");
19 gSystem->Load(
"StEmcADCtoEMaker");
20 gSystem->Load(
"StEpcMaker");
21 gSystem->Load(
"StDbBroker");
22 gSystem->Load(
"StEEmcUtil");
23 gSystem->Load(
"StAssociationMaker");
25 gSystem->Load(
"StTriggerUtilities");
26 gSystem->Load(
"StEmcOfflineCalibrationMaker");
28 const int ntowers=4800;
29 const bool lookForSwaps=
false;
31 cout<<
"input filelist: "<<file_list<<endl;
32 cout<<
"histogram file: "<<skimfile<<endl;
36 TChain* calib_tree =
new TChain(
"calibTree");
37 ifstream filelist(file_list);
41 if(!filelist.good())
break;
43 calib_tree->Add(file);
47 calib_tree->SetBranchAddress(
"event_branch",&myEvent);
51 TH2F* mapcheck =
new TH2F(
"mapcheck",
"check mapping",4800,0.5,4800.5,4800,0.5,4800.5);
52 mapcheck->SetXTitle(
"Track Projection ID");
53 mapcheck->SetYTitle(
"Tower hit above 5 rms");
54 TH1* mip_histo[ntowers];
56 for(
int k=0; k<ntowers; k++){
57 sprintf(name,
"mip_histo_%i",k+1);
58 mip_histo[k] =
new TH1D(name,name,250,-50.5,199.5);
62 set<int> track_towers;
63 set<int> excluded_towers;
66 unsigned int nentries = calib_tree->GetEntries();
67 for(
unsigned int i=0; i<nentries; i++){
68 if(i%100000 == 0) cout<<
"processing "<<i<<
" of "<<nentries<<endl;
71 excluded_towers.clear();
73 calib_tree->GetEntry(i);
76 if(TMath::Abs(myEvent->vz[0]) > 30.)
continue;
79 for(
int j=0; j<myEvent->tracks->GetEntries(); j++){
81 int id = mip->tower_id[0];
83 if(track_towers.find(
id) != track_towers.end()){
84 excluded_towers.insert(
id);
87 track_towers.insert(
id);
94 for(
int j=0; j<myEvent->tracks->GetEntries(); j++){
97 double pedsub = mip->tower_adc[0] - mip->tower_pedestal[0];
100 if(excluded_towers.find(mip->tower_id[0]) != excluded_towers.end())
continue;
101 if(mip->p < 1.)
continue;
103 if(mip->tower_id[0] != mip->tower_id_exit)
continue;
105 for(
int k = 0; k < 9; k++){
106 if(mip->tower_adc[k] - mip->tower_pedestal[k] < 5*mip->tower_pedestal_rms[k])
continue;
107 mapcheck->Fill(mip->tower_id[0],mip->tower_id[k]);
110 if(mip->highest_neighbor > 2.)
continue;
111 if(pedsub < 1.5*mip->tower_pedestal_rms[0])
continue;
114 int index = mip->tower_id[0];
115 mip_histo[index-1]->Fill(pedsub);
121 cout<<
"Added "<<ngood<<
" tracks of "<<ntracks<<endl;
122 TFile* output_file =
new TFile(skimfile,
"RECREATE");
123 for(
int k=0; k<ntowers; k++) mip_histo[k]->Write();
125 output_file->Close();