Beispiel #1
0
void CompareESD() {
  TFile *fold=TFile::Open("AliESDs_old.root");
  TFile *fnew=TFile::Open("AliESDs.root");

  TTree *told=(TTree*)fold->Get("esdTree");
  Int_t nold=told->GetEntries();
  TTree *tnew=(TTree*)fnew->Get("esdTree");
  Int_t nnew=tnew->GetEntries();
  if (nold != nnew) {
    cout<<"Number of events is different !"<<endl;
    return;
  }

  AliESDEvent *eold = new AliESDEvent();
  eold->ReadFromTree(told); 
  AliESDEvent *enew = new AliESDEvent();
  enew->ReadFromTree(tnew); 

  for (Int_t i=0; i<nnew; i++) {
      cout<<"Checking event #"<<i<<endl;
      told->GetEvent(i);
      tnew->GetEvent(i);
      Int_t ntold=eold->GetNumberOfTracks();
      Int_t ntnew=enew->GetNumberOfTracks();
      if (ntold != ntnew) {
	 cout<<"Number of tracks is different ! "<<ntold<<' '<<ntnew<<endl;
         return;
      }
      for (Int_t j=0; j<ntnew; j++) {
	  AliESDtrack *to=eold->GetTrack(j);
	  AliESDtrack *tn=enew->GetTrack(j);
          ULong64_t so=to->GetStatus();
          ULong64_t sn=tn->GetStatus();
          if (so != sn) {
	     cout<<"Track status is different !"<<endl;
	     return;
          }
          Int_t idxo[20], idxn[20];
          Int_t nco=to->GetITSclusters(idxo);
          Int_t ncn=tn->GetITSclusters(idxn);
          if (nco != ncn) {
	     cout<<"Track #"<<j<<' ';
	     cout<<"Number of clusters is different ! "<<nco<<' '<<ncn<<endl;
	     return;
          }
          for (Int_t k=0; k<ncn; k++) {
	      if (idxo[k] != idxn[k]) {
	         cout<<"Cluster index is different !"<<endl;
	         return;
	      }
	  }
      }
  }

}
Beispiel #2
0
Int_t AliPMDesdanal() { 
   TStopwatch timer;

   gStyle->SetOptStat(111110);
   gStyle->SetOptFit(1);

//****** File with the ESD
   TFile *ef=TFile::Open("AliESDs.root");
   if (!ef || !ef->IsOpen()) {cerr<<"Can't AliESDs.root !\n"; return 1;}
   AliESDEvent * event = new AliESDEvent;
   TTree* tree = (TTree*) ef->Get("esdTree");
   if (!tree) {cerr<<"no ESD tree found\n"; return 1;};
   event->ReadFromTree(tree);
   Int_t n=0;

//******* The loop over events
   while (tree->GetEvent(n)) {
     cout<<endl<<"Processing event number : "<<n++<<endl;


     Int_t npmdcl=event->GetNumberOfPmdTracks();
     cout<<"Number of PMD tracks : "<<npmdcl<<endl; 

     //****** The loop over PMD clusters
     while (npmdcl--) {
       AliESDPmdTrack *pmdtr = event->GetPmdTrack(npmdcl);
       
       Int_t   det   = pmdtr->GetDetector(); 
       Float_t clsX  = pmdtr->GetClusterX();
       Float_t clsY  = pmdtr->GetClusterY();
       Float_t clsZ  = pmdtr->GetClusterZ();
       Float_t ncell = pmdtr->GetClusterCells();
       Float_t adc   = pmdtr->GetClusterADC();
       Float_t pid   = pmdtr->GetClusterPID();
       
     }
   }

   delete event;

   timer.Stop();
   timer.Print();

   return 0;
}
Beispiel #3
0
// analisi
Bool_t CheckSingle(const char* esdFileName,Bool_t kGRID){
  //inizializzo a zero ncluster (di tree T)
  //for (int ifc=0;ifc<10000;ifc++) ncluster[ifc]=0;
  
  // check the content of the ESD
  
  AliPIDResponse *pidr = new AliPIDResponse();
  
  // open the ESD file
  TFile* esdFile = TFile::Open(esdFileName);
  if (!esdFile || !esdFile->IsOpen()){
    Error("CheckESD", "opening ESD file %s failed", esdFileName);
    return kFALSE;
  }
  
  TString mctrkref(esdFileName);
  mctrkref.ReplaceAll("AliESDs.root","TrackRefs.root");
  TString fgal(esdFileName);
  fgal.ReplaceAll("AliESDs.root","galice.root");
  
  if(kGRID){
    fgal.Insert(0,"alien://");
    mctrkref.Insert(0,"alien://");
  }
  
  TTree *trkref;
  
  printf("ESD = %s\n",esdFileName);
  
  TFile *ftrkref; 
  if(isMC) ftrkref = TFile::Open(mctrkref.Data());
  
  AliHeader *h = new AliHeader();
  
  TFile *fgalice;
  if(isMC) fgalice = TFile::Open(fgal.Data());
  TTree *tgalice;
  if(isMC){
    tgalice = (TTree *) fgalice->Get("TE");
    tgalice->SetBranchAddress("Header",&h);
  }
  
  AliRunLoader* runLoader = NULL;
  
  AliRun *gAlice;
  if(isMC) runLoader = AliRunLoader::Open(fgal.Data());
  if(runLoader){
    runLoader->LoadgAlice();
    gAlice = runLoader->GetAliRun();
    if (!gAlice) {
      Error("CheckESD", "no galice object found");
      return kFALSE;
    }
    runLoader->LoadKinematics();
    runLoader->LoadHeader();
  }
  
  AliESDEvent * esd = new AliESDEvent;
  //  printf("esd object = %x\n",esd);
  TTree* tree = (TTree*) esdFile->Get("esdTree");
  if (!tree){
    Error("CheckESD", "no ESD tree found");
    return kFALSE;
  }
  esd->ReadFromTree(tree); // crea link tra esd e tree
  
  TClonesArray* tofcl;  // array dinamico
  TClonesArray* tofhit;
  TClonesArray* tofmatch;
  
  Int_t nev = tree->GetEntries(); //ogni entries evento
  Float_t mag;
  
  printf("nev = %i\n",nev);
  
  //azzero il contatore delle tracce del TTree T
  //ntracks=0;
  AliStack* stack=NULL;
  
  Int_t trkassociation[1000000];
  
  for(Int_t ie=0;ie < nev;ie++){
    if(runLoader){
      runLoader->GetEvent(ie);
      
      // select simulated primary particles, V0s and cascades
      stack = runLoader->Stack();
    }
    
    if(isMC) trkref = (TTree *) ftrkref->Get(Form("Event%i/TreeTR",ie));
    tree->GetEvent(ie);
    if(isMC) tgalice->GetEvent(ie);
    
    if(isMC) interactiontime = h->GenEventHeader()->InteractionTime()*1E+12;
    
    mag = esd->GetMagneticField();
    
    AliTOFHeader *tofh = esd->GetTOFHeader();
    ntofcl = tofh->GetNumberOfTOFclusters();
    
    esd->ConnectTracks(); // Deve essere sempre chiamato dopo aver letto l'evento (non troverebbe l'ESDevent). Scrivo in tutte le tracce l origine dell evento così poi da arrivare ovunque(tipo al cluster e al tempo quindi).
    
    
    //Riempio variabile del tree "T"
    //nevento=ie;
    
    if(! esd->GetVertex()){
      esd->ResetStdContent();
      continue;// una volta fatto il connect manda un flag ; siccome qua c'era un continue(non si arriva in fondo al ciclo) bisogna resettarlo altrimenti lo trova già attivo.
    }
    
    tofcl = esd->GetESDTOFClusters(); // AliESDTOFCluster *cltof = tofcl->At(i);
    if(tofcl->GetEntries() == 0){
      esd->ResetStdContent();
      continue;
    }
    tofhit = esd->GetESDTOFHits(); // AliESDTOFHit *hittof = tofhit->At(i);
    tofmatch = esd->GetESDTOFMatches(); // AliESDTOFHit *mathctof = tofmatch->At(i);
    
    // loop over tracks
    
    pidr->SetTOFResponse(esd,AliPIDResponse::kTOF_T0); //per recuperare lo start time ("esd", "tipo start time"), tipo cioè o il TOF stesso o il T0 o il best, ovvero la combinazione dei 2
    
    Int_t ntrk = esd->GetNumberOfTracks();
    
    //printf("%i) TPC tracks = %i -- TOF cluster = %i - TOF hit = %i -- matchable info = %i\n",ie,ntrk,tofcl->GetEntries(),tofhit->GetEntries(),tofmatch->GetEntries());
    
    Double_t time[AliPID::kSPECIESC];
    
    
    if(isMC && stack){// create association trackref
      printf("nMC track = %i\n",stack->GetNtrack());
      for(Int_t ist=0;ist < stack->GetNtrack();ist++){
	trkassociation[ist]=-1;
      }
      for(Int_t iref=0;iref < trkref->GetEntries();iref++){
	trkref->GetEvent(iref);
	Int_t trkreference = trkref->GetLeaf("TrackReferences.fTrack")->GetValue();
	if(trkreference > -1 && trkreference < 1000000){
	  trkassociation[trkreference] = iref;
	}
      }
    }
    
    for (Int_t iTrack = 0; iTrack < ntrk; iTrack++){
      AliESDtrack* track = esd->GetTrack(iTrack);
      
      // select tracks of selected particles
      if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;//almeno un hit nell ITS
      if (track->GetConstrainedChi2() > 4) continue; //se brutto X^2
      if ((track->GetStatus() & AliESDtrack::kTOFout) == 0) continue; //se traccia matchata con tof
      if(track->GetNumberOfTPCClusters() < 70) continue;
      Float_t p =track->P();
      
      itrig = 0;
      timetrig = 0;
      
      if(p > 0.9 && p < 1.1){
 	track->GetIntegratedTimes(time);
	
	itrig = iTrack;
	timetrig = track->GetTOFsignal() - time[2];
	iTrack = ntrk;
      }
    }
    
    printf("real loop, ntrk = %i\n",ntrk);
  
    for (Int_t iTrack = 0; iTrack < ntrk; iTrack++){
      AliESDtrack* track = esd->GetTrack(iTrack);
      
      // select tracks of selected particles
      if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;//almeno un hit nell ITS
      if (track->GetConstrainedChi2() > 4) continue; //se brutto X^2
      
      //if ((track->GetStatus() & AliESDtrack::kTOFout) == 0) continue; //se traccia matchata con tof
      if(track->GetNumberOfTPCClusters() < 70) continue;

      TOFout = (track->GetStatus() & AliESDtrack::kTOFout) > 0;

      track->GetIntegratedTimes(time);
      
      Float_t dx = track->GetTOFsignalDx(); //leggo i residui tra traccia e canale tof acceso
      Float_t dz = track->GetTOFsignalDz();
      
      mism = 0;
      
      dedx = track->GetTPCsignal();
      
      Int_t label = TMath::Abs(track->GetLabel());
      if(stack){
	TParticle *part=stack->Particle(label);
	pdg = part->GetPdgCode();
      }
      
      Int_t TOFlabel[3];
      track->GetTOFLabel(TOFlabel);
      
      //  printf("%i %i %i %i\n",label,TOFlabel[0],TOFlabel[1],TOFlabel[2]);
      
      ChannelTOF[0] = track->GetTOFCalChannel();
      //      printf("geant time = %f\n",gtime);
      //getchar();
      // if(TMath::Abs(dx) > 1.25 || TMath::Abs(dz) > 1.75) continue; // is inside the pad
      
      //riempio il numro di cludter e impulso trasverso per traccia del TTree T
      ncluster=track->GetNTOFclusters();
      impulso_trasv=track->Pt();
      impulso=track->P();
      
      StartTime = pidr->GetTOFResponse().GetStartTime(track->P());
      StartTimeRes = pidr->GetTOFResponse().GetStartTimeRes(track->P());
      
      if(track->Pt() > 0.9 && track->Pt() < 1.5){  //impulso non troppo alto per separazione tra particelle
	Float_t dt = track->GetTOFsignal() - time[2] - pidr->GetTOFResponse().GetStartTime(track->P());//tempo TOF(è lo stesso di Gettime, solo che lo prendo dale tracce)(già calibrato) -ip del PI (posizione 0 e, posizione 1 mu, pos 2 PI, pos 3 K,pos 4 p) -start time
	Float_t dtKa = track->GetTOFsignal() - time[3] - pidr->GetTOFResponse().GetStartTime(track->P());
	Float_t dtPr = track->GetTOFsignal() - time[4] - pidr->GetTOFResponse().GetStartTime(track->P());
	hdt->Fill(dt);
	hdtKa->Fill(dtKa);
	hdtPr->Fill(dtPr);
      }
      
      charge = track->Charge();
      phi = track->Phi();
      eta = track->Eta();

      GetPositionAtTOF(track,mag,coord);
      phiExt = TMath::ATan2(coord[1],coord[0]);
      etaExt =  -TMath::Log(TMath::Tan(0.5*TMath::ATan2(sqrt(coord[0]*coord[0]+coord[1]*coord[1]),coord[2])));

      for (int i=0;i<(track->GetNTOFclusters());i++){
	int idummy=track->GetTOFclusterArray()[i];
        
	AliESDTOFCluster *cl = (AliESDTOFCluster *) tofcl->At(idummy);
        
	tempo[i]=cl->GetTime();
	tot[i]=cl->GetTOT();
        
	ChannelTOF[i]=cl->GetTOFchannel();
		
	if(i==0){
	  GetResolutionAtTOF(track,mag,ChannelTOF[i],res);
	}
	
	for(int im=cl->GetNMatchableTracks();im--;){ //o così o da n-1 a 0 //for(int im=cl->GetNMatchableTracks();im>0;im--) non andava bene perchè non prendeva mai lo 0  
	  
	  //	    if(track->GetNTOFclusters()==2) printf("-- %i) %f %f\n",im,cl->GetLength(im),cl->GetIntegratedTime(2,im));
	  
	  if(cl->GetTrackIndex(im) == track->GetID()){
	    exp_time_el[i] = cl->GetIntegratedTime(0,im); // pi = 2
	    exp_time_mu[i] = cl->GetIntegratedTime(1,im); // pi = 2
	    exp_time_pi[i] = cl->GetIntegratedTime(2,im); // pi = 2
	    exp_time_ka[i] = cl->GetIntegratedTime(3,im); // pi = 2
	    exp_time_pr[i] = cl->GetIntegratedTime(4,im); // pi = 2
	    L[i] = cl->GetLength(im);
	    //		  if(track->GetNTOFclusters()==2)printf("%i) %f %f\n",i,L[i],exp_time_pi[i]);
	    DeltaX[i]=cl->GetDx(im); // mettendolo dentro questo if dovrei prendere i residui di una stessa traccia
	    DeltaZ[i]=cl->GetDz(im);
	  }
	}
      }
         
      //ReMatch();
      
      Int_t jref=0;
      if(isMC){
	if(TOFlabel[0] > -1 && TOFlabel[0] < 1000000){
	  trkref->GetEvent(trkassociation[TOFlabel[0]]);
	  if(TOFlabel[0] == trkref->GetLeaf("TrackReferences.fTrack")->GetValue()){
	    //  printf("trk -> %i (%i)\n",trkref->GetLeaf("TrackReferences.fTrack")->GetValue(),trkref->GetLeaf("TrackReferences.fTrack")->GetValue(jref));	
	    while(jref > -1 && trkref->GetLeaf("TrackReferences.fTrack")->GetValue(jref) != 0){
	      //printf("det = %i\n",trkref->GetLeaf("TrackReferences.fDetectorId")->GetValue(jref));
	      if(trkref->GetLeaf("TrackReferences.fDetectorId")->GetValue(jref) == 4){
		gtime=trkref->GetLeaf("TrackReferences.fTime")->GetValue(jref)*1E+12;
		xgl = trkref->GetLeaf("TrackReferences.fX")->GetValue(jref);
		ygl = trkref->GetLeaf("TrackReferences.fY")->GetValue(jref);
		zgl = trkref->GetLeaf("TrackReferences.fZ")->GetValue(jref);
		MakeTrueRes();
		jref =  100;
	      }
	      jref++;
	    }
	  }
	}
      }
      
      
      if(TMath::Abs(label) != TOFlabel[0] && stack){
	mism=2;
	
	while(TOFlabel[0] != -1 && TOFlabel[0] != label){
	  TOFlabel[0] = stack->Particle(TOFlabel[0])->GetMother(0);
	}
	
	if(label == TOFlabel[0])
	  mism=1;	
	
      }
      
      //AddDelay();
      T->Fill(); //cout<<"riempio il tree  "<<endl; //Riempio tree "T"
    
      
      
      //incremento il contatore delle tracce del TTree T matchate e che superano i tagli
      //ntracks++;
      
    }//end of for(tracks)
      
      
    
    esd->ResetStdContent();
    
    
    
  } //end of for(events)

  if(runLoader){
    runLoader->UnloadHeader();
    runLoader->UnloadKinematics();
    delete runLoader;
  }
  
  esdFile->Close();
  if(isMC) ftrkref->Close();
  if(isMC) fgalice->Close();
}
Beispiel #4
0
void CheckSDDInESD(TString filename="AliESDs.root", Int_t optTracks=kAll){


  TFile* esdFile = TFile::Open(filename.Data());
  if (!esdFile || !esdFile->IsOpen()) {
    printf("Error in opening ESD file");
    return;
  }

  AliESDEvent * esd = new AliESDEvent;
  TTree* tree = (TTree*) esdFile->Get("esdTree");
  if (!tree) {
    printf("Error: no ESD tree found");
    return;
  }
  esd->ReadFromTree(tree);
  TH1F* hpt=new TH1F("hpt","",100,0.,10.);
  TH1F* hphi=new TH1F("hphi","",100,-1,1);
  TH1F* hlam=new TH1F("hlam","",100,-2.,2.);
  TH1F* halpha=new TH1F("halpha","",100,-7,7);
  TH1F* hitscl=new TH1F("hitscl","",7,-0.5,6.5);
  TH1F* htpccl=new TH1F("htpccl","",200,-0.5,199.5);
  TH1F* hitsmap=new TH1F("hitsmap","",64,-0.5,63.5);
  TH1F* hclulay=new TH1F("hclulay","",7,-1.5,5.5);

  TH1F* hvx=new TH1F("hvx","",100,-1.,1.);
  TH1F* hvy=new TH1F("hvy","",100,-1.,1.);
  TH1F* hvz=new TH1F("hvz","",100,-20.,20.);
  TH1F* hdedx3=new TH1F("hdedx3","",100,0.,300.);
  TH1F* hdedx4=new TH1F("hdedx4","",100,0.,300.);
  TH1F* hdedx5=new TH1F("hdedx5","",100,0.,300.);
  TH1F* hdedx6=new TH1F("hdedx6","",100,0.,300.);
  TH1F* hStatus=new TH1F("hStatus","",11,-1.5,9.5);


  // -- Local coordinates


  // -- Module histos

  TH1F* hAllPMod  = new TH1F("hAllPmod","Crossing Tracks vs. Module",260,239.5,499.5);
  TH1F* hGoodPMod  = new TH1F("hGoodPmod","PointsAssocToTrack per Module",260,239.5,499.5);
  TH1F* hBadRegMod  = new TH1F("hBadRegmod","Tracks in BadRegion per Module",260,239.5,499.5);
  TH1F* hMissPMod  = new TH1F("hMissPmod","Missing Points per Module",260,239.5,499.5);
  TH1F* hSkippedMod  = new TH1F("hSkippedmod","Tracks in Skipped Module",260,239.5,499.5);
  TH1F* hOutAccMod  = new TH1F("hOutAccmod","Tracks outside zAcc per Module",260,239.5,499.5);
  TH1F* hNoRefitMod  = new TH1F("hNoRefitmod","Points rejected in refit per Module",260,239.5,499.5);

  TH1F* hAllPXloc  = new TH1F("hAllPxloc","Crossing Tracks vs. Xloc",75, -3.75, 3.75);
  TH1F* hGoodPXloc  = new TH1F("hGoodPxloc","PointsAssocToTrack vs. Xloc",75, -3.75, 3.75);
  TH1F* hBadRegXloc  = new TH1F("hBadRegxloc","Tracks in BadRegion vs. Xloc",75, -3.75, 3.75);
  TH1F* hMissPXloc  = new TH1F("hMissPxloc","Missing Points vs. Xloc",75, -3.75, 3.75);
  TH1F* hAllPZloc  = new TH1F("hAllPzloc","Crossing Tracks vs. Zloc",77, -3.85, 3.85);
  TH1F* hGoodPZloc  = new TH1F("hGoodPzloc","PointsAssocToTrack vs. Zloc",77, -3.85, 3.85);
  TH1F* hBadRegZloc  = new TH1F("hBadRegzloc","Tracks in BadRegion vs. Zloc",77, -3.85, 3.85);
  TH1F* hMissPZloc  = new TH1F("hMissPzloc","Missing Points vs. Zloc",77, -3.85, 3.85);
  TH2F* hdEdxVsMod=new TH2F("hdEdxVsMod","dE/dx vs. mod",260,239.5,499.5,100,0.,500.);

  gStyle->SetPalette(1);
  

  for (Int_t iEvent = 0; iEvent < tree->GetEntries(); iEvent++) {
    tree->GetEvent(iEvent);
    if (!esd) {
      printf("Error: no ESD object found for event %d", iEvent);
      return;
    }
    cout<<"-------- Event "<<iEvent<<endl;
    printf(" Tracks # = %d\n",esd->GetNumberOfTracks());
    const AliESDVertex *spdv=esd->GetVertex();
    printf(" SPD Primary Vertex in %f %f %f with %d contributors\n",spdv->GetX(),spdv->GetY(),spdv->GetZ(),spdv->GetNContributors());
    const AliESDVertex *trkv=esd->GetPrimaryVertex();
    printf(" Track Primary Vertex with %d contributors\n",trkv->GetNContributors());
    if(spdv->IsFromVertexer3D()){
      hvx->Fill(spdv->GetX());
      hvy->Fill(spdv->GetY());
      hvz->Fill(spdv->GetZ());
    }
    Double_t itss[4];
    for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
      AliESDtrack* track = esd->GetTrack(iTrack);
      Int_t nITSclus=track->GetNcls(0);
      UChar_t clumap=track->GetITSClusterMap();
      Int_t nPointsForPid=0;
      for(Int_t i=2; i<6; i++){
	if(clumap&(1<<i)) ++nPointsForPid;
      }
      //      track->PropagateTo(4.,5.);
      htpccl->Fill(track->GetNcls(1));
      ULong64_t status=track->GetStatus();
      Bool_t tpcin=0;
      hStatus->Fill(-1.);
      if(status & AliESDtrack::kTPCin){
	tpcin=1;
	hStatus->Fill(0.);
      }
      if(status & AliESDtrack::kTPCout){
	hStatus->Fill(1.);
      }
      if(status & AliESDtrack::kTPCrefit){
	hStatus->Fill(2.);
      }
      Bool_t itsin=0;
      if(status & AliESDtrack::kITSin){
	itsin=1;
	hStatus->Fill(3.);
      }
      if(status & AliESDtrack::kITSout){
	hStatus->Fill(4.);
      }
      if(status & AliESDtrack::kITSrefit){
	hStatus->Fill(5.);
      }
      if(!tpcin && itsin){
	hStatus->Fill(6.);
      }
      if(status & AliESDtrack::kITSpureSA){
	hStatus->Fill(7.);
      }

      if(status & AliESDtrack::kITSrefit){
	if((optTracks==kTPCITS) && !(status & AliESDtrack::kTPCin)) continue;
	if((optTracks==kITSsa) && (status & AliESDtrack::kTPCin)) continue;
	if((optTracks==kITSsa) && (status & AliESDtrack::kITSpureSA)) continue;
	if((optTracks==kITSpureSA) && (status & AliESDtrack::kITSpureSA)) continue;

	 track->GetITSdEdxSamples(itss);
	//	printf("Track %d (label %d) in ITS with %d clusters clumap %d pointspid= %d\n",iTrack,track->GetLabel(),nITSclus,clumap,nPointsForPid);
	//printf("   dedx=%f %f %f %f\n",itss[0],itss[1],itss[2],itss[3]);
	hitscl->Fill(nITSclus);
	hdedx3->Fill(itss[0]);
	hdedx4->Fill(itss[1]);
	hdedx5->Fill(itss[2]);
	hdedx6->Fill(itss[3]);
	hitsmap->Fill(clumap);
	hclulay->Fill(-1.);
	for(Int_t iLay=0;iLay<6;iLay++){
	  if(clumap&1<<iLay) hclulay->Fill(iLay);
	}
	hpt->Fill(track->Pt());
	hphi->Fill(TMath::ASin(track->GetSnp()));
	hlam->Fill(TMath::ATan(track->GetTgl()));
	halpha->Fill(track->GetAlpha());
	Int_t iMod,status;
	Float_t xloc,zloc;
	for(Int_t iLay=2; iLay<=3; iLay++){
	  Bool_t ok=track->GetITSModuleIndexInfo(iLay,iMod,status,xloc,zloc);
	  if(ok){
	    iMod+=240;
	    hAllPMod->Fill(iMod);
	    hAllPXloc->Fill(xloc);
	    hAllPZloc->Fill(zloc);
	    if(status==1){
	      hGoodPMod->Fill(iMod);
	      hGoodPXloc->Fill(xloc);
	      hGoodPZloc->Fill(zloc);
	      if(track->Pt()>1.) hdEdxVsMod->Fill(iMod,itss[iLay-2]);
	    }
	    else if(status==2){ 
	      hBadRegMod->Fill(iMod);
	      hBadRegXloc->Fill(xloc);
	      hBadRegZloc->Fill(zloc);
	    }
	    else if(status==3) hSkippedMod->Fill(iMod);
	    else if(status==4) hOutAccMod->Fill(iMod);
	    else if(status==5){
	      hMissPMod->Fill(iMod);
	      hMissPXloc->Fill(xloc);
	      hMissPZloc->Fill(zloc);
	    }
	    else if(status==6) hNoRefitMod->Fill(iMod);
	  }
	}
      }
    }
  }
  Float_t norm=hclulay->GetBinContent(1);
  if(norm<1.) norm=1.;
  hclulay->Scale(1./norm);
  gStyle->SetLineWidth(2);

  TCanvas* c1=new TCanvas("c1","Track quantities",900,900);
  c1->Divide(2,2);
  c1->cd(1);
  htpccl->Draw();
  htpccl->GetXaxis()->SetTitle("Clusters in TPC ");
  c1->cd(2);
  hitscl->Draw();
  hitscl->GetXaxis()->SetTitle("Clusters in ITS ");
  c1->cd(3);
  hclulay->Draw();
  hclulay->GetXaxis()->SetRange(2,7);
  hclulay->GetXaxis()->SetTitle("# ITS Layer");
  hclulay->GetYaxis()->SetTitle("Fraction of tracks with point in Layer x");
  c1->cd(4);

  TCanvas* c2=new TCanvas("c2","dedx per Layer",900,900);
  c2->Divide(2,2);
  c2->cd(1);
  hdedx3->Draw();
  hdedx3->GetXaxis()->SetTitle("dE/dx Lay3");
  c2->cd(2);
  hdedx4->Draw();
  hdedx4->GetXaxis()->SetTitle("dE/dx Lay4");
  c2->cd(3);
  hdedx5->Draw();
  hdedx5->GetXaxis()->SetTitle("dE/dx Lay5");
  c2->cd(4);
  hdedx6->Draw();
  hdedx6->GetXaxis()->SetTitle("dE/dx Lay6");

  hdEdxVsMod->SetStats(0);
  TCanvas* cdedx=new TCanvas("cdedx","dedx SDD",1400,600);
  cdedx->SetLogz();
  hdEdxVsMod->Draw("col"); 
  hdEdxVsMod->GetXaxis()->SetTitle("SDD Module Id");
  hdEdxVsMod->GetYaxis()->SetTitle("dE/dx (keV/300 #mum)");
  hdEdxVsMod->GetYaxis()->SetTitleOffset(1.25);



  TCanvas* cv=new TCanvas("cv","Vertex",600,900);
  cv->Divide(1,3);
  cv->cd(1);
  hvx->Draw();
  hvx->GetXaxis()->SetTitle("Xv (cm)");
  cv->cd(2);
  hvy->Draw();
  hvy->GetXaxis()->SetTitle("Yv (cm)");
  cv->cd(3);
  hvz->Draw();
  hvz->GetXaxis()->SetTitle("Xv (cm)");

  hGoodPMod->SetStats(0);
  hGoodPMod->SetTitle("");
  TCanvas* ceff0=new TCanvas("ceff0","ModuleIndexInfo",1000,600);
  hGoodPMod->Draw("e");
  hGoodPMod->GetXaxis()->SetTitle("SDD Module Id");
  hGoodPMod->GetYaxis()->SetTitle("Number of tracks");
  hMissPMod->SetLineColor(2);
  hMissPMod->SetMarkerColor(2);
  hMissPMod->SetMarkerStyle(22);
  hMissPMod->SetMarkerSize(0.5);
  hMissPMod->Draw("psame");
  hBadRegMod->SetLineColor(kGreen+1);
  hBadRegMod->SetMarkerColor(kGreen+1);
  hBadRegMod->SetMarkerStyle(20);
  hBadRegMod->SetMarkerSize(0.5);
  hBadRegMod->Draw("esame");
  hSkippedMod->SetLineColor(kYellow);
  hSkippedMod->Draw("esame");
  hOutAccMod->SetLineColor(4);
  hOutAccMod->Draw("esame");
  hNoRefitMod->SetLineColor(6);
  hNoRefitMod->Draw("esame");
  TLatex* t1=new TLatex(0.7,0.85,"Good Point");
  t1->SetNDC();
  t1->SetTextColor(1);
  t1->Draw();
  TLatex* t2=new TLatex(0.7,0.8,"Missing Point");
  t2->SetNDC();
  t2->SetTextColor(2);
  t2->Draw();
  TLatex* t3=new TLatex(0.7,0.75,"Bad Region");
  t3->SetNDC();
  t3->SetTextColor(kGreen+1);
  t3->Draw();
  ceff0->Update();

  TH1F* heff=new TH1F("heff","",260,239.5,499.5);
  for(Int_t imod=0; imod<260;imod++){
    Float_t numer=hGoodPMod->GetBinContent(imod+1)+hBadRegMod->GetBinContent(imod+1)+hOutAccMod->GetBinContent(imod+1)+hNoRefitMod->GetBinContent(imod+1);
    Float_t denom=hAllPMod->GetBinContent(imod+1);
    Float_t eff=0.;
    Float_t erreff=0.;
    if(denom>0){
      eff=numer/denom;
      erreff=TMath::Sqrt(eff*(1-eff)/denom);
    }
    heff->SetBinContent(imod+1,eff);
    heff->SetBinError(imod+1,erreff);
  }

  printf("---- Modules with efficiency < 90%% ----\n");
  heff->SetStats(0);
  TCanvas* ceff1=new TCanvas("ceff1","Efficiency",1000,600);
  heff->Draw();
  heff->GetXaxis()->SetTitle("SDD Module Id");
  heff->GetYaxis()->SetTitle("Fraction of tracks with point in good region");
  for(Int_t ibin=1; ibin<=heff->GetNbinsX(); ibin++){
    Float_t e=heff->GetBinContent(ibin);
    if(e<0.9){
      Int_t iMod=(Int_t)heff->GetBinCenter(ibin);
      Int_t lay,lad,det;
      AliITSgeomTGeo::GetModuleId(iMod,lay,lad,det);
      printf("Module %d - Layer %d Ladder %2d Det %d  -   Eff. %.3f\n",iMod,lay,lad,det,heff->GetBinContent(ibin));
    }
  }
  ceff1->Update();



  hGoodPXloc->SetTitle("");
  hGoodPZloc->SetTitle("");
  hGoodPXloc->SetStats(0);
  hGoodPZloc->SetStats(0);
  hGoodPXloc->SetMinimum(0);
  hGoodPZloc->SetMinimum(0);
  TCanvas* ceff2=new TCanvas("ceff2","LocalCoord",1000,600);
  ceff2->Divide(2,1);
  ceff2->cd(1);
  hGoodPXloc->Draw("e");
  hGoodPXloc->GetXaxis()->SetTitle("Xlocal (cm)");
  hGoodPXloc->GetYaxis()->SetTitle("Number of tracks");
  hMissPXloc->SetLineColor(2);
  hMissPXloc->SetMarkerColor(2);
  hMissPXloc->SetMarkerStyle(22);
  hMissPXloc->SetMarkerSize(0.5);
  hMissPXloc->Draw("psame");
  hBadRegXloc->SetLineColor(kGreen+1);
  hBadRegXloc->SetMarkerColor(kGreen+1);
  hBadRegXloc->SetMarkerStyle(20);
  hBadRegXloc->SetMarkerSize(0.5);
  hBadRegXloc->Draw("psame");
  t1->Draw();
  t2->Draw();
  t3->Draw();
  ceff2->cd(2);
  hGoodPZloc->Draw("e");
  hGoodPZloc->GetXaxis()->SetTitle("Zlocal (cm)");
  hGoodPZloc->GetYaxis()->SetTitle("Number of tracks");
  hMissPZloc->SetLineColor(2);
  hMissPZloc->SetMarkerColor(2);
  hMissPZloc->SetMarkerStyle(22);
  hMissPZloc->SetMarkerSize(0.5);
  hMissPZloc->Draw("psame");
  hBadRegZloc->SetLineColor(kGreen+1);
  hBadRegZloc->SetMarkerColor(kGreen+1);
  hBadRegZloc->SetMarkerStyle(20);
  hBadRegZloc->SetMarkerSize(0.5);
  hBadRegZloc->Draw("psame");
  t1->Draw();
  t2->Draw();
  t3->Draw();
  ceff2->Update();


  
}
Beispiel #5
0
Bool_t CheckESD(const char* gAliceFileName = "galice.root", 
		const char* esdFileName = "AliESDs.root")
{
// check the content of the ESD
 
  // check values
  Int_t    checkNGenLow = 1;

  Double_t checkEffLow = 0.5;
  Double_t checkEffSigma = 3;
  Double_t checkFakeHigh = 0.5;
  Double_t checkFakeSigma = 3;

  Double_t checkResPtInvHigh = 5;
  Double_t checkResPtInvSigma = 3;
  Double_t checkResPhiHigh = 10;
  Double_t checkResPhiSigma = 3;
  Double_t checkResThetaHigh = 10;
  Double_t checkResThetaSigma = 3;

  Double_t checkPIDEffLow = 0.5;
  Double_t checkPIDEffSigma = 3;
  Double_t checkResTOFHigh = 500;
  Double_t checkResTOFSigma = 3;

  Double_t checkPHOSNLow = 5;
  Double_t checkPHOSEnergyLow = 0.3;
  Double_t checkPHOSEnergyHigh = 1.0;
  Double_t checkEMCALNLow = 50;
  Double_t checkEMCALEnergyLow = 0.05;
  Double_t checkEMCALEnergyHigh = 1.0;

  Double_t checkMUONNLow = 1;
  Double_t checkMUONPtLow = 0.5;
  Double_t checkMUONPtHigh = 10.;

  Double_t cutPtV0 = 0.3;
  Double_t checkV0EffLow = 0.02;
  Double_t checkV0EffSigma = 3;
  Double_t cutPtCascade = 0.5;
  Double_t checkCascadeEffLow = 0.01;
  Double_t checkCascadeEffSigma = 3;

  // open run loader and load gAlice, kinematics and header
  AliRunLoader* runLoader = AliRunLoader::Open(gAliceFileName);
  if (!runLoader) {
    Error("CheckESD", "getting run loader from file %s failed", 
	    gAliceFileName);
    return kFALSE;
  }
  runLoader->LoadgAlice();
  gAlice = runLoader->GetAliRun();
  if (!gAlice) {
    Error("CheckESD", "no galice object found");
    return kFALSE;
  }
  runLoader->LoadKinematics();
  runLoader->LoadHeader();

  // open the ESD file
  TFile* esdFile = TFile::Open(esdFileName);
  if (!esdFile || !esdFile->IsOpen()) {
    Error("CheckESD", "opening ESD file %s failed", esdFileName);
    return kFALSE;
  }
  AliESDEvent * esd = new AliESDEvent;
  TTree* tree = (TTree*) esdFile->Get("esdTree");
  if (!tree) {
    Error("CheckESD", "no ESD tree found");
    return kFALSE;
  }
  esd->ReadFromTree(tree);

  // efficiency and resolution histograms
  Int_t nBinsPt = 15;
  Float_t minPt = 0.1;
  Float_t maxPt = 3.1;
  TH1F* hGen = CreateHisto("hGen", "generated tracks", 
			   nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");
  TH1F* hRec = CreateHisto("hRec", "reconstructed tracks", 
			   nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");
  Int_t nGen = 0;
  Int_t nRec = 0;
  Int_t nFake = 0;

  TH1F* hResPtInv = CreateHisto("hResPtInv", "", 100, -10, 10, 
           "(p_{t,rec}^{-1}-p_{t,sim}^{-1}) / p_{t,sim}^{-1} [%]", "N");
  TH1F* hResPhi = CreateHisto("hResPhi", "", 100, -20, 20, 
			      "#phi_{rec}-#phi_{sim} [mrad]", "N");
  TH1F* hResTheta = CreateHisto("hResTheta", "", 100, -20, 20, 
				"#theta_{rec}-#theta_{sim} [mrad]", "N");

  // PID
  Int_t partCode[AliPID::kSPECIES] = 
    {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
  const char* partName[AliPID::kSPECIES+1] = 
    {"electron", "muon", "pion", "kaon", "proton", "other"};
  Double_t partFrac[AliPID::kSPECIES] = 
    {0.01, 0.01, 0.85, 0.10, 0.05};
  Int_t identified[AliPID::kSPECIES+1][AliPID::kSPECIES];
  for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) {
    for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
      identified[iGen][iRec] = 0;
    }
  }
  Int_t nIdentified = 0;

  // dE/dx and TOF
  TH2F* hDEdxRight = new TH2F("hDEdxRight", "", 300, 0, 3, 100, 0, 400);
  hDEdxRight->SetStats(kFALSE);
  hDEdxRight->GetXaxis()->SetTitle("p [GeV/c]");
  hDEdxRight->GetYaxis()->SetTitle("dE/dx_{TPC}");
  hDEdxRight->SetMarkerStyle(kFullCircle);
  hDEdxRight->SetMarkerSize(0.4);
  TH2F* hDEdxWrong = new TH2F("hDEdxWrong", "", 300, 0, 3, 100, 0, 400);
  hDEdxWrong->SetStats(kFALSE);
  hDEdxWrong->GetXaxis()->SetTitle("p [GeV/c]");
  hDEdxWrong->GetYaxis()->SetTitle("dE/dx_{TPC}");
  hDEdxWrong->SetMarkerStyle(kFullCircle);
  hDEdxWrong->SetMarkerSize(0.4);
  hDEdxWrong->SetMarkerColor(kRed);
  TH1F* hResTOFRight = CreateHisto("hResTOFRight", "", 100, -1000, 1000, 
				   "t_{TOF}-t_{track} [ps]", "N");
  TH1F* hResTOFWrong = CreateHisto("hResTOFWrong", "", 100, -1000, 1000, 
				   "t_{TOF}-t_{track} [ps]", "N");
  hResTOFWrong->SetLineColor(kRed);

  // calorimeters
  TH1F* hEPHOS = CreateHisto("hEPHOS", "PHOS", 100, 0, 50, "E [GeV]", "N");
  TH1F* hEEMCAL = CreateHisto("hEEMCAL", "EMCAL", 100, 0, 50, "E [GeV]", "N");

  // muons
  TH1F* hPtMUON = CreateHisto("hPtMUON", "MUON", 100, 0, 20, 
			      "p_{t} [GeV/c]", "N");

  // V0s and cascades
  TH1F* hMassK0 = CreateHisto("hMassK0", "K^{0}", 100, 0.4, 0.6, 
			      "M(#pi^{+}#pi^{-}) [GeV/c^{2}]", "N");
  TH1F* hMassLambda = CreateHisto("hMassLambda", "#Lambda", 100, 1.0, 1.2, 
				  "M(p#pi^{-}) [GeV/c^{2}]", "N");
  TH1F* hMassLambdaBar = CreateHisto("hMassLambdaBar", "#bar{#Lambda}", 
				     100, 1.0, 1.2, 
				     "M(#bar{p}#pi^{+}) [GeV/c^{2}]", "N");
  Int_t nGenV0s = 0;
  Int_t nRecV0s = 0;
  TH1F* hMassXi = CreateHisto("hMassXi", "#Xi", 100, 1.2, 1.5, 
			      "M(#Lambda#pi) [GeV/c^{2}]", "N");
  TH1F* hMassOmega = CreateHisto("hMassOmega", "#Omega", 100, 1.5, 1.8, 
				 "M(#LambdaK) [GeV/c^{2}]", "N");
  Int_t nGenCascades = 0;
  Int_t nRecCascades = 0;

  // loop over events
  for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
    runLoader->GetEvent(iEvent);

    // select simulated primary particles, V0s and cascades
    AliStack* stack = runLoader->Stack();
    Int_t nParticles = stack->GetNtrack();
    TArrayF vertex(3);
    runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(vertex);
    TObjArray selParticles;
    TObjArray selV0s;
    TObjArray selCascades;
    for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {
      TParticle* particle = stack->Particle(iParticle);
      if (!particle) continue;
      if (particle->Pt() < 0.001) continue;
      if (TMath::Abs(particle->Eta()) > 0.9) continue;
      TVector3 dVertex(particle->Vx() - vertex[0], 
		       particle->Vy() - vertex[1],
		       particle->Vz() - vertex[2]);
      if (dVertex.Mag() > 0.0001) continue;

      switch (TMath::Abs(particle->GetPdgCode())) {
      case kElectron:
      case kMuonMinus:
      case kPiPlus:
      case kKPlus:
      case kProton: {
	if (particle->Pt() > minPt) {
	  selParticles.Add(particle);
	  nGen++;
	  hGen->Fill(particle->Pt());
	}
	break;
      }
      case kK0Short:
      case kLambda0: {
	if (particle->Pt() > cutPtV0) {
	  nGenV0s++;
	  selV0s.Add(particle);
	}
	break;
      }
      case kXiMinus:
      case kOmegaMinus: {
	if (particle->Pt() > cutPtCascade) {
	  nGenCascades++;
	  selCascades.Add(particle);
	}
	break;
      }
      default: break;
      }
    }

    // get the event summary data
    tree->GetEvent(iEvent);
    if (!esd) {
      Error("CheckESD", "no ESD object found for event %d", iEvent);
      return kFALSE;
    }

    // loop over tracks
    for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
      AliESDtrack* track = esd->GetTrack(iTrack);

      // select tracks of selected particles
      Int_t label = TMath::Abs(track->GetLabel());
      if (label > stack->GetNtrack()) continue;     // background
      TParticle* particle = stack->Particle(label);
      if (!selParticles.Contains(particle)) continue;
      if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;
      if (track->GetConstrainedChi2() > 1e9) continue;
      selParticles.Remove(particle);   // don't count multiple tracks

      nRec++;
      hRec->Fill(particle->Pt());
      if (track->GetLabel() < 0) nFake++;

      // resolutions
      hResPtInv->Fill(100. * (TMath::Abs(track->GetSigned1Pt()) - 1./particle->Pt()) * 
		      particle->Pt());
      hResPhi->Fill(1000. * (track->Phi() - particle->Phi()));
      hResTheta->Fill(1000. * (track->Theta() - particle->Theta()));

      // PID
      if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) continue;
      Int_t iGen = 5;
      for (Int_t i = 0; i < AliPID::kSPECIES; i++) {
	if (TMath::Abs(particle->GetPdgCode()) == partCode[i]) iGen = i;
      }
      Double_t probability[AliPID::kSPECIES];
      track->GetESDpid(probability);
      Double_t pMax = 0;
      Int_t iRec = 0;
      for (Int_t i = 0; i < AliPID::kSPECIES; i++) {
	probability[i] *= partFrac[i];
	if (probability[i] > pMax) {
	  pMax = probability[i];
	  iRec = i;
	}
      }
      identified[iGen][iRec]++;
      if (iGen == iRec) nIdentified++;

      // dE/dx and TOF
      Double_t time[AliPID::kSPECIES];
      track->GetIntegratedTimes(time);
      if (iGen == iRec) {
	hDEdxRight->Fill(particle->P(), track->GetTPCsignal());
        if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) {
	  hResTOFRight->Fill(track->GetTOFsignal() - time[iRec]);
	}
      } else {
	hDEdxWrong->Fill(particle->P(), track->GetTPCsignal());
        if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) {
	  hResTOFWrong->Fill(track->GetTOFsignal() - time[iRec]);
	}
      }
    }

    // loop over muon tracks
    {
    for (Int_t iTrack = 0; iTrack < esd->GetNumberOfMuonTracks(); iTrack++) {
      AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
      Double_t ptInv = TMath::Abs(muonTrack->GetInverseBendingMomentum());
      if (ptInv > 0.001) {
	hPtMUON->Fill(1./ptInv);
      }
    }
    }

    // loop over V0s
    for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) {
      AliESDv0* v0 = esd->GetV0(iV0);
      if (v0->GetOnFlyStatus()) continue;
      v0->ChangeMassHypothesis(kK0Short);
      hMassK0->Fill(v0->GetEffMass());
      v0->ChangeMassHypothesis(kLambda0);
      hMassLambda->Fill(v0->GetEffMass());
      v0->ChangeMassHypothesis(kLambda0Bar);
      hMassLambdaBar->Fill(v0->GetEffMass());

      Int_t negLabel = TMath::Abs(esd->GetTrack(v0->GetNindex())->GetLabel());
      if (negLabel > stack->GetNtrack()) continue;     // background
      Int_t negMother = stack->Particle(negLabel)->GetMother(0);
      if (negMother < 0) continue;
      Int_t posLabel = TMath::Abs(esd->GetTrack(v0->GetPindex())->GetLabel());
      if (posLabel > stack->GetNtrack()) continue;     // background
      Int_t posMother = stack->Particle(posLabel)->GetMother(0);
      if (negMother != posMother) continue;
      TParticle* particle = stack->Particle(negMother);
      if (!selV0s.Contains(particle)) continue;
      selV0s.Remove(particle);
      nRecV0s++;
    }

    // loop over Cascades
    for (Int_t iCascade = 0; iCascade < esd->GetNumberOfCascades(); 
	 iCascade++) {
      AliESDcascade* cascade = esd->GetCascade(iCascade);
      Double_t v0q;
      cascade->ChangeMassHypothesis(v0q,kXiMinus);
      hMassXi->Fill(cascade->GetEffMassXi());
      cascade->ChangeMassHypothesis(v0q,kOmegaMinus);
      hMassOmega->Fill(cascade->GetEffMassXi());

      Int_t negLabel = TMath::Abs(esd->GetTrack(cascade->GetNindex())
				  ->GetLabel());
      if (negLabel > stack->GetNtrack()) continue;     // background
      Int_t negMother = stack->Particle(negLabel)->GetMother(0);
      if (negMother < 0) continue;
      Int_t posLabel = TMath::Abs(esd->GetTrack(cascade->GetPindex())
				  ->GetLabel());
      if (posLabel > stack->GetNtrack()) continue;     // background
      Int_t posMother = stack->Particle(posLabel)->GetMother(0);
      if (negMother != posMother) continue;
      Int_t v0Mother = stack->Particle(negMother)->GetMother(0);
      if (v0Mother < 0) continue;
      Int_t bacLabel = TMath::Abs(esd->GetTrack(cascade->GetBindex())
				  ->GetLabel());
      if (bacLabel > stack->GetNtrack()) continue;     // background
      Int_t bacMother = stack->Particle(bacLabel)->GetMother(0);
      if (v0Mother != bacMother) continue;
      TParticle* particle = stack->Particle(v0Mother);
      if (!selCascades.Contains(particle)) continue;
      selCascades.Remove(particle);
      nRecCascades++;
    }

    // loop over the clusters
    {
      for (Int_t iCluster=0; iCluster<esd->GetNumberOfCaloClusters(); iCluster++) {
	AliESDCaloCluster * clust = esd->GetCaloCluster(iCluster);
	if (clust->IsPHOS()) hEPHOS->Fill(clust->E());
	if (clust->IsEMCAL()) hEEMCAL->Fill(clust->E());
      }
    }

  }

  // perform checks
  if (nGen < checkNGenLow) {
    Warning("CheckESD", "low number of generated particles: %d", Int_t(nGen));
  }

  TH1F* hEff = CreateEffHisto(hGen, hRec);

  Info("CheckESD", "%d out of %d tracks reconstructed including %d "
	 "fake tracks", nRec, nGen, nFake);
  if (nGen > 0) {
    // efficiency
    Double_t eff = nRec*1./nGen;
    Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGen);
    Double_t fake = nFake*1./nGen;
    Double_t fakeError = TMath::Sqrt(fake*(1.-fake) / nGen);
    Info("CheckESD", "eff = (%.1f +- %.1f) %%  fake = (%.1f +- %.1f) %%",
	 100.*eff, 100.*effError, 100.*fake, 100.*fakeError);

    if (eff < checkEffLow - checkEffSigma*effError) {
      Warning("CheckESD", "low efficiency: (%.1f +- %.1f) %%", 
	      100.*eff, 100.*effError);
    }
    if (fake > checkFakeHigh + checkFakeSigma*fakeError) {
      Warning("CheckESD", "high fake: (%.1f +- %.1f) %%", 
	      100.*fake, 100.*fakeError);
    }

    // resolutions
    Double_t res, resError;
    if (FitHisto(hResPtInv, res, resError)) {
      Info("CheckESD", "relative inverse pt resolution = (%.1f +- %.1f) %%",
	   res, resError);
      if (res > checkResPtInvHigh + checkResPtInvSigma*resError) {
	Warning("CheckESD", "bad pt resolution: (%.1f +- %.1f) %%", 
		res, resError);
      }
    }

    if (FitHisto(hResPhi, res, resError)) {
      Info("CheckESD", "phi resolution = (%.1f +- %.1f) mrad", res, resError);
      if (res > checkResPhiHigh + checkResPhiSigma*resError) {
	Warning("CheckESD", "bad phi resolution: (%.1f +- %.1f) mrad", 
		res, resError);
      }
    }

    if (FitHisto(hResTheta, res, resError)) {
      Info("CheckESD", "theta resolution = (%.1f +- %.1f) mrad", 
	   res, resError);
      if (res > checkResThetaHigh + checkResThetaSigma*resError) {
	Warning("CheckESD", "bad theta resolution: (%.1f +- %.1f) mrad", 
		res, resError);
      }
    }

    // PID
    if (nRec > 0) {
      Double_t eff = nIdentified*1./nRec;
      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nRec);
      Info("CheckESD", "PID eff = (%.1f +- %.1f) %%", 
	   100.*eff, 100.*effError);
      if (eff < checkPIDEffLow - checkPIDEffSigma*effError) {
	Warning("CheckESD", "low PID efficiency: (%.1f +- %.1f) %%", 
		100.*eff, 100.*effError);
      }
    }

    printf("%9s:", "gen\\rec");
    for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
      printf("%9s", partName[iRec]);
    }
    printf("\n");
    for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) {
      printf("%9s:", partName[iGen]);
      for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
	printf("%9d", identified[iGen][iRec]);
      }
      printf("\n");
    }

    if (FitHisto(hResTOFRight, res, resError)) {
      Info("CheckESD", "TOF resolution = (%.1f +- %.1f) ps", res, resError);
      if (res > checkResTOFHigh + checkResTOFSigma*resError) {
	Warning("CheckESD", "bad TOF resolution: (%.1f +- %.1f) ps", 
		res, resError);
      }
    }

    // calorimeters
    if (hEPHOS->Integral() < checkPHOSNLow) {
      Warning("CheckESD", "low number of PHOS particles: %d", 
	      Int_t(hEPHOS->Integral()));
    } else {
      Double_t mean = hEPHOS->GetMean();
      if (mean < checkPHOSEnergyLow) {
	Warning("CheckESD", "low mean PHOS energy: %.1f GeV", mean);
      } else if (mean > checkPHOSEnergyHigh) {
	Warning("CheckESD", "high mean PHOS energy: %.1f GeV", mean);
      }
    }

    if (hEEMCAL->Integral() < checkEMCALNLow) {
      Warning("CheckESD", "low number of EMCAL particles: %d", 
	      Int_t(hEEMCAL->Integral()));
    } else {
      Double_t mean = hEEMCAL->GetMean();
      if (mean < checkEMCALEnergyLow) {
	Warning("CheckESD", "low mean EMCAL energy: %.1f GeV", mean);
      } else if (mean > checkEMCALEnergyHigh) {
	Warning("CheckESD", "high mean EMCAL energy: %.1f GeV", mean);
      }
    }

    // muons
    if (hPtMUON->Integral() < checkMUONNLow) {
      Warning("CheckESD", "low number of MUON particles: %d", 
	      Int_t(hPtMUON->Integral()));
    } else {
      Double_t mean = hPtMUON->GetMean();
      if (mean < checkMUONPtLow) {
	Warning("CheckESD", "low mean MUON pt: %.1f GeV/c", mean);
      } else if (mean > checkMUONPtHigh) {
	Warning("CheckESD", "high mean MUON pt: %.1f GeV/c", mean);
      }
    }

    // V0s
    if (nGenV0s > 0) {
      Double_t eff = nRecV0s*1./nGenV0s;
      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenV0s);
      if (effError == 0) effError = checkV0EffLow / TMath::Sqrt(1.*nGenV0s);
      Info("CheckESD", "V0 eff = (%.1f +- %.1f) %%", 
	   100.*eff, 100.*effError);
      if (eff < checkV0EffLow - checkV0EffSigma*effError) {
	Warning("CheckESD", "low V0 efficiency: (%.1f +- %.1f) %%", 
		100.*eff, 100.*effError);
      }
    }

    // Cascades
    if (nGenCascades > 0) {
      Double_t eff = nRecCascades*1./nGenCascades;
      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenCascades);
      if (effError == 0) effError = checkV0EffLow / 
			   TMath::Sqrt(1.*nGenCascades);
      Info("CheckESD", "Cascade eff = (%.1f +- %.1f) %%", 
	   100.*eff, 100.*effError);
      if (eff < checkCascadeEffLow - checkCascadeEffSigma*effError) {
	Warning("CheckESD", "low Cascade efficiency: (%.1f +- %.1f) %%", 
		100.*eff, 100.*effError);
      }
    }
  }

  // draw the histograms if not in batch mode
  if (!gROOT->IsBatch()) {
    new TCanvas;
    hEff->DrawCopy();
    new TCanvas;
    hResPtInv->DrawCopy("E");
    new TCanvas;
    hResPhi->DrawCopy("E");
    new TCanvas;
    hResTheta->DrawCopy("E");
    new TCanvas;
    hDEdxRight->DrawCopy();
    hDEdxWrong->DrawCopy("SAME");
    new TCanvas;
    hResTOFRight->DrawCopy("E");
    hResTOFWrong->DrawCopy("SAME");
    new TCanvas;
    hEPHOS->DrawCopy("E");
    new TCanvas;
    hEEMCAL->DrawCopy("E");
    new TCanvas;
    hPtMUON->DrawCopy("E");
    new TCanvas;
    hMassK0->DrawCopy("E");
    new TCanvas;
    hMassLambda->DrawCopy("E");
    new TCanvas;
    hMassLambdaBar->DrawCopy("E");
    new TCanvas;
    hMassXi->DrawCopy("E");
    new TCanvas;
    hMassOmega->DrawCopy("E");
  }

  // write the output histograms to a file
  TFile* outputFile = TFile::Open("check.root", "recreate");
  if (!outputFile || !outputFile->IsOpen()) {
    Error("CheckESD", "opening output file check.root failed");
    return kFALSE;
  }
  hEff->Write();
  hResPtInv->Write();
  hResPhi->Write();
  hResTheta->Write();
  hDEdxRight->Write();
  hDEdxWrong->Write();
  hResTOFRight->Write();
  hResTOFWrong->Write();
  hEPHOS->Write();
  hEEMCAL->Write();
  hPtMUON->Write();
  hMassK0->Write();
  hMassLambda->Write();
  hMassLambdaBar->Write();
  hMassXi->Write();
  hMassOmega->Write();
  outputFile->Close();
  delete outputFile;

  // clean up
  delete hGen;
  delete hRec;
  delete hEff;
  delete hResPtInv;
  delete hResPhi;
  delete hResTheta;
  delete hDEdxRight;
  delete hDEdxWrong;
  delete hResTOFRight;
  delete hResTOFWrong;
  delete hEPHOS;
  delete hEEMCAL;
  delete hPtMUON;
  delete hMassK0;
  delete hMassLambda;
  delete hMassLambdaBar;
  delete hMassXi;
  delete hMassOmega;

  delete esd;
  esdFile->Close();
  delete esdFile;

  runLoader->UnloadHeader();
  runLoader->UnloadKinematics();
  delete runLoader;

  // result of check
  Info("CheckESD", "check of ESD was successfull");
  return kTRUE;
}
Beispiel #6
0
Bool_t CheckESD(const char* gAliceFileName = "galice.root", 
		const char* esdFileName = "AliESDs.root")
{
  // open run loader and load gAlice, kinematics and header
  AliRunLoader* runLoader = AliRunLoader::Open(gAliceFileName);
  if (!runLoader) {
    Error("CheckESD", "getting run loader from file %s failed", 
	    gAliceFileName);
    return kFALSE;
  }
  runLoader->LoadgAlice();
  gAlice = runLoader->GetAliRun();
  if (!gAlice) {
    Error("CheckESD", "no galice object found");
    return kFALSE;
  }
  runLoader->LoadKinematics();
  runLoader->LoadHeader();

  // open the ESD file
  TFile* esdFile = TFile::Open(esdFileName);
  if (!esdFile || !esdFile->IsOpen()) {
    Error("CheckESD", "opening ESD file %s failed", esdFileName);
    return kFALSE;
  }
  AliESDEvent * esd = new AliESDEvent;
  TTree* tree = (TTree*) esdFile->Get("esdTree");
  if (!tree) {
    Error("CheckESD", "no ESD tree found");
    return kFALSE;
  }
  esd->ReadFromTree(tree);

  // loop over events
  for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
    runLoader->GetEvent(iEvent);

    // get the event summary data
    tree->GetEvent(iEvent);
    if (!esd) {
      Error("CheckESD", "no ESD object found for event %d", iEvent);
      return kFALSE;
    }

  }

  // write the output histograms to a file
  TFile* outputFile = TFile::Open("check.root", "recreate");
  if (!outputFile || !outputFile->IsOpen()) {
    Error("CheckESD", "opening output file check.root failed");
    return kFALSE;
  }
  outputFile->Close();
  delete outputFile;

  delete esd;
  esdFile->Close();
  delete esdFile;

  runLoader->UnloadHeader();
  runLoader->UnloadKinematics();
  delete runLoader;

  // result of check
  Info("CheckESD", "check of ESD was successfull");
  return kTRUE;
}
Beispiel #7
0
void ExtractOutputHistos(Bool_t onlyPrims=0,Bool_t onlyPion=0,Int_t plotFlag=0) {

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

  const Int_t nbins=20;
  Double_t ptmin=0.06;//04;
  Double_t ptmax=2.0;//GeV
  Double_t logxmin = TMath::Log10(ptmin);
  Double_t logxmax = TMath::Log10(ptmax);
  Double_t binwidth = (logxmax-logxmin)/(nbins+1);
  enum {nb=nbins+1};
  Double_t xbins[nb];
  xbins[0] = ptmin;
  for (Int_t i=1;i<=nbins;i++) {
    xbins[i] = ptmin + TMath::Power(10,logxmin+(i)*binwidth);
    //    cout<<xbins[i]<<endl;
  }
  //  TH1F *h = new TH1F("h","hist with log x axis",nbins,xbins);

  TH1F *hMultCount = new TH1F("mult","averaged multiplicity (charg. prim)",80,-4.,4.);
  hMultCount->GetXaxis()->SetTitle("eta");
  hMultCount->GetYaxis()->SetTitle("N/d#eta");

  TH1F *hAllMC = new TH1F("allMC","All Tracks MC primaries",nbins,xbins);
  TH1F *hAllFound = new TH1F("allFound","All Tracks found",nbins,xbins);
  TH1F *hImperfect = new TH1F("imperfect","Imperfect tracks",nbins,xbins);
  TH1F *hPerfect = new TH1F("perfect","Perfect tracks",nbins,xbins);
  TH1F *hEff = new TH1F("efficiency","Efficiency (Perfect tracks in \"ALL MC\")",nbins,xbins);
  TH1F *hFake = new TH1F("fake","Fake tracks (Inperfect tracks in \"ALL MC\")",nbins,xbins);
  TH1F *hPurity = new TH1F("purity","Purity (Perfect tracks in \"All Found\")",nbins,xbins);
  TH1F *hAnna = new TH1F("annaEff","AnnalisaEff ",nbins,xbins);
  TH1F *hNoMCTrack = new TH1F("noMCtrack","noMCtrack ",nbins,xbins);

  TH1F *hEta = new TH1F("","",50,-2,2);
  //  TH1F *hEtaMC = new TH1F("","",50,-2,2);

  TH2D *h2Ddca = new TH2D("dca2D","DCAvsPt2D",nbins,xbins,50,-0.05,0.05);
  TH2D *h2Dpt = new TH2D("dPt2D","dPtdvsPt2D",nbins,xbins,50,-25,25);

  // open run loader and load gAlice, kinematics and header
  AliRunLoader* runLoader = AliRunLoader::Open("galice.root");
  if (!runLoader) {
    Error("Check kine", "getting run loader from file %s failed",
          "galice.root");
    return;
  }
  runLoader->LoadgAlice();
  gAlice = runLoader->GetAliRun();
  if (!gAlice) {
    Error("Check kine", "no galice object found");
    return;
  }
  runLoader->LoadHeader();
  runLoader->LoadKinematics();

  TFile* esdFile = TFile::Open("AliESDs.root");
  if (!esdFile || !esdFile->IsOpen()) {
    Error("CheckESD", "opening ESD file %s failed", "AliESDs.root");
    return;
  }
  AliESDEvent *esd = new AliESDEvent();
  TTree* tree = (TTree*) esdFile->Get("esdTree");
  if (!tree) {
    Error("CheckESD", "no ESD tree found");
    return;
  }
  esd->ReadFromTree(tree);
  
  Int_t nTrackTotalMC = 0;
  Int_t nTrackFound = 0;
  Int_t nTrackImperfect = 0;
  Int_t nTrackPerfect = 0;
  Int_t nNoMCTrack = 0;

  
  for(Int_t iEv =0; iEv<tree->GetEntries(); iEv++){
    tree->GetEvent(iEv);
    runLoader->GetEvent(iEv);
    
    printf("+++ event %i (of %lld) +++++++++++++++++++++++  # ESDtracks: %d \n",iEv,tree->GetEntries()-1,esd->GetNumberOfTracks());
    Int_t nESDtracks = esd->GetNumberOfTracks();
    for (Int_t iTrack = 0; iTrack < nESDtracks; iTrack++) {
      AliESDtrack* track = esd->GetTrack(iTrack);
      if (!(iTrack%1000)) printf("event %i: ESD track count %d (of %d)\n",iEv,iTrack,nESDtracks);

      Int_t label = track->GetLabel();
  
      Int_t idx[12];
      //      Int_t ncl = track->GetITSclusters(idx);
   
      if(label<0) {
	//	cout<< " ESD track label " << label;
	//	cout<<"  ---> imperfect track (label "<<label<<"<0) !! -> track Pt: "<< track->Pt() << endl;
      }

      AliStack* stack = runLoader->Stack();
      //     nTrackTotalMC += stack->GetNprimary();
    

      TParticle* particle = stack->Particle(TMath::Abs(label)); 
      Double_t pt = track->Pt();
      
      if(particle) {

	if (TMath::Abs(particle->Eta())>etaCut) continue;

	Double_t ptMC = particle->Pt();

	// Efficiencies
	if (onlyPion && TMath::Abs(particle->GetPdgCode())!=211) continue;

	if ( (!onlyPrims) || stack->IsPhysicalPrimary(TMath::Abs(label))) {
	  //  cout<<" # clusters "<<ncl<<endl;

	  nTrackFound++;
	  hAllFound->Fill(ptMC);
	  hEta->Fill(track->Eta());
	  
	  if (label<0) {
	    nTrackImperfect++;
	    hImperfect->Fill(ptMC);
	  } else {
	    nTrackPerfect++;
	    hPerfect->Fill(ptMC);
	  }

	}


	// following only for "true tracks, pions

	if(particle->Pt() < 0.001)continue;
	if (TMath::Abs(particle->GetPdgCode())!=211) continue;
	if (label>0) {
	  
	  // Impact parameters for Pions only
	  Double_t dca = track->GetD(0,0,0.5);
	  h2Ddca->Fill(ptMC,dca);
	  
	  // Pt resolution for Pions only
	  Double_t dPt = (pt-ptMC)/ptMC*100;
	  h2Dpt->Fill(ptMC,dPt);
	}

      } else {
	nNoMCTrackFound++;
	hNoMCTrack->Fill(pt);
	cout<<" according MC particle not found"<<endl;
      }
      
    } //entries track esd
  

  }//entries tree
  runLoader->UnloadHeader();
  runLoader->UnloadKinematics();
  delete runLoader;

 
  // Count trackable MC tracks
  CountTrackableMCs(hAllMC, onlyPrims, onlyPion);


  // Count trackable MC tracks
  CountPrimaries(hMultCount);

 


  // Get Errors right
  hMultCount->Sumw2();
  hAllMC->Sumw2();   
  hAllFound->Sumw2();
  hPerfect->Sumw2(); 
  hImperfect->Sumw2(); 
  h2Dpt->Sumw2();
  h2Ddca->Sumw2();

  // -- Global efficienies

  nTrackTotalMC = hAllMC->GetEntries();
  Double_t eff = ((Double_t)nTrackPerfect)/nTrackTotalMC;
  printf("-> Total number of events: %lld -> MCtracks %d -> nPerfect %d  -> Eff: %3.2lf \n",
	 tree->GetEntries(),nTrackTotalMC,nTrackPerfect,eff);

  Double_t purity = ((Double_t)nTrackPerfect)/nTrackFound;
  printf("-> Total number of events: %lld -> FoundTracks %d -> nPerfect %d  -> Purity: %3.2lf \n",
	 tree->GetEntries(),nTrackFound,nTrackPerfect,purity);

  // Efficiencies - and normalize to 100%

  TF1 f1("f1","100+x*0",0.,1.e3);

  hPurity->Divide(hPerfect,hAllFound,1,1,"b"); 
  hPurity->Multiply(&f1);
  hPurity->SetMarkerColor(kGreen);
  hPurity->SetMarkerStyle(21);
  hPurity->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
  hPurity->SetStats(0);

  hPurity->GetYaxis()->SetRangeUser(0,100);
  hPurity->SetTitle("Efficiency & Purity");

  hEff->Divide(hPerfect,hAllMC,1,1,"b");
  hEff->Multiply(&f1);
  hEff->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
  hEff->SetMarkerColor(kBlue);
  hEff->SetMarkerStyle(21);
  hEff->SetStats(0);

  hFake->Divide(hImperfect,hAllMC,1,1,"b");
  hFake->Multiply(&f1);
  hFake->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
  hFake->SetMarkerColor(kRed);
  hFake->SetMarkerStyle(21);
  hFake->SetStats(0);


  hAnna->Divide(hAllFound,hAllMC,1,1,"b");
  hAnna->Multiply(&f1);
  hAnna->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
  hAnna->SetMarkerColor(kBlack);
  hAnna->SetMarkerStyle(21);
  hAnna->SetStats(0);

  TCanvas *c1 = new TCanvas("c1","NoMCTrackFound");//,200,10,900,900);
  TVirtualPad *pad =   c1->cd();
  pad->SetGridx();   pad->SetGridy();
  hNoMCTrack->Draw();

  TCanvas *c2 = new TCanvas("c2","Eff&Purity");//,200,10,900,900);
  TVirtualPad *pad =   c2->cd();
  pad->SetGridx();   pad->SetGridy();
  //  pad->SetLogx();

  hPurity->Draw("E");
  hEff->Draw("Same E");
  hFake->Draw("Same E");
  hAnna->Draw("Same E");

  TLegend *leg = new TLegend(0.1,0.8,0.6,0.9);leg->SetFillColor(0);
  leg->AddEntry(hPurity,"Purity (\"Perfect tracks\" within \"Found Tracks\")","PE");
  leg->AddEntry(hEff,"Efficiency (\"Perfect tracks\" within \"MC findable Tracks\")","PE");
  leg->AddEntry(hFake,"Fake (\"Inperfect tracks\" within \"MC findable Tracks\")","PE");
  leg->AddEntry(hAnna,"AnnaLisa - Efficiency (\"Found tracks\" within \"MC findable Tracks\")","PE");
  leg->Draw();


  if (plotFlag==1){
    hAllMC->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
    hAllMC->Draw();  // MC pt distribution
    hAllFound->SetLineColor(2);
    hAllFound->Draw("same");  // MC pt distribution
  }
 
 
  /*

  .L ~/ITSupgrade/BuildDetector/DetectorK.cxx+
  
  // All NEW
  DetectorK its("ALICE","ITS");
  its.MakeAliceAllNew(0);
  its.SetMaxRadiusOfSlowDetectors(0.01);
  its.SolveViaBilloir(0);
  TGraph *c = its.GetGraphRecoEfficiency(0,3,2);
  c->Draw("C");


  // Current
  DetectorK its("ALICE","ITS");
  its.MakeAliceCurrent(0,0);
  its.SetMaxRadiusOfSlowDetectors(0.01);
  its.SolveViaBilloir(0);
  TGraph *c = its.GetGraphRecoEfficiency(0,4,2);
  c->Draw("C");

  */

  TCanvas *c3 = new TCanvas("c3","impact");//,200,10,900,900);
  c3->Divide(2,1); c3->cd(1);
  // Impact parameter

  // Impact parameter resolution ---------------
  h2Ddca->Draw("colz");
  h2Ddca->FitSlicesY() ;
  TH2D *dcaM = (TH2D*)gDirectory->Get("dca2D_1"); dcaM->Draw("same");
  TH2D *dcaRMS = (TH2D*)gDirectory->Get("dca2D_2"); //dcaRMS->Draw();
  TGraphErrors *d0 = new TGraphErrors(); 
  for (Int_t ibin =1; ibin<=dcaRMS->GetXaxis()->GetNbins(); ibin++) {
    d0->SetPoint(     ibin-1,dcaRMS->GetBinCenter(ibin),dcaRMS->GetBinContent(ibin)*1e4); // microns
    d0->SetPointError(ibin-1,0,dcaRMS->GetBinError(ibin)*1e4); // microns
  }
  d0->SetMarkerStyle(21);
  d0->SetMaximum(200);  d0->SetMinimum(0);
  d0->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
  d0->GetYaxis()->SetTitle("R-#phi Pointing Resolution (#mum)");
  d0->SetName("dca");  d0->SetTitle("DCAvsPt");

  c3->cd(1);  h2Ddca->Draw("surf2");
  c3->cd(2);  d0->Draw("APE");

  // PT RESOLUTION ------------
  TCanvas *c4 = new TCanvas("c4","pt resolution");//,200,10,900,900);
  c4->Divide(2,1); c4->cd(1);
  // Impact parameter
  h2Dpt->Draw("colz");
  h2Dpt->FitSlicesY() ;
  TH2D *dPtM = (TH2D*)gDirectory->Get("dPt2D_1"); dPtM->Draw("same");
  TH2D *dPtRMS = (TH2D*)gDirectory->Get("dPt2D_2"); // dPtRMS->Draw("");
  TGraphErrors *gPt = new TGraphErrors(); 
  for (Int_t ibin =1; ibin<=dPtRMS->GetXaxis()->GetNbins(); ibin++) {
    gPt->SetPoint(     ibin-1,dPtRMS->GetBinCenter(ibin),dPtRMS->GetBinContent(ibin)); 
    gPt->SetPointError(ibin-1,0,dPtRMS->GetBinError(ibin)); 
  }
  gPt->SetMarkerStyle(21);
  gPt->SetMaximum(20);  gPt->SetMinimum(0);
  gPt->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
  gPt->GetYaxis()->SetTitle("relative momentum resolution (%)");
  gPt->SetName("dPt");  gPt->SetTitle("DPTvsPt");

  c4->cd(1);  h2Dpt->Draw("surf2");
  c4->cd(2);  gPt->Draw("APE");


  // EXPORT --------

  TFile f("histos.root","RECREATE");

  hMultCount->Write();
  hAllMC->Write();
  hAllFound->Write();
  hImperfect->Write();
  hPerfect->Write();
  hNoMCTrack->Write();

  hPurity->Write();
  hEff->Write();
  hFake->Write();
  hAnna->Write();

  h2Ddca->Write();
  d0->Write();

  h2Dpt->Write();
  gPt->Write();

  f.Close();

  return;

}
Beispiel #8
0
void MatchComparison()
{
	//
	// Initialize AliRun manager
	//
	
	//
	// Initialize run loader and load Kinematics
	//
	AliRunLoader *runLoader = AliRunLoader::Open("galice.root");
	if (!runLoader) return;
	runLoader->LoadgAlice();
	gAlice = runLoader->GetAliRun();
	runLoader->LoadKinematics();
	
	//
	// Initialize histograms with their error computation
	//
	TH1D *hgood  = new TH1D("hgood", "Well matched tracks", 40, 0.0,  40.0);
	TH1D *hfake  = new TH1D("hfake", "Fake matched tracks", 40, 0.0,  40.0);
	TH1D *htrue  = new TH1D("htrue", "True matches"       , 40, 0.0,  40.0);
	TH1D *hfound = new TH1D("hfound","Found matches"      , 40, 0.0,  40.0);
	hgood->Sumw2();
	hfake->Sumw2();
	htrue->Sumw2();
	hfound->Sumw2();
	
	//
	// Open file containing true matches,
	// retrieve the Tree and link to a cursor.
	//
	TFile *fileTrue = TFile::Open("true-matches.root");
	match_t trueMatch;
	
	//
	// Open file of found matches,
	// link the modified ESD container.
	//
	TFile *fileFound = TFile::Open("matchESD.root");
	TTree *treeFound = (TTree*)fileFound->Get("esdTree");
	AliESDEvent* esd = new AliESDEvent();
	esd->ReadFromTree(treeFound);
	Long64_t nEvents = treeFound->GetEntries();
	
	//
	// Loop on all events
	//
	Int_t im, it, ic, nTrueMatches, nTracks;
	Int_t label, trkLabel, cluLabel;
	for (Long64_t iev = 0; iev < nEvents; iev++) {
		
		// get true matches tree of given event
		TTree *treeTrue = (TTree*)fileTrue->Get(Form("tm_%d", iev));
		treeTrue->SetBranchAddress("matches", &trueMatch);
		nTrueMatches = treeTrue->GetEntries();
		
		// set TTree pointers to selected event
		runLoader->GetEvent(iev);
		treeFound->GetEntry(iev);
		AliStack *stack = runLoader->Stack();
		nTracks = esd->GetNumberOfTracks();
		
		// read all true pairs
		for (im = 0; im < nTrueMatches; im++) {
			treeTrue->GetEntry(im);
			AliESDtrack *track = esd->GetTrack(trueMatch.indexT);
			if (!track) continue;
			
			label = TMath::Abs(track->GetLabel());
			TParticle *p = stack->Particle(label);
			htrue->Fill(p->Pt());
			cout <<"filling true"<< endl;
		}
		
		// compare found matches
		for (Int_t it = 0; it < nTracks; it++) {
			AliESDtrack *track = esd->GetTrack(it);
			ic = track->GetEMCALcluster();
			if (ic == AliEMCALTracker::kUnmatched) continue;
			ic = TMath::Abs(ic);
			AliESDCaloCluster *cl = esd->GetCaloCluster(ic);
			if (!cl) continue;
			if (!cl->IsEMCAL()) continue ;
			trkLabel = TMath::Abs(track->GetLabel());
			cluLabel = cl->GetLabel();
			if (trkLabel == cluLabel && trkLabel >= 0) {
				TParticle *p = stack->Particle(TMath::Abs(trkLabel));
				hgood->Fill(p->Pt());
				hfound->Fill(p->Pt());
				cout <<"filling GOOD, pt:" << p->Pt()<< endl;
			}
			else  {
				TParticle *p = stack->Particle(TMath::Abs(trkLabel));
				hfake->Fill(p->Pt());
				hfound->Fill(p->Pt());
				cout <<"filling FAKE" << endl;
			}
		}
	}
	
	cout << "True matches : " << htrue->GetEntries() << endl;
	cout << "Found matches: " << hfound->GetEntries() << endl;
	cout << "Good matches : " << hgood->GetEntries() << endl;
	cout << "Fake matches : " << hfake->GetEntries() << endl;
	
	TFile *fout = TFile::Open("match-comparison.root", "RECREATE");
	hgood->Write();
	hfake->Write();
	htrue->Write();
	hfound->Write();
	fout->Close();
}
Beispiel #9
0
void CheckESD(const char* fileNameE="AliESDsTmp.root",const char* fileNameR="alien:///alice/data/2010/LHC10h/000137549/ESDs/pass1_4plus/10000137549001.100/AliESDs.root") {
	
	Int_t nev = 10;
	Int_t nskip = 0;
	const char* fileNameM = "AliESDs.root";
	const char *trgname;
	
	if (gSystem->Getenv("DC_ESDFILE")) {
    fileNameR = gSystem->Getenv("DC_ESDFILE");
  }
  if (gSystem->Getenv("DC_NEVENTS")) {
    nev = atoi(gSystem->Getenv("DC_NEVENTS"));
  }
	if (gSystem->Getenv("DC_TRGNAME")) {
    trgname = gSystem->Getenv("DC_TRGNAME");
  }
	if (gSystem->Getenv("DC_EEVENT")) {
		nskip = atoi(gSystem->Getenv("DC_EEVENT"));
	}
	
	if (!gGrid) TGrid::Connect("alien://");
  TFile *_fileE = TFile::Open(fileNameE);
  TFile *_fileR = TFile::Open(fileNameR);
  AliESDEvent* esdE = new AliESDEvent();
  AliESDEvent* esdR = new AliESDEvent();
	
	AliESDRun* runM = 0x0;
	AliESDHeader* headM = 0x0;
	AliESDZDC* zdcM = 0x0;
	AliESDVZERO* vzeroM = 0x0;
	AliMultiplicity *multM = 0x0;
	
	TTree* treeESDE;
  TTree* treeESDR;
  _fileE->GetObject("esdTree", treeESDE);
  _fileR->GetObject("esdTree", treeESDR);
  esdE->ReadFromTree(treeESDE);
  esdR->ReadFromTree(treeESDR);
	
	// Output ESDs
	TFile *_fileM = TFile::Open(fileNameM, "RECREATE");
	TTree *treeESDM = new TTree("esdTree", "Tree with ESD objects");
  AliESDEvent *esdM = new AliESDEvent();
  esdM->CreateStdContent();
	esdM->WriteToTree(treeESDM);
	
  Int_t nEventsE = treeESDE->GetEntries();
  Int_t nEventsR = treeESDR->GetEntries();
  Int_t nEvents = TMath::Min(nEventsE,nEventsR);
	nEvents = TMath::Min(nEvents,nev);
	Int_t lastSelectedEvent = -1;
	if (nskip>0) {
		printf("We will skip %d events\n",nskip);
		lastSelectedEvent = nskip-1;
	}
  for (Int_t iEv=0; iEv<nEvents; iEv++) {
    printf("Event %i\n",iEv);
		
    treeESDE->GetEvent(iEv);
		if (trgname) {
			for (Int_t jEv=lastSelectedEvent+1; jEv<nEventsR; jEv++) {
				treeESDR->GetEvent(jEv);
				
				TString firedTrigClasses = esdR->GetFiredTriggerClasses();
				if (firedTrigClasses.Contains(trgname)) {
					lastSelectedEvent = jEv;
					break;
				}
			}
		}	else {
			treeESDR->GetEvent(iEv);
			lastSelectedEvent = iEv;
		}
		printf("and Event %i\n",lastSelectedEvent);
		
    // Copy the esd event from the Merged (Signal) reconstrcution
		*esdM = *esdE;
		
		// Replace some branches with those from original esd event
		runM = dynamic_cast<AliESDRun *>(esdM->FindListObject("AliESDRun"));
		*runM = *(dynamic_cast<AliESDRun *>(esdR->FindListObject("AliESDRun")));
		headM = dynamic_cast<AliESDHeader *>(esdM->FindListObject("AliESDHeader"));
		*headM = *(dynamic_cast<AliESDHeader *>(esdR->FindListObject("AliESDHeader")));
		zdcM = dynamic_cast<AliESDZDC *>(esdM->FindListObject("AliESDZDC"));
		*zdcM = *(dynamic_cast<AliESDZDC *>(esdR->FindListObject("AliESDZDC")));
		vzeroM = dynamic_cast<AliESDVZERO *>(esdM->FindListObject("AliESDVZERO"));
		*vzeroM = *(dynamic_cast<AliESDVZERO *>(esdR->FindListObject("AliESDVZERO")));
		multM = dynamic_cast<AliMultiplicity *>(esdM->FindListObject("AliMultiplicity"));
		*multM = *(dynamic_cast<AliMultiplicity *>(esdR->FindListObject("AliMultiplicity")));
		
		treeESDM->Fill();
  }
	_fileM->cd();
	treeESDM->Write(treeESDM->GetName(),TObject::kOverwrite);
	_fileM->Close();
	
}