StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdEztMuSmdCal.C
1 TObjArray *HList;
2 //for 2006 pp200, minB_trigID =117001
3 
4 int rdEztMuSmdCal( int run,
5  int trigID=117001,
6  int nEve=1000000,
7  Int_t nFiles = 1000
8  ){
9  TString fileS="R";
10  fileS+=run; fileS+=".lis";
11  //char* inDir ="/star/data05/scratch/wissink/MBRunsDay89/7089008/";
12  //fileS="st_physics_7089008_raw_1010001.MuDst.root";
13  char* inDir = "./";
14  char* file=fileS.Data();
15 
16  int sectID=6;
17  // TString outF="iter1-pp/sect";
18  // outF+=sectID; outF+="/";
19 
20  TString outF="iter5-pp/";
21 
22  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
23  loadSharedLibraries();
24  cout << " loading done " << endl;
25 
26  assert( !gSystem->Load("StEEmcUtil"));
27  assert( !gSystem->Load("StEzSmdCal"));
28 
29  // libraries below are needed for DB interface
30  assert( !gSystem->Load("StDbBroker"));
31  assert( !gSystem->Load("St_db_Maker"));
32  assert( !gSystem->Load("StEEmcDbMaker"));
33 
34  // create chain
35  chain = new StChain("StChain");
36 
37  printf("adding muDst from '%s' ....\n",file);
38 
39  // Now we add Makers to the chain...
40  muMk = new StMuDstMaker(0,0,inDir,file,"MuDst.root",nFiles);
41  TChain* tree=muMk->chain(); assert(tree);
42  int nEntries=(int)tree->GetEntries();
43  printf("total eve in chain =%d\n",nEntries);
44  printf("in=%s%s=\n",inDir,file);
45  // return;
46  St_db_Maker *stDb = new St_db_Maker("StarDb", "MySQL:StarDb");
47  new StEEmcDbMaker("eemcDb");
48 
49  // stDb->SetFlavor("onlPed","eemcPMTped");
50  stDb->SetFlavor("slope2006","eemcPIXcal"); //get 1st pass gains for strips from db
51  stDb->SetFlavor("sim","eemcPMTcal"); //use to get ideal gains for towers
52 
53 //#define IS_MC // M-C events
54 #ifdef IS_MC
55  //stDb->SetFlavor("sim","eemcPMTped"); // better use real if pedSmear is ON
56  stDb->SetFlavor("sim","eemcPMTcal");
57  stDb->SetFlavor("sim","eemcPIXcal");
58  stDb->SetDateTime(20050505,0);
59 
60 #if 1
61  assert( !gSystem->Load("StEEmcSimulatorMaker"));
62  StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
63  slowSim->setDropBad(0); // 0=no action, 1=drop chn marked bad in db
64  slowSim->setAddPed(1); // 0=no action, 1=ped offset from db
65  slowSim->setSmearPed(1); // 0=no action, 1=gaussian ped, width from db
66  slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
67 #endif
68 #endif
69 
70 
71  // MIP cut .........
72  float thrMipSmdE=0.4/1000.; // was 0.5 MeV for data
73  // line below added 3/12/2007 - sww
74  int emptyStripCount=11;
75  // int emptyStripCount=7;
76  float offCenter=0.7; // fiducial area of tower =offCenter^2, was 0.8,CuCuwas0.7
77  float twMipRelEneLow=0.5, twMipRelEneHigh=2.; // was 0.5,1.5
78  int thrMipPresAdc=12; // thres over pedestal for pre/post (was 12 if no energy cut)
79 
80  HList=new TObjArray;
81 
82  int id;
83  for(id=1;id<=12;id++) {
84  sectID=id;
85  myMk3=new MuEzSmdCalMaker("mySmdCal","MuDst");
86  // myMk3->setEZtree(false); // switch input: EzTree or regular muDst collection
87  myMk3->setHList(HList);
88  myMk3->setSector(sectID);
89  myMk3->setTwCuts(twMipRelEneLow, twMipRelEneHigh,offCenter);
90  myMk3->setSmdCuts(thrMipSmdE,emptyStripCount);
91  myMk3->setPreCuts(thrMipPresAdc);
92  myMk3->setTrigIdFilter(trigID);
93  // if(id>=3)
94  //break;
95  }
96 
97  gMessMgr->SwitchOn("I");
98  gMessMgr->SwitchOff("W");
99 
100 #ifndef IS_MC
101  muMk->SetStatus("*",0);
102  muMk->SetStatus("EztAll",1);
103  muMk->SetStatus("MuEvent",1);
104 #endif
105 
106  chain->Init();
107  chain->ls(3);
108  // muMk->printArrays();
109 
110  StEEmcDbMaker *myDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb");
111  // Two lines below added 1/9/07 to mask / set gains for smd
112  if (myDb) myDb->changeMask("iter4-pp/smdAllMaskDay89v1.dat");
113  // if (myDb) myDb->changeGains("iter1-pp/smdAllSect-slopes.dat");
114  // if (myDb) myDb->setSectors(sectID,sectID);
115 
116  printf("All Ezt-branches set\n");
117  int eventCounter=0;
118  int stat=0;
119  int t1=time(0);
120  StMuTimer timer;
121  timer.start();
122 
123  //---------------------------------------------------
124  while ( 1) {// loop over events
125  if(eventCounter>=nEve) break;
126  eventCounter++;
127  chain->Clear();
128  stat = chain->Make();
129  if(stat) break;
130  // printf ("stat=%d\n",stat);
131  if(eventCounter%200!=0)continue;
132 
133  printf("====================%5d processing ==============\n", eventCounter);
134 
135  }
136  if (myDb) myDb->print(); //EEmcDb::exportAscii
137 
138  printf("sorting done, nEve=%d of %d\n",eventCounter, nEntries);
139  int t2=time(0);
140  if(t1==t2) t2++;
141  float rate=1.*eventCounter/(t2-t1);
142  float nMnts=(t2-t1)/60.;
143  printf("sorting done %d of nEve=%d, elapsed rate=%.1f Hz, tot %.1f minutes\n",eventCounter,nEntries,rate,nMnts);
144 
145  if (eventCounter) {
146  cout << "CPU time/event= " << timer.elapsedTime()/eventCounter << " sec "
147  << " rate= " << eventCounter/timer.elapsedTime() << " Hz" << endl;
148  }
149 
150  outF+="/R"; outF+=run;
151 
152  // myMk3->saveHisto("smdCal-X");
153  myMk3->saveHisto(outF.Data());
154 
155  char tt1[100];
156  sprintf(tt1,"my%02dStat",sectID);
157  h=(TH1F *) HList->FindObject(tt1); assert(h);
158  float *my=h->GetArray();
159  printf("sec=%d nInp=%d -->UxV multi=%.1f one=%.1f, MIP any=%.1f tw=%.1f\n",sectID,eventCounter,my[2],my[3],my[4],my[5]);
160  printf(" -->MIP cntr=%.1f w/post=%.1f \n",my[6],my[7]);
161 
162  chain->Finish();
163 }
164 
165 #if 0
166 AUXILIARY code
167  // stDb->SetFlavor("sim","eemcPMTcal");
168  //stDb->SetFlavor("sim","eemcPMTstat");
169 
170 
171  myDb->changeMask( "/star/u/balewski/WWW-E/calibration/run5/absMipCal/iter1-inp/smdAllMaskDay49v1.dat");
172  myDb->changeMask( "/star/u/balewski/WWW-E/calibration/run5/absMipCal/iter1-inp/tileAllMaskDay49v1.dat");
173 
174  //....... pre/post
175  // myDb->changeGains("/star/u/balewski/WWW-E/calibration/run5/absMipCal/iter1-inp/smdAllSecG-slopes.dat");
176  myDb->changeGains("/star/u/balewski/WWW-E/calibration/run5/absMipCal/iter2-inp/smdAllSec-absGain.dat");
177  myDb->changeGains("/star/u/balewski/WWW-E/calibration/run5/absMipCal/iter3-inp/gainsP-allSect.dat");
178  myDb->changeGains("/star/u/balewski/WWW-E/calibration/run5/absMipCal/iter3-inp/gainsQ-allSect.dat");
179  myDb->changeGains("/star/u/balewski/WWW-E/calibration/run5/absMipCal/iter3-inp/gainsR-allSect.dat");
180 
181  // ... towers
182  // myDb->changeGains("/star/u/balewski/WWW-E/calibration/run5/absMipCal/iter3-inp/gainsT-allSect.dat");
183 
184 
185 for pp
186  myDb->changeGains("/star/u/balewski/WWW-E/calibration/run5/absMipCal/iter5-out/auxilGain.dat");
187 
188 #endif
189 
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
Definition: StMuDstMaker.h:426
void SetStatus(const char *arrType, int status)
Slow simulator for EEMC.