StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runqa.C
1 #include <TSystem.h>
2 
3 int runqa( Int_t runnumber = 14032027, Int_t ped=0, Int_t nevents = 9999999, int zs=1,
4  const Char_t *evpdir = "/evp/a/",
5  Float_t chargrms=1.0, Float_t thr=4.0, Float_t thr2add=3.0,
6  Bool_t useSeed5=true, Bool_t cutShortEvents = 0){
7 
8  int day=runnumber/1000;
9 
10  LoadLibs();
11  Int_t ierr = 0;
12 
13  cout << "Constructing the chain" << endl;
14  StChain* analysisChain = new StChain("fgtQAChain");
15 
16  TString dir0 = "MySQL:StarDb";
17  TString dir1 = "$STAR/StarDb";
18  St_db_Maker *dbMkr = new St_db_Maker( "dbMkr", dir0, dir1 );
19 
20  cout << "Constructing StFgtDbMaker" << endl;
21  fgtDbMkr = new StFgtDbMaker();
22  //dbMkr->SetDateTime(20120401,000000); //run2012???
23 
24  cout << "Constructing the FGT raw daq reader" << endl;
25  char filename[200];
26  sprintf(filename,"%s/%d",evpdir,runnumber);
27  //sprintf(filename,"%s/%d_DELETE",evpdir,runnumber);
28  daqRdr = new StFgtRawDaqReader( "daqReader", filename);
29  daqRdr->setIsCosmic( false );
30  daqRdr->cutShortEvents( cutShortEvents );
31  //daqRdr->setStartTbin(1);
32  //daqRdr->setNumTbin(8);
33  if(zs>0){daqRdr->setZSdataOnly();}
34 
35  if(ped==1) {
36  daqRdr->setNoneZSdataOnly();
37  cout << "Loading and Constructing the StFgtPedMaker" << endl;
38  gSystem->Load("StFgtPedMaker");
40  pedMkr->setFgtDbMkrName("fgtDb");
41  pedMkr->setTimeBinMask(0x0);
42  pedMkr->setNumBins(4200);
43  pedMkr->setMaxAdc(4200);
44  pedMkr->setNumSmooth(0);
45  sprintf(filename,"%d/ped/ped.%d.txt",day,runnumber);
46  pedMkr->setToSaveToFile(filename);
47 
48  cout << "Loading and Constructing the Status Maker" << endl;
49  gSystem->Load("StFgtStatusMaker");
50  StFgtStatusMaker *statMkr = new StFgtStatusMaker( "FgtStatusMaker", "FgtPedMaker" );
51  sprintf(filename,"%d/status/status.%d.txt",day,runnumber);
52  statMkr->setToSaveToFile(filename);
53  statMkr->setTimeBin(0);
54  statMkr->setPedRange(200,1000);
55  statMkr->setRmsRange(15,200);
56  statMkr->setFracRange(0.0,1.0);
57  statMkr->setMaxDeadPerApv(128);
58  }else{
59  cout << "Loading and Constructing the StFgtA2CMaker" << endl;
60  gSystem->Load("StFgtA2CMaker");
61  StFgtA2CMaker* a2cMkr = new StFgtA2CMaker( "FgtA2CMaker" );
62  a2cMkr->setFgtDb(fgtDbMkr->getDbTables());
63  a2cMkr ->setAbsThres( -5000 ); // set to below -4096 to skip cut
64  // a2cMkr ->setAbsThres( 300 ); // set to below -4096 to skip cut
65  //a2cMkr ->setRelThres( 3.); // set to zero to skip cut
66  a2cMkr ->setRelThres(thr); // set to zero to skip cut
67  // a2cMkr->doCutBadStatus(true);//parameter is useless from looking at the function
68  a2cMkr->doCutBadStatus();
69  a2cMkr->acceptLongPulses(true);
71  //a2cMkr->setClusterThreshold(0.6);
72  a2cMkr->setClusterThreshold(thr/5.0);
73  a2cMkr->setPedSigFactor4Charge(chargrms);
74  a2cMkr->useLeastRestrictiveSeed(useSeed5);
76  // a2cMkr->doRemoveNonSignal(false);
77  // a2cMkr->doRemoveNonPulse(false);
78  a2cMkr->setPedestalFile("ped.txt");
79  a2cMkr->setStatusFile("status.txt");
80 
81  gSystem->Load("StFgtClusterMaker");
82  Char_t *myMaker = "StFgtClusterMaker";
83  StFgtClusterMaker* clusterMk =new StFgtClusterMaker("FgtClustMaker");
84  clusterMk->SetDEBUG();
85  // simpleClusAlgo = new StFgtSimpleClusterAlgo();
86  seededClusAlgo = new StFgtSeededClusterAlgo();
87  seededClusAlgo->setJumpSingleStrip(true); // if a strip in cluster has no charge
88  seededClusAlgo->setThreshold2AddStrip(thr2add); //threshold to add strips to cluster
89  clusterMk->setClusterAlgo( seededClusAlgo );
90 
91  gSystem->Load("StFgtPointMaker");
92  StFgtPointMaker* pointMk =new StFgtPointMaker();
93  StFgtSimplePointAlgo * simplePointAlgo = new StFgtSimplePointAlgo();
94  pointMk->setPointAlgo( simplePointAlgo );
95  simplePointAlgo->setMaxChargeAsym(0.2);
96 
97  gSystem->Load("StFgtClusterTools");
98  fgtGenBase=new StFgtGeneralBase("fgtGenBase");
99  fgtGenBase->fillFromEvent();
100  fgtStraightTrackMaker =new StFgtStraightTrackMaker("fgtStraightTracker");
101  fgtStraightTrackMaker->setMinNumFitPoints(3);
102  fgtStraightTrackMaker->setMaxClusters(30);
103  //fgtStraightPlotter=new StFgtStraightPlotter("fgtStraightPlotter");
104 
105  gSystem->Load("libMinuit");
106  gSystem->Load("StFgtAlignmentMaker");
108  algMk->setTrackType(0);
109  algMk->setDataSource(2);
110  algMk->setRunNumber(runnumber);
111  sprintf(filename,"%d/alignment_trkout.%d.root",day,runnumber);
112  algMk->setWriteTree(filename);
113 
114  gSystem->Load("StFgtQAMaker");
115  StFgtQAMaker* qaMkr =new StFgtQAMaker();
116  qaMkr->setRunNumber(runnumber);
117  }
118 
119  cout << "Initializing" << endl;
120  ierr = analysisChain->Init();
121 
122  if( ierr ){
123  cout << "Error initializing" << endl;
124  return;
125  };
126 
127  if( nevents < 0 )
128  nevents = 1<<30; // a big number
129 
130  cout << "max nevents = " << nevents << endl;
131  for( int i=0; i<nevents && !ierr; ++i ){
132  if( i+1 % 100 == 1 ) cout << "\t on event number **************" << i << endl;
133  //cout << "clear (agv)" << endl;
134  analysisChain->Clear();
135  //cout << "make" << endl;
136  ierr = analysisChain->Make();
137  //cout <<" done " <<endl;
138  };
139 
140  // fgtDbMkr->printFgtDumpCSV("fgtMapDump.csv");
141  //
142  // Calls the ::Finish() method on all makers
143  //
144  cout << "finish" << endl;
145  analysisChain->Finish();
146 
147  // Now write a status table
148 
149  /*
150  if( runnumber ){
151  std::stringstream ss;
152  fout << "Times given in the run log are " << endl;
153  ss << "lynx -dump 'http://online.star.bnl.gov/RunLogRun12/index.php?r=" << runnumber << "' | grep GMT";
154  FILE *f = gSystem->OpenPipe(ss.str().data(),"r");
155  Char_t c;
156  while((c=fgetc(f))!=EOF)
157  fout << c;
158  };
159  */
160 
161  bool doOutputPdf=false;
162  // convert ps to pdf
163  if( doOutputPdf ){
164  cout << "converting ps to pdf" << endl;
165  gSystem->Exec(( std::string("ps2pdf -dAutoRotatePages=/None ") + pdfFile ).data());
166  };
167 
168  cout << "\tall done" << endl;
169  return;
170 };
171 
172 
173 // load the shared libraries
174 void LoadLibs() {
175  gROOT->Macro("loadMuDst.C");
176  gSystem->Load("libPhysics");
177  gSystem->Load("St_base");
178  gSystem->Load("StChain");
179  gSystem->Load("StUtilities");
180  gSystem->Load("StEvent");
181  gSystem->Load("libStDb_Tables.so");
182  gSystem->Load("StDbLib.so");
183  gSystem->Load("St_db_Maker");
184  gSystem->Load("StDbBroker");
185  gSystem->Load("RTS");
186  gSystem->Load("StFgtUtil");
187  gSystem->Load("StFgtDbMaker");
188  gSystem->Load("StFgtRawDaqReader");
189 };
void acceptLongPulses(Bool_t accept)
set status mask to some other value
void setRelThres(Float_t thres)
set to below -kFgtMaxAdc (-4096) to skip cut
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
A typical Analysis Class.
Int_t setClusterAlgo(StFgtIClusterAlgo *)
clear function is empty at the moment
void doCutBadStatus()
set pointer to StFgtDb
void setFgtDb(StFgtDb *fgtDb)
set to zero to skip cut
virtual Int_t Make()
Definition: StChain.cxx:110
A typical Analysis Class.
Definition: StFgtQAMaker.h:68