Пример #1
0
void runTree(char* dir="hist_pAu2", char* filter="16142010", unsigned int neventsIn = 0){  
  // If nEvents is negative, reset to the maximum possible value for an Int_t
  if( neventsIn <= 0 ) neventsIn = 1<<31-1;

  TSystemDirectory DIR(dir, dir);
  TList *files = DIR.GetListOfFiles();
  TChain* trees = new TChain();
  int nfile=0;
  if (files) {
      TSystemFile *file;
      TString fname;
      TIter next(files);
      while ((file=(TSystemFile*)next())) {
	  fname = file->GetName();
	  if (!file->IsDirectory() && fname.BeginsWith(filter) && fname.EndsWith("tree.root")) {
	      cout << Form("Adding %s/%s to TChain",dir,fname.Data())<<endl;
	      trees->AddFile(Form("%s/%s/dipi0",dir,fname.Data()));
	      nfile++;
	  }
      }
  }
  cout << Form("%d files added",nfile) << endl;

  // load the shared libraries
  std::cout << "***** Loading libraries *****" << endl;
  LoadLibs();

  // Create the analysis chain
  analysisChain = new StChain("dipi0Chain");
  
  //cout << "Constructing StFmsDbMaker" << endl;
  //StFmsDbMaker* fmsDbMkr = new StFmsDbMaker( "fmsDb" );
  //fmsDbMkrName = fgtDbMkr->GetName();

  gSystem->Load("StFmsDiPi0");
  StFmsDiPi0* dipi0=new StFmsDiPi0;
  TString filenameDiPi0(Form("%s/%s.dipi0.root",dir,filter));
  cout << "DiPi0 outfile name = " << filenameDiPi0.Data()<<endl;
  dipi0->setFileName(filenameDiPi0.Data());
  dipi0->setReadTree(trees);

  analysisChain->Init();

  Int_t ierr  = kStOK;  // err flag
  Int_t nevents = 0;    // cumulative number of events in
  for( ; nevents < neventsIn && !ierr; ++nevents ){
    if(nevents%10000==0) cout <<"event: "<< nevents <<endl;
    analysisChain->Clear();
    ierr = analysisChain->Make();
  } 
  analysisChain->Finish(); 

  analysisChain->Delete();
  return;
};
Пример #2
0
int simpleTestStandTest( const Char_t *filename = "testfile.sfs",
                         Int_t nevents = 10,
                         Int_t numDiscs = 6 ){

   LoadLibs();
   Int_t ierr = 0;

   cout << "Constructing the chain" << endl;
   analysisChain = new StChain("eemcAnalysisChain");

   cout << "Constructing the maker" << endl;
   cosmicMkr = new StFgtCosmicMaker( "cosmicMaker", filename );
   cosmicMkr->setNumDiscs( numDiscs );

   cout << "Initializing" << endl;
   ierr = analysisChain->Init();

   if( ierr ){
      cout << "Error initializing" << endl;
      return;
   };

   if( nevents < 0 )
      nevents = 1e100; // a big number

   for( int i=0; i<nevents && !ierr; ++i ){

      cout << "event number " << i << endl;

      cout << "clear" << endl;
      analysisChain->Clear();

      cout << "make" << endl;
      ierr = analysisChain->Make();

      // count number of events
      StFgtEvent *fgtEventPtr = cosmicMkr->getFgtEventPtr();
      for( Int_t disc = 0; disc < numDiscs; ++disc ){
         StFgtDisc *discPtr = fgtEventPtr->getDiscPtr( disc );
         if( discPtr )
            cout << "\tDisc " << disc << ", number of raw hits " << discPtr->getNumRawHits() << endl;
      };
   };

   //
   // Calls the ::Finish() method on all makers
   //
   cout << "finish" << endl;
   analysisChain->Finish(); 

   cout << "all done" << endl;
   return;
};
Пример #3
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;
};
Пример #4
0
void runMuFgtOccTxtMkr( const Char_t *filename, 
                        Int_t neventsIn = 10 ){

   // load the shared libraries
   std::cout << "***** Loading libraries *****" << endl;
   LoadLibs();

   std::cout << "***** Done loading libraries *****" << endl;
   std::cout << "***** Instanciating all the classes *****" << endl;

   //
   // Create the analysis chain
   //
   analysisChain = new StChain("eemcAnalysisChain");

   //
   // MuDst maker for reading input
   //
   Int_t nfiles = 10000;
   muDstMaker = new StMuDstMaker( 0, 0, "", filename, "MuDst", nfiles );
   muDstMaker->SetStatus("*",0);
   muDstMaker->SetStatus("Event",1);
   muDstMaker->SetStatus("MuEvent",1);
   muDstMaker->SetStatus("PrimaryVertices",1);
   muDstMaker->SetStatus("FgtStrip",1);
   muDstMaker->SetStatus("FgtCluster",1);

   //
   // now the QA maker
   //
   occTxtMkr = new StMuFgtOccTxtMkr( "fgtOccTxtMkr" );


   // debugging info
   std::cout << "***** Done instanciating all the classes *****" << endl;
   //analysisChain.ls(3);

   //
   // Initialize all makers
   //
   std::cout << "***** Initializing all makers in the analysis chain *****" << std::endl;

   analysisChain->Init();

   std::cout << "***** Initialization done *****" << std::endl;

   //
   // Finally ready to loop over the events 
   //

   // If nEvents is negative, reset to the maximum possible value
   // for an Int_t
   if( neventsIn < 0 )
      neventsIn = 1<<31-1;

   Int_t ierr  = kStOK;  // err flag
   Int_t nevents = 0;    // cumulative number of events in
   for( ; nevents < neventsIn && !ierr; ++nevents ){
      // clear
      analysisChain->Clear();

      // make
      ierr = analysisChain->Make();
   };
 
   //---------------------------------------------------------------


   //
   // Calls the ::Finish() method on all makers
   //
   analysisChain->Finish(); 

   //
   // Delete the chain
   //
   analysisChain->Delete();

   return;
};
Пример #5
0
int fgtRawSpectraQA( const Char_t *filenameIn = "testfile.daq",
                     const Char_t *filebaseOut = "testfile.rawQA",
                     Int_t date = 20120115,
                     Int_t time = 0,
                     Float_t pedRelThres = 0,    // 0 = no cut, otherwise: # of sigma above pedestal for cut
                     Int_t nevents = 2000,
                     Int_t timebin = 2,
                     UInt_t statusMask,
                     Bool_t cutShortEvents = 1 ){

   LoadLibs();
   Int_t ierr = 0;

   //
   // START CONSTRUCTING THE CHAIN
   //

   cout << "Constructing the chain" << endl;
   analysisChain = new StChain("eemcAnalysisChain");

   //
   // THE DATABASE
   //

   // note: DB is used to convert elec coords into geoIds in
   // StEvent/StFgtStrip, and do determine the disc and quad given
   // an rdo/arm/apv combination.

   cout << "Constructing St_db_Maker" << endl;

   TString dir0 = "MySQL:StarDb";
   TString dir1 = "$STAR/StarDb";
   St_db_Maker *dbMkr = new St_db_Maker( "dbMkr", dir0, dir1 );
   dbMkr->SetDateTime(date,time);

   cout << "Constructing StFgtDbMaker" << endl;
   fgtDbMkr = new StFgtDbMaker( "fgtDbMkr" );

   //
   // NOW THE OTHER READERS AND MAKERS
   //

   cout << "Constructing the daq reader" << endl;
   daqRdr = new StFgtRawDaqReader( "daqReader", filenameIn, "" );
   daqRdr->setIsCosmic( 0 );
   daqRdr->cutShortEvents( cutShortEvents );

//    a2cMkr = new StFgtA2CMaker( "a2cMkr" );
//    a2cMkr->setStatusMask( statusMask );
//    a2cMkr->setAbsThres( -10000 );  // set to below -4096 to skip cut
//    a2cMkr->setRelThres( pedRelThres );  // set to zero to skip cut

   cout << "Constructing the QA Makers" << endl;
   qaMkr = new StFgtQaRawOctAdc( "qaMkr", 2 );
   qaMkr->setTimeBin( 2 );

   // debug
   analysisChain->ls(4);

   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 == 0 )
         cout << "\ton event number " << i << endl;

      //cout << "clear" << endl;
      analysisChain->Clear();

      //cout << "make" << endl;
      ierr = analysisChain->Make();

   };

   //
   // Calls the ::Finish() method on all makers
   //
   cout << "finish" << endl;
   analysisChain->Finish();

   cout << "Making plots" << endl;

   gROOT->SetStyle("Plain");
   gStyle->SetOptStat(0);
   gStyle->SetPalette(1);

   can = new TCanvas( "fgtRawQA", "fgtRawQA", 850, 1100);
   can->Divide( 1, 4 );

   // open output file
   can->Print( (std::string(filebaseOut) + ".ps[").data() );

   //std::vector< TH2F* >& hist = qaMkr->getHistVec();

   cout << "First hist at " << qaMkr->getHist(0) << endl;

   cout << "Finding max" << endl;

   // get max
   Float_t max = 0;
   for( Int_t idx = 0; idx < 48; ++idx ){
      if( qaMkr->getHist(idx) )
         if( qaMkr->getHist(idx)->GetMaximum() > max )
            max = qaMkr->getHist(idx)->GetMaximum();
   };
   max = 0.9*max;

   cout << "Max is " << max << endl;

   TH2F *dummy[4];
   const Char_t dummyNames[4][20] = { "dummy1", "dummy2", "dummy3", "dummy4" };

   Float_t xMin = qaMkr->getHist(0)->GetXaxis()->GetXmin();
   Float_t xMax = qaMkr->getHist(0)->GetXaxis()->GetXmax();
   Float_t yMin = qaMkr->getHist(0)->GetYaxis()->GetXmin();
   Float_t yMax = qaMkr->getHist(0)->GetYaxis()->GetXmax();

   for( Int_t i=0; i<4; ++i )
      dummy[i] = new TH2F( dummyNames[i], "", 5, xMin, xMax, 1, yMin, yMax );

   std::stringstream ss;

   Int_t subpad = 1;
   idx = 0;
   for( Int_t rdo = 1; rdo < 3; ++rdo ){
      for( Int_t arm = 0; arm < 6; ++arm ){
         for( Int_t startIdx = 0; startIdx < 4; ++startIdx, ++idx ){
            for( Int_t oct = 0; oct < 1; ++oct ){

               cout << "rdo/arm/disc/oct = " << rdo << '/' << arm << '/' << startIdx << '/' << oct << endl;
               if( qaMkr->getHist(idx)->GetEntries() > 0 ){
                  can->cd(subpad);
                  gPad->SetLeftMargin( 0.06 );
                  gPad->SetRightMargin( 0.05 );
                  gPad->SetBottomMargin( 0.11 );

                  qaMkr->getHist(idx)->SetMaximum( max );
                  dummy[subpad-1]->GetXaxis()->SetTitleOffset(0.9);
                  dummy[subpad-1]->GetXaxis()->SetTitleSize(0.06);
                  dummy[subpad-1]->GetXaxis()->SetLabelSize(0.06);
                  dummy[subpad-1]->GetYaxis()->SetTitleOffset(0.55);
                  dummy[subpad-1]->GetYaxis()->SetTitleSize(0.06);
                  dummy[subpad-1]->GetYaxis()->SetLabelSize(0.06);

                  gPad->SetGridx(0);
                  gPad->SetGridy(0);

                  for( Int_t i = 0; i<5; ++i ){
                     ss.str("");
                     ss.clear();
                     ss << "channels in APV "; // startArray[startIdx]+i;
                     dummy[subpad-1]->GetXaxis()->SetBinLabel( i+1, ss.str().data() );
                  };
                  dummy[subpad-1]->GetXaxis()->SetNdivisions(222,0);
                  dummy[subpad-1]->SetMinimum( 0 );
                  dummy[subpad-1]->SetMaximum( max );
                  dummy[subpad-1]->SetTitle( qaMkr->getHist(idx)->GetTitle() );
                  qaMkr->getHist(idx)->SetTitle("");

                  dummy[subpad-1]->GetYaxis()->SetTitle( qaMkr->getHist(idx)->GetYaxis()->GetTitle() );
                  qaMkr->getHist(idx)->GetYaxis()->SetTitle("");
                  dummy[subpad-1]->Draw("COLZ");

                  qaMkr->getHist(idx)->Draw("COLZ SAME");

                  gPad->Update();
                  gPad->Modified();

                  TPaveText *title = (TPaveText*)(gPad->GetPrimitive("title"));
                  if( title ){
                     title->SetX1NDC( 0.045 );
                     title->SetX2NDC( 0.55 );
                     title->SetY1NDC( 0.91 ) ;
                     title->SetY2NDC( 0.999 );
                     title->SetBorderSize(0);
                     title->SetTextAlign( 12 );
                     title->SetTextColor(kBlue);
                     title->Draw();
                  };

                  TPave *palette = (TPave*)(gPad->GetPrimitive("palette"));
                  if( palette ){
                     palette->SetX1NDC( 0.955 );
                     palette->SetX2NDC( 0.985 );
                     palette->Draw();
                  };

                  ++subpad;
                  if( subpad == 5 ){
                     subpad = 1;
                     can->Print( (std::string(filebaseOut) + ".ps").data() );
                  };
               };
            };
         };
      };
   };

   if( subpad != 1 )
      can->Print( (std::string(filebaseOut) + ".ps").data() );
   can->Print( (std::string(filebaseOut) + ".ps]").data() );

   gSystem->Exec(( std::string("ps2pdf -dAutoRotatePages=/None ") + filebaseOut + ".ps" ).data());


   cerr << "\tall done" << endl;
   return;
};
Пример #6
0
void runEEmcMcPi0( Int_t nevents = 1000,
			Char_t *name = "dipi0_10000evts.MuDst.root",
			//Char_t *name = "/star/data05/scratch/hew/JanSample/pi0_set2.MuDst.root",
			Char_t *ofile= "test.root",
			Char_t *path = "/star/u/hew/pi0finder/ezGames/backyard/multiphoton/",
			//Char_t *path = "",///star/data13/reco/pp200/pythia6_205/25_35gev/cdf_a/y2004y/gheisha_on/p05ih/", 
			Int_t nfiles = 100)
		      
{
  
  TString pathname = path; 
  pathname += name;
  TString fileG=name;
  fileG.ReplaceAll("MuDst","geant");
  
  fileG=path+fileG;
  
  //--
  //-- Load shared libraries
  //--
  LoadLibs();
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");

  //assert(!gSystem->Load("StEEmcMcReadMaker"));

  //--
  //-- Create the analysis chain
  //--
  mChain = new StChain("eemcAnalysisChain");
  
  StIOMaker* ioMaker = new StIOMaker();

  printf("%s\n",fileG.Data());
  ioMaker->SetFile(fileG);

  ioMaker->SetIOMode("r");
  ioMaker->SetBranch("*",0,"1");             //deactivate all branches
  ioMaker->SetBranch("geantBranch",0,"r");   //activate geant Branch
  ioMaker->SetBranch("minimcBranch",0,"r");   //activate geant Branch

  
  //--
  //-- MuDst maker for reading input
  //--
  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
  mMuDstMaker->SetStatus("*",0);
  mMuDstMaker->SetStatus("MuEvent",1);
  mMuDstMaker->SetStatus("EmcAll",1);

  StMcEventMaker *mcEventMaker = new StMcEventMaker();
  mcEventMaker->doPrintEventInfo = false;
  mcEventMaker->doPrintMemoryInfo = false;

  //--
  //-- Connect to the STAR databse
  //--
  mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");


#ifdef MONTE_CARLO  
  //--
  //-- Setup ideal gains for processing MC data
  //--
  
  mStarDatabase->SetFlavor("sim","eemcPMTcal");
  mStarDatabase->SetFlavor("sim","eemcPIXcal");
  mStarDatabase->SetFlavor("sim","eemcPMTped");
  mStarDatabase->SetFlavor("sim","eemcPMTstat");
  mStarDatabase->SetFlavor("sim","eemcPMTname");
  mStarDatabase->SetFlavor("sim","eemcADCconf");
  mStarDatabase->SetDateTime(20050101,0);

#endif

  //--
  //-- Initialize EEMC database
  //--
  new StEEmcDbMaker("eemcDb");
  gMessMgr -> SwitchOff("D");
  gMessMgr -> SwitchOn("I");

  mSpinDb = new StSpinDbMaker("mSpinDb");

#ifdef MONTE_CARLO
  //--
  //-- Initialize slow simulator
  //--
  StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
  slowSim->setDropBad(0);   // 0=no action, 1=drop chn marked bad in db
  slowSim->setAddPed(0);    // 0=no action, 1=ped offset from db
  slowSim->setSmearPed(0);  // 0=no action, 1=gaussian ped, width from db
  slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
  slowSim->setNpePerMipSmd(1.0);
 
#endif
 

  //--
  //-- Energy to ADC maker
  //--
  mEEanalysis=new StEEmcA2EMaker("AandE");
  mEEanalysis->database("eemcDb");          // sets db connection
  mEEanalysis->source("MuDst",1);           // sets mudst as input
  mEEanalysis->threshold(3.0,0);            // tower threshold
  mEEanalysis->threshold(3.0,1);            // pre1 threshold 
  mEEanalysis->threshold(3.0,2);            // pre2 threshold
  mEEanalysis->threshold(3.0,3);            // post threshold
//mEEanalysis->threshold(4,5.0);            // smdu threshold
//mEEanalysis->threshold(5,5.0);            // smdv threshold
  mEEanalysis->scale(1.3);                  // scale energies by x1.2
  
  
  //--
  //-- Some simple QA histograms
  //--
  StEEmcQAMaker *eemcQA=new StEEmcQAMaker("eeqa");
  eemcQA->analysis("AandE");
  eemcQA->mudst("MuDst");
//eemcQA->trigger(96261);      // add specified trigger to list  
  eemcQA->nVertexMin=0;        // cut on min number of verticies
  eemcQA->nVertexMax=999;      // cut on max number of verticies


  //--
  //-- Cluster maker.  Generates tower, preshower, postshower clusters
  //-- (using Minesweeper algo) and smd clusters (seed strip w/ truncation).
  //--
  mEEclusters=new StEEmcIUClusterMaker("mEEclusters");
  mEEclusters->analysis("AandE");
  mEEclusters->seedEnergy(0.8,0);       // tower seed energy
  mEEclusters->seedEnergy(1.5/1000.,4); // 2 MeV smd-u strip
  mEEclusters->seedEnergy(1.5/1000.,5); // 2 MeV smd-v strip
  mEEclusters->setSeedFloor(1.0);       // floating seed threshold near clusters
  mEEclusters->setMaxExtent(3);         // maximum distance from seed strip
//mEEclusters->suppress();              // disallows seeds in two strips adjacent to any cluster
  
  //--
  //-- Point maker.  Matches pairs of smd clusters to active towers.
  //-- Energy is divided between points using a tower energy-sharing
  //-- vs position function.
  //--
  mEEpoints=new StEEmcIUPointMaker("mEEpoints");
  //mEEpoints=new StEEmcPointFitMaker("mEEpoints");
  mEEpoints->analysis("AandE");
  mEEpoints->clusters("mEEclusters");
  mEEpoints->setEnergyMode(0);
  mEEpoints->setLimit(10);
  //  mEEpoints -> doPermutations(false);

  // output maker  tracker
  HList=new TObjArray;
  StMcOutputMaker *mySputMk=new StMcOutputMaker("mcRead");
  mySputMk->SetHList(HList);


  //--
  //-- Pi0 mixer, takes the points identified above and mixes pi0 pairs.
  //--
  mEEmixer = new StEEmcIUMixMaker("mEEmixer");
  mEEmixer -> mudst("MuDst");
  mEEmixer -> analysis("AandE");
  mEEmixer -> points("mEEpoints");
  for ( Int_t i=0;i<12;i++ ) // activate all 12 sectors
    mEEmixer->sector(i); 
//mEEmixer->trigger(96251); // specify trigger id(s) to process
//for Monte-Carlo sample, fix vertex to zero. Otherwise, comment it out.
  mEEmixer->fixedVertex(0.,0.,0.);  // fixes the vertex positiion

 
  //pi0 analysis
  mEEpi0analysis=new StEEmcIUPi0Analysis("pi0analy");
  // mEEpi0analysis->trigger(96261);
  //mEEpi0analysis->minbias(96011);
  mEEpi0analysis->mudst("MuDst");
  mEEpi0analysis->points("mEEpoints");
  mEEpi0analysis->mixer("mEEmixer");
  mEEpi0analysis->analysis("AandE"); 
  mEEpi0analysis->spin("mSpinDb");


  //--
  //-- QA/analysis histograms for pi0's
  //--
  //mEEmixqa = new StEEmcMixQAMaker("mEEmixqa");
  //mEEmixqa -> mixer( "mEEmixer", 0.08, 0.18 ); // specify mixer and mass range for gated histograms
  //mEEmixqa -> points( "mEEpoints" );
  //mEEmixqa -> maxPerCluster =   1;  // max number of pairs matched to a cluster of towers
  //mEEmixqa -> maxPerSector  =   100;  // max number of pairs allowed per sector
  //mEEmixqa -> maxPerEvent   = 100;  // max number of pairs allowed per event

  mChain->ls(3);
  mChain->Init();

  //-----------------------------------------------------------------
  //--
  //-- This is where the business happens.  We loop over all events.
  //-- when mChain -> Make() is called, ::Make() will be called on 
  //-- all of the makers created above.

  Int_t stat  = 0;    // error flag
  Int_t count = 0;    // event count
  int TTnumsmdu=0,TTnumsmdv=0,Tnumsmdu=0,Tnumsmdv=0,Tnumpoints=0,Tnumpairs=0,Tnumfp=0,n2clusteru=0,n2clusterv=0,n2point=0,j=0;
  //FILE *fout=fopen("lowratio.txt","w");assert(fout);
  while ( stat == 0 ) {


    //--
    //-- Terminate once we reach nevents --
    //--
    if ( count++ >= nevents && nevents>0 ) break;

    //--
    //-- Call clear on all makers 
    //--
    mChain -> Clear();

    
    //--
    //-- Process the event through all makers 
    //--
    stat = mChain -> Make();

    //--
    //-- Set to printout on every 10th event
    //--
    if ( (count%prescale)==0 ) //continue;
      {
	std::cout << "------------------------------------------------";
	std::cout << "event=" << count << std::endl;
      }
    //--
    //-- Print the number of hits in the towers, pre/postshower layers
    //--
    Int_t nhits[]={0,0,0,0,0,0};
    float umeandiff=0,vmeandiff;
    for ( int i = 0; i < 4; i++ ) {
      //      std::cout << " layer=" << i 
      //		<< " nhits=" << mEEanalysis->numberOfHitTowers(i) << std::endl;
      nhits[i]+=mEEanalysis->numberOfHitTowers(i);
    }

    //--
    //-- Print the total number of smd strips which fired
    //--
    Int_t nu=0,nv=0;
    for ( Int_t sec=0;sec<12;sec++ )
      {
	nu+=mEEanalysis->numberOfHitStrips(sec,0);
	nv+=mEEanalysis->numberOfHitStrips(sec,1);
      }
    nhits[4]=nu;
    nhits[5]=nv;


    //--
    //-- Print number of clusters in each layer
    //--
    Int_t ncl[8]={0,0,0,0,0,0,0,0};
    for ( Int_t i=0;i<12;i++ )
      {
	ncl[0]+=mEEclusters->numberOfClusters(i,0);
	ncl[1]+=mEEclusters->numberOfClusters(i,1);
	ncl[2]+=mEEclusters->numberOfClusters(i,2);
	ncl[3]+=mEEclusters->numberOfClusters(i,3);
	ncl[4]+=mEEclusters->numberOfSmdClusters(i,0);
	ncl[5]+=mEEclusters->numberOfSmdClusters(i,1);
	ncl[6]+=mEEclusters->TnumberOfSmdClusters(i,0);
	ncl[7]+=mEEclusters->TnumberOfSmdClusters(i,1);

      }
    
    // h0->Fill(ncl[4]);
    //h1->Fill(ncl[5]);
    //h3->Fill(mEEpoints -> numberOfPoints());
    if(ncl[4]==2) n2clusteru+=1;
    if(ncl[5]==2) n2clusterv+=1;
    if(mEEpoints->numberOfPoints()==2) n2point+=1;

    
    Tnumsmdu+=ncl[4];
    Tnumsmdv+=ncl[5];
    TTnumsmdu+=ncl[6];
    TTnumsmdv+=ncl[7];
    Tnumpoints+=mEEpoints->numberOfPoints();
    Tnumpairs+=mEEmixer -> numberOfCandidates();
 
  }
  std::cout << "total number of cluster in smdu=" << Tnumsmdu << std::endl;
  std::cout << "total number of cluster in smdv=" << Tnumsmdv << std::endl;
  std::cout << "temp total number of cluster in smdu=" << TTnumsmdu << std::endl;
  std::cout << "temp total number of cluster in smdv=" << TTnumsmdv << std::endl;
  std::cout << "total number of points =" << Tnumpoints << std::endl;
  std::cout << "number of 2cluster/event in Vplane" << n2clusterv << std::endl;
  std::cout << "total number of pairs =" << Tnumpairs << std::endl;
  std::cout << "number of 2cluster/event in Uplane" << n2clusteru << std::endl;
  std::cout << "number of 2point  /event          " << n2point    << std::endl;

  //-----------------------------------------------------------------


  //--
  //-- For debugging purposes, it's often useful to print out the 
  //-- database 
  //--
  mEEmcDatabase = (StEEmcDb*)mChain->GetDataSet("StEEmcDb");
  if (mEEmcDatabase) mEEmcDatabase->exportAscii("dbdump.dat"); 

  //--
  //-- Calls the ::Finish() method on all makers
  //--
  mChain -> Finish(); 


  //--
  //-- Output the QA histograms to disk
  //--
  TFile *file=new TFile(ofile,"RECREATE");

  mEEclusters -> GetHistList() -> Write();
  mEEpoints -> GetHistList() -> Write();
  mEEanalysis->GetHistList()->Write(); 
  mEEpi0analysis->GetHistList()->Write(); 
  mySputMk->GetHistList()->Write();
  mEEmixer->GetHistList()->Write();

  file->Close();



  delete file;


  return;
    
}
Пример #7
0
void MakePIDqaReport(const char* inputFile, const char* outputFile="PIDqaReport.pdf", TString dirInFile = "")
{
  //
  // Make a pdf file with the efficiency report
  //

  LoadLibs();
  SetupStyle();

  TFile f(inputFile);
  if (!f.IsOpen()){
    printf("Could not open file '%s'\n",f.GetName());
    return;
  }
  
  TString listName = "PIDqa";
  if (dirInFile != "")
    listName = listName.Prepend(Form("%s/", dirInFile.Data()));
  
  printf("%s", listName.Data());
  TList *qaList = (TList*) f.Get(listName.Data());
  if (!qaList){
    printf("Could not find list '%s' in file '%s'\n",listName.Data(), f.GetName());
    return;
  }

  fCanvas=new TCanvas;

  TPDF p(outputFile);

  //
  // Invariant mass plots
  //


  //
  // Make QA info
  //

  // ITS PID
  PublishCanvas(qaList,"ITS","hNsigmaP_ITS_%s");

  // TPC PID
  TList *qaListTPC = (TList*)qaList->FindObject("TPC");
  if (qaListTPC){
    PublishCanvas(qaListTPC,"TPCBasic","hNsigmaP_TPC_Basic_%s");
    PublishCanvas(qaListTPC,"TPCV0","hNsigmaP_TPC_V0_%s");
    //   if (man->GetCurrentPeriod()=="11h"){
      //     PublishCanvas(qaListTPC,"TPC","hNsigmaP_TPC_Basic_%s_Hybrid","Hybrid");
    //     PublishCanvas(qaListTPC,"TPC","hNsigmaP_TPC_Basic_%s_OROChigh","OROChigh");
    //   }
  }
  else {
    printf("Could not find list '%s/TPC' in file '%s'\n", listName.Data(), f.GetName());
  }

  // TPC PID after 3 sigma TOF cut
  PublishCanvas(qaList,"TPC_TOF","hNsigmaP_TPC_TOF_%s");

  // TOF PID
  PublishCanvas(qaList,"TOF","hNsigmaP_TOF_%s");

  // TRD PID
  fCanvas->Divide(2,3);
  TH2 *hLikeP_TRD_3tls_electron=Get2DHistogramfromList(qaList,"TRD","hLikeP_TRD_3tls_electron");
  TH2 *hLikeP_TRD_3tls_pion=Get2DHistogramfromList(qaList,"TRD","hLikeP_TRD_3tls_pion");
  TH2 *hLikeP_TRD_4tls_electron=Get2DHistogramfromList(qaList,"TRD","hLikeP_TRD_4tls_electron");
  TH2 *hLikeP_TRD_4tls_pion=Get2DHistogramfromList(qaList,"TRD","hLikeP_TRD_4tls_pion");
  TH2 *hLikeP_TRD_5tls_electron=Get2DHistogramfromList(qaList,"TRD","hLikeP_TRD_5tls_electron");
  TH2 *hLikeP_TRD_5tls_pion=Get2DHistogramfromList(qaList,"TRD","hLikeP_TRD_5tls_pion");

  /*
   *  cTRDnsigma[countcanvas]->cd(1);
   *  TPaveText pt3TRD(.02,.02,.49,.52);
   *  pt3TRD.SetTextAlign(11);
   *  pt3TRD.SetTextSizePixels(16);
   *  pt3TRD.AddText(Form(" TRD PID QA %s.%s.%d", first.Data(), man->GetCurrentPeriod().Data(), pass));
   *  pt3TRD.Draw();
   */
  fCanvas->cd(1);
  SetupPadStyle();
  hLikeP_TRD_3tls_electron->Draw("colz");
  fCanvas->cd(2);
  SetupPadStyle();
  hLikeP_TRD_3tls_pion->Draw("colz");
  fCanvas->cd(3);
  SetupPadStyle();
  hLikeP_TRD_4tls_electron->Draw("colz");
  fCanvas->cd(4);
  SetupPadStyle();
  hLikeP_TRD_4tls_pion->Draw("colz");
  fCanvas->cd(5);
  SetupPadStyle();
  hLikeP_TRD_5tls_electron->Draw("colz");
  fCanvas->cd(6);
  SetupPadStyle();
  hLikeP_TRD_5tls_pion->Draw("colz");

  fCanvas->Update();
  fCanvas->Clear();

  // TPC Response info
  TObjArray *qaInfo=(TObjArray*)qaList->FindObject("QAinfo");
  TObjArray *tpcInfo=0x0;
  if (qaInfo && (tpcInfo=(TObjArray*)qaInfo->FindObject("TPC_info"))){
    TObjArray *tpcSplineInfo=(TObjArray*)tpcInfo->FindObject("TPC_spline_names");
    TObjArray *tpcConfigInfo=(TObjArray*)tpcInfo->FindObject("TPC_config_info");
    fCanvas->Divide(1,2);
  
    TPaveText pt(.1,.1,.9,.9,"NDC");
    pt.SetBorderSize(1);
    pt.SetFillColor(0);
    pt.SetTextSizePixels(16);

    if (tpcSplineInfo){
      for (Int_t i=0; i<tpcSplineInfo->GetEntriesFast();++i) pt.AddText(tpcSplineInfo->At(i)->GetName());
    }
    
    TPaveText pt2(.1,.1,.9,.9,"NDC");
    pt2.SetBorderSize(1);
    pt2.SetFillColor(0);
    pt2.SetTextSizePixels(16);
    if (tpcConfigInfo){
      for (Int_t i=0; i<tpcConfigInfo->GetEntriesFast();++i) pt2.AddText(tpcConfigInfo->At(i)->GetName());
    }

    fCanvas->cd(1);
    pt.Draw();
    fCanvas->cd(2);
    pt2.Draw();
    
    fCanvas->Update();
    fCanvas->Clear();
  }
  
  delete qaList;

  p.Close();
  delete fCanvas;
}
Пример #8
0
Int_t makeADCplot( const Char_t *filename = "testfile.sfs",
                   const Char_t *pedfilename = "testfile.Ped.txt",
                   Int_t disc = 0,
                   Int_t quad = 0,
                   Char_t plotVsStrip = 'c',
                   Int_t subtrPeds = 1,
                   const Char_t *runname = "testrun",
                   const Char_t *quadname = "010",
                   Int_t nevents = -1,
                   Int_t timeBin = 4,
                   Int_t numDiscs = 3 ){
   LoadLibs();
   Int_t ierr = 0;

   Short_t timeBinMask = (1<<timeBin);

   cout << "Constructing the chain" << endl;
   analysisChain = new StChain("eemcAnalysisChain");

   cout << "Constructing the cosmic maker" << endl;
   cosmicMkr = new StFgtCosmicMaker( "cosmicMaker", filename );
   cosmicMkr->setNumDiscs( numDiscs );

   cout << "Constructing the ADC corrector" << endl;

   // useful for removing extra time bins even if not ped subtracting

   adcCorrector = new StFgtCorAdcMaker( "adcCorrector", "cosmicMaker" );
   adcCorrector->setPedReaderFile( pedfilename );
   adcCorrector->setTimeBinMask( timeBinMask );
   adcCorrector->setAbsThres( -10000 );  // set below -4096 to skip cut
   adcCorrector->setRelThres( 0 );       // set to zero to skip cut
   adcCorrector->doSubtrPeds( subtrPeds );
   adcCorrector->doRemoveOtherTimeBins( 1 );

   cout << "Constructing the QA maker" << endl;

   // ranges and number of strips/channels to average over
   Int_t binFactorX = 8, binFactorY = 32;
   Float_t sansPedYmax = 1024;
   Float_t sansPedYmin = -512;
   Int_t sansPedYbins = 4096/binFactorY;

   if( plotVsStrip == 'R' || plotVsStrip == 'r' )
      binFactorX = 1;
   else if ( plotVsStrip == 'P' )
      binFactorX = 4;

   if( subtrPeds )
      binFactorY = 1;

   adcPlotter = new StFgtQaAdcVsChannel( "fgtQaAdc_1", "cosmicMaker", disc, quad, quadname );
   adcPlotter->setTimeBin( timeBin );
   adcPlotter->setFilenameBase( "" );     // do not save
   adcPlotter->setToPlotVsStrip( plotVsStrip );
   adcPlotter->setToSubtrPeds( 0 );       // already done
   adcPlotter->setBinFactors( binFactorX, binFactorY );
   if( subtrPeds ){
      adcPlotter->setYbins( sansPedYbins );
      adcPlotter->setYrange( sansPedYmin, sansPedYmax );
   };

   cout << "Initializing" << endl;
   ierr = analysisChain->Init();
   cout << "\t done initializing" << endl;

   if( ierr ){
      cout << "Error initializing" << endl;
      return;
   };

   if( nevents < 0 )
      nevents = 1<<30; // a big number

   cout << "Looping over events..." << endl;
   for( int i=0; i<nevents && !ierr; ++i ){

      if( (i+1)%1000 == 1 )
         cout << "event number " << i << endl;

      //cout << "clear" << endl;
      analysisChain->Clear();

      //cout << "make" << endl;
      ierr = analysisChain->Make();

      if( cosmicMkr->atEOF() )
         ierr = 127;
   };

   cout << "Making plots..." << endl;

   // now do some plotting
   TH2F* hAdc        = adcPlotter->getHist();       

   gROOT->SetStyle("Plain");
   gStyle->SetOptStat(0);
   gStyle->SetEndErrorSize(0);
   gStyle->SetTitleBorderSize(0);
   gStyle->SetTitleTextColor(kRed);

   Int_t width = 1800;
   Int_t height = 600;
   if( plotVsStrip == 'R' || plotVsStrip == 'r' || plotVsStrip == 'P' ){
      width /= 3;
      height = width+1;
   };

   gROOT->SetStyle("Plain");
   TCanvas *can = new TCanvas( "fgtQAcan", "Fgt Cosmic QA", width, height );

   gStyle->SetOptStat(0);
   gStyle->SetPalette(1);

   //can->SetRightMargin( 0.02 );
   //can->SetLeftMargin( 0.13 );
   //hAdc->GetYaxis()->SetTitleOffset( 1.55 );

   hAdc->SetMaximum( subtrPeds ? 100 : 200 );
   hAdc->Draw("COLZ");

   cout << "ready to save" << endl;

   std::string fileOut = "fgtCQA.ADCplot.";
   fileOut += runname;
   fileOut += ".fgt";
   fileOut += quadname;
   fileOut += ".eps";

   cout << "\tsaving to '" << fileOut << "'" << endl;
   can->Print( fileOut.data() );

   TFile *f = new TFile ("testfile.root", "RECREATE");
   hAdc->Write();
   f->Close();

   //
   // Calls the ::Finish() method on all makers
   //
   cout << "finish" << endl;
   analysisChain->Finish();   // bug in LOG_ makes this fail

   cout << "all done" << endl;
   return;
};
Пример #9
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;
}
Пример #10
0
void runFgtLHTracking_MuDst( const Char_t *filenameIn, 
                             const Char_t *filenameOut,
                             Int_t neventsIn = 10 ){

   // load the shared libraries
   std::cout << "***** Loading libraries *****" << endl;
   LoadLibs();

   std::cout << "***** Done loading libraries *****" << endl;
   std::cout << "***** Instanciating all the classes *****" << endl;

   //
   // Create the analysis chain
   //
   analysisChain = new StChain("fgtTrackingChain");

   //
   // MuDst maker for reading input
   //
   Int_t nfiles = 10000;
   muDstMaker = new StMuDstMaker( 0, 0, "", filenameIn, "MuDst", nfiles );
   muDstMaker->SetStatus("*",0);
   muDstMaker->SetStatus("Event",1);
   muDstMaker->SetStatus("MuEvent",1);
   muDstMaker->SetStatus("PrimaryVertices",1);
   muDstMaker->SetStatus("FgtStrip",1);
   muDstMaker->SetStatus("FgtCluster",1);
   muDstMaker->SetStatus("EmcAll",1);

   //
   // Connect to the STAR databse
   //
   starDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");

   //
   // EEMC raw map maker
   //
   eemcDbMaker = new StEEmcDbMaker( "EEmcDbMkr" );
   rawMapMkr = new StEEmcRawMapMaker( "EEmcRawMapMaker" );
   rawMapMkr->setInput("MuDst",1);           // sets mudst as input

   //
   // the track maker
   //
   fgtTrkMkr = new StFgtLHTracking( "fgtTrkMkr" );
   fgtTrkMkr->setFitThres( 1 );     // cm
   fgtTrkMkr->setIncludeThres( 1 ); // cm
   fgtTrkMkr->setNumPoints( 3 ); // cm
   fgtTrkMkr->setNumAgreeThres( 1 ); // cm
   fgtTrkMkr->setUseVertex(1);

   //
   // QA Makers
   //
   fgtTrkQa = new StEEmcFgtLHTrackQa( "EEmcFgtLHTrackQa", "EEmcRawMapMaker", "fgtTrkMkr" );
   fgtTrkQa->setFileOutName( filenameOut );

   // debugging info
   std::cout << "***** Done instanciating all the classes *****" << endl;
   //analysisChain->ls(3);

   //
   // Initialize all makers
   //
   std::cout << "***** Initializing all makers in the analysis chain *****" << std::endl;

   analysisChain->Init();

   std::cout << "***** Initialization done *****" << std::endl;

   //
   // Finally ready to loop over the events 
   //

   // If nEvents is negative, reset to the maximum possible value
   // for an Int_t
   if( neventsIn < 0 )
      neventsIn = 1<<31-1;

   Int_t ierr  = kStOK;  // err flag
   Int_t nevents = 0;    // cumulative number of events in
   for( ; nevents < neventsIn && !ierr; ++nevents ){
      // clear
      analysisChain->Clear();

      // make
      ierr = analysisChain->Make();
   };
 
   //---------------------------------------------------------------

   //
   // Calls the ::Finish() method on all makers
   //
   analysisChain->Finish(); 

   //
   // Delete the chain
   //
   analysisChain->Delete();

   return;
};
Пример #11
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;
};
Пример #12
0
void InterpolateRatiosAndYields() {
#if !(!defined (__CINT__) || (defined(__MAKECINT__)))
  LoadLibs();
#endif
  collSystem = 2; energy =2760;
  // *************** pi, K, pr *****************
  //  arr=   AliParticleYield::ReadFromASCIIFile("PbPb_2760_PiKaPr.txt");
  // Interpolate0010(211);
  // Interpolate0010(-211);
  // Interpolate0010(321);
  // Interpolate0010(-321);
  // Interpolate0010(2212);
  // Interpolate0010(-2212);
  // InterpolateRatios(2212,211, "V0M0005", "V0M0510", "V0M0010");  
  // InterpolateRatios(321,211 , "V0M0005", "V0M0510", "V0M0010");  
  // Interpolate6080(211);
  // Interpolate6080(-211);
  // Interpolate6080(2212);
  // Interpolate6080(-2212);
  // Interpolate6080(321);
  // Interpolate6080(-321);
  // InterpolateRatios(2212,211, "V0M6070", "V0M7080", "V0M6080");  
  //  InterpolateRatios(321,211, "V0M6070", "V0M7080", "V0M6080");    

  // Interpolate2040(211);
  // Interpolate2040(-211);
  // Interpolate2040(2212);
  // Interpolate2040(-2212);
  // Interpolate2040(321);
  // Interpolate2040(-321);

  // *************** Lambda and K0 *****************
  // arr=   AliParticleYield::ReadFromASCIIFile("PbPb_2760_LambdaK0.txt");
  // Interpolate0010(3122);
  // Interpolate0010(310);
  // *************** Helium 3 *****************
  arr = AliParticleYield::ReadFromASCIIFile("PbPb_2760_DeuHelium3.txt");
  arr->AbsorbObjects(AliParticleYield::ReadFromASCIIFile("./PbPb_2760_AveragedNumbers.txt"));
  // --> 0-10

  //  ExtrapolateWithConstantRatioToPions(1000020030, "V0M0020", "V0M0010");
  // --> 10-20
  arr->AbsorbObjects(AliParticleYield::ReadFromASCIIFile("./pbpb_2760_pikapr.txt"));
  ExtrapolateWithConstantRatioToPions(1000020030, "V0M0020", "V0M1020");
  // *************** Kstar *****************
  // arr = AliParticleYield::ReadFromASCIIFile("PbPb_2760_Kstar892.txt");
  // arr->AbsorbObjects(AliParticleYield::ReadFromASCIIFile("./PbPb_2760_AveragedNumbers.txt"));
  // ExtrapolateWithConstantRatioToPions(313, "V0M0020", "V0M0010");

  // *************** pPb, deuteron *********************
  //  collSystem = 1; energy = 5020;
  // 1. Average pions
  //arr = AliParticleYield::ReadFromASCIIFile("pPb_5020_PiKaPrLamndaK0.txt");
  //  Interpolate0010(211);
  //  Interpolate0010(-211);
  // 2. Extrapolate the deuteron
  // arr = AliParticleYield::ReadFromASCIIFile("pPb_5020_deuteron.txt");
  // arr->AbsorbObjects(AliParticleYield::ReadFromASCIIFile("pPb_5020_PiKaPrLamndaK0.txt"));
  //  ExtrapolateWithConstantRatioToPions(1000010020, "V0A0010", "V0A0005");
  // ExtrapolateWithConstantRatioToPions(-1000010020, "V0A0010", "V0A0005");
  // ExtrapolateWithConstantRatioToPions(1000010020, "V0A6000", "V0A6080");
  // ExtrapolateWithConstantRatioToPions(-1000010020, "V0A6000", "V0A6080");


}
Пример #13
0
//     const char*   cDataType      = "AOD",       // set the analysis type, AOD or ESD
//##################################################
AliAnalysisManager* EmcalJetCDF (
    const char*   cRunPeriod     = "LHC11d",    // set the run period
    const char*   cLocalFiles    = "data.txt",  // set the local list file
    const Int_t   arg_sel_chg    = 3145763,   // "mykEMC_noGA",  // physics selection
    const Int_t   arg_sel_full   = 3145763,   // "mykEMC_noGA",  // physics selection
    const Int_t   mgr_mode       = 0,         // local = 0, proof = 1, grid = 2, mixing = 3
    const Int_t   alien_mode     = 0,         // test = 0, offline = 1, submit = 2, merge = 3, full = 4
    const char*   cTaskName      = "CDFJets",   // sets name of task manager
    unsigned int  iNumFiles      = 100,         // numger of files to process from list file
    unsigned int  iNumEvents     = 999999999,   // number of events to be analyzed
    bool          bDoChargedJets = true,        // enable charge jets
    bool          bDoFullJets    = false        // enable full jets
) {
//Load needed libs
TString     ListLibs      = ""; // string list of loaded libs
TString     ListLibsExtra = ""; // string list of loaded extra libs
LoadLibs( ListLibs, ListLibsExtra );

AnalysisType  ManagerMode = static_cast<AnalysisType>(mgr_mode);
PluginType    PluginMode  = static_cast<PluginType>(alien_mode);

namespace CDF = PWGJE::EMCALJetTasks::AliAnalysisTaskEmcalJetCDF_NS; // shortcut to task namespace
unsigned int       kGridFilesPerJob         = iNumFiles;      // Maximum number of files per job (gives size of AOD)
unsigned int       kTTL                     = 64800 ;         // Time To Live; 18h = 64800; 12h = 43200

bool bDoBackgroundSubtraction = true;
bool bDoEmbedding = false;

// Embeded Configuration options
// Embedding files list
const TString embeddedFilesList = "aodFilesEmbed.txt";
// If true, events that are not selected in the PbPb will not be used for embedding.
// This ensures that good embedded events are not wasted on bad PbPb events.
const bool internalEventSelection = true;
// Do jet matching
const bool useJetTagger = true;


TString sGridMode ("test");
if ( PluginMode == PluginType::offline ) { sGridMode = "offline"; }
if ( PluginMode == PluginType::submit )  { sGridMode = "submit"; }
if ( PluginMode == PluginType::merge )   { sGridMode = "merge"; }
if ( PluginMode == PluginType::full )    { sGridMode = "full"; }
const char* cGridMode = sGridMode.Data();

TString sAnalysisType ("local");
if ( ManagerMode == AnalysisType::proof )  { sAnalysisType = "proof"; }
if ( ManagerMode == AnalysisType::grid )   { sAnalysisType = "grid"; }
if ( ManagerMode == AnalysisType::mixing ) { sAnalysisType = "mix"; }
const char* cAnalysisType = sAnalysisType.Data();

cout << std::endl << ">>>>>>>> ManagerMode : " << ManagerMode << " ; String value : " << cAnalysisType << std::endl << ">>>>>>>> PluginMode : " << PluginMode << " ; String value : " << cGridMode << std::endl << std::endl;

//---------------------------------------------------------------------------------------------
TRegexp false_regex ("[f,F][a,A][l,L][s,S][e,E]");
TRegexp true_regex ("[t,T][r,R][u,U][e,E]");
TRegexp enable_regex ("[e,E][n,N][a,A][b,B][l,L][e,E]");
TRegexp disable_regex ("[d,D][i,I][s,S][a,A][b,B][l,L][e,E]");

bool  bDoSample = false;
TString ENV_doSAMPLE = gSystem->Getenv("CDF_doSAMPLE");
if (!ENV_doSAMPLE.IsNull() && ( ENV_doSAMPLE.EqualTo("0") || ENV_doSAMPLE.Contains(false_regex) ) ) { bDoSample = kFALSE; }
if (!ENV_doSAMPLE.IsNull() && ( ENV_doSAMPLE.EqualTo("1") || ENV_doSAMPLE.Contains(true_regex)  ) ) { bDoSample = kTRUE; }

bool  bDoCDF    = true;
TString ENV_doCDF = gSystem->Getenv("CDF_doCDF");
if (!ENV_doCDF.IsNull() && ( ENV_doCDF.EqualTo("0") || ENV_doCDF.Contains(false_regex) ) ) { bDoCDF = kFALSE; }
if (!ENV_doCDF.IsNull() && ( ENV_doCDF.EqualTo("1") || ENV_doCDF.Contains(true_regex)  ) ) { bDoCDF = kTRUE; }

// ######   DEBUG    ######
Int_t           debug              =  0 ; // kFatal = 0, kError, kWarning, kInfo, kDebug, kMaxType
UInt_t          mgr_debug          =  0 ; // AliAnalysisManager debug level
UInt_t          kUseSysInfo        =  0 ; // activate debugging

TString ENV_DEBUG = gSystem->Getenv("CDF_DEBUG");
if (!ENV_DEBUG.IsNull() && ENV_DEBUG.IsDigit() ) { debug = ENV_DEBUG.Atoi(); }

TString ENV_DEBUG_MGR = gSystem->Getenv("CDF_DEBUG_MGR");
if (!ENV_DEBUG_MGR.IsNull() && ENV_DEBUG_MGR.IsDigit() ) { mgr_debug = ENV_DEBUG_MGR.Atoi(); }

TString ENV_NSYSINFO = gSystem->Getenv("CDF_NSYSINFO");
if (!ENV_NSYSINFO.IsNull() && ENV_NSYSINFO.IsDigit() ) { kUseSysInfo = ENV_NSYSINFO.Atoi(); }

if ( debug == 0 ) { AliLog::SetGlobalLogLevel ( AliLog::kFatal   ); }
if ( debug == 1 ) { AliLog::SetGlobalLogLevel ( AliLog::kError   ); }
if ( debug == 2 ) { AliLog::SetGlobalLogLevel ( AliLog::kWarning ); }
if ( debug == 3 ) { AliLog::SetGlobalLogLevel ( AliLog::kInfo    ); }
if ( debug >= 4 ) { AliLog::SetGlobalLogLevel ( AliLog::kDebug   ); }

// Progress bar
Bool_t bUseProgBar = kFALSE; // N.B. !! if true will set fDebug to 0
TString ENV_USEPROGBAR = gSystem->Getenv("PROGRESSBAR");
if (!ENV_USEPROGBAR.IsNull() && ( ENV_USEPROGBAR.EqualTo("1") || ENV_USEPROGBAR.Contains(true_regex) ) )  { bUseProgBar = kTRUE; }

//##################################################
//        AliEN plugin variables
//##################################################
const char* curdir = gSystem->BaseName(gSystem->pwd());
TString     kJobTag (curdir);

TString execArgs (" -l -b -q -x");
TString exec =
//               "aliroot";
              "root.exe";

TString     kPluginExecutableCommand = exec + execArgs;

TString     kAliPhysicsVersion       = "vAN-20190304-1";

// == grid plugin files rules
TString     kGridExtraFiles          = ""; // extra files that will be added to the input list in the JDL
TString     kGridMergeExclude        = "AliAOD.root AliAOD.Jets.root"; // Files that should not be merged
TString     kGridOutputStorages      = "disk=2"; // Make replicas on the storages

// FILES USED IN MACRO
TString     kCommonOutputFileName    = "AnalysisResults.root";

//--------------------
//   PROOF SETTINGS
//--------------------
TString kAAF        = "";
Int_t   kProofReset = 0; (void)kProofReset;
Int_t   kWorkers    = 20; (void)kWorkers;
Int_t   kCores      = 8  ; (void)kCores;
// AliRoot mode among the list supported by the proof cluster.
// TString     kAlirootMode             = "ALIROOT";     // STEERBase,ESD,AOD,ANALYSIS,ANALYSISalice (default aliroot mode)

//############################################################
// const AliAnalysisTaskEmcal::EDataType_t kAod = AliAnalysisTaskEmcal::kAOD;
// const AliAnalysisTaskEmcal::EDataType_t kEsd = AliAnalysisTaskEmcal::kESD;

const AliJetContainer::EJetType_t    fulljet = AliJetContainer::kFullJet;
const AliJetContainer::EJetType_t     chgjet = AliJetContainer::kChargedJet;
const AliJetContainer::EJetAlgo_t     antikt = AliJetContainer::antikt_algorithm;
const AliJetContainer::EJetAlgo_t         kt = AliJetContainer::kt_algorithm;
const AliJetContainer::ERecoScheme_t  recomb = AliJetContainer::pt_scheme;

// kTPC, kTPCfid, kEMCAL, kEMCALfid, kDCAL, kDCALfid, kDCALonly, kDCALonlyfid, kPHOS, kPHOSfid, kUser
const AliEmcalJet::JetAcceptanceType acc_chgjets  = AliEmcalJet::kTPCfid;
const AliEmcalJet::JetAcceptanceType acc_fulljets = AliEmcalJet::kEMCALfid;
//############################################################

// data source name
TString kDataSource (cLocalFiles);

// label of dataset from InputData.C
TString kGridDataSet ("");
if ( ManagerMode == AnalysisType::grid ) { kGridDataSet = kDataSource;}

//############################################################
// SETUP OF TRIGGERS
const AliEmcalPhysicsSelection::EOfflineEmcalTypes mykEMCAL  = AliEmcalPhysicsSelection::kEmcalOk;
const AliVEvent::EOfflineTriggerTypes  mykEMC             = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMCEJE | AliVEvent::kEMCEGA);
const AliVEvent::EOfflineTriggerTypes  mykEMC_noGA        = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMCEJE);

const AliVEvent::EOfflineTriggerTypes  mykMB              = AliVEvent::kAnyINT;
const AliVEvent::EOfflineTriggerTypes  mykMB_central      = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kCentral);
const AliVEvent::EOfflineTriggerTypes  mykMB_semicentral  = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kSemiCentral);
const AliVEvent::EOfflineTriggerTypes  mykMB_mostcentral  = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kCentral | AliVEvent::kSemiCentral);

AliVEvent::EOfflineTriggerTypes kPhysSel   = mykMB; //AliVEvent::kAnyINT; // physics selection
// AliVEvent::EOfflineTriggerTypes kSel_tasks = mykMB;

AliVEvent::EOfflineTriggerTypes kSel_chg   = static_cast<AliVEvent::EOfflineTriggerTypes>(arg_sel_chg);
AliVEvent::EOfflineTriggerTypes kSel_full  = static_cast<AliVEvent::EOfflineTriggerTypes>(arg_sel_full);

//############################################################
// Analysis manager
  AliAnalysisManager* pMgr = new AliAnalysisManager(cTaskName);
  pMgr->SetDebugLevel(mgr_debug);
  if ( kUseSysInfo > 0 ) { pMgr->SetNSysInfo ( kUseSysInfo ); }

  // actual runName in the form of LHCXXX....
  TString sRunName;
  Bool_t kIsAOD = kTRUE;
  AliAnalysisTaskEmcal::EDataType_t iDataType = AliAnalysisTaskEmcal::kAOD; // assuming default is to process AOD
  TString file;
  AliAnalysisAlien* plugin = NULL;
  if ( ManagerMode == AnalysisType::grid ) {  // start grid analysis
    // ( const char* gridMode, const char* tag, unsigned int nr_test_files, unsigned int TTL, const char* outdir, const char subworkdir, const char* extradirlvl);
    plugin = CreateAlienHandler(cGridMode, kJobTag.Data(), kGridFilesPerJob, kTTL);
    if ( !plugin ) { ::Error ( "runEMCalJetSampleTask.C - StartGridAnalysis", "plugin invalid" ); return NULL; }
    pMgr->SetGridHandler(plugin);

    // use this command to run the macro
    plugin->SetExecutableCommand(kPluginExecutableCommand.Data());

    // AliPhysics version.
    plugin->SetAliPhysicsVersion ( kAliPhysicsVersion.Data() ); // Here you can set the (Ali)PHYSICS version you want to use

    gROOT->LoadMacro("InputData.C");
    InputData(kGridDataSet);
    sRunName = CDF::GetPeriod( plugin->GetGridDataDir() );

    file = CDF::GetFileFromPath(plugin->GetDataPattern());
    if (file.Contains("AliESD")) { iDataType = AliAnalysisTaskEmcal::kESD; kIsAOD = kFALSE; }

    plugin->SetMergeExcludes(kGridMergeExclude.Data());
    }

  if ( ManagerMode == AnalysisType::local ) { // start local analysis
    if ( kDataSource.IsNull() ) { Printf("You need to provide the list of local files!"); return NULL; }
    TChain* pChain = CDF::CreateChain(kDataSource.Data(), "auto", "", iNumFiles);
    if (!pChain) { std::cout << ">>>>>>>>>>>>>>   CHAIN NOT CREATED   <<<<<<<<<<<<<<" << std::endl; return NULL; }
    Printf("Setting local analysis for %d files from list %s, max events = %d", iNumFiles, kDataSource.Data(), iNumEvents);

    // get the path of first file
    file = pChain->GetFile()->GetEndpointUrl()->GetUrl();
    sRunName = CDF::GetPeriod(file.Data()); // get the run name : first token beggining with lhc
    if ( CDF::GetFileFromPath(file).Contains("AliESD") ) { iDataType = AliAnalysisTaskEmcal::kESD; kIsAOD = kFALSE; }
    }

  TString sDataType ("AOD");
  if (!kIsAOD) { sDataType = "ESD"; }
  std::cout << ">>> Analysis data type : " << sDataType.Data() << std::endl;

  // name of de period (for MC is the name of "achored to" production)
  TString sRunPeriod (cRunPeriod);
  sRunPeriod.ToLower();

  bool isMC = false;
  isMC = CDF::PeriodIsMC(sRunName.Data());

  // EMCAL corrections task configuration file
  TString EMCALcfg ("CDF_CorrectionsConf.yaml");
  if (isMC) {EMCALcfg = "CDF_MC_CorrectionsConf.yaml";}

  if ( !kGridExtraFiles.IsNull() ) {kGridExtraFiles += " ";}
  kGridExtraFiles += EMCALcfg;

  AliAnalysisTaskEmcal::BeamType iBeamType = AliAnalysisTaskEmcal::kpp;
  Bool_t bIsRun2 = kFALSE;

  if (sRunPeriod.Length() == 6 && (sRunPeriod.BeginsWith("lhc15") || sRunPeriod.BeginsWith("lhc16") || sRunPeriod.BeginsWith("lhc17") || sRunPeriod.BeginsWith("lhc18") ) ) { bIsRun2 = kTRUE; }

  if (sRunPeriod == "lhc10h" || sRunPeriod == "lhc11h" || sRunPeriod == "lhc15o" || sRunPeriod == "lhc17n" )                            { iBeamType = AliAnalysisTaskEmcal::kAA; }
  if (sRunPeriod == "lhc12g" || sRunPeriod == "lhc13b" || sRunPeriod == "lhc13c" || sRunPeriod == "lhc13d" || sRunPeriod == "lhc13e" ||
      sRunPeriod == "lhc13f" || sRunPeriod == "lhc16q" || sRunPeriod == "lhc16r" || sRunPeriod == "lhc16s" || sRunPeriod == "lhc16t" )  { iBeamType = AliAnalysisTaskEmcal::kpA; }

  Double_t kGhostArea = 0.01;
  if (iBeamType != AliAnalysisTaskEmcal::kpp) { kGhostArea = 0.005; }

  AliTrackContainer::SetDefTrackCutsPeriod(sRunPeriod);
  Printf("Default track cut period set to: %s", AliTrackContainer::GetDefTrackCutsPeriod().Data());

  Bool_t bDoEmcalCorrections  = kFALSE;
  if (bDoFullJets) { bDoEmcalCorrections  = kTRUE; }

// ###   Containers and string definitions
  TString name_tracks   = "usedefault";
  TString name_clusters = "usedefault";
  TString name_cells    = "usedefault";
  // Set centrality estimator for centrality task
  TString cent_est_chg  = "V0M" ;
  TString cent_est_full = "V0M" ;

  TString mc_container ("");
  if (isMC) { mc_container = "mcparticles"; }

/*
  // General input object names
  TString tracksName             = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kTrack);
  TString clustersName           = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kCluster);
  TString emcalCellsName         = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kCaloCells);
  // Combined (PbPb + embedded det level)
  TString emcalCellsCombined = emcalCellsName + "Combined";
  TString clustersCombined = clustersName + "Combined";
*/

//##########################
//   TASKS DEFINITIONS   ###
//##########################
  AliAODInputHandler* pAODHandler = NULL;
  AliESDInputHandler* pESDHandler = NULL;
  if (kIsAOD)
    { pAODHandler = AliAnalysisTaskEmcal::AddAODHandler(); }
  else
    { pESDHandler = AliAnalysisTaskEmcal::AddESDHandler(); }

  // CDBconnect task
  AliTaskCDBconnect* taskCDB = AliTaskCDBconnect::AddTaskCDBconnect();
  taskCDB->SetFallBackToRaw(kTRUE); // Needed for the moment as not all grid sites do support cvmfs OCDB for the moment
  if (!taskCDB) { std::cout << "--------->>>>  taskCDB :: could not connect!!!! CHECK CVMFS" << std::endl; return NULL;}

  // Physics selection task
  AliPhysicsSelectionTask* pPhysSelTask = NULL;
  if (!kIsAOD) {
    // signature : (Bool_t mCAnalysisFlag = kFALSE, Bool_t applyPileupCuts = kFALSE, UInt_t deprecatedFlag2 = 0, Bool_t useSpecialOutput=kFALSE)
    pPhysSelTask = AliPhysicsSelectionTask::AddTaskPhysicsSelection();
    }

  // Centrality task
  // The Run 2 condition is too restrictive, but until the switch to MultSelection is complete, it is the best we can do
  AliCentralitySelectionTask* pCentralityTask = NULL;
  if ( !kIsAOD && (iBeamType != AliAnalysisTaskEmcal::kpp && bIsRun2) ) {
    //signature : (Bool_t fillHistos=kTRUE, Bool_t aod=kFALSE)
    pCentralityTask = AliCentralitySelectionTask::AddTaskCentrality(kFALSE, kIsAOD);
    pCentralityTask->SelectCollisionCandidates(AliVEvent::kAny);
    }

  // AliMultSelection
  AliMultSelectionTask* pMultSelTask = NULL;
  if (bIsRun2) {
    // signature : ( Bool_t lCalibration = kFALSE, TString lExtraOptions = "", Int_t lNDebugEstimators = 1, const TString lMasterJobSessionFlag = "")
    pMultSelTask = AliMultSelectionTask::AddTaskMultSelection();
    pMultSelTask->SelectCollisionCandidates(AliVEvent::kAny);
    }

  // Embedding task
  if (bDoEmbedding) {
    // Debug options
    //AliLog::SetClassDebugLevel("AliAnalysisTaskEmcalEmbeddingHelper", AliLog::kDebug+0);

    // Setup embedding task
    AliAnalysisTaskEmcalEmbeddingHelper * embeddingHelper = AliAnalysisTaskEmcalEmbeddingHelper::AddTaskEmcalEmbeddingHelper();
    embeddingHelper->SelectCollisionCandidates(kPhysSel);
    // The pt hard bin should be set via the filenames in this file
    // If using a file pattern, it could be configured via embeddingHelper->SetPtHardBin(ptHardBin);
    embeddingHelper->SetFileListFilename(embeddedFilesList.Data());

    // Some example settings for LHC12a15e_fix (anchored to LHC11h)
    embeddingHelper->SetNPtHardBins(11);
    embeddingHelper->SetMCRejectOutliers();

    // Setup internal event selection and additional configuration options
    embeddingHelper->SetConfigurationPath("EmbeddingConfigurationExample.yaml");

    // Initialize the task to complete the setup.
    embeddingHelper->Initialize();
    }

  // EMCal corrections
  AliEmcalCorrectionTask* correctionTask = NULL;
  if (bDoEmcalCorrections) {
    // Configuration of the Correction Task is handled via a YAML file, which is setup below
    // signature : (TString suffix)
    correctionTask = AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask();
//  correctionTask = AliEmcalCorrectionTask::ConfigureEmcalCorrectionTaskOnLEGOTrain(suffix);
    correctionTask->SelectCollisionCandidates(kPhysSel);
    correctionTask->SetUseNewCentralityEstimation(bIsRun2);
    correctionTask->SetForceBeamType(static_cast<AliEmcalCorrectionTask::BeamType>(iBeamType));

    // Configure and initialize
    correctionTask->SetUserConfigurationFilename( EMCALcfg.Data() );
    //correctionTask->SetUserConfigurationFilename("alien:///alice/cern.ch/user/m/mfasel/EMCALCorrectionConfig/ConfigDataPWGJEhighClusterThresholds.yaml");
    correctionTask->Initialize(true);

    }

//     TObjArray correctionTasks;
//
//     // Create the Correction Tasks
//     // "data" corresponds to the PbPb level
//     // "embed" corresponds to the embedded detector level
//     // "combined" corresponds to the hybrid (PbPb + embedded detector) level
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("data"));
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("embed"));
//     // It is important that combined is last!
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("combined"));
//
//     // Loop over all of the correction tasks to configure them
//     AliEmcalCorrectionTask * tempCorrectionTask = 0;
//     TIter next(&correctionTasks);
//     while (( tempCorrectionTask = static_cast<AliEmcalCorrectionTask *>(next()))) {
//       tempCorrectionTask->SelectCollisionCandidates(kPhysSel);
//       // Configure centrality
//       tempCorrectionTask->SetNCentBins(5);
//       tempCorrectionTask->SetUseNewCentralityEstimation(bIsRun2);
//       tempCorrectionTask->SetUserConfigurationFilename("$ALICE_PHYSICS/PWGJE/EMCALJetTasks/macros/EMCalCorrectionTaskEmbeddingExample.yaml");
//
//       tempCorrectionTask->Initialize(true);
//       }

  // Background
  TString sRhoChName;
  TString sRhoFuName;
  AliAnalysisTaskRho* pRhoTask = NULL;
  if ( bDoBackgroundSubtraction && iBeamType != AliAnalysisTaskEmcal::kpp ) {
    sRhoChName = "Rho";
    sRhoFuName = "Rho_Scaled";

    AliEmcalJetTask* pKtChJetTask = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", kt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 0., kFALSE, kFALSE);
    pKtChJetTask->SelectCollisionCandidates(kPhysSel);

    //signature :
    // const char* nTracks = "usedefault", const char* nClusters = "usedefault", const char* nRho = "Rho", Double_t jetradius = 0.2, UInt_t acceptance = AliEmcalJet::kTPCfid,
    // AliJetContainer::EJetType_t jetType = AliJetContainer::kChargedJet, const Bool_t histo = kFALSE, AliJetContainer::ERecoScheme_t rscheme = AliJetContainer::pt_scheme, const char* suffix = ""
    pRhoTask = AliAnalysisTaskRho::AddTaskRhoNew(name_tracks.Data(), name_clusters.Data(), sRhoChName, 0.4);
    pRhoTask->SetExcludeLeadJets(2);
    pRhoTask->SelectCollisionCandidates(kPhysSel);
    pRhoTask->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);

    if (bDoFullJets) {
      TString sFuncPath = "alien:///alice/cern.ch/user/s/saiola/LHC11h_ScaleFactorFunctions.root";
      TString sFuncName = "LHC11h_HadCorr20_ClustersV2";
      pRhoTask->LoadRhoFunction(sFuncPath, sFuncName);
      }
    }

  // Find Charged jets
  AliEmcalJetTask* pChJet02Task = NULL;
  AliEmcalJetTask* pChJet04Task = NULL;
  AliEmcalJetTask* pChJet02Task_MC = NULL;
  AliEmcalJetTask* pChJet04Task_MC = NULL;
  if (bDoChargedJets) {
    pChJet02Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", antikt, 0.2, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pChJet02Task->SelectCollisionCandidates(kSel_chg);

    pChJet04Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", antikt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pChJet04Task->SelectCollisionCandidates(kSel_chg);

    if (isMC) {
      pChJet02Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), "", antikt, 0.2, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pChJet02Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pChJet02Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks02Task_MC = pChJet02Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks02Task_MC->SetIsEmbedding(kTRUE);
        }

      pChJet04Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), "", antikt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pChJet04Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pChJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks04Task_MC = pChJet04Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks04Task_MC->SetIsEmbedding(kTRUE);
        }
      } // isMC
    } // bDoChargedJets

  // Find Full jets
  AliEmcalJetTask* pFuJet02Task = NULL;
  AliEmcalJetTask* pFuJet04Task = NULL;
  AliEmcalJetTask* pFuJet02Task_MC = NULL;
  AliEmcalJetTask* pFuJet04Task_MC = NULL;
  if (bDoFullJets) {
    pFuJet02Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), name_clusters.Data(), antikt, 0.2, fulljet, 0.15, 0.30, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pFuJet02Task->SelectCollisionCandidates(kSel_full);
    pFuJet02Task->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    pFuJet04Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), name_clusters.Data(), antikt, 0.4, fulljet, 0.15, 0.30, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pFuJet04Task->SelectCollisionCandidates(kSel_full);
    pFuJet04Task->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (isMC) {
      pFuJet02Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), name_clusters.Data(), antikt, 0.2, fulljet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pFuJet02Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pFuJet02Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks02Task_MC = pFuJet02Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks02Task_MC->SetIsEmbedding(kTRUE);
        }

      pFuJet04Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), name_clusters.Data(), antikt, 0.4, fulljet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pFuJet04Task_MC->SelectCollisionCandidates(kSel_chg);
      pFuJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
      if (bDoEmbedding) {
        pFuJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks04Task_MC = pFuJet04Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks04Task_MC->SetIsEmbedding(kTRUE);
        }
      } // isMC
    } // bDoFullJets

////////////////////////
//   ANALYSIS TASKS   //
////////////////////////

  // Sample task - charge jets
  AliAnalysisTaskEmcalJetSample* sampleTaskchg = NULL;
  if (bDoSample && bDoChargedJets) {
    sampleTaskchg = AliAnalysisTaskEmcalJetSample::AddTaskEmcalJetSample(name_tracks.Data(), "", "", "SMPCHG");
    sampleTaskchg->SetHistoBins(600, 0, 300);
    sampleTaskchg->SelectCollisionCandidates(kSel_chg);
    sampleTaskchg->SetDebugLevel(debug);

    AliParticleContainer* sampleTaskchg_partCont = sampleTaskchg->GetParticleContainer(0);
    sampleTaskchg_partCont->SetParticlePtCut(0.15);

    if (bDoEmbedding) { sampleTaskchg_partCont->SetIsEmbedding(kTRUE); }

    if ( pMultSelTask ) {
      sampleTaskchg->SetUseNewCentralityEstimation(bIsRun2);
      sampleTaskchg->SetNCentBins(5);
      }
    }

  // Sample task - full jets
  AliAnalysisTaskEmcalJetSample* sampleTaskfull = NULL;
  if (bDoSample && bDoFullJets) {
    sampleTaskfull = AliAnalysisTaskEmcalJetSample::AddTaskEmcalJetSample(name_tracks.Data(), name_clusters.Data(), name_cells.Data(), "SMPFULL");
    sampleTaskfull->SetHistoBins(600, 0, 300);
    sampleTaskfull->SelectCollisionCandidates(kSel_full);
    sampleTaskfull->SetDebugLevel(debug);

    AliParticleContainer* sampleTaskfull_partCont = sampleTaskfull->GetParticleContainer(0);
    sampleTaskfull_partCont->SetParticlePtCut(0.15);

    AliClusterContainer* sampleTaskfull_clusCont = sampleTaskfull->GetClusterContainer(0);
    sampleTaskfull_clusCont->SetClusECut(0.);
    sampleTaskfull_clusCont->SetClusPtCut(0.);
    sampleTaskfull_clusCont->SetClusNonLinCorrEnergyCut(0.);
    sampleTaskfull_clusCont->SetClusHadCorrEnergyCut(0.30);
    sampleTaskfull_clusCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (bDoEmbedding) {
      sampleTaskfull_partCont->SetIsEmbedding(kTRUE);
      sampleTaskfull_clusCont->SetIsEmbedding(kTRUE);
      }

    if ( pMultSelTask ) {
      sampleTaskfull->SetUseNewCentralityEstimation(bIsRun2);
      sampleTaskfull->SetNCentBins(5);
      }
    }


  //###   CDF task - charged jets
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFchg = NULL;
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFchg_MC = NULL;
  if (bDoCDF && bDoChargedJets) {
    anaTaskCDFchg = CDF::AddTaskEmcalJetCDF ( name_tracks.Data(), "", "", "", "CDFchg" );
    anaTaskCDFchg->SetHistoBins(600, 0, 300);
    anaTaskCDFchg->SelectCollisionCandidates(kSel_chg);
    anaTaskCDFchg->SetDebugLevel(debug);

    AliParticleContainer* anaTaskCDFchg_partCont = anaTaskCDFchg->GetParticleContainer(0);
    anaTaskCDFchg_partCont->SetParticlePtCut(0.15);

    if (bDoEmbedding) { anaTaskCDFchg_partCont->SetIsEmbedding(kTRUE); }

    if ( pMultSelTask ) {
      anaTaskCDFchg->SetUseNewCentralityEstimation(bIsRun2);
      anaTaskCDFchg->SetNCentBins(5);
      anaTaskCDFchg->SetCentralityEstimator(cent_est_chg.Data());
      }

    //#################################################
    if (isMC){
      anaTaskCDFchg_MC = CDF::AddTaskEmcalJetCDF ( mc_container.Data(), "", "", "", "CDFchgMC" );
      anaTaskCDFchg_MC->SetHistoBins(600, 0, 300);
      anaTaskCDFchg_MC->SelectCollisionCandidates(kSel_chg);
      anaTaskCDFchg_MC->SetDebugLevel(debug);

      AliParticleContainer* anaTaskCDFchg_partCont_MC = anaTaskCDFchg_MC->GetMCParticleContainer(0);
      anaTaskCDFchg_partCont->SetParticlePtCut(0.15);

      if (bDoEmbedding) { anaTaskCDFchg_partCont_MC->SetIsEmbedding(kTRUE); }

      if ( pMultSelTask ) {
        anaTaskCDFchg_MC->SetUseNewCentralityEstimation(bIsRun2);
        anaTaskCDFchg_MC->SetNCentBins(5);
        anaTaskCDFchg_MC->SetCentralityEstimator(cent_est_chg.Data());
        }
      }
    }

  //###   CDF task - full jets
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFfull = NULL;
  if (bDoCDF && bDoFullJets) {
    anaTaskCDFfull = CDF::AddTaskEmcalJetCDF ( name_tracks.Data(), name_clusters.Data(), name_cells.Data(), mc_container.Data(), "CDFfull" );
    anaTaskCDFfull->SetHistoBins(600, 0, 300);
    anaTaskCDFfull->SelectCollisionCandidates(kSel_full);
    anaTaskCDFfull->SetDebugLevel(debug);

    AliParticleContainer* anaTaskCDFfull_partCont = anaTaskCDFfull->GetParticleContainer(0);
    anaTaskCDFfull_partCont->SetParticlePtCut(0.15);

    AliClusterContainer* anaTaskCDFfull_clusCont = anaTaskCDFfull->GetClusterContainer(0);
    anaTaskCDFfull_clusCont->SetClusECut(0.);
    anaTaskCDFfull_clusCont->SetClusPtCut(0.);
    anaTaskCDFfull_clusCont->SetClusNonLinCorrEnergyCut(0.);
    anaTaskCDFfull_clusCont->SetClusHadCorrEnergyCut(0.30);
    anaTaskCDFfull_clusCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (bDoEmbedding) {
      anaTaskCDFfull_partCont->SetIsEmbedding(kTRUE);
      anaTaskCDFfull_clusCont->SetIsEmbedding(kTRUE);
      }

    if ( pMultSelTask ) {
      anaTaskCDFfull->SetUseNewCentralityEstimation(bIsRun2);
      anaTaskCDFfull->SetNCentBins(5);
      anaTaskCDFfull->SetCentralityEstimator(cent_est_full.Data());
      }
    }

//########################
//   ANALYSIS TASKS - CONTAINERS SETUP
//########################

//   AliEmcalJetTask* pChJet02Task_MC = NULL;
//   AliEmcalJetTask* pChJet04Task_MC = NULL;

// add jet containers to CDF task for charged jets
  if (bDoChargedJets && bDoCDF) {
    AliJetContainer* jetcont_chg = NULL;
    for ( Float_t fi = 0 ; fi<=100 ; fi+=10) {
      // CHG JETS 0.2
      jetcont_chg  = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
      CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

      // CHG JETS 0.4
      jetcont_chg  = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");
      CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

      if (isMC) {
        // CHG JETS MC 0.2
        jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet02Task_MC, acc_chgjets);
        CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

        // CHG JETS MC 0.4
        jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet04Task_MC, acc_chgjets);
        CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);
        }
      }

    jetcont_chg   = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
    CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);
    jetcont_chg   = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");
    CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);

    if (isMC) {
      jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet02Task_MC, acc_chgjets);
      CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);

      jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet04Task_MC, acc_chgjets);
      CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);
      }

    jetcont_chg = NULL;
    }

  // add jet containers to CDF task for full jets
  if (bDoFullJets && bDoCDF) {
    AliJetContainer* jetcont_full = NULL;
    for ( Float_t fi = 0 ; fi<=100 ; fi+=10) {
      // FULL JETS 0.2
      jetcont_full  = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
      CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 2);

      // FULL JETS 0.4
      jetcont_full  = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");
      CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 2);

      if (isMC) {
        // CHG JETS MC 0.2
        jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet02Task_MC, acc_fulljets);
        CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 0);

        // CHG JETS MC 0.4
        jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet04Task_MC, acc_fulljets);
        CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 0);
        }
      }

    jetcont_full   = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
    CDF::jetContSetParams (jetcont_full,     1., 500., 0, 2);

    jetcont_full   = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");
    CDF::jetContSetParams (jetcont_full,     1., 500., 0, 2);

    if (isMC) {
      jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet02Task_MC, acc_fulljets);
      CDF::jetContSetParams (jetcont_full,     1., 500., 0, 0);

      jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet04Task_MC, acc_fulljets);
      CDF::jetContSetParams (jetcont_full,     1., 500., 0, 0);
      }
    jetcont_full = NULL;
    }

  // add jet containers to sample task for charged jets
  if (bDoChargedJets && bDoSample) {
    AliJetContainer* jetCont02chg_sample = sampleTaskchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
    AliJetContainer* jetCont04chg_sample = sampleTaskchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");

    if (iBeamType != AliAnalysisTaskEmcal::kpp) {
      jetCont02chg_sample->SetRhoName(sRhoChName);
      jetCont02chg_sample->SetPercAreaCut(0.6);

      jetCont04chg_sample->SetRhoName(sRhoChName);
      jetCont04chg_sample->SetPercAreaCut(0.6);
      }
    }

  // add jet containers to sample task for full jets
  if (bDoFullJets && bDoSample) {
    AliJetContainer* jetCont02full_sample = sampleTaskfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
    AliJetContainer* jetCont04full_sample = sampleTaskfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");

    if (iBeamType != AliAnalysisTaskEmcal::kpp) {
      jetCont02full_sample->SetRhoName(sRhoFuName);
      jetCont02full_sample->SetPercAreaCut(0.6);

      jetCont04full_sample->SetRhoName(sRhoFuName);
      jetCont04full_sample->SetPercAreaCut(0.6);
      }
    }


  TObjArray* tasks_list = pMgr->GetTasks(); TIter task_iter (tasks_list); AliAnalysisTaskSE* task = NULL;
  while (( task = dynamic_cast<AliAnalysisTaskSE*>(task_iter.Next()) )) {
    if (task->InheritsFrom("AliAnalysisTaskEmcal")) {
      Printf("Setting beam type %d for task %s", iBeamType, static_cast<AliAnalysisTaskEmcal*>(task)->GetName());
      static_cast<AliAnalysisTaskEmcal*>(task)->SetForceBeamType(iBeamType);
      }
    }

  //   Let's start #########################################################################################################
  if ( !pMgr->InitAnalysis() ) { std::cout << ">>>>>>>>>>>>>> AliAnalysisManager Initialising FAILED!!! " << std::endl; return NULL; }
  std::cout << "##-->> Initialising Analysis :: Status :" << std::endl;
  pMgr->PrintStatus();
  pMgr->SetUseProgressBar(bUseProgBar, 100);

  // task profiling
  if ( kUseSysInfo > 0 ) {
    for ( int i = 0; i < pMgr->GetTopTasks()->GetEntries(); i++ ) { pMgr->ProfileTask (i); }
    }

  CDF::SaveManager("train.root");

  if ( ManagerMode == AnalysisType::local ) { // start local analysis
    // enable class level debugging for these classes
    if ( debug > 2 ) {
    //   pMgr->AddClassDebug("AliJetContainer", 100);
    //   pMgr->AddClassDebug("AliEmcalJetTask", 100);
      if (bDoCDF)    { pMgr->AddClassDebug("AliAnalysisTaskEmcalJetCDF", 100); }
      if (bDoSample) { pMgr->AddClassDebug("AliAnalysisTaskEmcalJetSample", 100); }
      }

    TChain* pChain = CDF::CreateChain(kDataSource.Data(), "auto", "", iNumFiles);
    if (!pChain) { std::cout << ">>>>>>>>>>>>>>   CHAIN NOT CREATED   <<<<<<<<<<<<<<" << std::endl; return NULL; }

    // start analysis
    Printf("Starting LOCAL Analysis...");
    pMgr->StartAnalysis( cAnalysisType, pChain, iNumEvents );
    }

  if ( ManagerMode == AnalysisType::grid ) {  // start grid analysis
    // start analysis
    Printf("Starting GRID Analysis...");

    ListLibs += kGridExtraFiles;
    if ( ListLibs.Length() )       { plugin->SetAdditionalLibs     ( ListLibs.Data() ); }
    if ( ListLibsExtra.Length() )  { plugin->SetAdditionalRootLibs ( ListLibsExtra.Data() ); }

    if ( PluginMode == PluginType::test )
      { plugin->StartAnalysis(iNumEvents); }
    else {
      pMgr->SetDebugLevel(0);
      plugin->StartAnalysis();
      }
    }

cout << "END of EmcalJetCDF.C" << std::endl;
return pMgr;
}
Пример #14
0
void Config() {

  //  AliLog::SetClassDebugLevel("AliMFT", 1);

  LoadLibs();

  new TGeant3TGeo("C++ Interface to Geant3");

  // Create the output file

  AliRunLoader* rl=0x0;

  printf("Config.C: Creating Run Loader ...");
  rl = AliRunLoader::Open("galice.root", AliConfig::GetDefaultEventFolderName(), "recreate");
  if (rl == 0x0) {
    gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
    return;
  }
  rl->SetCompressionLevel(2);
  rl->SetNumberOfEventsPerFile(1000);
  gAlice->SetRunLoader(rl);

  // ************* STEERING parameters FOR ALICE SIMULATION **************
  // --- Specify event type to be tracked through the ALICE setup
  // --- All positions are in cm, angles in degrees, and P and E in GeV
  
  gMC->SetProcess("DCAY",1);
  gMC->SetProcess("PAIR",1);
  gMC->SetProcess("COMP",1);
  gMC->SetProcess("PHOT",1);
  gMC->SetProcess("PFIS",0);
  gMC->SetProcess("DRAY",0);
  gMC->SetProcess("ANNI",1);
  gMC->SetProcess("BREM",1);
  gMC->SetProcess("MUNU",1);
  gMC->SetProcess("CKOV",1);
  gMC->SetProcess("HADR",1);
  gMC->SetProcess("LOSS",2);
  gMC->SetProcess("MULS",1);
  gMC->SetProcess("RAYL",1);
  
  Float_t cut = 1.e-3;        // 1MeV cut by default
  Float_t tofmax = 1.e10;
  
  gMC->SetCut("CUTGAM", cut);
  gMC->SetCut("CUTELE", cut);
  gMC->SetCut("CUTNEU", cut);
  gMC->SetCut("CUTHAD", cut);
  gMC->SetCut("CUTMUO", cut);
  gMC->SetCut("BCUTE",  cut); 
  gMC->SetCut("BCUTM",  cut); 
  gMC->SetCut("DCUTE",  cut); 
  gMC->SetCut("DCUTM",  cut); 
  gMC->SetCut("PPCUTM", cut);
  gMC->SetCut("TOFMAX", tofmax); 
  
  TVirtualMCDecayer *decayer = new AliDecayerPythia();
  decayer->SetForceDecay(kAll);
  decayer->Init();
  gMC->SetExternalDecayer(decayer);
  
  // Generator
  AliGenerator* gener = 0x0;
  if (proc == kPythia6)                        gener = MbPythia(); 
  else if (proc == kPythiaPerugia0)            gener = MbPythiaTunePerugia0();
  else if (proc == kHijing)                    gener = Hijing();	
  else if (proc == kHijing2500)                gener = Hijing2500();	
  else if (proc == kHijing2500Cocktail)        gener = Hijing2500Cocktail();
  else if (proc == kGenBox)                    gener = GenBox();
  else if (proc == kGenMuonLMR)                gener = GenMuonLMR();
  else if (proc == kGenParamJpsi)              gener = GenParamJpsi();
  else if (proc == kGenCorrHF)                 gener = GenCorrHF();
  else if (proc == kGenPionKaon)               gener = GenParamPionKaon();
  else if (proc == kPythiaPerugia0BtoJpsi2mu)  gener = MbPythiaTunePerugia0BtoJpsi2mu();
  else if (proc == kCocktailSignals)           gener = CocktailSignals();

  // Size of the interaction diamond
  Float_t sigmaz  = 5.4 / TMath::Sqrt(2.);     // [cm]
  Float_t betast  = 3.5;                       // beta* [m]
  Float_t eps     = 3.75e-6;                   // emittance [m]
  Float_t gamma   = energy / 2.0 / 0.938272;   // relativistic gamma [1]
  Float_t sigmaxy = TMath::Sqrt(eps * betast / gamma) / TMath::Sqrt(2.) * 100.;  // [cm]

  printf("\n \n Diamond size x-y: %10.3e z: %10.3e\n \n", sigmaxy, sigmaz);
    
  gener->SetOrigin(0,0,0);
  gener->SetSigma(sigmaxy, sigmaxy, sigmaz);      // Sigma in (X,Y,Z) (cm) on IP position
  gener->SetVertexSmear(kPerEvent);
  gener->Init();

  printf("\n \n Comment: %s \n \n", comment.Data());

  //  TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kG, AliMagF::kBeamTypeAA, 2750.));
  TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kG, AliMagF::kBeamTypepp, 7000.));

  rl->CdGAFile();
  
  // Detector Setup

  Int_t iABSO  = 1;
  Int_t iDIPO  = 1;
  Int_t iHALL  = 1;
  Int_t iMUON  = 1;
  Int_t iPIPE  = 1;
  Int_t iSHIL  = 1;
  Int_t iT0    = 0;
  Int_t iVZERO = 1;
  Int_t iMFT   = 1;
  Int_t iACORDE= 0;
  Int_t iEMCAL = 0;
  Int_t iFMD   = 0;
  Int_t iFRAME = 0;
  Int_t iITS   = 0;
  Int_t iMAG   = 1;
  Int_t iPHOS  = 0;
  Int_t iPMD   = 0;
  Int_t iHMPID = 0;
  Int_t iTOF   = 0;
  Int_t iTPC   = 0;
  Int_t iTRD   = 0;
  Int_t iZDC   = 0;
  

  AliBODY *BODY = new AliBODY("BODY", "Alice envelop");

  if (iMAG)       AliMAG    *MAG    = new AliMAG("MAG", "Magnet");
  if (iABSO)      AliABSO   *ABSO   = new AliABSOv3("ABSO", "Muon Absorber");
  if (iDIPO)      AliDIPO   *DIPO   = new AliDIPOv3("DIPO", "Dipole version 3");
  if (iHALL)      AliHALL   *HALL   = new AliHALLv3("HALL", "Alice Hall");
  if (iSHIL)      AliSHIL   *SHIL   = new AliSHILv3("SHIL", "Shielding Version 3");
  if (iITS)       gROOT->ProcessLine(".x $ALICE_ROOT/ITS/UPGRADE/testITSU/CreateITSU.C");
  if (iTPC)       AliTPC    *TPC    = new AliTPCv2("TPC", "Default");
  if (iTOF)       AliTOF    *TOF    = new AliTOFv6T0("TOF", "normal TOF");
  if (iHMPID)     AliHMPID  *HMPID  = new AliHMPIDv3("HMPID", "normal HMPID");
  if (iFMD)       AliFMD    *FMD    = new AliFMDv1("FMD", "normal FMD");
  if (iPHOS)      AliPHOS   *PHOS   = new AliPHOSv1("PHOS", "noCPV_Modules123");
  if (iPMD)       AliPMD    *PMD    = new AliPMDv1("PMD", "normal PMD");
  if (iT0)        AliT0     *T0     = new AliT0v1("T0", "T0 Detector");
  if (iEMCAL)     AliEMCAL  *EMCAL  = new AliEMCALv2("EMCAL", "EMCAL_FIRSTYEARV1");
  if (iACORDE)    AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE");
  if (iVZERO)     AliVZERO  *VZERO  = new AliVZEROv7("VZERO", "normal VZERO");
  if (iFRAME) {
    AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
    FRAME->SetHoles(1);
  }
  if (iPIPE) {
    //    AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe");
    AliPIPE *PIPE = new AliPIPEv4("PIPE", "Beam Pipe");
  }
  if (iZDC) {
    AliZDC *ZDC = new AliZDCv3("ZDC", "normal ZDC");
    ZDC->SetSpectatorsTrack();	
    ZDC->SetLumiLength(0.);
  }
  if (iTRD) {
    AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
  }
  if (iMUON) {
    AliMUON *MUON = new AliMUONv1("MUON", "default");
    MUON->SetTriggerEffCells(1); // not needed if raw masks 
    Char_t* digitstore="AliMUONDigitStoreV2S";    
    MUON->SetDigitStoreClassName(digitstore);
  }
  if (iMFT) {
    AliMFT *MFT = new AliMFT("MFT", "normal MFT");
  }

  TIter next(gAlice->Modules());
  AliModule *detector;
  printf("gAlice->Modules:\n");
  while((detector = (AliModule*)next())) printf("%s\n",detector->GetName());

}
Пример #15
0
bool wxGISServerApp::OnInit()
{

#ifdef wxUSE_SNGLINST_CHECKER
    m_pChecker = new wxSingleInstanceChecker(wxT("wxgisserverapp"));
    if ( m_pChecker->IsAnotherRunning() )
    {
        wxLogError(_("Another program instance is already running, aborting."));

        wxDELETE( m_pChecker ); // OnExit() won't be called if we return false

        return false;
    }
#endif

    m_oConfig = GetConfig();
	if(!m_oConfig.IsOk())
		return false;

    //create application
    m_pServer = new wxGISServer();
    SetApplication(m_pServer);

	//setup loging
	wxString sLogDir = m_oConfig.GetLogDir();
    //if(!m_pServer->SetupLog(sLogDir))
    //    return;

	//setup locale
	wxString sLocale = m_oConfig.GetLocale();
	wxString sLocaleDir = m_oConfig.GetLocaleDir();
    if(!m_pServer->SetupLoc(sLocale, sLocaleDir))
        return false;

   	//setup sys
    wxString sSysDir = m_oConfig.GetSysDir();
    //if(!m_pServer->SetupSys(sSysDir))
    //    return;

   	//setup debug
	bool bDebugMode = m_oConfig.GetDebugMode();
    //m_pServer->SetDebugMode(bDebugMode);

    //some default GDAL
	wxString sGDALCacheMax = m_oConfig.Read(enumGISHKCU, wxString(wxT("wxGISCommon/GDAL/cachemax")), wxString(wxT("128")));
	CPLSetConfigOption( "GDAL_CACHEMAX", sGDALCacheMax.mb_str() );
    CPLSetConfigOption ( "LIBKML_USE_DOC.KML", "no" );
    //GDAL_MAX_DATASET_POOL_SIZE
    //OGR_ARC_STEPSIZE

	OGRRegisterAll();
	GDALAllRegister();

#ifdef __WXMSW__
	wxLogDebug(wxT("wxSocketBase::Initialize"));
    wxSocketBase::Initialize();
#endif

	//store values

	m_oConfig.SetLogDir(sLogDir);
	m_oConfig.SetLocale(sLocale);
	m_oConfig.SetLocaleDir(sLocaleDir);
	m_oConfig.SetSysDir(sSysDir);
	m_oConfig.SetDebugMode(bDebugMode);

	//gdal
	m_oConfig.Write(enumGISHKCU, wxString(wxT("wxGISCommon/GDAL/cachemax")), sGDALCacheMax);

    wxString sKey(wxT("wxGISCommon/libs"));
    //load libs
	wxXmlNode* pLibsNode = m_oConfig.GetConfigNode(enumGISHKCU, sKey);
	if(pLibsNode)
		LoadLibs(pLibsNode);
	pLibsNode = m_oConfig.GetConfigNode(enumGISHKLM, sKey);
	if(pLibsNode)
		LoadLibs(pLibsNode);

    //send interesting things to console
    return wxAppConsole::OnInit();
	//return true;
}
Пример #16
0
int fgtSingleEvents( const Char_t *filenameIn = "testfile.daq",
                     const Char_t *filenameOut = "testfile.root",
                     Int_t nevents = 200,
                     Bool_t isCosmic = 0,
                     Bool_t cutShortEvents = 0 ){

   LoadLibs();
   Int_t ierr = 0;

   if( isCosmic )
      cout << "Is Cosmic" << endl;
   else
      cout << "Is not cosmic" << endl;

   //
   // START CONSTRUCTING THE CHAIN
   //

   cout << "Constructing the chain" << endl;
   analysisChain = new StChain("eemcAnalysisChain");

   std::string fgtDbMkrName = "";

   if( !isCosmic ){
      // always cut short events if it is cosmic data
      cutShortEvents = 1;

      cout << "Loading St_db_Maker" << endl;
      gSystem->Load("libStDb_Tables.so");
      gSystem->Load("StDbLib.so");
      gSystem->Load("St_db_Maker");
      gSystem->Load("StDbBroker");

      TString dir0 = "MySQL:StarDb";
      TString dir1 = "$STAR/StarDb";
      St_db_Maker *dbMkr = new St_db_Maker( "dbMkr", dir0, dir1 );
      dbMkr->SetDateTime(20120115,1);

      cout << "Loading StFgtDbMaker" << endl;
      gSystem->Load("StFgtDbMaker");

      cout << "Constructing StFgtDbMaker" << endl;
      fgtDbMkr = new StFgtDbMaker( "fgtDbMkr" );
      //fgtDbMkr->SetFlavor("ideal",""); // mapping is wrong, but at least the code runs...

      fgtDbMkrName = fgtDbMkr->GetName();
   };

   //
   // NOW THE OTHER READERS AND MAKERS
   //

   cout << "Constructing the daq reader" << endl;
   daqRdr = new StFgtRawDaqReader( "daqReader", filenameIn, fgtDbMkrName.data() );
   daqRdr->setIsCosmic( isCosmic );
   daqRdr->cutShortEvents( cutShortEvents );

   cout << "Constructing the A2C converter" << endl;
   a2cMkr = new StFgtA2CMaker( "a2cMaker" );
   //a2cMkr->setTimeBinMask( 0xFF );
   a2cMkr->setAbsThres( 100 );  // set to below -4096 to skip cut
   a2cMkr->setRelThres( 0 );  // set to zero to skip cut
   if( !isCosmic )
      a2cMkr->setFgtDb( fgtDbMkr->getDbTables() );
   //a2cMkr->doRemoveOtherTimeBins( 0 );
   //a2cMkr->doCutBadStatus( 0 );

   cout << "Constructing the QA Maker" << endl;
   qaMkr = new StFgtSingleEventQA( "fgtSingleEventQA" );
   qaMkr->setFilename( filenameOut );

   // debug
   // analysisChain->ls(4);

   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 == 0 )
         cout << "\ton event number " << i << endl;

      //cout << "clear" << endl;
      analysisChain->Clear();

      //cout << "make" << endl;
      ierr = analysisChain->Make();

   };

   //
   // Calls the ::Finish() method on all makers
   //
   cout << "finish" << endl;
   analysisChain->Finish();

   cerr << "\tall done" << endl;
   return;
};