Esempio n. 1
0
void treeTest(  const TString fList = "temp.list",
                const TString fOutName = "fOut.root",
                Long64_t nEvents = 9999
                ) 
{

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

    TFile* fOut = new TFile(fOutName.Data(),"RECREATE");

    TH1D* hZdc = new TH1D("hZdc","hZdc", 50, 0.5, 5000.5);

	//----------------- Read data using StMuDstMaker ---------------//
	StChain* muChain = new StChain("StChain");
	StMuDstMaker* muMaker = new StMuDstMaker(0,0,"",fList.Data(),"st:MuDst.root", 100, "MuDst");

    muChain->Init();
    Float_t zdcCut = 1623;

    TEventList* eventList = makeEventList(muMaker->chain(), zdcCut);
    muMaker->SetEventList(eventList);
    Long64_t nList = eventList->GetN();
    if(nList < nEvents) {nEvents = nList;}

    for(Int_t i = 0; i <= (nEvents-1); i++)
    {
        muChain->Make();
        Float_t zdcWest = muMaker->muDst()->event()->zdcTriggerDetector().adc(0);
        Float_t zdcEast = muMaker->muDst()->event()->zdcTriggerDetector().adc(4);

        hZdc->Fill(zdcWest);
        hZdc->Fill(zdcEast);


    }

    muChain->Finish();
    fOut->Write();
    fOut->Close();

    delete muChain;
    delete eventList;

}
Esempio n. 2
0
// ------------------ Here is the actual method -----------------------------------------
void doEvents(const Char_t *fileList, const Char_t *outputname)
{
  Int_t nEvents = 1000;
  Int_t nfiles = 100;

  //
  // First load some shared libraries we need
  //
  if (gClassTable->GetID("TTable") < 0) {
    gSystem->Load("libStar");
    gSystem->Load("libPhysics");
  }  
  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  gSystem->Load("StarMagField");
  gSystem->Load("StMagF");
  gSystem->Load("StTpcDb");
//  gSystem->Load("StDbUtilities");
  gSystem->Load("StDaqLib");
  gSystem->Load("StDbBroker");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("StDbUtilities");
  gSystem->Load("St_db_Maker");

  gSystem->Load("StEvent");
  gSystem->Load("StEventMaker");
  gSystem->Load("StarMagField");
  gSystem->Load("StTofUtil");   
 
  gSystem->Load("StVpdAnalysisMaker");
    //
    // Handling depends on whether file is a ROOT file or XDF file
    //
    chain  = new StChain("StChain");


    delete setFiles; setFiles =0;
    if (fileList) {     //Normal case
      setFiles= new StFile();
    } else        {     //
      return;
    }
    ifstream* inputStream = new ifstream;
    inputStream->open(fileList);
    if (!(inputStream)) {
      cout << "can not open list file" << endl;
      return;
    }
    cout<<"Open file list: --- "<<fileList<<endl;

    char line[512];
    for (;inputStream->good();) {
      inputStream->getline(line,512);
      if  ( inputStream->good() ) {
	//cout<<" root file "<<line<<endl;
	TFile *ftmp = new TFile(line);
	 //----------
         if (!(ftmp->IsOpen())) {
           cout<<line<<" open failed ! not chained"<<endl;
           continue;   
         }
         if (ftmp->IsZombie()) {
           cout<<"sth. very wrong with "<<line<<", not chained "<<endl;
           continue;   
         }
         if (ftmp->TestBit(1024)) { 
           cout<<"revocer procedure applied to "<<line<<endl;
           continue;   
         } 
	 //--------------------------           
         if( ftmp && ftmp->IsOpen() && ftmp->GetNkeys()) {
	    cout << "add file " << line << endl;
	    setFiles->AddFile(line);
	 } else {
	     cout << " cannot open file " << line << endl;
    	 }
    	 delete ftmp;
       }
    }


   StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",fileList,"MuDst.root",nfiles);
   muDstMaker->SetStatus("*",0);
   muDstMaker->SetStatus("MuEvent",1);
   muDstMaker->SetStatus("TofRawData",1);

   cout<<endl<<"============  Data Base ========="<<endl;
   dbMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");

   StVpdAnalysisMaker *vpdAna = new StVpdAnalysisMaker();
   vpdAna->SetDebug();

    //
    // Initialize chain
    //
    Int_t iInit = chain->Init();
    if (iInit) chain->Fatal(iInit,"on init");
    chain->PrintInfo();
    
    //
    // Event loop
    //
    int istat = 0, i = 1;
EventLoop: if (i <= nEvents && istat != 2) {
   
   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;}
   
   //   gObjectTable->Print();
   i++;
   goto EventLoop;
 }
    
    i--;
  cout<<endl<<"============================ Event "<<i<<" finish ============================"<<endl;

  //
  // Chain Finish
  //
  if (nEvents > 1) {
    chain->Finish();
  }


}
Esempio n. 3
0
void rdMu2TrigSimu(char *file="/star/data47/reco/pp200/pythia6_410/9_11gev/cdf_a/y2006c/gheisha_on/p07ic/rcf1309_*_2000evts.MuDst.root"){
  
  int nevents = 200;
  int flagMC=1;  // 0/1 == Using Real/Simulation data files 
  int useEemc=1; // 0/1 == Exclude/Include EEMC in Trigger Decisions 
  int useBemc=1; // 0/1 == Exclude/Include BEMC in Trigger Decisions 
  int useL2=1;   // 0/1 == Exclude/Include L2 in Trigger Decisions 
  int L2ConfigYear=2006; // possible: 2006, 2008
  int bemcConfig=2; // Online==1, Offline==2, Expert==3
  int playConfig=0; // jan:100_199
  int emcEveDump=0; // extrating raw EMC data in a custom format
  int outputL2Histo=0;//output L2 histos to directory outL2
  TString outDir="./outL2/"; 


  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  assert( !gSystem->Load("StDetectorDbMaker"));
  assert( !gSystem->Load("StDbUtilities"));
  assert( !gSystem->Load("StDbBroker"));
  assert( !gSystem->Load("St_db_Maker"));
  assert( !gSystem->Load("StEEmcUtil")); // needed by eemcDb
  assert( !gSystem->Load("StEEmcDbMaker"));
  assert( !gSystem->Load("StDaqLib")); // needed by bemcDb
  assert( !gSystem->Load("StEmcRawMaker"));
  assert( !gSystem->Load("StEmcADCtoEMaker"));
  if (flagMC) {
    assert( !gSystem->Load("StMcEvent"));
    assert( !gSystem->Load("StMcEventMaker"));
    assert( !gSystem->Load("StEmcSimulatorMaker"));
    assert( !gSystem->Load("StEEmcSimulatorMaker"));
    assert( !gSystem->Load("StEpcMaker"));
  }
  assert( !gSystem->Load("StTriggerUtilities"));

  gROOT->Macro("LoadLogger.C");
  cout << " loading done " << endl;
  
  chain= new StChain("StChain"); 

  if (flagMC){
    TString geantFile;
    geantFile += file;
    geantFile.ReplaceAll("MuDst.root", "geant.root");
    printf("geantFile=%s\n", geantFile.Data());
    StIOMaker* ioMaker = new StIOMaker();
    ioMaker->SetFile(geantFile);
    ioMaker->SetIOMode("r");
    ioMaker->SetBranch("*",0,"0");             //deactivate all branches
    ioMaker->SetBranch("geantBranch",0,"r");   //activate geant Branch
    StMcEventMaker *evtMaker = new StMcEventMaker();
  }

  //Need MuDstMaker to get data
  printf(" Analyzing file=%s\n",file);  
  StMuDstMaker* muDstMaker =new StMuDstMaker(0,0,"",file,"",1000);

  //Database -- get a real calibration from the database
  St_db_Maker* dbMk =0;
  if(useEemc || useL2) // full DB access
    dbMk = new St_db_Maker("StarDb","MySQL:StarDb","MySQL:StarDb","$STAR/StarDb");
  else // only Barrel is uploaded, is faster 
    dbMk  = new St_db_Maker("Calibrations","MySQL:Calibrations_emc");

    
  //If MC then must set database time and date
  //If Endcap fast simu is used tower gains in DB do not matter,JB
  if (flagMC) dbMk->SetDateTime(20060522, 55000);//timestamp R7142018
  
  //Collect all output histograms 
  TObjArray* HList=new TObjArray; 
  
  //Endcap DB
  if(useEemc || useL2) new StEEmcDbMaker("eemcDb");
  

  //Get BEMC adc values
  if (flagMC && useBemc) {
    StEmcSimulatorMaker* emcSim = new StEmcSimulatorMaker(); //use this instead to "redo" converstion from geant->adc
    if (bemcConfig == 1) {
        emcSim->setCheckStatus(kBarrelEmcTowerId,false); //this returns hits regardless of offline tower status
    }
    emcSim->setCalibSpread(kBarrelEmcTowerId,0.15);//spread gains by 15%
  }
  if (flagMC==0 && useBemc){
    StEmcADCtoEMaker *bemcAdc = new StEmcADCtoEMaker();//for real data this sets calibration and status
    if (bemcConfig == 1) {
        bemcAdc->setCheckStatus(kBarrelEmcTowerId,false);
    }
  }

  //must use slow simulator to get pedestals correct for L2
  if (flagMC==1 && useEemc){
    StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
    slowSim->setSamplingFraction(0.0384); // effectively scales all Tower energies with a factor of 1.3 (added by: Ilya Selyuzhenkov; April 11, 2008)
    slowSim->setAddPed(true);
    slowSim->setSmearPed(true);
  }
 
  //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(flagMC && useEemc==2){
    // pass one argument to M-C as generic switch    
    // Endcap specific params -- ok Jan you need to change this to a default "online" setup
    int eemcDsmSetup[20]; // see StEemcTriggerSimu::initRun() for definition
    memset(eemcDsmSetup, 0,sizeof(eemcDsmSetup));// clear all, may be a bad default
    eemcDsmSetup[0]=3;  // HTthr0
    eemcDsmSetup[1]=12; // HTthr1
    eemcDsmSetup[2]=22; // HTthr2
    eemcDsmSetup[3]=1;  // TPthr0
    eemcDsmSetup[4]=17; // TPthr1
    eemcDsmSetup[5]=31; // TPthr2
    eemcDsmSetup[10]=2; //HTTPthrSelc, 2=use_thres_#1
    simuTrig->eemc->setDsmSetup(eemcDsmSetup);    
  }


  if(useL2) {
    /* 
       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();
    simuTrig->useL2(simL2Mk);
  }

  
  //if(emcEveDump) new StJanEventMaker;
    
  StTriggerSimuPlayMaker *playMk= new StTriggerSimuPlayMaker; // to develope user  analysis of trigQA 
  playMk->setConfig(playConfig);
  playMk->setHList(HList);
  
  
  chain->ls(3);
  chain->Init();
 
  for (Int_t iev=0;iev<nevents; iev++) {
    cout << "\n****************************************** " << endl;
    cout << "Working on eventNumber:\t" << iev <<"\tof:\t"<<nevents<<endl;
    cout << "****************************************** " << endl;
    chain->Clear();
    int iret = chain->Make(iev);
    total++;   
    if (iret % 10 == kStEOF || iret % 10 == kStFatal)  {
      cout << "Bad return code!" << endl;
      break;
    }

    int trigID[3]={127213,117211,137611};
    StMuDst *muDst = muDstMaker->muDst();
    StMuEvent *muEvent = muDst->event();    
    StMuTriggerIdCollection trig = muEvent -> triggerIdCollection();
    StTriggerId l1trig = trig.nominal();
    if( l1trig.isTrigger(trigID[0])) {
      cout<<" SimuTrigger 127213 ="<<simuTrig->isTrigger(trigID[0])<<" BEMC="<<simuTrig->bemc->triggerDecision(trigID[0])<<" L2="<<simuTrig->lTwo->triggerDecision(trigID[0])<<endl;
     }
    if( l1trig.isTrigger(trigID[1])) {
      cout<<" SimuTrigger 117211 ="<<simuTrig->isTrigger(trigID[1])<<" BEMC="<<simuTrig->bemc->triggerDecision(trigID[1])<<" L2="<<simuTrig->lTwo->triggerDecision(trigID[1])<<endl;
     }
    if( l1trig.isTrigger(trigID[2])) {
      cout<<" SimuTrigger 137611 ="<<simuTrig->isTrigger(trigID[2])<<" BEMC="<<simuTrig->bemc->triggerDecision(trigID[2])<<" L2="<<simuTrig->lTwo->triggerDecision(trigID[2])<<endl;
    }

    
    StTriggerSimuResult trigResult = simuTrig->detailedResult(trigID[2]);
    if (trigResult.bemcDecision()==1){
       vector<short> towerId = trigResult.highTowerIds();
      for (unsigned i=0; i<towerId.size(); i++) {
      	cout<<" LO Trigger BEMC Tower="<<towerId[i]<<" adc="<<trigResult.highTowerAdc(towerId[i])<<endl;
      }
    }


   if (trigResult.l2Decision()==1){
       vector<short> towerId = trigResult.highTowerIds();
      for (unsigned i=0; i<towerId.size(); i++) {
      	cout<<" L2 Trigger BEMC Tower="<<towerId[i]<<" adc="<<trigResult.highTowerAdc(towerId[i])<<endl;
      }
    }
 
  }

 
  chain->Finish();
  cout << "****************************************** " << endl;
  cout << "total number of events  " << total << endl;
  cout << "****************************************** " << endl;


  if (outputL2Histo==1) {
  
    TString fileMu=file;
    printf("=%s=\n",fileMu.Data());
    if(fileMu.Contains(".lis")) fileMu.ReplaceAll(".lis",".trgSim");
    if(fileMu.Contains(".MuDst.root")) fileMu.ReplaceAll(".MuDst.root",".trgSim");
    TString outF=outDir+fileMu;
    outF+=".hist.root";
    printf("=%s=\n",outF.Data());
    hf=new TFile(outF,"recreate");
    if(hf->IsOpen()) {
      HList->Write();
      printf("\n Histo saved -->%s<\n",outF.Data());
    } 
    else {
      printf("\n Failed to open Histo-file -->%s<, continue\n",outF.Data());
    }
  }
  
  //cout <<Form("sorting done %d of   nEve=%d, CPU rate=%.1f Hz, total time %.1f minute(s) \n\n",total,nEntries,rate,tMnt)<<endl;
 
}
Esempio n. 4
0
/**
 * 1. Data sample : pp200 W->e nu with  pile-up corresponding to 1 MHz min. bias
 * events, 50 K event y2011, 10 K event y2012.
 *
 * 2. Proof of principal: no pile-up for both PPV and KFV
 *
 *   a.  Reconstructed primary track multiplicity versus corresponding MC
 *   "reconstructable" (i.e. in n STAR acceptance,no. TPC MC hits >= 15)  tracks
 *   multiplicity.
 *
 *   b.  Corrected reconstructed primary track multiplicity (i.e. multiplied by
 *   QA/100.) versus corresponding MC "reconstructable"  (i.e. in n STAR
 *   acceptance,no. TPC MC hits >= 15)  tracks multiplicity.
 *
 *   c.  Efficiency primary vertex reconstruction versus  MC "reconstructable"
 *   tracks multiplicity.
 *
 * 3. With pileup. repeat above (a-c) with old ranking scheme for
 *
 *     I. Any reconstructed primary vertex which is matched with MC trigger
 *     vertex (MC = 1)
 *
 *    II. The best (in sense of ranking) reconstructed primary vertex which is
 *    matched with MC trigger vertex (MC = 1)
 *
 *   III. The best (in sense of ranking) reconstructed primary vertex which is
 *   not matched with MC trigger vertex (MC != 1)
 *
 * 4. With pileup. repeat above (a-c) with new ranking scheme for cases I-III
 */
void MuMcPrVKFV2012(Long64_t nevent, const char *file, const std::string& outFile, bool fillNtuple)
{
#ifdef __TMVA__
   boost::replace_last(outFile, ".root", "");
   outFile += ".TMVArank.root";

   // create a set of variables and declare them to the reader
   // - the variable names must corresponds in name and type to
   // those given in the weight file(s) that you use
   TString separator(":");
   TString Vnames(vnames);
   TObjArray *array = Vnames.Tokenize(separator);

   std::vector<std::string> inputVars;
   TIter next(array);
   TObjString *objs;

   while ((objs = (TObjString *) next())) {
      std::cout << objs->GetString() << std::endl;
   }

   inputVars.push_back("beam");
   inputVars.push_back("postx");
   inputVars.push_back("prompt");
   inputVars.push_back("cross");
   inputVars.push_back("tof");
   inputVars.push_back("notof");
   inputVars.push_back("EEMC");
   inputVars.push_back("noEEMC");
   inputVars.push_back("chi2");

   std::vector<double> *inputVec = new std::vector<double>( inputVars.size() );
   IClassifierReader *classReader = new ReadBDT( inputVars );

#endif /* __TMVA__ */

   TFile *fOut = TFile::Open(outFile.c_str(), "recreate");
   data_t data;

   // Book histograms
   const int nMcRecMult = 75;
   TArrayD xMult(nMcRecMult + 1);
   xMult[0] = -0.5;

   for (int i = 1; i <= nMcRecMult; i++) {
      if      (xMult[i - 1] <  50) xMult[i] = xMult[i - 1] +   1; //  1 - 50
      else if (xMult[i - 1] < 100) xMult[i] = xMult[i - 1] +   2; // 51 - 75
      else if (xMult[i - 1] < 200) xMult[i] = xMult[i - 1] +  10; // 76 - 85
      else                         xMult[i] = xMult[i - 1] + 100; // 86 -100
   }

   TH1D *McRecMulT = new TH1D("McRecMulT", "Reconstructable multiplicity for trigger Mc Vertex", nMcRecMult, xMult.GetArray());
   struct Name_t {
      const Char_t *Name;
      const Char_t *Title;
   };
   const Name_t HCases[3] = {
      {"Any", "Any vertex matched with MC == 1"},
      {"Good", "The best rank vertex with MC == 1"},
      {"Bad", "The best rank vertex with MC != 1"}
   };
   const Name_t Plots[4] = {
      {"Mult"    , "the reconstructed (uncorrected) track multiplicity versus Reconstructable multiplicity"},
      {"MultQA"  , "the reconstructed (corrected for QA) track multiplicity versus Reconstructable multiplicity"},
      {"McRecMul", "Reconstructable multiplicity"},
      {"YvsX"    , "Bad versus Good value"}
   };
   /*         h  p  */
   TH1 *hists[3][4];

   for (int h = 0; h < 3; h++) {
      for (int p = 0; p < 4; p++) {
         TString Name(Plots[p].Name); Name += HCases[h].Name;
         TString Title(Plots[p].Title); Title += " for "; Title += HCases[h].Title; Title += " vertex";

         if      (p <  2)  hists[h][p] = new TH2D(Name, Title, nMcRecMult, xMult.GetArray(), nMcRecMult, xMult.GetArray());
         else if (p == 2)  hists[h][p] = new TH1D(Name, Title, nMcRecMult, xMult.GetArray());
      }
   }

   TNtuple *VertexG = new TNtuple("VertexG", "good vertex & global params info", vnames);
   TNtuple *VertexB = new TNtuple("VertexB", "bad  vertex & global params info", vnames);
   // ----------------------------------------------
   StMuDstMaker *maker = new StMuDstMaker(0, 0, "", file, "st:MuDst.root", 1e9); // set up maker in read mode
   //                       0,0                        this mean read mode
   //                           dir                    read all files in this directory
   //                               file               bla.lis real all file in this list, if (file!="") dir is ignored
   //                                    filter        apply filter to filenames, multiple filters are separated by ':'
   //                                          10      maximum number of file to read
   maker->SetStatus("*", 0);

   std::vector<std::string> activeBranchNames = {
      "MuEvent",
      "PrimaryVertices",
      "StStMuMcVertex",
      "StStMuMcTrack"
   };

   // Set Active braches
   for (const auto& branchName : activeBranchNames)
      maker->SetStatus(branchName.c_str(), 1);

   TChain *tree = maker->chain();
   Long64_t nentries = tree->GetEntries();
   nevent = TMath::Min(nevent, nentries);
   std::cout << nentries << " events in chain " << nevent << " will be read." << std::endl;
   tree->SetCacheSize(-1);        //by setting the read cache to -1 we set it to the AutoFlush value when writing
   tree->SetCacheLearnEntries(1); //one entry is sufficient to learn
   tree->SetCacheEntryRange(0, nevent);

   for (Long64_t ev = 0; ev < nevent; ev++) {
      if (maker->Make()) break;

      StMuDst *muDst = maker->muDst();   // get a pointer to the StMuDst class, the class that points to all the data
      StMuEvent *muEvent = muDst->event(); // get a pointer to the class holding event-wise information
      int referenceMultiplicity = muEvent->refMult(); // get the reference multiplicity

      TClonesArray *PrimaryVertices   = muDst->primaryVertices();
      int nPrimaryVertices = PrimaryVertices->GetEntriesFast();

      TClonesArray *MuMcVertices   = muDst->mcArray(0);
      int nMuMcVertices = MuMcVertices->GetEntriesFast();

      TClonesArray *MuMcTracks     = muDst->mcArray(1);
      int nMuMcTracks = MuMcTracks->GetEntriesFast();

      if ( nevent >= 10 && ev % int(nevent*0.1) == 0 )
      {
         std::cout << "Event #" << ev << "\tRun\t" << muEvent->runId()
                   << "\tId: " << muEvent->eventId()
                   << " refMult= " << referenceMultiplicity
                   << "\tPrimaryVertices " << nPrimaryVertices
                   << "\t" << " " << nMuMcVertices
                   << "\t" << " " << nMuMcTracks
                   << std::endl;
      }

      //    const Double_t field = muEvent->magneticField()*kilogauss;
      if (! nMuMcVertices || ! nMuMcTracks || nPrimaryVertices <= 0) {
         std::cout << "Ev. " << ev << " has no MC information ==> skip it" << std::endl;
         std::cout << "OR no reconstructed verticies found" << std::endl;
         continue;
      }

      // Count number of MC tracks at a vertex with TPC reconstructable tracks
      std::multimap<int, int> Mc2McHitTracks;

      for (int m = 0; m < nMuMcTracks; m++) {
         StMuMcTrack *McTrack = (StMuMcTrack *) MuMcTracks->UncheckedAt(m);

         if (McTrack->No_tpc_hit() < 15) continue;

         Mc2McHitTracks.insert(std::pair<int, int>(McTrack->IdVx(), McTrack->Id()));
      }

      // This is the "reconstructable" track multiplicity
      int nMcTracksWithHits = Mc2McHitTracks.count(1);

      // Let's skip events in which we do not expect to reconstruct any tracks
      // (and thus vertex) from the primary vertex
      if (nMcTracksWithHits <= 0) continue;

      // This is our denominator histogram for efficiencies
      McRecMulT->Fill(nMcTracksWithHits);

      // =============  Build map between  Rc and Mc vertices
      std::map<StMuPrimaryVertex *, StMuMcVertex *> reco2McVertices;
      TArrayF vertexRanks(nPrimaryVertices);
      int mcMatchedVertexIndex  = -1; // any vertex with MC==1 and highest reconstrated multiplicity.
      int vertexMaxMultiplicity = -1;

      // First loop over all verticies in this event. There is at least one
      // must be available
      for (int recoVertexIndex = 0; recoVertexIndex < nPrimaryVertices; recoVertexIndex++)
      {
         vertexRanks[recoVertexIndex] = -1e10;

         StMuPrimaryVertex *recoVertex = (StMuPrimaryVertex *) PrimaryVertices->UncheckedAt(recoVertexIndex);

         if ( !AcceptVX(recoVertex) ) continue;

         // Check Mc
         if (recoVertex->idTruth() < 0 || recoVertex->idTruth() > nMuMcVertices) {
            std::cout << "ERROR: Illegal idTruth " << recoVertex->idTruth() << " The track is ignored" << std::endl;
            continue;
         }

         StMuMcVertex *mcVertex = (StMuMcVertex *) MuMcVertices->UncheckedAt(recoVertex->idTruth() - 1);

         if (mcVertex->Id() != recoVertex->idTruth()) {
            std::cout << "ERROR: Mismatched idTruth " << recoVertex->idTruth() << " and mcVertex Id " <<  mcVertex->Id()
                 << " The vertex is ignored" <<  std::endl;
            continue;
         }

         reco2McVertices[recoVertex] = mcVertex;
         vertexRanks[recoVertexIndex] = recoVertex->ranking();

         if (recoVertex->idTruth() == 1 && recoVertex->noTracks() > vertexMaxMultiplicity)
         {
            mcMatchedVertexIndex  = recoVertexIndex;
            vertexMaxMultiplicity = recoVertex->noTracks();
         }

         FillData(data, recoVertex);

#ifdef __TMVA__
         Float_t *dataArray = &data.beam;

         for (size_t j = 0; j < inputVec->size(); j++)
            (*inputVec)[j] = dataArray[j];

         vertexRanks[recoVertexIndex] = classReader->GetMvaValue( *inputVec );
#endif
      }

      // If we reconstructed a vertex which matches the MC one we fill the
      // numerator of the "Any" efficiency histogram
      if (mcMatchedVertexIndex != -1) {

         StMuPrimaryVertex *recoVertexMatchedMc = (StMuPrimaryVertex*) PrimaryVertices->UncheckedAt(mcMatchedVertexIndex);

         double nTracks = recoVertexMatchedMc->noTracks();
         double nTracksQA = nTracks * recoVertexMatchedMc->qaTruth() / 100.;

         hists[0][0]->Fill(nMcTracksWithHits, nTracks);
         hists[0][1]->Fill(nMcTracksWithHits, nTracksQA);
         hists[0][2]->Fill(nMcTracksWithHits);
      }

      // Now deal with the highest rank vertex
      int maxRankVertexIndex = TMath::LocMax(nPrimaryVertices, vertexRanks.GetArray());

      StMuPrimaryVertex *recoVertexMaxRank = (StMuPrimaryVertex*) PrimaryVertices->UncheckedAt(maxRankVertexIndex);
      StMuMcVertex *mcVertex = reco2McVertices[recoVertexMaxRank];

      double nTracks = recoVertexMaxRank->noTracks();
      double nTracksQA = nTracks * recoVertexMaxRank->qaTruth() / 100.;

      // Fill numerator for "good" and "bad" efficiencies
      int h = ( mcVertex && mcVertex->Id() == 1) ? 1 : 2;

      hists[h][0]->Fill(nMcTracksWithHits, nTracks);
      hists[h][1]->Fill(nMcTracksWithHits, nTracksQA);
      hists[h][2]->Fill(nMcTracksWithHits);


      // Proceed with filling ntuple only if requested by the user
      if ( !fillNtuple ) continue;


      // Second loop over all verticies in this event
      for (int recoVertexIndex = 0; recoVertexIndex < nPrimaryVertices; recoVertexIndex++)
      {
         StMuPrimaryVertex *recoVertex = (StMuPrimaryVertex *) PrimaryVertices->UncheckedAt(recoVertexIndex);

         if ( !AcceptVX(recoVertex) ) continue;

         StMuMcVertex *mcVertex = reco2McVertices[recoVertex];

         if ( !mcVertex ) {
            std::cout << "No Match from RC to MC" << std::endl;
            continue;
         }

         if (vtxeval::gDebugFlag) {
            std::cout << Form("Vx[%3i]", recoVertexIndex) << *recoVertex << " " << *mcVertex;
            int nMcTracksWithHitsatL = Mc2McHitTracks.count(recoVertex->idTruth());
            std::cout << Form("Number of McTkHit %4i rank %8.3f", nMcTracksWithHitsatL, vertexRanks[recoVertexIndex]);
         }

         int IdPar = mcVertex->IdParTrk();

         if (IdPar > 0 && IdPar <= nMuMcTracks) {
            StMuMcTrack *mcTrack = (StMuMcTrack *) MuMcTracks->UncheckedAt(IdPar - 1);

            if (mcTrack && vtxeval::gDebugFlag) std::cout << " " << mcTrack->GeName();
         }

         FillData(data, recoVertex);

         double nTracks = recoVertex->noTracks();

         if (mcVertex->Id() == 1 && nTracks == vertexMaxMultiplicity) {// good
            VertexG->Fill(&data.beam);
         }
         else {   // bad
            VertexB->Fill(&data.beam);
         }
      }

      if ( !gROOT->IsBatch() ) {
         if (vtxeval::ask_user()) return;
      }
      else { vtxeval::gDebugFlag = false; }
   }

   fOut->Write();
}
Esempio n. 5
0
void makePicoDst(const Int_t runnumber=999999,
                 const Char_t *inputFile="/star/institutions/lbl_prod/mlomnitz/SSD_Simu/StEvent/hijing_**.MuDst.root",
                 const Char_t *inputGeant="/star/institutions/lbl_prod/mlomnitz/SSD_Simu/StEvent/hijing_**.McEvent.root",
                 TString outfilename="out",
                 const bool creatingPhiWgt = kFALSE, const int prodMod = 0, const int emcMode=0,
                 const bool createMcBranch = kTRUE
                 
                 ){
    Int_t nEvents = 10000000;
    //Int_t nEvents = 50;
    //Load all the System libraries
    cout<<inputFile<<endl;
    gSystem->Load("libTable");
    gSystem->Load("libPhysics");
    gSystem->Load("St_base");
    gSystem->Load("StChain");
    gSystem->Load("St_Tables");
    gSystem->Load("StUtilities");        // new addition 22jul99
    gSystem->Load("StTreeMaker");
    gSystem->Load("StIOMaker");
    gSystem->Load("StarClassLibrary");
    gSystem->Load("StTriggerDataMaker"); // new starting from April 2003
    gSystem->Load("StBichsel");
    gSystem->Load("StEvent");
    gSystem->Load("StEventUtilities");
    gSystem->Load("StDbLib");
    gSystem->Load("StEmcUtil");
    gSystem->Load("StTofUtil");
    gSystem->Load("StPmdUtil");
    gSystem->Load("StPreEclMaker");
    gSystem->Load("StStrangeMuDstMaker");
    gSystem->Load("StMuDSTMaker");
    if( createMcBranch){
        gSystem->Load("StMcEvent");
        gSystem->Load("StAssociationMaker");
    }
    if(!creatingPhiWgt&&emcMode) {
        gSystem->Load("StTpcDb");
        gSystem->Load("StMcEvent");
        gSystem->Load("StMcEventMaker");
        gSystem->Load("StDaqLib");
        gSystem->Load("libgen_Tables");
        gSystem->Load("libsim_Tables");
        gSystem->Load("libglobal_Tables");
        gSystem->Load("StEmcTriggerMaker");
        gSystem->Load("StEmcUtil");//mine
        gSystem->Load("StEmcRawMaker");
        gSystem->Load("StEmcADCtoEMaker");
        gSystem->Load("StPreEclMaker");
        gSystem->Load("StEpcMaker");
        gSystem->Load("StEmcSimulatorMaker");
        gSystem->Load("StEmcUtil");
        gSystem->Load("StDbBroker");
        gSystem->Load("StDetectorDbMaker");
        gSystem->Load("StDbUtilities");
        gSystem->Load("StEEmcUtil");
        gSystem->Load("StEEmcDbMaker");
        gSystem->Load("St_db_Maker");
        gSystem->Load("StTriggerUtilities");
    }
    
    gSystem->Load("StPicoDstMaker");
    
    chain = new StChain();
    if( createMcBranch ){
        StIOMaker* ioMaker = new StIOMaker("IO","r",inputGeant,"bfcTree");
        ioMaker->SetDebug();
        ioMaker->SetIOMode("r");
        ioMaker->SetBranch("*",0,"0");                 //deactivate all branches
        //ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
        ioMaker->SetBranch("McEventBranch",0,"r"); //activate geant Branch
        ioMaker->SetBranch("eventBranch",0,"r"); //activate geant Branch
        StAssociationMaker* associator    = new StAssociationMaker;
        cout<<"created new StAssociationMaker"<<endl;
        associator->useInTracker();
    }
    
    StMuDstMaker *MuDstMaker = new StMuDstMaker(0,0,"",inputFile,"MuDst",100);
    MuDstMaker->SetStatus("*",0);
    MuDstMaker->SetStatus("MuEvent",1);
    MuDstMaker->SetStatus("PrimaryVertices",1);
    MuDstMaker->SetStatus("PrimaryTracks",1);
    MuDstMaker->SetStatus("GlobalTracks",1);
    MuDstMaker->SetStatus("CovGlobTrack",1);
    //MuDstMaker->SetStatus("BTof*",1);
    //MuDstMaker->SetStatus("Emc*",1);
    
    if(!creatingPhiWgt&&emcMode) {
        St_db_Maker *dbMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
        
        // Endcap database
        StEEmcDbMaker* eemcDb = new StEEmcDbMaker;
        
        StEmcADCtoEMaker *adc2e = new StEmcADCtoEMaker();
        adc2e->setPrint(false);
        //adc2e->setFillHisto(false);
        //adc2e->setDebug(false); //more histograms
        //adc2e->setSMDRmsCut(0,0);
        adc2e->saveAllStEvent(true);
        //adc2e->setRemoveGhostEvent(false);
        //adc2e->setTallyHist(mTally);
        //adc2e->setDbName("Calibrations/emc/y3");
        
        StPreEclMaker *pre_ecl=new StPreEclMaker();
        pre_ecl->setPrint(kFALSE);
        StEpcMaker *epc=new StEpcMaker();
        epc->setPrint(kFALSE);
        
#if 1
        // Trigger simulator
        StTriggerSimuMaker* trigSimu = new StTriggerSimuMaker;
        trigSimu->setMC(false);
        trigSimu->useBemc();
        trigSimu->useEemc();
        trigSimu->useOnlineDB();
        
        trigSimu->bemc->setConfig(StBemcTriggerSimu::kOffline);
#endif
        
    }
    
    StPicoDstMaker *picoMaker = new StPicoDstMaker(1,Form("st_%i.picoDst.root",runnumber),"picoDst");
    picoMaker->setRunNumber(runnumber);
    picoMaker->setEmcMode(emcMode); // 0-No EMC, 1-EMC ON
    picoMaker->setMcMode(createMcBranch);
    
    
    chain->Init();
    cout<<"chain->Init();"<<endl;
    int total = 0;
    cout<<MuDstMaker->chain()->GetEntries()<<endl;
    if( nEvents > MuDstMaker->chain()->GetEntries() )
    nEvents=MuDstMaker->chain()->GetEntries();
    for (Int_t i=0; i<nEvents; i++){
        if(i%100==0)
        cout << "Working on eventNumber " << i << endl;
        
        chain->Clear();
        int iret = chain->Make(i);
        
        if (iret) { cout << "Bad return code!" << iret << endl; break;}
        
        total++;
        
    }
    
    cout << "****************************************** " << endl;
    cout << "Work done... now its time to close up shop!"<< endl;
    cout << "****************************************** " << endl;
    chain->Finish();
    cout << "****************************************** " << endl;
    cout << "total number of events  " << total << endl;
    cout << "****************************************** " << endl;
    
    delete chain;
    
    
}
Esempio n. 6
0
//==========================================================================================
void ProcessQQ(const Int_t mode, const Int_t fsti, const Int_t nevents,
	       const Char_t **fileList, const Char_t* dirName)
{
  cout << "Loading libraries ..." << endl;
  gSystem->Load("St_base");
  gSystem->Load("StChain");
  gSystem->Load("StDaqLib");
  gSystem->Load("St_Tables");
  gSystem->Load("StarMagField");
  gSystem->Load("StMagF");
  gSystem->Load("StUtilities");
  gSystem->Load("StTreeMaker");
  gSystem->Load("StIOMaker");
  gSystem->Load("StarClassLibrary");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("StTpcDb");
  gSystem->Load("StDbUtilities");
  gSystem->Load("StBichsel");
  gSystem->Load("StTriggerDataMaker");
  gSystem->Load("StEvent");
  gSystem->Load("StEventUtilities");
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");
  gSystem->Load("StAssociationMaker");

  //if( mode & 0x2){
  // EMC specific
  cout << " EMC mode enabled" << endl;
  gSystem->Load("StEmcUtil");
  gSystem->Load("StDbLib");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");
  //}

  if( mode & 0x4){
    // RICH
    cout << " RICH mode enabled" << endl;
    gSystem->Load("StRrsMaker");
    gSystem->Load("StRchMaker");
    gSystem->Load("StRichPIDMaker");
    gSystem->Load("StRichSpectraMaker");
  }

  gSystem->Load("StMcAnalysisMaker");
  gSystem->Load("StStrangeMuDstMaker");
  gSystem->Load("StMuDSTMaker");

  if( mode & 0x2 ){
    // EMC specific
    gSystem->Load("StEmcADCtoEMaker"); // analysis maker
    gSystem->Load("StPreEclMaker");    // analysis maker
    gSystem->Load("StEpcMaker");       // analysis maker
  }
  cout << "Loading done " << endl;


  chain = new StChain("StChain");
  chain->SetDebug();


  StFile *setFiles= new StFile();
  for (int ifil=0; fileList[ifil]; ifil++)
    setFiles->AddFile(fileList[ifil]);


  // ********************************
  // Now we add Makers to the chain...
  // ********************************

  // *************
  // file handling
  // *************
  StIOMaker* ioMaker = new StIOMaker("IOMaker","r",setFiles,"bfcTree");
  ioMaker->SetDebug();

  ioMaker->SetIOMode("r");
  ioMaker->SetDebug();
  ioMaker->SetBranch("*",0,"0");           //deactivate all branches
  ioMaker->SetBranch("eventBranch",0,"r"); //activate evt.root Branch
  ioMaker->SetBranch("emcBranch",0,"r");   //activate evt.root Branch
  ioMaker->SetBranch("runcoBranch",0,"r"); //activate runcoBranch



  // ***********************************************
  // MuDstMaker(s) instantiation / chain activation
  // ***********************************************
  // Common MuDST part
  StStrangeMuDstMaker* v0dst = new StStrangeMuDstMaker("strangeMuDst");
  v0dst->DoV0();      //Set v0MiniDstMaker to find only v0s
  v0dst->DoXi();      //Set v0MiniDstMaker to find only v0s
  v0dst->DoKink();    //Set v0MiniDstMaker to find only v0s
  v0dst->SetNoKeep();

  // RICH part
  if( mode & 0x4 ){
    StRichSpectraMaker* spectraMaker = new StRichSpectraMaker("spectraMaker");
  }

  StAddRunInfoMaker* addRunInfoMaker = new StAddRunInfoMaker();

  StMuDstMaker* maker = new StMuDstMaker(1,1,dirName);
  // You can change the PIDTable map using the above method.
  //maker->setProbabilityPidFile("Path/PIDTable.root");
  maker->setProbabilityPidFile();

  StMuL3Filter* l3Filter = new StMuL3Filter(); maker->setL3TrackFilter(l3Filter);
  StMuFilter* filter = new StMuFilter();       maker->setTrackFilter(filter);

  // EMC part
  if( mode & 0x2){
    St_db_Maker *dbMk = new St_db_Maker("StarDb","MySQL:StarDb");
    StEmcADCtoEMaker *adc = new StEmcADCtoEMaker();
    StPreEclMaker *pre = new StPreEclMaker();
    StEpcMaker *epc = new StEpcMaker();
    StEmcMicroDstMaker *write = new StEmcMicroDstMaker();
    write->setOutputDir(dirName);
  }


  if ( fsti == 1){
    //select for Sti tracks
    filter->addEncodedMethod(263);
  }



  // This should call the Init() method in ALL makers
  chain->Init();
  chain->PrintInfo();

  // Event Loop
  Int_t iev=0;
  for ( ; iev < nevents ; iev++) {
    cout << "-----> Working on eventNumber " << iev << endl;
    chain->Clear();
    int iret = chain->Make(iev); // This should call the Make() method in ALL makers
    if (iret) {
      cout << "Bad return code!" << endl;
      break;
    }
  }
  chain->Finish();    // This should call the Finish() method in ALL makers

  iev--;
  cout << endl << "******************* Last event processed = " << iev << endl;
}
void Run2006SimuTriggerMaker(const char *dir ="",
			     const char* file="/star/data32/reco/pp200/pythia6_205/above_35gev/cdf_a/y2004y/gheisha_on/p05ih/rcf1230_10_4000evts.MuDst.root",
			     const char *fname="/star/data32/reco/pp200/pythia6_205/above_35gev/cdf_a/y2004y/gheisha_on/p05ih/rcf1230_10_4000evts.event.root",
			     const char *filter = "")
{
  int nevents = 10;
  
  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  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("StPreEclMaker");
  gSystem->Load("StEpcMaker");
  gSystem->Load("StEmcSimulatorMaker");
  gSystem->Load("StEmcUtil");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");
  gSystem->Load("StEEmcUtil");
  gSystem->Load("StEEmcDbMaker");
  gSystem->Load("StEmcTriggerMaker");

  double pi = atan(1.0)*4.0;
  cout << " loading done " << endl;
  
  chain= new StChain("StChain"); 
  chain->SetDebug(1);
  gMessMgr->SwitchOff("D");
  gMessMgr->SwitchOff("I");
  
  StIOMaker* ioMaker = new StIOMaker();
  ioMaker->SetFile(fname);
  ioMaker->SetIOMode("r");
  ioMaker->SetBranch("*",0,"0");             //deactivate all branches
  ioMaker->SetBranch("geantBranch",0,"r");   //activate geant Branch

  class StMcEventMaker *mcEventMaker = new StMcEventMaker();
  mcEventMaker->doPrintEventInfo = false;
  mcEventMaker->doPrintMemoryInfo = false;
  
  StMuDebug::setLevel(1); 
  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,dir,file,filter,1e6,"MuDst");
 
  //Database -- get a real calibration from the database
  St_db_Maker* dbMk = new St_db_Maker("StarDb","MySQL:StarDb","MySQL:StarDb","$STAR/StarDb");
  dbMk->SetDateTime(20060506,214129 ); // for simulation
 
  //to use ideal ideal gains/status/calib uncommment correct line below
  //dbMk->SetFlavor("sim","bemcPed");
  //dbMk->SetFlavor("sim","bemcStatus");
  //dbMk->SetFlavor("sim","bemcCalib");
  //dbMk->SetFlavor("sim","bemcGain");
  //dbMk->SetFlavor("sim","eemcPMTcal");
  //dbMk->SetFlavor("sim","eemcPIXcal");

  chain->ls(3);
 //Database interface
  StDetectorDbMaker* detDbMk = new StDetectorDbMaker();

 //Endcap DB
  StEEmcDbMaker* eemcb = new StEEmcDbMaker("eemcDb");
  
  //StEmcADCtoEMaker *adc = new StEmcADCtoEMaker(); // this will just convert what's in MuDst to ADC, use for data only!
  StEmcSimulatorMaker* emcSim = new StEmcSimulatorMaker(); //use this instead to "redo" converstion from geant->adc
  emcSim->setCalibSpread(kBarrelEmcTowerId, 0.15);
  StPreEclMaker* preEcl = new StPreEclMaker(); //need this to fill new StEvent information
  
  //StEmcTrigger
  StEmcTriggerMaker *emcTrig = new StEmcTriggerMaker("bemctrigger");

  chain->Init();
  chain->PrintInfo();
  
  chain->ls(3);
  TChain* fileChain = muDstMaker->chain(); 


  int BL1_ADC[6];
  int hold=-1;
  for (Int_t iev=0;iev<nevents; iev++) {
    cout << "****************************************** " << endl;
    cout << "Working on eventNumber:\t" << iev <<"\tof:\t"<<nevents<<endl;
    cout << "*************************1***************** " << endl;
    chain->Clear();
    int iret = chain->Make(iev);
    total++;
    if (iret) {
      cout << "Bad return code!" << endl;
      break;
    }

    cout<<"           "<<endl;
    map<int,int>::iterator iter;
    map<int,int> tower;
    map<int,int> tpatch;
    map<int,int> jpatch;

    cout<<endl;
    cout<<endl;
    cout<<" 1101 ht1 = "<<emcTrig->isTrigger(1101)<<" = "<<emcTrig->is2003HT1()<<endl;    
    tower=emcTrig->barrelTowersAboveThreshold(1101);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old tower id="<<emcTrig->get2003HT1_ID()<<" adc="<<emcTrig->get2003HT1_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 2101 ht1 = "<<emcTrig->isTrigger(2201)<<" = "<<emcTrig->is2003HT1()<<endl;   
    tower=emcTrig->barrelTowersAboveThreshold(2201);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old tower id="<<emcTrig->get2003HT1_ID()<<" adc="<<emcTrig->get2003HT1_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 2202 ht2 = "<<emcTrig->isTrigger(2202)<<" = "<<emcTrig->is2003HT2()<<endl;   
    tower=emcTrig->barrelTowersAboveThreshold(2202);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old tower id="<<emcTrig->get2003HT2_ID()<<" adc="<<emcTrig->get2003HT2_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 45201 ht1 = "<<emcTrig->isTrigger(45201)<<" =  "<<emcTrig->is2004HT1()<<endl;   
    tower=emcTrig->barrelTowersAboveThreshold(45201);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old tower id="<<emcTrig->get2004HT1_ID()<<" adc="<<emcTrig->get2004HT1_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 45202 ht1 = "<<emcTrig->isTrigger(45202)<<" =  "<<emcTrig->is2004HT2()<<endl;   
    tower=emcTrig->barrelTowersAboveThreshold(45202);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old tower id="<<emcTrig->get2004HT2_ID()<<" adc="<<emcTrig->get2004HT2_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 45206 jp1 = "<<emcTrig->isTrigger(45206)<<" =  "<<emcTrig->is2004JP1()<<endl;   
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(45206);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old patch id="<<emcTrig->get2004JP1_ID()<<" adc="<<emcTrig->get2004JP1_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 45207 jp2 = "<<emcTrig->isTrigger(45207)<<"  =  "<<emcTrig->is2004JP2()<<endl;   
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(45207);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
      cout<<"old patch id="<<emcTrig->get2004JP2_ID()<<" adc="<<emcTrig->get2004JP2_ADC()<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 127212 ht2 (matrix0)="<<emcTrig->isTrigger(127212)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(127212);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 127213 ht2 (matrix1)="<<emcTrig->isTrigger(127213)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(127213);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137213 ht2 (matrix3) ="<<emcTrig->isTrigger(127213)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(127213);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 127501 jp0 (matrix1)="<<emcTrig->isTrigger(127501)<<endl;
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(127501);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137501 jp0 (matrix3) ="<<emcTrig->isTrigger(137501)<<endl;
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(137501);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 127221 jp1 (matrix1)="<<emcTrig->isTrigger(127221)<<endl;
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(127221);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137221 jp1 (matrix2)="<<emcTrig->isTrigger(137221)<<endl;
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(137221);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137222 jp1 (matrix3)="<<emcTrig->isTrigger(137222)<<endl;
    jpatch=emcTrig->barrelJetPatchesAboveThreshold(127501);
    cout<<"Total #'s of jpatches="<<jpatch.size()<<endl;
    for ( iter=jpatch.begin();iter !=jpatch.end(); iter++){
      cout<<"jpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 127821 http (matrix1)="<<emcTrig->isTrigger(127821)<<endl;
    tpatch=emcTrig->barrelTriggerPatchesAboveThreshold(127821);
    cout<<"Total #'s of tpatches="<<tpatch.size()<<endl;
    for ( iter=tpatch.begin();iter !=tpatch.end(); iter++){
      cout<<"tpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }
    tower=emcTrig->barrelTowersAboveThreshold(127821);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
        int triggerPatch = emcTrig->barrelTriggerPatchForTower(iter->first);
        cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<"  tp (id,adc)=("<< triggerPatch << "," << tpatch[triggerPatch] << ")" <<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137821 http (matrix3) ="<<emcTrig->isTrigger(137821)<<endl;
    tpatch=emcTrig->barrelTriggerPatchesAboveThreshold(137821);
    cout<<"Total #'s of tpatches="<<tpatch.size()<<endl;
    for ( iter=tpatch.begin();iter !=tpatch.end(); iter++){
      cout<<"tpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }
    tower=emcTrig->barrelTowersAboveThreshold(137821);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
        int triggerPatch = emcTrig->barrelTriggerPatchForTower(iter->first);
        cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<"  tp (id,adc)=("<< triggerPatch << "," << tpatch[triggerPatch] << ")" <<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137822 http (matrix4)="<<emcTrig->isTrigger(137822)<<endl;
    tpatch=emcTrig->barrelTriggerPatchesAboveThreshold(137822);
    cout<<"Total #'s of tpatches="<<tpatch.size()<<endl;
    for ( iter=tpatch.begin();iter !=tpatch.end(); iter++){
      cout<<"tpatch id="<<iter->first<<"  adc="<<iter->second<<endl;
    }  
    tower=emcTrig->barrelTowersAboveThreshold(137822);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
        int triggerPatch = emcTrig->barrelTriggerPatchForTower(iter->first);
        cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<"  tp (id,adc)=("<< triggerPatch << "," << tpatch[triggerPatch] << ")" <<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 117705 jpsi (matrix1)="<<emcTrig->isTrigger(117705)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(117705);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 117602 upsilon (matrix1)="<<emcTrig->isTrigger(117602)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(117602);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }

    cout<<endl;
    cout<<endl;
    cout<<" 137602 upsilon (matrix3)="<<emcTrig->isTrigger(137602)<<endl;
    tower=emcTrig->barrelTowersAboveThreshold(137602);
    cout<<"Total #'s of towers="<<tower.size()<<endl;
    for ( iter=tower.begin();iter !=tower.end(); iter++){
      cout<<"tower id="<<iter->first<<"  adc="<<iter->second<<endl;
    }


    cout<<endl;
    cout<<endl;
    cout<<" 127611 http-L2="<<emcTrig->isTrigger(127611)<<endl;
    
    cout<<endl;
    cout<<endl;
    cout<<" 127622 jp0-etot-L2="<<emcTrig->isTrigger(127622)<<endl;
 
    cout<<endl;
    cout<<endl;
    cout<<" 137622  jp0-etot-L2="<<emcTrig->isTrigger(137622)<<endl;

    for (int j=0;j<6;j++){
      BL1_ADC[j]=0.0;
      emcTrig->get2006BL1_ADC(j,&hold);
      BL1_ADC[j]=hold;
      cout<<" 2x1 Patch "<<j<<" = "<<BL1_ADC[j]<<endl;
    }
 

  }

  chain->Finish();
  cout << "****************************************** " << endl;
  cout << "total number of events  " << total << endl;
  cout << "****************************************** " << endl;
 
}
Esempio n. 8
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 ;
}
Esempio n. 9
0
void makeTrees(string fileList, string jobID){

  bool makePairs = true;
	bool makeTrackQA = false;
	
	
//LOAD LIBRARIES
	cout << "\n";
	gROOT->Macro("/star/u/klandry/ucladisk/2012IFF/StRoot/LoadLibs.C");
	if (makePairs)
	{
	  gSystem->Load("pionPair");
	  cout << " loading of pionPair library done" << endl;
	  gSystem->Load("pionPairTreeMaker");
	  cout << " loading of pionPairTreeMaker library done" << endl;
	}
	if (makeTrackQA)
	{
	  gSystem->Load("trackQAmaker");
	  cout << " loading of trackQAmaker library done" << endl;
	}
	
	cout << "\n";
	cout << "\n";

	
//CHAIN OF MAKERS
  StChain* chain = new StChain; 
	
//MUDST READER
  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",fileList.c_str(),"",100000,"MuDst");

	chain->Make(0);
	StMuEvent* MuEvent = muDstMaker->muDst()->event();
	int runID = MuEvent->runId();

	stringstream ss;
	ss << runID;
	string runNumber = ss.str();
	

//StarDbMaker
	St_db_Maker* dbMaker = new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb");

//SPINDBMAKER
	StSpinDbMaker* spinDbMaker = new StSpinDbMaker("StSpinDbMaker");
	
	cout << "\n";
	
//pionPairTreemaker
	if (makePairs)
	{
		pionPairTreeMaker* piTreeMaker = new pionPairTreeMaker(muDstMaker);
		string outFileName;
		outFileName  = "run";
		outFileName += runNumber;
		outFileName += "_";
		outFileName += jobID;
		outFileName += "_pionTree.root";
		
		piTreeMaker->setOutputFile(outFileName.c_str());
    cout << "pionPairTree file name: " << outFileName << endl;	
	}
	
//trackQAmaker
	if (makeTrackQA)
	{
		trackQAmaker* trkQAmaker = new trackQAmaker(muDstMaker);
		string trackOutFileName;
		trackOutFileName  = "run";
		trackOutFileName += runNumber;
		trackOutFileName += "_";
		trackOutFileName += jobID;
		trackOutFileName += "_trackQA.root";
		
		trkQAmaker->setOutputFile(trackOutFileName.c_str());
		cout << "track QA file name: " << trackOutFileName << endl;
	}

	
	int iEvent = 0;
	
	cout << "\n";
	cout << "\n";
	cout << "Init() ......." << endl;
	cout << "\n";
	cout << "\n";

	chain->Init();
		
	cout << "\n";
	cout << "\n";
	cout << "Make() ......." << endl;
	cout << "\n";
	cout << "\n";
	
	//int nEvents = 2;
	//chain->EventLoop(nEvents);

	//*
	while (chain->Make(iEvent) == kStOK)
	{
		iEvent++;
	  if (iEvent%100000 == 0) {cout << "processing event number " << iEvent << endl;}
		//if (iEvent >= 10000){break;}
		
	}//end while
	//*/
	

	chain->Finish();
	
	
	delete chain;
	
	

}
Esempio n. 10
0
void dlMudst(/*string fileList*/){

	string fileList = "./xml/schedB57622DD24C1A0ECDF3F996978585EA7_4.list";
//	string fileList = "./xml/testlist.list";

	gROOT->Macro("/star/u/klandry/ucladisk/2012IFF/StRoot/LoadLibs.C");
  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();
  gSystem->Load("StarMagField");
  gSystem->Load("StMagF");
  gSystem->Load("StTpcDb");
	//  gSystem->Load("StDbUtilities");
  gSystem->Load("StDaqLib");
  gSystem->Load("StDbBroker");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("StDbUtilities");
  gSystem->Load("St_db_Maker");
	
  gSystem->Load("StEvent");
  gSystem->Load("StEventMaker");
  gSystem->Load("StarMagField");
  gSystem->Load("StTofUtil");   
  gSystem->Load("StTofMaker");  
	
  //gSystem->Load("libtpc_Tables");
  gSystem->Load("libGeom");
  gSystem->Load("St_g2t"); 
  gSystem->Load("geometry");
  gSystem->Load("St_geant_Maker");
	
  gSystem->Load("StTofMuDstReader");
	
	TFile* outfile = new TFile("/star/u/klandry/ucladisk/2012IFF/2012Mudstshort.root","Recreate");

	char* outputname = "testout.root";
	
	StChain* muChain = new StChain();

  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",fileList.c_str(),"",100000,"MuDst");
  muDstMaker->SetStatus("BTofHeader",1) ;      // Turn on the global track data
	muDstMaker->SetStatus("TofRawData",1);
	muDstMaker->SetStatus("TofData",1);
	muDstMaker->SetStatus("TofHit",1);
	
	//StTofMuDstReader *tofMaker = new StTofMuDstReader("tofMaker",outputname,muDstMaker);

  StMuDst* muDst;
		
	TTree* tree = new TTree("mudst","mudst");
	
	tree->Branch("muDst", &muDst);
	
	
	TH1D* hSigmaPiontof = new TH1D("tofsigmapion","tofsigmapion",100,-10,10);
	TH1D* hSigmaPiontpc = new TH1D("tpcsigmapion","tpcsigmapion",100,-10,10);


	
	int iEvent = 0;
	
	while (muChain->Make(iEvent) == kStOK)
	{
		muDst = muDstMaker->muDst();
		cout << "number of TOF Hits " << muDst->numberOfTofHit() << endl;
		
		for (int iHit=0; iHit<muDst->numberOfTofHit(); iHit++)
		{
			
			StMuTofHit *tof = (StMuTofHit*)muDst->tofHit(iHit);
			//StMuBTofHit* bTofHit = muDst->btofHit(iHit);
			
			if (!muDst->tofHit(iHit))
			{
				cout << "jdflksfjldsfjlsdjf" << endl;
			}
					
			//hSigmaPiontof->Fill(tofHit->sigmaPion());
	
			//cout << "tofFilled" << endl;
			
		}
	
		
		for (int iTrack=0; iTrack<muDst->numberOfPrimaryTracks(); iTrack++)
		{
			
			StMuTrack* track = muDst->primaryTracks(iTrack);
			
			hSigmaPiontpc->Fill(track->nSigmaPion());
			
			//cout << "tpcFilled" << endl;
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		//cout << muDstMaker->muDst()->event()->runId() << endl;
		//cout << muDst->event()->runId() << endl;
		
		tree->Fill();

	
		iEvent++;
		
		if (iEvent%1000 == 0)
		{
			cout << iEvent << endl;
			//cout << muDst->event->runId() << endl;
		}
		
		
		if (iEvent == 1000){break;}
		
	}
	
	
	tree->Write();
	hSigmaPiontof->Write();
	hSigmaPiontpc->Write();
	
	outfile->Write();
		
}