StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doSmdGains.C
1 class SmdGains;
2 SmdGains *task=0;
3 TObjArray *HList;
4 TFile *fd;
5 
6 // doSmdGains( int sectID=6 , int iU=0){
7 doSmdGains( int sectID , int iU) {
8 
9  TString iPath="iter5-pp/sect";
10  if (sectID<10) iPath+="0";
11  iPath+=sectID; iPath+="/";
12 
13  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
14  loadSharedLibraries();
15 
16  gStyle->SetPalette(1,0);
17 
18  gSystem->Load("StEEmcUtil");
19  gSystem->Load("StEzSmdCal");
20  printf("loaded libraries\n");
21 
22  HList=new TObjArray;
23  task=new SmdGains;
24 
25  char tt[500];
26  sprintf(tt,"%ssum-sect%d.hist.root",iPath.Data(),sectID);
27 
28  fd=task->open(tt);
29  // fd=task->open(iPath+"smdCal-R6049129.hist.root");
30  // fd=task->open(iPath+"sum.hist.root");
31  // return;
32 
33  task->set(HList,sectID,'U'+iU);
34  task->init();
35 
36  int str1=267,str2=270;
37 
38 #if 0
39  //=== iteration 0 =====> SMD gains from slopes
40  // just plot all SMD slopes for given sector for one plain
41  for(str1=1;str1<288;str1+=30) {
42  str2=str1+29;
43  if(str2>288) str2=288;
44  task->fitSlopesSmd(str1,str2,1);
45  // sww 1/26/2007 change conv fact from 760. -> 850.
46  //task-> doSlopesOnly(760./1.4); // for CuCu200-minB
47  task-> doSlopesOnly(850./1.4); // for 2006 pp minbias
48  // break;
49  }
50 #endif
51 
52 
53 #if 1
54  //=== iteration 1 =====> SMD gains from MIPs from pairs of strips
55  str1=1; str2=288;
56  task->doGainCorr(str1,str2,12,1);
57  task->plTGraph("pol0",1,1); // avearge MIP energy
58  task->saveHisto();
59 
60  if(0) {
61  task->plFGC();
62  task->plTGraph("pol0",0); // individual gain corrections
63 
64  }
65  #endif
66 
67  /* === iteration 1b =====> run reCalSmd.C to
68  - average gain corrections among plains
69  - calculate new gains from the old gains
70  */
71 
72  char tt[100];
73  sprintf(tt,"smd%02d%c.dat",sectID,'U'+iU);
74  FILE *fd=fopen(tt,"w"); assert(fd);
75  fprintf(fd,"# gains for SMD plain %02d%c, inverted slopes\n# stripName, gain[ch/GeV], erGain, anything\n",sectID,'U'+iU);
76  task->saveGains(fd);
77  fclose(fd);
78  return;
79 
80 }
81 
82 //--------------------------------
83 // UTIL
84 //-------------------------------
85 
86 void plotAllTiles() {
87  // fit raw P,Q,R,T spectra with expo, just plot
88  char cT[4]={'P','Q','R','T'};
89  int iT;
90  for(iT=0;iT<4;iT++) {
91  task->fitSlopesTile(1,6,cT[iT],3);
92  task->fitSlopesTile(7,6,cT[iT],3);
93  }
94 }