Example #1
0
int runqa(Int_t run=16020057,Int_t ped=0,Int_t nevents=0,const Char_t *evpdir = "/evp/a/"){
  int day=run/1000;
  LoadLibs();   
  Int_t ierr = 0;
  
  cout << "Constructing the chain" << endl;
  StChain* analysisChain = new StChain("fpsQAChain");
  
  TString dir0 = "MySQL:StarDb";
  TString dir1 = "$STAR/StarDb";
  St_db_Maker *dbMkr = new St_db_Maker( "dbMkr", dir0, dir1 );  
  
  cout << "Constructing StFmsDbMaker" << endl;
  fgtDbMkr = new StFmsDbMaker();
  

  cout << "Constructing the FPS raw daq reader" << endl;
  char filename[200]; 
  sprintf(filename,"%s/%d",evpdir,run);
  //sprintf(filename,"%s/%d_DELETE",evpdir,run);
  daqRdr = new StFpsRawDaqReader( "daqReader", filename);
  //daqRdr->SetDebug();
  
  cout << "Constructing the FPS QA maker" << endl;
  StFpsQaMaker *qaMkr=new StFpsQaMaker("FpsQa");  
  qaMkr->setRun(run);
  qaMkr->setPed(ped);

  cout << "Initializing" << endl;
  ierr = analysisChain->Init();
  
  if( ierr ){
    cout << "Error initializing" << endl;
    return;
  };
  
  if(nevents<=0) nevents = 1<<30; // a big number
  
  cout << "Max nevents = " << nevents << endl;
  for( int i=0; i<nevents && !ierr; ++i ){
    if( i%100 == 0 ) cout << " Eevent= " << i << endl;
    //cout << " Eevent number " << i << endl;
    ierr = analysisChain->Make();    
    analysisChain->Clear();
  };
  cout << "Finish" << endl;
  analysisChain->Finish();
  return 0;
};
Example #2
0
void SchedulerExample(const char* fileList, const char* outFile="SchedulerExample.root") {
    gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
    loadSharedLibraries();

  // create the chain"
  StChain * chain = new StChain("StChain"); 
  chain->SetDebug(0);

  // now create StMuDstMaker
  // agruments are:
  // 0  : read mode
  // 0  : name mode (has no effect on read mode) 
  // "" : input directory, ignored when filename or fileList is specified
  // fileList : list of files to read
  // "" : filter 
  // 1e9 : maximum number of files to read
  // MuDstMaker : name of the maker
  //cout << " press any key " << endl; cin.ignore();
  //StMuDebug::setLevel(0);
  //  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",fileList,"",10,"MuDstMaker");


  // now add your analysis maker
  //  SchedulerExample* analysis = new SchedulerExample(outFile);
 
  // Init the chain
  chain->Init(); // This should call the Init() method in ALL makers
  chain->PrintInfo();
  
  int iret = 0;
  int iev =0;
  // now loop over events, makers are call in order of creation
  while ( !iret ) {
    cout << "SchedulerExample.C -- Working on eventNumber " << iev++ << endl;
    chain->Clear();
    iret = chain->Make(iev); // This should call the Make() method in ALL makers    
  } // Event Loop
  chain->Finish(); // This should call the Finish() method in ALL makers

}
void RunFmsTrigOverData(int nevents = 1000, const char* mudstfile = "/star/data27/reco/pp500_production_2011/ReversedFullField/P11id/2011/056/12056013/st_physics_12056013_raw_5020002.MuDst.root")
{
  // Load shared libraries
  gROOT->Macro("loadMuDst.C");
  gROOT->Macro("LoadLogger.C");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");
  gSystem->Load("StEEmcUtil");
  gSystem->Load("StFmsTriggerMaker");

  // Create chain
  StChain* chain = new StChain;

  // Instantiate MuDst maker
  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",mudstfile,".",1000,"MuDst");

  // STAR database
  St_db_Maker* starDb = new St_db_Maker("StarDb","MySQL:StarDb");

  // FMS trigger simulator
  StFmsTriggerMaker* fmstrig = new StFmsTriggerMaker;
  fmstrig->useMuDst();

  // Initialize chain
  chain->Init();

  // Event loop
  for (int iEvent = 1; iEvent <= nevents; ++iEvent) {
    chain->Clear();
    int status = chain->Make(iEvent);
    if (status == kStSkip) continue;
    if (status % 10 == kStEOF || status % 10 == kStFatal) break;

    // Test FMS dijet trigger
    if (fmstrig->FmsDijet()) {
      printf("Run=%d Event=%d - Got FMS dijet trigger\n",chain->GetRunNumber(),chain->GetEventNumber());
    }
  } // Event loop
}
Example #4
0
void reconstruct_v0(TString InputFileList, Int_t nFiles, Int_t nEvents, TString OutputDir, TString JobIdName ) 
{
 
  // Load libraries
  gROOT   -> Macro("loadMuDst.C");

  //gSystem->Load("StDbBroker");
  //gSystem->Load("StDbUtilities");
  //gSystem->Load("St_db_Maker");  //They are used for Run9 to calculate the Primary Vertex

  gSystem -> Load("StV0Maker.so") ;
  gSystem -> Load("StXiMaker.so") ;

  // List of member links in the chain
  StChain*                    chain  =  new StChain ;

  StMuDstMaker*          muDstMaker  =  new StMuDstMaker(0,0,"",InputFileList,"MuDst",nFiles) ;
  // Turn off everything but Primary tracks in order to speed up the analysis and eliminate IO
  muDstMaker -> SetStatus("*",0) ;               // Turn off all branches
  muDstMaker -> SetStatus("MuEvent",1) ;         // Turn on the Event data (esp. Event number)
  muDstMaker -> SetStatus("GlobalTracks",1) ;    // Turn on the global track data
  muDstMaker -> SetStatus("BTofHeader",1) ;    // Turn on the global track data
  muDstMaker -> SetDebug(0) ;                    // Turn off Debug information
//muDstMaker -> SetDebug(1) ;                  //Turn on Debug information
  //cout<<endl<<"============  Data Base ========="<<endl;
  //dbMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
  //dbMk->SetMaxEntryTime(20100130,0);  //They are used for Run9 to calculate the Primary Vertex

  //first pass to get the raw signal of Lambda
  StV0Maker* rawsig  =  new StV0Maker(muDstMaker,"v0makerfirst") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".lambda.histo.root") ;
  rawsig -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  rawsig -> setV0TreeFileName(OutputDir+JobIdName+".lambda.picodst.root"); // V0 candidate tree file for further cuts. 
  rawsig -> setV0Type(kLambda);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! 
  rawsig -> setRotate(false); 
  rawsig -> setDumpNull(true);
  rawsig -> SetDebug(0);
  
  //second pass to get the raw signal of AntiLambda
  StV0Maker* antirawsig  =  new StV0Maker(muDstMaker,"v0makersecond") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".antilambda.histo.root") ;
  antirawsig -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  antirawsig -> setV0TreeFileName(OutputDir+JobIdName+".antilambda.picodst.root"); // V0 candidate tree file for further cuts. 
  antirawsig -> setV0Type(kAntiLambda);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! 
  antirawsig -> setRotate(false); 
  antirawsig -> SetDebug(0);

  
  //third pass to get the raw signal of Kshort
  StV0Maker* ksrawsig  =  new StV0Maker(muDstMaker,"v0makerthird") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".ks.histo.root") ;
  ksrawsig -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  ksrawsig -> setV0TreeFileName(OutputDir+JobIdName+".ks.picodst.root"); // V0 candidate tree file for further cuts. 
  ksrawsig -> setV0Type(kKs);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! 
  ksrawsig -> setRotate(false); 
//  ksrawsig -> setDumpNull(true); //FIXME: essential option to get correct normalization!!!!
  ksrawsig -> SetDebug(0);
 
 /*
  //fourth pass to estimate the background by rotating the transverse coordinate and momentum of second daughter.
  StV0Maker* backgr  =  new StV0Maker(muDstMaker,"v0makerfourth") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".lambdarot.histo.root") ;
  backgr -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  backgr -> setV0TreeFileName(OutputDir+JobIdName+".lambdarot.picodst.root"); // V0 candidate tree file for further cuts. 
  backgr -> setV0Type(kLambda);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! 
  backgr -> setRotate(true); 
  backgr -> SetDebug(0);

  //fifth pass to estimate the background by rotating the transverse coordinate and momentum of second daughter.
  StV0Maker* backgr2  =  new StV0Maker(muDstMaker,"v0makerfifth") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".antilambdarot.histo.root") ;
  backgr2 -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  backgr2 -> setV0TreeFileName(OutputDir+JobIdName+".antilambdarot.picodst.root"); // V0 candidate tree file for further cuts. 
  backgr2 -> setV0Type(kAntiLambda);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! 
  backgr2 -> setRotate(true); 
  backgr2 -> SetDebug(0);

  
  //sixth pass to estimate the background by rotating the transverse coordinate and momentum of second daughter.
  StV0Maker* backgr3  =  new StV0Maker(muDstMaker,"v0makersixth") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".ksrot.histo.root") ;
  backgr3 -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  backgr3 -> setV0TreeFileName(OutputDir+JobIdName+".ksrot.picodst.root"); // V0 candidate tree file for further cuts. 
  backgr3 -> setV0Type(kKs);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! 
  backgr3 -> setRotate(true); 
  backgr3 -> SetDebug(0);
*/  

  
  // use StXiMaker to reconstruct Xi or Omega
  StXiMaker* rawxi  =  new StXiMaker(muDstMaker, rawsig, "StXiMakerfirst") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".xi.histo.root") ;
  rawxi -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  rawxi -> setXiTreeFileName(OutputDir+JobIdName+".xi.picodst.root"); // V0 candidate tree file for further cuts. 
  rawxi -> setXiType(kXi);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! do not try to mess things up for the time being.
  rawxi -> setRotate(false); 
  rawxi -> SetDebug(0);
/*
  // use StXiMaker to reconstruct Xi or Omega
  StXiMaker* rawxirotate  =  new StXiMaker(muDstMaker, rawsig, "StXiMakersecond") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".xirot.histo.root") ;
  rawxirotate -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  rawxirotate -> setXiTreeFileName(OutputDir+JobIdName+".xirot.picodst.root"); // V0 candidate tree file for further cuts. 
  rawxirotate -> setXiType(kXi);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! do not try to mess things up for the time being.
  rawxirotate -> setRotate(true); 
  rawxirotate -> SetDebug(0);
 */
  // use StXiMaker to reconstruct Xi or Omega
  StXiMaker* rawantixi  =  new StXiMaker(muDstMaker, antirawsig, "StXiMakerAntiXi") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".antixi.histo.root") ;
  rawantixi -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  rawantixi -> setXiTreeFileName(OutputDir+JobIdName+".antixi.picodst.root"); // V0 candidate tree file for further cuts. 
  rawantixi -> setXiType(kAntiXi);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! do not try to mess things up for the time being.
  rawantixi -> setRotate(false); 
  rawantixi -> SetDebug(0);
/*
   // use StXiMaker to reconstruct Xi or Omega
  StXiMaker* rawantixirotate  =  new StXiMaker(muDstMaker, antirawsig, "StXiMakerAntiXiRot") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".antixirot.histo.root") ;
  rawantixirotate -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  rawantixirotate -> setXiTreeFileName(OutputDir+JobIdName+".antixirot.picodst.root"); // V0 candidate tree file for further cuts. 
  rawantixirotate -> setXiType(kAntiXi);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! do not try to mess things up for the time being.
  rawantixirotate -> setRotate(true); 
  rawantixirotate -> SetDebug(0);
 */
  // use StXiMaker to reconstruct Xi or Omega
  StXiMaker* rawomega  =  new StXiMaker(muDstMaker, rawsig, "StXiMakerthird") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".omega.histo.root") ;
  rawomega -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  rawomega -> setXiTreeFileName(OutputDir+JobIdName+".omega.picodst.root"); // V0 candidate tree file for further cuts. 
  rawomega -> setXiType(kOmega);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! do not try to mess things up for the time being.
  rawomega -> setRotate(false); 
  rawomega -> SetDebug(0);
/*
  // use StXiMaker to reconstruct Xi or Omega
  StXiMaker* rawomegarotate  =  new StXiMaker(muDstMaker, rawsig, "StXiMakerfourth") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".omegarot.histo.root") ;
  rawomegarotate -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  rawomegarotate -> setXiTreeFileName(OutputDir+JobIdName+".omegarot.picodst.root"); // V0 candidate tree file for further cuts. 
  rawomegarotate -> setXiType(kOmega);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! do not try to mess things up for the time being.
  rawomegarotate -> setRotate(true); 
  rawomegarotate -> SetDebug(0);
 */
  // use StXiMaker to reconstruct Xi or Omega
  StXiMaker* rawantiomega  =  new StXiMaker(muDstMaker, antirawsig, "StXiMakerAntiOmega") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".antiomega.histo.root") ;
  rawantiomega -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  rawantiomega -> setXiTreeFileName(OutputDir+JobIdName+".antiomega.picodst.root"); // V0 candidate tree file for further cuts. 
  rawantiomega -> setXiType(kAntiOmega);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! do not try to mess things up for the time being.
  rawantiomega -> setRotate(false); 
  rawantiomega -> SetDebug(0);
/*
  // use StXiMaker to reconstruct Xi or Omega
  StXiMaker* rawantiomegarotate  =  new StXiMaker(muDstMaker, antirawsig, "StXiMakerAntiOmegaRot") ;
  // Miscellaneous things we need before starting the chain
  TString Name = JobIdName ;
  Name.Append(".antiomegarot.histo.root") ;
  rawantiomegarotate -> setHistoFileName(OutputDir+Name) ; // Name the output file for histograms
  rawantiomegarotate -> setXiTreeFileName(OutputDir+JobIdName+".antiomegarot.picodst.root"); // V0 candidate tree file for further cuts. 
  rawantiomegarotate -> setXiType(kAntiOmega);   //set V0 type. kKs, or kLambda, kAntiLambda. once a time! do not try to mess things up for the time being.
  rawantiomegarotate -> setRotate(true); 
  rawantiomegarotate -> SetDebug(0);
*/
  if ( nEvents == 0 )  nEvents = 10000000 ;       // Take all events in nFiles if nEvents = 0

  // Loop over the links in the chain
  Int_t iInit = chain -> Init() ;
  if (iInit) chain->Fatal(iInit,"on init");
  
  // chain -> EventLoop(1,nEvents) ;  //will output lots of useless debugging info.
  Int_t istat = 0, i = 1;
  while (i <= nEvents && istat != 2) {
     //if(i==740){i++; continue;}
     if(i%10000==0)cout << endl << "== Event " << i << " start ==" << endl;
     chain->Clear();
     istat = chain->Make(i);
     //if(i%1000==0)cout << endl << "== Event " << i << " finish =="<< endl;
     if (istat == 2)
	  cout << "Last  event processed. Status = " << istat << endl;
     if (istat == 3)
	  cout << "Error event processed. Status = " << istat << endl;
     i++;
  }

  if (nEvents > 1) chain -> Finish() ;

  // Cleanup
  delete chain ;
}
Example #5
0
void TestJpsiTopo(int nevents = 1e6, const char* mudstfile = "/star/data28/reco/ppProductionJPsi/FullField/P06id/2006/139/7139023/st_jpsi_7139023_raw_1130010.MuDst.root")
{
  gROOT->Macro("loadMuDst.C");
  gROOT->Macro("LoadLogger.C");

  // Load shared libraries
  gSystem->Load("StTpcDb");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("StDbUtilities");
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");
  gSystem->Load("StDaqLib");
  gSystem->Load("StEmcRawMaker");
  gSystem->Load("StEmcADCtoEMaker");
  gSystem->Load("StEpcMaker");
  gSystem->Load("StEmcSimulatorMaker");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");
  gSystem->Load("StEEmcUtil");
  gSystem->Load("StEEmcDbMaker");
  gSystem->Load("StTriggerUtilities");

  // Create chain
  StChain* chain = new StChain; 

  // MuDst reader
  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",mudstfile,"",100000,"MuDst");

  // StMuDbReader...
  StMuDbReader* db = StMuDbReader::instance();

  // star database
  St_db_Maker* starDb = new St_db_Maker("StarDb","MySQL:StarDb");

  // Endcap database
  StEEmcDbMaker* eemcDb = new StEEmcDbMaker;

  // Barrel ADC to energy maker
  StEmcADCtoEMaker* adc2e = new StEmcADCtoEMaker;

  // Trigger simulator
  StTriggerSimuMaker* trigSimu = new StTriggerSimuMaker;
  trigSimu->setMC(false);
  trigSimu->useBemc();
  trigSimu->bemc->setConfig(StBemcTriggerSimu::kOffline);

  // Initialize chain
  chain->Init();

  // Event loop
  for (int iEvent = 1; iEvent <= nevents; ++iEvent) {
    chain->Clear();
    int status = chain->Make(iEvent);
    if (status == kStSkip) continue;
    if (status % 10 == kStEOF || status % 10 == kStFatal) break;

    cout << "Run = " << chain->GetRunNumber() << ", Event = " << chain->GetEventNumber() << endl;

    // Test J/psi topology trigger in Run 6
    if (trigSimu->isTrigger(117705) || trigSimu->isTrigger(137705)) {
      // Print number of J/psi candidate BEMC tower pairs that could have fired the J/psi trigger
      cout << "Number of J/psi candidates = " << trigSimu->bemc->numberOfJpsiCandidates() << endl;
      // Loop over J/psi candidates
      for (int i = 0; i < trigSimu->bemc->numberOfJpsiCandidates(); ++i) {
	cout << "J/psi candidate #" << i
	     << ": towerId1 = " << trigSimu->bemc->jpsiCandidateFirstTowerId(i)
	     << ", towerId2 = " << trigSimu->bemc->jpsiCandidateSecondTowerId(i)
	     << endl;
      }	// End loop over J/psi candidates
    }

  } // End event loop
}
Example #6
0
void Macro(int nEvents = 1e5,
		const char* filelist = "test.list", 
		const char* nametag  = "test",
		    int nFiles = 8
		    )
{
  gROOT->Macro("LoadLogger.C");
  gROOT->Macro("loadMuDst.C");
  gSystem->Load("StarMagField.so");
  gSystem->Load("StMagF");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("StTpcDb");
  gSystem->Load("St_db_Maker");
  gSystem->Load("StDbUtilities");
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");
  gSystem->Load("StDaqLib");
  gSystem->Load("StEmcRawMaker");
  gSystem->Load("StEmcADCtoEMaker");
  gSystem->Load("StEpcMaker");
  gSystem->Load("StTriggerUtilities");
  gSystem->Load("StDbBroker");
  gSystem->Load("libgeometry_Tables");
  gSystem->Load("StEEmcUtil");
  gSystem->Load("StEEmcDbMaker");
  gSystem->Load("StPreEclMaker");
  gSystem->Load("StEpcMaker");
 
  gSystem->Load("libTStarJetPico.so");
  gSystem->Load("JetPicoMaker");
	
  StChain* chain = new StChain("StChain");
	
  // MuDst maker
  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",filelist,"",nFiles);

  // star database
  St_db_Maker *dbMaker = new St_db_Maker("StarDb","MySQL:StarDb");
  // Endcap database
  StEEmcDbMaker* eemcb = new StEEmcDbMaker("eemcDb");
  // Barrel ADC to energy maker
  StEmcADCtoEMaker *adc = new StEmcADCtoEMaker();
  StPreEclMaker *pre_ecl  = new StPreEclMaker();
  StEpcMaker *epc         = new StEpcMaker();

  //get control table so we can turn off BPRS zero-suppression and save hits from "bad" caps
  controlADCtoE_st* control_table = adc->getControlTable();
  control_table->CutOff[1] = -1;
  control_table->CutOffType[1] = 0;
  control_table->DeductPedestal[1] = 2;
  adc->saveAllStEvent(kTRUE);

  StTriggerSimuMaker* trigsim = new StTriggerSimuMaker();
  trigsim->setMC(false);
  trigsim->useBemc();
  trigsim->useEemc();
  //trigsim->useBbc();
  trigsim->useOnlineDB();
  trigsim->bemc->setConfig(StBemcTriggerSimu::kOnline);



  StMuJetAnalysisTreeMaker *ana = new StMuJetAnalysisTreeMaker;
  ana->SetVerbose(10);
  ana->setRootFile(Form("pAu15Pico_%s.root",nametag));  
  ana->SetFlagData(12); //For pAu Y15
  ana->GetV0Cuts()->SetStandardCutspp();   
  ana->SetDoV0s(kFALSE);      
  //TString outfile(name);
  //StEmcOfflineCalibrationMaker* bemcCalibMaker = new StEmcOfflineCalibrationMaker("bemcCalibMaker",outfile.Data());

  StMemStat memory;
  memory.PrintMem(NULL);
	
  chain->Init();
  cout<<"chain initialized"<<endl;
	
  TStopwatch total;
  TStopwatch timer;
	
  int i=0;
  while(i<nEvents && chain->Make()==kStOk)
    {
      if(i % 100000 == 0){
	cout<<"done with event "<<i;
	cout<<"\tcpu: "<<timer.CpuTime()<<"\treal: "<<timer.RealTime()<<"\tratio: "<<timer.CpuTime()/timer.RealTime();//<<endl;
	timer.Start();
	memory.PrintMem(NULL);
      }
      i++;
      chain->Clear();
    }
	
  chain->ls(3);
  chain->Finish();
  printf("my macro processed %i events in %s",i,nametag);
  cout<<"\tcpu: "<<total.CpuTime()<<"\treal: "<<total.RealTime()<<"\tratio: "<<total.CpuTime()/total.RealTime()<<endl;

  cout << endl;
  cout << "-------------" << endl;
  cout << "(-: Done :-) " << endl;
  cout << "-------------" << endl;
  cout << endl;
}
Example #7
0
void bitcheck(int run=16043074, int file=1, int nEvents=10000, int useDSM=1, int plt=0){
  char name[200]; sprintf(name,"trg/run%d.%d.dat",run,file);
  cout << "Reading up to "<<nEvents<<" events from "<<name<<endl;

  LoadLibs();   
   
  StChain* chain = new StChain;
  StIOMaker* iomaker = new StIOMaker("IO","r", name);
  StTriggerDataMaker* trgmaker = new StTriggerDataMaker(); 
  //trgmaker->setDebug(1);
  StFmsTriggerMaker* fmstrg = new StFmsTriggerMaker(); 
  fmstrg->useTrgData();
  fmstrg->forceRunNumber(run);
  if(useDSM==0) fmstrg->useQTSim();
  if(useDSM==1) fmstrg->useDsmData();
  StFmsBitCheckMaker* bitcheck = new StFmsBitCheckMaker();
  bitcheck->setRun(run);
  bitcheck->setPrint(20);
  StFmsTrgQaMaker* qa = new StFmsTrgQaMaker();
  qa->setRun(run);  

  chain->Init();

  if(plt==1){
    c1=new TCanvas("FMS","FMS",700,800);
    gStyle->SetOptStat(111110);
    gStyle->SetStatW(0.4); gStyle->SetStatH(0.4);
    for(int i=0; i<=NX*2; i++){
      int x=i-NX;  
      char tt[100];
      sprintf(tt,"FMS xing=%d",x);
      HF[i]=new TH1F(tt,tt,50,0,5000); HF[i]->SetFillColor(kRed);
      sprintf(tt,"BBC xing=%d",x);      
      HB[i]=new TH1F(tt,tt,50,0,5000); HB[i]->SetFillColor(kRed);
    }
  }

  unsigned long long bxkeep=0;
  for(int iev=0; iev<nEvents; iev++){
    if(iev%100==0) cout << "****event="<<iev<<endl;
    chain->Clear();
    int ierr=chain->Make();
    if(ierr>1) break;

    if(plt==1){      
      StTriggerData *td = (StTriggerData*)chain->GetDataSet("StTriggerData")->GetObject();
      int npre=td->numberOfPreXing();
      int npost=td->numberOfPostXing();
      for(int i=0; i<=2*NX; i++){
	int x=i-NX;  
	if(-x>npre || x>npost) continue;
	int sumF=0, sumB=0;
	for(int crt=1; crt<=4; crt++){
	  for(int adr=0; adr<16; adr++){
	    for(int ch=0; ch<32; ch++){
	      sumF+=td->fmsADC(crt,adr,ch,x);
	    }
	  }
	}
	for(int ch=0; ch<16; ch++){
	  sumB+=td->bbcADC(0,ch,x);
	  sumB+=td->bbcADC(1,ch,x);
	}
	HF[i]->Fill(sumF);
	HB[i]->Fill(sumB);
      }
    }	    
  }
  chain->Finish();  

  if(plt==1){
    c1->Divide(2,NX*2+1);
    for(int i=0; i<=2*NX; i++){
      TVirtualPad *pad1 = c1->cd(i*2+1); pad1->SetLogy(); HF[i]->Draw();
      TVirtualPad *pad2 = c1->cd(i*2+2); pad2->SetLogy(); HB[i]->Draw();
    }
    c1->Update();
    char fname[100];
    sprintf(fname,"fms_%d.png",run);
    c1->SaveAs(fname);
  }

  delete chain;
}
Example #8
0
int runqa( Int_t runnumber = 14032027, Int_t ped=0, Int_t nevents = 9999999, int zs=1,
	   const Char_t *evpdir = "/evp/a/",
	   Float_t chargrms=1.0, Float_t thr=4.0, Float_t thr2add=3.0, 
	   Bool_t useSeed5=true, Bool_t cutShortEvents = 0){
  
  int day=runnumber/1000;

  LoadLibs();   
  Int_t ierr = 0;
  
  cout << "Constructing the chain" << endl;
  StChain* analysisChain = new StChain("fgtQAChain");
  
  TString dir0 = "MySQL:StarDb";
  TString dir1 = "$STAR/StarDb";
  St_db_Maker *dbMkr = new St_db_Maker( "dbMkr", dir0, dir1 );  
  
  cout << "Constructing StFgtDbMaker" << endl;
  fgtDbMkr = new StFgtDbMaker();
  //dbMkr->SetDateTime(20120401,000000); //run2012???
  
  cout << "Constructing the FGT raw daq reader" << endl;
  char filename[200]; 
  sprintf(filename,"%s/%d",evpdir,runnumber);
  //sprintf(filename,"%s/%d_DELETE",evpdir,runnumber);
  daqRdr = new StFgtRawDaqReader( "daqReader", filename);
  daqRdr->setIsCosmic( false );
  daqRdr->cutShortEvents( cutShortEvents );
  //daqRdr->setStartTbin(1);
  //daqRdr->setNumTbin(8);
  if(zs>0){daqRdr->setZSdataOnly();}
  
  if(ped==1) {
    daqRdr->setNoneZSdataOnly();
    cout << "Loading and Constructing the StFgtPedMaker" << endl;
    gSystem->Load("StFgtPedMaker");
    StFgtRobustPedMaker* pedMkr  = new StFgtRobustPedMaker();
    pedMkr->setFgtDbMkrName("fgtDb");
    pedMkr->setTimeBinMask(0x0);
    pedMkr->setNumBins(4200);
    pedMkr->setMaxAdc(4200);
    pedMkr->setNumSmooth(0);
    sprintf(filename,"%d/ped/ped.%d.txt",day,runnumber);
    pedMkr->setToSaveToFile(filename);

    cout << "Loading and Constructing the Status Maker" << endl;
    gSystem->Load("StFgtStatusMaker");
    StFgtStatusMaker *statMkr = new StFgtStatusMaker( "FgtStatusMaker", "FgtPedMaker" );
    sprintf(filename,"%d/status/status.%d.txt",day,runnumber);
    statMkr->setToSaveToFile(filename);
    statMkr->setTimeBin(0);
    statMkr->setPedRange(200,1000);
    statMkr->setRmsRange(15,200);
    statMkr->setFracRange(0.0,1.0);
    statMkr->setMaxDeadPerApv(128);
  }else{
    cout << "Loading and Constructing the StFgtA2CMaker" << endl;
    gSystem->Load("StFgtA2CMaker");
    StFgtA2CMaker* a2cMkr  = new StFgtA2CMaker(  "FgtA2CMaker" );
    a2cMkr->setFgtDb(fgtDbMkr->getDbTables());
    a2cMkr ->setAbsThres( -5000 );  // set to below -4096 to skip cut
    //    a2cMkr ->setAbsThres( 300 );  // set to below -4096 to skip cut
    //a2cMkr ->setRelThres( 3.);  // set to zero to skip cut
    a2cMkr ->setRelThres(thr);  // set to zero to skip cut
    //    a2cMkr->doCutBadStatus(true);//parameter is useless from looking at the function
    a2cMkr->doCutBadStatus();
    a2cMkr->acceptLongPulses(true);
    ////you have to set the relative threshold to 3 if you set the cluster threshold to 0.6 (meaning 3)
    //a2cMkr->setClusterThreshold(0.6);  
    a2cMkr->setClusterThreshold(thr/5.0);  
    a2cMkr->setPedSigFactor4Charge(chargrms);
    a2cMkr->useLeastRestrictiveSeed(useSeed5);
    ///this cuts ~10% of the events
    //   a2cMkr->doRemoveNonSignal(false);
    //   a2cMkr->doRemoveNonPulse(false);
    a2cMkr->setPedestalFile("ped.txt");
    a2cMkr->setStatusFile("status.txt");
    
    gSystem->Load("StFgtClusterMaker");
    Char_t *myMaker = "StFgtClusterMaker";
    StFgtClusterMaker* clusterMk =new StFgtClusterMaker("FgtClustMaker"); 
    clusterMk->SetDEBUG();
    //  simpleClusAlgo = new StFgtSimpleClusterAlgo();
    seededClusAlgo = new StFgtSeededClusterAlgo();
    seededClusAlgo->setJumpSingleStrip(true); // if a strip in cluster has no charge 
    seededClusAlgo->setThreshold2AddStrip(thr2add); //threshold to add strips to cluster 
    clusterMk->setClusterAlgo( seededClusAlgo );
    
    gSystem->Load("StFgtPointMaker");
    StFgtPointMaker* pointMk =new StFgtPointMaker();
    StFgtSimplePointAlgo * simplePointAlgo = new StFgtSimplePointAlgo();    
    pointMk->setPointAlgo( simplePointAlgo );
    simplePointAlgo->setMaxChargeAsym(0.2);

    gSystem->Load("StFgtClusterTools");
    fgtGenBase=new StFgtGeneralBase("fgtGenBase");
    fgtGenBase->fillFromEvent();
    fgtStraightTrackMaker =new StFgtStraightTrackMaker("fgtStraightTracker");
    fgtStraightTrackMaker->setMinNumFitPoints(3);
    fgtStraightTrackMaker->setMaxClusters(30);
    //fgtStraightPlotter=new StFgtStraightPlotter("fgtStraightPlotter");
    
    gSystem->Load("libMinuit");
    gSystem->Load("StFgtAlignmentMaker");
    StFgtAlignmentMaker* algMk =new StFgtAlignmentMaker();
    algMk->setTrackType(0);
    algMk->setDataSource(2);
    algMk->setRunNumber(runnumber);
    sprintf(filename,"%d/alignment_trkout.%d.root",day,runnumber);
    algMk->setWriteTree(filename);

    gSystem->Load("StFgtQAMaker");
    StFgtQAMaker* qaMkr =new StFgtQAMaker();
    qaMkr->setRunNumber(runnumber);
  }
   
  cout << "Initializing" << endl;
  ierr = analysisChain->Init();
  
  if( ierr ){
    cout << "Error initializing" << endl;
    return;
  };
  
  if( nevents < 0 )
    nevents = 1<<30; // a big number
  
  cout << "max nevents = " << nevents << endl;
  for( int i=0; i<nevents && !ierr; ++i ){
    if( i+1 % 100 == 1 ) cout << "\t on event number **************" << i << endl;
    //cout << "clear (agv)" << endl;
    analysisChain->Clear();
    //cout << "make" << endl;
    ierr = analysisChain->Make();
    //cout <<" done " <<endl;
  };
  
  //   fgtDbMkr->printFgtDumpCSV("fgtMapDump.csv");
  //
  // Calls the ::Finish() method on all makers
  //
  cout << "finish" << endl;
  analysisChain->Finish();
  
  // Now write a status table
  
  /*
    if( runnumber ){
    std::stringstream ss;
    fout << "Times given in the run log are " << endl;
    ss << "lynx -dump 'http://online.star.bnl.gov/RunLogRun12/index.php?r=" << runnumber << "' | grep GMT";
    FILE *f = gSystem->OpenPipe(ss.str().data(),"r");
    Char_t c;
    while((c=fgetc(f))!=EOF)
    fout << c;
    };
  */
  
  bool doOutputPdf=false;
  // convert ps to pdf
  if( doOutputPdf ){
    cout << "converting ps to pdf" << endl;
    gSystem->Exec(( std::string("ps2pdf -dAutoRotatePages=/None ") + pdfFile ).data());
  };
  
  cout << "\tall done" << endl;
  return;
};
Example #9
0
void makeMuDstQA(TString InputFileList, Int_t nFiles, Int_t nEvents, TString OutputDir ) 
{
 
  // Load libraries for CINT mode
#ifdef __CINT__
  gROOT   -> Macro("loadMuDst.C");
#endif

  // List of member links in the chain
  StChain*                    chain  =  new StChain ;

  StMuDstMaker*          muDstMaker  =  new StMuDstMaker(0,0,"",InputFileList,"MuDst",nFiles) ;

  // ---------------- modify here according to your QA purpose --------------------------
  // Turn off everything but Primary tracks in order to speed up the analysis and eliminate IO
  muDstMaker -> SetStatus("*",0) ;               // Turn off all branches
  muDstMaker -> SetStatus("MuEvent",1) ;         // Turn on the Event data (esp. Event number)
  muDstMaker -> SetStatus("PrimaryVertices",1) ;    // Turn on the primary track data
  muDstMaker -> SetStatus("PrimaryTracks",1) ;    // Turn on the primary track data
  muDstMaker -> SetStatus("GlobalTracks",1) ;    // Turn on the global track data
  muDstMaker -> SetStatus("CovGlobTrack",1);   // to fix the refmult in Run14!!!
  muDstMaker -> SetStatus("BTofHeader",1) ;    // Turn on the btof data
  muDstMaker -> SetDebug(0) ;                    // Turn off Debug information

  if ( nEvents == 0 )  nEvents = 10000000 ;       // Take all events in nFiles if nEvents = 0

  // ---------------- modify here according to your QA purpose --------------------------
  //book histograms or trees if you need
  TString oFile(muDstMaker->GetFile());
  TString oChopFile;
  int fileBeginIndex = oFile.Index("st_",0);
  oFile.Remove(0,fileBeginIndex);
  short indx1 = oFile.First('.');
  short indx2 = oFile.Last('.');
  if (indx1!=indx2) oFile.Remove(indx1+1,(indx2-indx1));
  oChopFile=oFile;
  oFile.Insert(indx1+1,"moretags.");
  oFile.Prepend(OutputDir);
  oChopFile.Insert(indx1+1,"chopper.");
  oChopFile.ReplaceAll("root","txt");
  oChopFile.Prepend(OutputDir);

  ofstream chop_output(oChopFile);

  TFile *tags_output = new TFile( oFile, "recreate" ) ;
  tags_output->cd();

  //TH1F *hPhi = new TH1F("hPhi","Phi of proton",200,-TMath::Pi(),TMath::Pi());
  //TH2F *hPhiFirstZ = new TH2F("hPhiFirstZ","Phi vs. FirstZ",200,-150,150,200,-TMath::Pi(),TMath::Pi()); 

  //Prepare the output tree
  Int_t mRunId, mEvtId;
  Int_t mnRefMult, mngRefMult, mnTofMatch;
  Float_t mVX, mVY, mVZ;
  Float_t mVpdVz;
  Float_t mPVRank;
  TTree *mMoreTagsTree = new TTree("MoreTags","MoreTags");
  mMoreTagsTree->Branch("RunId",&mRunId,"RunId/I");
  mMoreTagsTree->Branch("EvtId",&mEvtId,"EvtId/I");
  mMoreTagsTree->Branch("nRefMult",&mnRefMult,"nRefMult/I");
  mMoreTagsTree->Branch("ngRefMult",&mngRefMult,"ngRefMult/I");
  mMoreTagsTree->Branch("nTofMatch",&mnTofMatch,"nTofMatch/I");
  mMoreTagsTree->Branch("VX",&mVX,"VX/F");
  mMoreTagsTree->Branch("VY",&mVY,"VY/F");
  mMoreTagsTree->Branch("VZ",&mVZ,"VZ/F");
  mMoreTagsTree->Branch("VpdVz",&mVpdVz,"VpdVz/F");
  mMoreTagsTree->Branch("PVRank",&mPVRank,"PVRank/F");
  mMoreTagsTree->SetAutoSave(10000000);

  
  // ---------------- end of histogram and tree booking --------------------------------

  // Loop over the links in the chain
  Int_t iInit = chain -> Init() ;
  if (iInit) chain->FatalErr(iInit,"on init");
  
  // chain -> EventLoop(1,nEvents) ;  //will output lots of useless debugging info.
  Int_t istat = 0, i = 1;
  while (i <= nEvents && istat != 2) {
     if(i%10==0)cout << endl << "== Event " << i << " start ==" << endl;
     chain->Clear();
     istat = chain->Make(i);

     if (istat == 2)
	  cout << "Last  event processed. Status = " << istat << endl;
     if (istat == 3)
	  cout << "Error event processed. Status = " << istat << endl;
     i++;

     if(istat != kStOK)continue; //skip those suspectible events
     
  // ---------------- modify here according to your QA purpose --------------------------
     //let's do the QA here...
     //start with event cutting...
     //cout<<"In event #. "<<i-1<<" Maker status "<<istat<<endl;

     StMuDst* mMuDst = muDstMaker->muDst();
     if(!mMuDst) {
	  LOG_WARN << " No MuDst " << endm; continue;
     }

     StMuEvent* mMuEvent = mMuDst->event();
     if(!mMuEvent) {
	  LOG_WARN << " No MuEvent " << endm; continue;
     }

     //vzVpd
     StBTofHeader const* mBTofHeader = mMuDst->btofHeader();
     Float_t vzVpd=-999;
     if (mBTofHeader) vzVpd = mBTofHeader->vpdVz();

/*
     //Run14 vertex selection
     //////////////////////////////////////
     // select the right vertex using VPD
     /////////////////////////////////////
     for(unsigned int i=0;i<mMuDst->numberOfPrimaryVertices();i++) {
	  StMuPrimaryVertex *vtx = mMuDst->primaryVertex(i);
	  if(!vtx) continue;
	  Float_t vz = vtx->position().z();
	  if(fabs(vzVpd)<100 && fabs(vzVpd-vz)<3.) {
	     mMuDst->setVertexIndex(i);
	     break;
	  }
     }
     /////////////////////////////////////
*/

/*
     //Run16 vertex selection
     ////////////////////////////////////////////////////////////////
     if (fabs(vzVpd) < 200)
     {
	  for (unsigned int iVtx = 0; iVtx < mMuDst->numberOfPrimaryVertices(); ++iVtx)
	  {
	     StMuPrimaryVertex* vtx = mMuDst->primaryVertex(iVtx);
	     if (!vtx) continue;

	     if (fabs(vzVpd - vtx->position().z()) < 3.)
	     {
		  mMuDst->setVertexIndex(iVtx);
		  break;
	     }
	  }
     }
     ////////////////////////////////////////////////////////////////
*/

/*
     //Run15 pAu & Run16 dAu vertex selection
     int index = 0;
     const double mTpcVpdVzDiffCut = 6;
     if (mBTofHeader && fabs(vzVpd) < 200) {
	  for (unsigned int iVtx = 0; iVtx < mMuDst->numberOfPrimaryVertices(); ++iVtx) {
	     StMuPrimaryVertex* vtx = mMuDst->primaryVertex(iVtx);
	     if (!vtx) continue;
	     if (fabs(vzVpd - vtx->position().z()) < mTpcVpdVzDiffCut) {
		  index = iVtx;
		  break;
	     }
	  }
     }
     if(index>=0) mMuDst->setVertexIndex(index);
*/

     mRunId = mMuEvent->runNumber();
     mEvtId = mMuEvent->eventNumber();
     mnRefMult = mMuEvent->refMult();

     Int_t nTofMatPrTrack = 0;
     TObjArray* prtracks = muDstMaker->muDst()->primaryTracks() ;    // Create a TObject array containing the global tracks  
     TObjArrayIter GetPrTracks(prtracks) ;                              // Create an iterator to step through the tracks  
     StMuTrack* prtrack ;                                             // Pointer to a track
     while ( ( prtrack = (StMuTrack*)GetPrTracks.Next() ) )             // Main loop for Iterating over tracks
     {
	  if(prtrack->btofPidTraits().matchFlag()) nTofMatPrTrack ++;
     }
     mnTofMatch = nTofMatPrTrack;

     mVX = mMuEvent->primaryVertexPosition().x();
     mVY = mMuEvent->primaryVertexPosition().y();
     mVZ = mMuEvent->primaryVertexPosition().z();

     mVpdVz = vzVpd;
     if(mMuDst->primaryVertex())mPVRank = mMuDst->primaryVertex()->ranking();
     else mPVRank = -1e9;

     Int_t nGlTrack = 0;
     TObjArray* gltracks = muDstMaker->muDst()->globalTracks() ;    // Create a TObject array containing the global tracks  
     TObjArrayIter GetGlTracks(gltracks) ;                              // Create an iterator to step through the tracks  
     StMuTrack* gltrack ;                                             // Pointer to a track
     while ( ( gltrack = (StMuTrack*)GetGlTracks.Next() ) )             // Main loop for Iterating over tracks
     {
	  if(fabs(gltrack->eta())>=0.5)continue;
	  if(gltrack->nHitsFit()<10)continue;
	  if(gltrack->dca().mag()>=3.0)continue;
	  nGlTrack++ ;
     }
     mngRefMult = nGlTrack;

     mMoreTagsTree->Fill();

     //Event info (for debug)
     //cout<<"Run#: "<<mMuEvent->runNumber()<<endl;
     //cout<<"Evt#: "<<mMuEvent->eventNumber()<<endl;
     //cout<<muDstMaker->muDst()->currentVertexIndex()<<endl;
     //cout<<"refmult: "<<mMuEvent->refMult()<<endl;

     //Event cuts (NO EVENT CUTS TILL HERE!)
     //trigger
     if ( ! mMuEvent->triggerIdCollection().nominal().isTrigger(410008) && ! mMuEvent->triggerIdCollection().nominal().isTrigger(410005) ) continue;
     //Vz
     if ( fabs(mMuEvent->primaryVertexPosition().z()) > 30.0 ) continue ;
     //Vr
     //if ( mMuEvent->primaryVertexPosition().perp() > 100.0 ) continue ;
     //VF failed (for some old dataset)
     //if ( fabs(mMuEvent->primaryVertexPosition().x()) < 1e-5 && fabs(mMuEvent->primaryVertexPosition().y()) < 1e-5 && fabs(mMuEvent->primaryVertexPosition().z()) < 1e-5 ) continue;

     chop_output<<mRunId<<'\t'<<mEvtId<<endl;
     
     /*
     //fill Event QA histograms
     TObjArray* tracks = muDstMaker->muDst()->primaryTracks() ;
     TObjArrayIter GetTracks(tracks) ;
     StMuTrack* gtrack ; 
     while ( ( gtrack = (StMuTrack*)GetTracks.Next() ) )
     {
	  //const StMuTrack * gtrack = track->globalTrack();
	  if(gtrack->nHits()<=15)continue;
	  if(gtrack->flag()<=0)continue;
	  if(abs(gtrack->charge())!=1) continue;
	  if(gtrack->pt()>0.5) continue;
	  if(fabs(gtrack->nSigmaProton())>2)continue;
	  hPhi->Fill(gtrack->phi());
	  hPhiFirstZ->Fill(gtrack->firstPoint().z(),gtrack->phi());
     }
     //end of the filling
     */
  }

  if (nEvents > 1) chain -> Finish() ;

  if(tags_output!=NULL) tags_output -> Write() ;
  if(tags_output!=NULL) tags_output -> Close() ;
  //flush(tags_output);
  delete tags_output;

  chop_output.close();
  // Cleanup
  delete chain ;
}
Example #10
0
void SkimPion(const char* fileList, const char* fileId="Skim.root") {

    int flagMC=0;  // 0== off, 1=Alan
    int useEemc=1; // 0== off
    int useBemc=1; // 0== off
    int useL2=1;   // 0== off
    int L2ConfigYear=2006; // possible: 2006, 2008
    int bemcConfig=2; // enum: kOnline=1, kOffline, kExpert
    int playConfig=100; // jan:100_199
    int emcEveDump=0; // extrating raw EMC data in a custom format
    const char *dirIn="";
    int nFiles = 100000; // make this big if you want to read all events from a run
    char *eemcSetupPath="/afs/rhic.bnl.gov/star/users/kocolosk/public/StarTrigSimuSetup/";

    TString outDir="./out2/"; 

    gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");

    loadSharedLibraries();
	
    gSystem->Load("StDetectorDbMaker");
    gSystem->Load("StDbUtilities");
    gSystem->Load("StDbBroker");
    gSystem->Load("St_db_Maker");
    gSystem->Load("StEEmcUtil");
    gSystem->Load("StEEmcDbMaker");
    gSystem->Load("StarMagField");
    gSystem->Load("geometry");
    gSystem->Load("St_g2t");
    gSystem->Load("St_geant_Maker");
    gSystem->Load("StDaqLib");
    gSystem->Load("StEmcRawMaker");
    gSystem->Load("StEmcADCtoEMaker");
    gSystem->Load("StTriggerUtilities");
    gSystem->Load("StEpcMaker");

    gSystem->Load("StSpinDbMaker");

    // Renees Trigger Maker
    //gSystem->Load("StEmcTriggerMaker");

    // Mikes relative luminosity interface
    gSystem->Load("StEsRelLum");

    //Load your maker here
    gSystem->Load("StSkimPionMaker");

    gROOT->Macro("LoadLogger.C");
    cout << "loading done " << endl;
    
    StChain *chain = new StChain("StChain");
    StMuDstMaker *mudst_mk = new StMuDstMaker(0,0,"",fileList,"MuDst.root",999); // MuDST reader

    //StMuDbReader
    StMuDbReader* db = StMuDbReader::instance();
    
    // Need St_db_Maker for Emc calibration
    St_db_Maker *db1 = new St_db_Maker("StarDb","$STAR/StarDb","MySQL:StarDb");
    
    //Database interface, needed for prescales
    StDetectorDbMaker* detDbMk = new StDetectorDbMaker();

    // Database for Spin data
    StSpinDbMaker *spDb=new StSpinDbMaker("spinDb");

    //Endcap DB
    if(useEemc || useL2) new StEEmcDbMaker("eemcDb");
    
    // Maker to apply calibration
    StEmcADCtoEMaker *adc_to_e=new StEmcADCtoEMaker();
    adc_to_e->setPrint(kFALSE);
    //adc_to_e->saveAllStEvent(true);

    //Collect all output histograms
    TObjArray* HList = new TObjArray;
    
    //Get TriggerMaker
    StTriggerSimuMaker *simuTrig = new StTriggerSimuMaker("StarTrigSimu");
    simuTrig->setHList(HList);
    simuTrig->setMC(flagMC); // must be before individual detectors, to be passed
    simuTrig->useBbc();
    
    if(useEemc) 
    {
        simuTrig->useEemc(0);//default=0:just process ADC, 1,2:comp w/trgData,see .
        simuTrig->eemc->setSetupPath(eemcSetupPath);
    } 
    if(useBemc)
        {
        simuTrig->useBemc();
        simuTrig->bemc->setConfig(bemcConfig);
    }


    if(1) 
    {
        /* 
           reads all input/setup files from  L2setup-yyyymmdd/
           writes all output files to L2out-yyyymmdd 
           depending on the DB time stamp 
           both dierectiorie MUST exist, setup must be reasonable
        */
    
        StGenericL2Emulator* simL2Mk=0;
        if(L2ConfigYear==2006) simL2Mk= new StL2_2006EmulatorMaker;
        else if(L2ConfigYear==2008) simL2Mk= new StL2_2008EmulatorMaker;
        assert(simL2Mk);
        simL2Mk->setSetupPath(eemcSetupPath);
        simL2Mk->setOutPath(outDir.Data());
        if (flagMC) simL2Mk->setMC();
        //simL2Mk->useStEvent(); // default : use muDst
        simuTrig->useL2(simL2Mk);
    }

    
    // Makers for clusterfinding
    StPreEclMaker *pre_ecl=new StPreEclMaker();
    pre_ecl->setPrint(kFALSE);
    StEpcMaker *epc=new StEpcMaker();
    epc->setPrint(kFALSE);

    //StEmcTrigger
    //StEmcTriggerMaker *emcTrig = new StEmcTriggerMaker("StEmcTriggerMaker");
    //emcTrig->setDbMaker(db1);
    
    // now add your analysis maker
    StSkimPionMaker* analysis = new StSkimPionMaker("SkimPionMaker", 1, fileId);
    
    chain->ls(3);
    chain->Init();
    
    //Tight cuts (esp. SMD)
    
    Int_t sizeMax = 4;
    Float_t energySeed = 0.4; // default is 0.7, usually 0.35
    Float_t energyAdd  = 0.05;  // default is 0.07, usually 0.035
    pre_ecl->SetClusterConditions("bemc", sizeMax, energySeed, energyAdd, 0.02, kFALSE);     
    // defaults for SMDs are ("...", 5, 0.4, 0.001, 0.1, kFALSE)
    pre_ecl->SetClusterConditions("bsmde", 5, 0.4,0.005, 0.1,kFALSE); // used 5, 0.2, 0.0005, 0.1
    pre_ecl->SetClusterConditions("bsmdp", 5, 0.4,0.005, 0.1,kFALSE);
    pre_ecl->SetClusterConditions("bprs", 1, 500., 500., 501., kFALSE);

    // TStopwatch totaltime;
    TStopwatch timer;
    TMemStat memory;
    
    Int_t n_event=100000000;
     int total =0;

    cout << "Chain initialized, starting up... " << endl;

    for(Int_t iev=0;iev<n_event; iev++) {
    
        cout << "****************************************** " << endl;
        cout << "\Processing Event " << iev << " of "<< n_event << endl;
        cout << "*************************1***************** " << endl;
        
        chain->Clear();
        
	if(iev % 500 == 0){
            cout<<"done with event "<<iev;
	    cout<<"\tcpu: "<<timer.CpuTime()<<"\treal: "<<timer.RealTime()<<"\tratio: "<<timer.CpuTime()/timer.RealTime()<<endl;
            timer.Start();
            memory.PrintMem(NULL);
        }

        int iret = chain->Make(iev);
        total++;
	
        if(iret % 10 == kStEOF || iret % 10 == kStFatal) 
        {
            cout << "Bad return code!" << endl;
            break;
        }
    
    }
  
    chain->Finish();
    cout << "****************************************** " << endl;
    cout << "total number of events  " << total << endl;
    cout << "****************************************** " << endl;

}
Example #11
0
void RunMipHistogramMaker(Int_t nEntries = 1e8,
			 const Char_t* listname="test.list",
			 const Char_t* outfile="testMipFile.root")

{
  gROOT->Macro("LoadLogger.C");
  gROOT->Macro("loadMuDst.C");
  gSystem->Load("StTpcDb");
  gSystem->Load("StDaqLib");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("St_db_Maker");
  gSystem->Load("StDbUtilities");
  gSystem->Load("StEmcRawMaker");
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");//***
  gSystem->Load("StEmcSimulatorMaker");//***
  gSystem->Load("StEmcADCtoEMaker");
  gSystem->Load("StEpcMaker");
  gSystem->Load("StDbBroker");
  gSystem->Load("StEEmcUtil");
  gSystem->Load("StAssociationMaker");
  gSystem->Load("StTriggerUtilities");
  gSystem->Load("StEmcOfflineCalibrationMaker");

  //Instantiate StChain
  StChain *chain = new StChain;

  TChain *MipChain = new TChain("calibTree");
  Char_t file[300];
  ifstream filelist(listname,ifstream::in);
  while(1){
    filelist >> file;
    if (!filelist.good()) break;
    cout << file << endl;
    MipChain->Add(file);
  }
  
  StEmcOfflineCalibrationMipAnalysis *mipAnalysis = new StEmcOfflineCalibrationMipAnalysis("StEmcOfflineCalibrationMipAnalysis",outfile,MipChain);
  
  //Initialize chain
  chain->Init();
  cout << "Successful Init" << endl;

  //Loop over all Make() in Chain
  for (Int_t iEntry = 0; iEntry < MipChain->GetEntries(); ++iEntry){
    if (MipChain->GetEvent(iEntry) <= 0)
      break;
    
    if (iEntry%10000 == 0)
      cout << "Working on event: " << iEntry << endl;
    
    chain->Clear();
    Int_t iret = chain->Make(iEntry);
    if(iret){
      cout << "Bad return code" << endl;
      break;
    }
  }
  
  chain->Finish();
}