Exemplo n.º 1
0
void ConfigOCDB(Int_t run=0) {
  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
  AliCDBManager::Instance()->SetRun(run);
  // magnetic field
  if ( !TGeoGlobalMagField::Instance()->GetField() ) {
    printf("Loading field map...\n");
    AliGRPManager grpMan;
    if( !grpMan.ReadGRPEntry() ) {
      printf("Cannot get GRP entry\n");
    }
    if( !grpMan.SetMagField() ) {
      printf("Problem with magnetic field setup\n");
    }
  }
  if ( !TGeoGlobalMagField::Instance()->GetField()){
    AliMagF::BMap_t smag = AliMagF::k5kG;
    Double_t bzfac = 1;
    AliMagF* magF= new AliMagF("Maps","Maps", bzfac, 1., smag);
    TGeoGlobalMagField::Instance()->SetField(magF);
  }
  //TPC calib
  AliTPCcalibDB *db=AliTPCcalibDB::Instance();
  db->SetRun(run);
  //geometry
  AliGeomManager::LoadGeometry();
  // init geometry in parameters
  if (db->GetParameters()) db->GetParameters()->ReadGeoMatrices();
}
Exemplo n.º 2
0
//_________________________________________________________________________________
void ProcessTRDRunQA(TString qaFile, Int_t runNumber, TString dataType, 
		     Int_t year, TString period, TString pass, 
		     TString ocdbStorage) {
  //
  // Process run level QA
  // Create standard QA plots and trending tree in the current directory
  const Char_t *friendsOpt="PID DET RES";
  
  //gStyle->SetTitleX(gStyle->GetPadLeftMargin());
	gStyle->SetGridColor(kBlack);
	gStyle->SetGridStyle(3);
	gStyle->SetGridWidth(1);

  // Load needed libraries
  gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_PHYSICS/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT -I$ALICE_PHYSICS -I$ALICE_ROOT/TRD");
  gSystem->Load("libSTEERBase");
  gSystem->Load("libSTAT");
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libTender");
  gSystem->Load("libTenderSupplies");
  gSystem->Load("libCORRFW");
  gSystem->Load("libPWGPP");
  
  // Initialize a tree streamer
  TTreeSRedirector *treeStreamer = new TTreeSRedirector("trending.root","RECREATE");
  (*treeStreamer)<< "trending"
          << "run=" << runNumber;
  
  // connect to grid if its the case
  if(qaFile.Contains("alien://") || ocdbStorage.Contains("alien://") || ocdbStorage[0]=='\0')
    TGrid::Connect("alien://");
  
  // trending values from the ESD task ------------------------------------------------
  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/TRD/macros/makeResults.C");
  Double_t esdTrendValues[100]; 
  for(Int_t i=0;i<100;i++) esdTrendValues[i]=0.0;
  makeSummaryESD(qaFile.Data(), esdTrendValues, 1);
  const Int_t kNESDtrends = 24;
  const TString kESDTrendNames[kNESDtrends] = {
    "TPCTRDmatchEffPosAll","TPCTRDmatchEffPosAllErr",
    "TPCTRDmatchEffNegAll","TPCTRDmatchEffNegAllErr",					      
    "TRDTOFmatchEffPosAll","TRDTOFmatchEffPosAllErr",					      
    "TRDTOFmatchEffNegAll","TRDTOFmatchEffNegAllErr",						     
    "AvTRDtrkltsPerTrackAll", "AvTRDtrkltsPerTrackAllErr",						      
    "AvNclsPerTrackAll", "AvNclsPerTrackAllErr",						      
    "PHplateauHeight", "PHplateauHeightErr",						
    "PHplateauSlope", "PHplateauSlopeErr",						
    "QtotLandauMPV1GeVAll", "QtotLandauWidth1GeVAll",
    "PHplateauHeightAbsolute", "PHplateauHeightErrAbsolute",
    "PHplateauSlopeAbsolute", "PHplateauSlopeErrAbsolute",						
    "QtotLandauMPV1GeVAllAbsolute", "QtotLandauWidth1GeVAllAbsolute"
  };
  for(Int_t i=0; i<kNESDtrends; ++i)
    (*treeStreamer)<< "trending" << Form("%s=",kESDTrendNames[i].Data()) << esdTrendValues[i];
  
  // process the QA output from the other tasks----------------------------------------
  if(dataType.Contains("sim"))
    makeResults(friendsOpt, qaFile.Data());
  else  
    makeResults(Form("NOMC %s", friendsOpt), qaFile.Data());
  
  TFile *trendFile = TFile::Open("TRD.Trend.root","READ");
  if(!trendFile || !trendFile->IsOpen() ){
    Warning("ProcessTRDRunQA.C", "Couldn't open the TRD.Trend.root file.");
    if(trendFile) delete trendFile; trendFile=0;
  }
  TFile *trendDB = TFile::Open("$ALICE_PHYSICS/PWGPP/TRD/data/TRD.Trend.root","READ");
  if(!trendDB || !trendDB->IsOpen() ){
    Error("ProcessTRDRunQA.C", "Couldn't open the Trending DB !");
    if(trendDB) delete trendDB; trendDB=0;
  }
  
  if(trendDB){
    TKey *tk(NULL); AliTRDtrendValue *tv(NULL); Int_t itv(0);
    const Int_t ntrends(5000);
    Double_t trendValues[ntrends]={0.0};
    TIterator *it(trendDB->GetListOfKeys()->MakeIterator());
    while((tk = (TKey*)it->Next()) && itv < ntrends){
      trendValues[itv] = -999.;
      if(trendFile && (tv = (AliTRDtrendValue*)trendFile->Get(tk->GetName()))){ 
        trendValues[itv] = tv->GetVal();
        printf("Found trend %03d \"%s\" %f\n", itv, tk->GetName(), trendValues[itv]);
      }
      (*treeStreamer)<< "trending" << Form("%s=", tk->GetName()) << trendValues[itv];
      itv++;
    }
  }
  
  // get OCDB information---------------------------------------------------------------
  // switch off grid infos to reduce output and logfilesize                                               
  AliLog::SetGlobalLogLevel(AliLog::kFatal);
  AliCDBManager* man=AliCDBManager::Instance();
  if(ocdbStorage[0]=='\0')
    man->SetDefaultStorage(Form("alien://folder=/alice/data/%d/OCDB/", year));
  else
    man->SetDefaultStorage(ocdbStorage.Data());
  man->SetRun(runNumber);
  
  AliCDBEntry* entryExB = 0x0;
  AliCDBEntry* entryGainFactor = 0x0;
  AliCDBEntry* entryT0 = 0x0;
  AliCDBEntry* entryVdrift = 0x0;
  entryExB = man->Get("TRD/Calib/ChamberExB");
  entryGainFactor = man->Get("TRD/Calib/ChamberGainFactor");
  entryT0 = man->Get("TRD/Calib/ChamberT0");
  entryVdrift = man->Get("TRD/Calib/ChamberVdrift");
  AliTRDCalDet *caldetExB=0x0;
  AliTRDCalDet *caldetGainFactor=0x0;
  AliTRDCalDet *caldetT0=0x0;
  AliTRDCalDet *caldetVdrift=0x0;
  if(entryExB)        caldetExB        = (AliTRDCalDet*)entryExB->GetObject();
  if(entryGainFactor) caldetGainFactor = (AliTRDCalDet*)entryGainFactor->GetObject();
  if(entryT0)         caldetT0         = (AliTRDCalDet*)entryT0->GetObject();
  if(entryVdrift)     caldetVdrift     = (AliTRDCalDet*)entryVdrift->GetObject();
  // get the values
  Double_t meanExB        = (caldetExB ? caldetExB->CalcMean(1) : 0.0);
  Double_t rmsExB         = (caldetExB ? caldetExB->CalcRMS(1) : 0.0);
  Double_t meanGainFactor = (caldetGainFactor ? caldetGainFactor->CalcMean(1) : 0.0);
  Double_t rmsGainFactor  = (caldetGainFactor ? caldetGainFactor->CalcRMS(1) : 0.0);
  Double_t meanT0         = (caldetT0 ? caldetT0->CalcMean(1) : 0.0);
  Double_t rmsT0          = (caldetT0 ? caldetT0->CalcRMS(1) : 0.0);
  Double_t meanVdrift     = (caldetVdrift ? caldetVdrift->CalcMean(1) : 0.0);
  Double_t rmsVdrift      = (caldetVdrift ? caldetVdrift->CalcRMS(1) : 0.0);
  (*treeStreamer)<< "trending"
                 << "meanExB=" << meanExB
                 << "rmsExB=" << rmsExB
                 << "meanGainFactor=" << meanGainFactor
                 << "rmsGainFactor=" << rmsGainFactor
                 << "meanT0=" << meanT0
                 << "rmsT0=" << rmsT0
                 << "meanVdrift=" << meanVdrift
                 << "rmsVdrift=" << rmsVdrift;
  
  // Get the beam luminosity
  AliCDBEntry *entryLHCData = man->Get("GRP/GRP/LHCData");		 
  AliLHCData *lhcData = (entryLHCData ? (AliLHCData*)entryLHCData->GetObject() : 0x0);
  Double_t beamIntensityA=0.0;
  Double_t beamIntensityC=0.0;
  if(lhcData) {
    Int_t nLumiMeasA=lhcData->GetNLuminosityTotal(0); Int_t nA=0;
    Int_t nLumiMeasC=lhcData->GetNLuminosityTotal(1); Int_t nC=0;
    // Sum up the measurements
    AliLHCDipValF *dipVal0,*dipVal1;
    for(Int_t iLumiMeas=0;iLumiMeas<nLumiMeasA;iLumiMeas++){
      dipVal0 = lhcData->GetLuminosityTotal(0,iLumiMeas);
      if(dipVal0) {
        beamIntensityA += dipVal0->GetValue();
        ++nA;
      }
    }
    if(nA) beamIntensityA /= Double_t(nA);
    for(Int_t iLumiMeas=0;iLumiMeas<nLumiMeasC;iLumiMeas++){
      dipVal1 = lhcData->GetLuminosityTotal(1,iLumiMeas);
      if(dipVal1) {
        beamIntensityC += dipVal1->GetValue();
        ++nC;
      }
    }
    if(nC) beamIntensityC /= Double_t(nC);
  }
  (*treeStreamer)<< "trending"
                 << "beamIntensityA=" << beamIntensityA
                 << "beamIntensityC=" << beamIntensityC;
                 
  // Get the magnetic field polarity
  Double_t Bfield=-2.;
  AliGRPManager grpManager;
  if(grpManager.ReadGRPEntry() && grpManager.SetMagField()){
    AliMagF *f=TGeoGlobalMagField::Instance()->GetField();
    Bfield=f->Factor();
  }                  
  (*treeStreamer)<< "trending"
                 << "Bfield=" << Bfield;
		 
  (*treeStreamer)<< "trending"
                 << "\n";
  delete treeStreamer;		 
}
Exemplo n.º 3
0
// read TPC Clusters compressed by HLT from a raw filename
TTree* readHLTClusters(AliRawReader *fRawReader)
{
    /*************************
     *  Raw IO Stuff
     **************************/
    
    cout<<"reader:"<<fRawReader<<endl;
    
    AliRawReader* rawReader = AliRawHLTManager::CreateRawReaderHLT(fRawReader, "TPC");
    cout<<"rawReader:"<<rawReader<<endl;
    
    rawReader->Select("TPC");
    
    /*************************
     *  HLT IO Stuff
     **************************/
    AliHLTSystem* hltSystem=AliHLTPluginBase::GetInstance();
    
    cout<<"hltSystem:"<<hltSystem<<endl;
    
    AliHLTOUT* hltOut = AliHLTOUT::New(rawReader);
    
    cout<<"hltOut:"<<hltOut<<endl;
    
    hltOut->Init();
    hltSystem->InitHLTOUT(hltOut);
    
    /*************************
     *  GRP Stuff
     **************************/
    AliGRPManager *manGRP = new AliGRPManager();
    cout<<"manGRP:"<<manGRP<<endl;
    
    AliRecoParam* recoParam = InitRecoParam();
    
    cout<<"recoParam:"<<recoParam<<endl;
    
    if(!recoParam){
        cout<<"No reco param"<<endl;
    }
    
    AliEveEventManager* curEventMan = (AliEveEventManager*)gEve->GetCurrentEvent();
    
    cout<<"a"<<endl;
    const AliRunInfo* runInfo = manGRP->GetRunInfo();
    cout<<"a.1:"<<runInfo<<endl;
    const THashTable* cosmicTriggers = manGRP->GetCosmicTriggers();
    cout<<"a.2:"<<cosmicTriggers<<endl;
    const AliEventInfo *eventinfo = GetEventInfo();
    
    if(!eventinfo){
        cout<<"Event info couldn't be retrived."<<endl;
        return 0;
    }
    
    recoParam->SetEventSpecie(runInfo,*eventinfo,cosmicTriggers);
    
    cout<<"aaa"<<endl;
    
    AliTPCRecoParam *tpcRecoParam = (AliTPCRecoParam*)recoParam->GetDetRecoParam(1); // TPC has index 1
    tpcRecoParam->SetUseHLTClusters(3); // reconstruct only HLT clusters
    
    cout<<"aaaa"<<endl;
    
    /**************************
     *  Reconstruction of Clusters
     **************************/
    
    
    TTree* outputClustersTree = new TTree();
    cout<<"a1"<<endl;
    AliTPCReconstructor *reconstructor = new AliTPCReconstructor();
    
    cout<<"a1.1"<<endl;
    reconstructor->SetOption("useHLT");
    cout<<"a1.2"<<endl;
    reconstructor->CreateTracker(); // this will set the option to reconstruct for only HLT clusters
    cout<<"a2"<<endl;
    
    reconstructor->SetRecoParam(tpcRecoParam);
    
    reconstructor->SetRunInfo((AliRunInfo*)runInfo);
    reconstructor->SetEventInfo((AliEventInfo*)eventinfo);
    cout<<"a3"<<endl;
    
    if(!rawReader){
        cout<<"No raw reader"<<endl;
    }
    
    reconstructor->Reconstruct(rawReader, outputClustersTree);
    
    if(reconstructor){
//        delete reconstructor;
        reconstructor=0;
    }
    cout<<"aaaaa"<<endl;
    
    hltSystem->ReleaseHLTOUT(hltOut);
    
    cout<<"aaaaaa"<<endl;
    
    return outputClustersTree;
    
}
Exemplo n.º 4
0
void sim() {
  Int_t nev = -1;
  Int_t run = 0;
	Int_t nskip = 0;
  const char *fname;
	//	char fnaneopt[1024];
  const char *esdname;
	const char *trgname;
  const char *embrun;
	const char *runtype;
  const char *fnameopt;
	
  if (gSystem->Getenv("DC_RUN")) {
    run = atoi(gSystem->Getenv("DC_RUN"));
  }
  if (gSystem->Getenv("DC_RAWFILE")) {
    fname = gSystem->Getenv("DC_RAWFILE");
  } else {
		printf("DC_RAWFILE is not set and is needed!!!");
		return;
	}
  if (gSystem->Getenv("DC_ESDFILE")) {
    esdname = gSystem->Getenv("DC_ESDFILE");
  } else {
		printf("DC_ESDFILE is not set and is needed!!!");
		return;
	}
  if (gSystem->Getenv("DC_NEVENTS")) {
    nev = atoi(gSystem->Getenv("DC_NEVENTS"));
		//    gSystem->Exec("echo ${DC_NEVENTS} > ${DC_NEVENTS}_${DC_NEVENTS}_0_${DC_NEVENTS}.stat"); // moved after selection!
  }
	if (gSystem->Getenv("DC_EEVENT")) {
		nskip = atoi(gSystem->Getenv("DC_EEVENT"));
	}
	if (gSystem->Getenv("DC_TRGNAME")) {
    trgname = gSystem->Getenv("DC_TRGNAME");
		printf("Looking for %s\n",trgname);
  } else {
		printf("DC_TRGNAME not set, will embedd in all events!!!");
		return;
	}
  if (gSystem->Getenv("CONFIG_EMBEDDING")) {
    embrun = gSystem->Getenv("CONFIG_EMBEDDING");
	} else {
		printf("CONFIG_EMBEDDING is not set and is needed");
		return;
	}
	if (gSystem->Getenv("CONFIG_RUN_TYPE")) {
    runtype = gSystem->Getenv("CONFIG_RUN_TYPE");
	} else {
		printf("CONFIG_RUN_TYPE is not set and is needed");
		return;
	}
	TString sfname(fname);
	
	printf("sim.C: running in %s mode on run %d for %d events and skipping %d esd events\n",embrun,run,nev,nskip);
	printf("sim.C: rawfile %s and esdfile %s \n",sfname.Data(),esdname);
	
  AliSimulation simulator;
  
  // BACKGROUND: Convert raw data to SDigits
  if (!(strcmp(embrun,"kBackground"))){
		
    AliCDBManager *cdbm = AliCDBManager::Instance();
    cdbm->SetDefaultStorage("alien://Folder=/alice/data/2011/OCDB");
    cdbm->SetRun(run);
		
		AliGRPManager grpM;
    grpM.ReadGRPEntry();
    grpM.SetMagField();
    printf("Field is locked now. It cannot be changed in Config.C\n");
		
    simulator.SetMakeSDigits("MUON ITS");
		
		// only physics events
		sfname += "?EventType=7";
		
		// select one trigger ...
		if (trgname){
			AliCDBEntry *grp_ctp = cdbm->Get("GRP/CTP/Config",run);
			AliTriggerConfiguration *trg_conf = (AliTriggerConfiguration *)grp_ctp->GetObject();
			trg_conf->Print();
			TObjArray trg_masks = trg_conf->GetClasses(); // Reference!!!
			std::vector<unsigned char> triggerconfs;
			for(Int_t iobj = 0; iobj < trg_masks.GetEntriesFast(); iobj++){
				AliTriggerClass *trg_class = (AliTriggerClass*)trg_masks.UncheckedAt(iobj);
				AliTriggerCluster *trg_clust = (AliTriggerCluster *)trg_class->GetCluster();
				//				printf("%s %s \n",trg_class->GetName(),trgname);
				if(TString(trg_class->GetName()).Contains(trgname)){
					printf("We will embed into events containing this trigger name(mask): %s(%d)\n",trg_class->GetName(),trg_class->GetMask());
					char triggerbuf[256];
					sprintf(triggerbuf, "?Trigger=%d", trg_class->GetMask());
					sfname += triggerbuf;
					//					triggerconfs.push_back(trg_class->GetMask());
				}
			}
			
			//			Int_t itrg = 0;
			//			printf("Number of Trigger Clusters including MUON: %d\n", (Int_t)triggerconfs.size());
			//    for(std::vector<unsigned char>::iterator it = triggerconfs.begin(); it < triggerconfs.end(); it++)
			//      printf("Trigger Mask %d for MUON: %d\n", itrg++, *it);
			//    filestring += "?EventType=7";
			//    char triggerbuf[256];
			//    Int_t triggerval = 0;
			//    for(std::vector<unsigned char>::iterator it = triggerconfs.begin(); it < triggerconfs.end(); it++)
			//      triggerval += *it;
			//    sprintf(triggerbuf, "?Trigger=%d", triggerval);
			//    filestring += triggerbuf; // This line does the trigger selection. It has to be uncommented if one wants to apply trigger selection
		}
		printf("Filename: %s\n", sfname.Data());
		
		Int_t iSelEvents = simulator.ConvertRaw2SDigits(sfname.Data(),esdname,nev,nskip);
		gSystem->Setenv("DC_NEVENTS",Form("%d",iSelEvents));
		gSystem->Exec("echo $DC_NEVENTS > selev.log");
		//			gSystem->Exec("echo ${DC_NEVENTS} > ${DC_NEVENTS}_${DC_NEVENTS}_0_${DC_NEVENTS}.stat"); // done in simrun.C
		gSystem->Exec("echo in sim.C $DC_NEVENTS");
		return;
	}
	
	// Signal: pure signal
	if (!(strcmp(embrun,"kSignal"))){
		
		if (!gSystem->Getenv("DC_NEVENTS")) {
			printf("DC_NEVENTS is not set and is needed at this step!!!");
			return;
		}
		
		AliCDBManager *cdbm = AliCDBManager::Instance();
		cdbm->SetDefaultStorage("alien://Folder=/alice/data/2011/OCDB");
		cdbm->SetRun(run);
		
		AliGRPManager grpM;
		grpM.ReadGRPEntry();
		grpM.SetMagField();
		printf("Field is locked now. It cannot be changed in Config.C\n");
		
		simulator.SetRunGeneration(kFALSE);
		simulator.SetMakeSDigits("");
		simulator.SetMakeDigitsFromHits("");
	}
	// MERGED: Simulate signal and merge with background
	if (!(strcmp(embrun,"kMerged"))){
		simulator.SetRunGeneration(kTRUE);
		simulator.SetMakeSDigits("MUON ITS");
		simulator.EmbedInto("Background/galice.root",1);
		// THE OCDB PART
		simulator.SetDefaultStorage("alien://Folder=/alice/data/2011/OCDB");
		
		// Read GRP Data from RAW
		simulator.SetSpecificStorage("GRP/GRP/Data","alien://Folder=/alice/data/2011/OCDB");
	}
	
	simulator.SetRunSimulation(kTRUE);
	simulator.SetMakeDigits("MUON ITS");
	simulator.SetRunHLT("");
	//  simulator.SetRunHLT("libAliHLTMUON.so chains=dHLT-sim");
	simulator.SetRunQA(":");
	//  simulator.SetRunQA("MUON:ALL");
	
	//  Mag.field from OCDB
	simulator.UseMagFieldFromGRP();
	
	// THE OCDB PART
	
	// MUON
	//	simulator.SetSpecificStorage("MUON/Calib/Gains","alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/");
		simulator.SetSpecificStorage("MUON/Align/Data","alien://Folder=/alice/simulation/2008/v4-15-Release/Full/");
	
	// MUON Trigger
	// 	simulator.SetSpecificStorage("MUON/Calib/GlobalTriggerCrateConfig","alien://folder=/alice/simulation/2008/v4-15-Release/Ideal");
	// 	simulator.SetSpecificStorage("MUON/Calib/LocalTriggerBoardMasks","alien://folder=/alice/simulation/2008/v4-15-Release/Ideal");
	// 	simulator.SetSpecificStorage("MUON/Calib/RegionalTriggerConfig","alien://folder=/alice/simulation/2008/v4-15-Release/Ideal");
	// 	simulator.SetSpecificStorage("MUON/Calib/TriggerEfficiency","alien://folder=/alice/simulation/2008/v4-15-Release/Full");
	
	// The rest
	
	simulator.Run(nev);
	
}