StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdMuFindBckg.C
1 class StChain;
2 StChain *chain;
3 
4 void rdMuFindBckg(int nevents=200000, char* outDir="./") {
5 
6  char *muDstFile;
7 
8  /*************************************************************/
9  // use single or list of muDsts: Example below from year 2006
10  /*************************************************************/
11 
12 #if 1 // barrelBckg run
13  muDstFile="/star/data05/scratch/qattan/myruns_R7138017/*.MuDst.root";
14  int RunNumber=7138017;
15 #endif
16 
17  /******************************************************/
18 
19  cout <<"MuDst chain file:\t"<<muDstFile<<endl;
20 
21 
22  if (gClassTable->GetID("TTable") < 0) {
23  gSystem->Load("libStar");
24  gSystem->Load("libPhysics");
25  }
26 
27  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
28  loadSharedLibraries();
29 
30  char *libL[]={
31  "StEmcRawMaker","StEmcADCtoEMaker",
32  "StDbBroker","St_db_Maker","StDaqLib",
33  "StEEmcUtil",
34  "StEEmcDbMaker",
35  "libStEmcPoolBckgFinder"
36  };
37  printf(".C Load :");
38  int i;
39  for(i=0;i<sizeof(libL)/sizeof(char*);i++) {
40  printf("'%s', ",libL[i]);
41  assert(!gSystem->Load(libL[i]));
42  }
43  printf(" \ndone loading %d libraries\n",i);
44 
45  // LoadLogger() ;
46 
47  chain= new StChain("StChain");
48 
49  //..............Instantiate the MuDstReader
50  printf("muDst: =%s=\n",muDstFile);
51  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",muDstFile,"",10,"MuDst");
52  muDstMaker->SetStatus("EztAll",1); // to get trigger data
53  TChain* tree=muDstMaker->chain(); assert(tree);
54  int nEntries=(int) tree->GetEntries();
55  printf("total eve in muDst chain =%d\n",nEntries); // return;
56 
57  if(nEntries<=0) return;
58  //......StMuDbReader...
59  StMuDbReader* dbRd = StMuDbReader::instance();
60 
61  //.......Database
62  St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb"); // default
63  //St_db_Maker *dbMk = new St_db_Maker("StarDb","/star/u/balewski/2005-jets-BTOW-DB-Fall/StarDb","MySQL:StarDb"); // private
64 
65  myDb=new StEEmcDbMaker("eemcDb"); //myDb->setSectors(11,12);
66 
67  mHList=new TObjArray;
68 
69 
70  StBemcBeamBckgFinderMaker *myMk= new StBemcBeamBckgFinderMaker("BemcBckgMaker");
71  myMk->SetHList(mHList);
72 
73  //********* SET TRIGGER TYPE ************************//
74  //trig selection use case:
75  //myMk->SetTrigger(-1); //accept any & print all
76  //myMk->SetTrigger(0); //accept any
77 
78  //myMk->SetTrigger(127221); //accept bemc-jp1-mb (year 2006 day122/run035 day122/run037)
79  myMk->SetTrigger(137222); //accept bemc-jp1-mb (year 2006 day137/run035 day138/run017)
80  //myMk->SetTrigger(137622); //accept bemc-jp0-etot-mb-L2jet (day 137/run035)
81 
82  //myMk->SetTrigger(1); //accept bemc-jp1
83 
84  //myMk->SetTrigger(96233); //bemc-jp2-mb-b (year 2005)
85  //myMk->SetTrigger(96221); //bemc-jp1-mb (year 2005)
86 
87 
88  //********* SET ADC THRESHOLD ************************//
89  myMk->SetAdcThreshold(10);
90 
91  //********* SET ADCSUM THRESHOLD *********************//
92  myMk->SetAdcSumThreshold(150.);
93 
94  //********* SET PATTERN LENGTH ***********************//
95  myMk->SetPatternLength(5);
96 
97  //********* SET MAXIMUM NUMBER OF PLOTS (POSTSCRIPT) TO PRODUCE WHEN EVENT=BACKGROUND *****************//
98  myMk->SetMaxYesPlots(0);
99 
100  //********* SET MAXIMUM NUMBER OF PLOTS (POSTSCRIPT) TO PRODUCE WHEN EVENT= NOT BACKGROUND ************//
101  myMk->SetMaxNoPlots(0);
102 
103  //*****************************************************************************************************//
104  chain->ls(3);
105  chain->Init();
106 
107  // return;
108 #ifdef doOflJets
109  TTree *tr=jetReader->tree();
110  jetReader->InitFile(jetTreeFile);
111 #endif
112 
113 
114  chain->PrintInfo();
115  int eventCounter=0;
116  int stat=0;
117  int t1=time(0);
118 
119  int Decision,eta1,phi1,eta2,Length;
120  float Adcsum;
121 
122 
123 
124  for (Int_t iev=0;iev<nevents; iev++) {
125 
126  chain->Clear();
127  int iret = chain->Make(iev);
128 
129  printf("*******************************************************************************\n");
130  printf("Working on eventNumber = %d:\n",iev+1);
131 
132 
133  myMk->GetDecision(Decision,eta1,phi1,eta2,Length,Adcsum);
134  const int *idL=myMk->GetSoftIdList();
135 
136  if(Decision==1) {
137 
138  printf("\n");
139  printf("EventDecision = YES --> THIS EVENT IS A BACKGROUND LOCATED AT: (eta1=%d phi1=%d eta2=%d), PATTERN LENGTH=%d, ADCSUM=%f\n",eta1,phi1,eta2,Length,Adcsum);
140 
141  printf("List of towers SoftIds in the background pattern found:\t");
142  int len=0;
143  while(*idL>0) {
144  printf("%d, ", *idL);
145  len++;
146  idL++;
147  }
148  printf("\n===============================================================================\n");
149 
150  } else {
151 
152  if(Decision==0) {
153  printf("===============================================================================\n");
154  printf("EventDecision = NO --> THIS EVENT IS NOT A BACKGROUND.\n");
155  printf("===============================================================================\n");
156  } else {
157 
158  printf("===============================================================================\n");
159  printf("EventDecision = NOT SEARCHED ..... NOT OF TRIGGER TYPE.\n");
160  printf("===============================================================================\n");
161  }
162  }
163 
164  eventCounter++;
165  if (iret) {
166  cout << "Bad return code!" << endl;
167  break;
168  }
169 
170  }
171 
172 
173  chain->Finish();
174  printf("\n*******************************************************************************\n");
175  // return;
176  int t2=time(0);
177  if(t2==t1) t2=t1+1;
178  float tMnt=(t2-t1)/60.;
179  float rate=1.*eventCounter/(t2-t1);
180  printf("Sorting Done: %d of nEve=%d, CPU rate=%.1f Hz, total time %.1f minute(s) \n\n",eventCounter,nEntries,rate,tMnt);
181 
182 
183  TString outF=outDir; outF+=RunNumber; outF+=".hist.root";
184  hf=new TFile(outF,"recreate");
185  // mHList->ls();
186  mHList->Write();
187  printf("\n Histo saved -->%s<\n",outF.Data());
188 
189 }
190 
191 void LoadLogger() {
192  gSystem->Load("liblog4cxx.so");
193  gSystem->Load("StStarLogger.so");
194  StLoggerManager::StarLoggerInit();
195 
196 }
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
virtual Int_t Make()
Definition: StChain.cxx:110
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)