]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDTagCreator.cxx
promoted 2 methods to public needed by AMORE
[u/mrichter/AliRoot.git] / STEER / AliESDTagCreator.cxx
index 5a3bc76d6a80d7521e0e595379403e5a07d426cd..856cee5ae7809efcd248b38c3474c5750f23f8c0 100644 (file)
@@ -30,6 +30,8 @@
 #include <TObjString.h>
 #include <TLorentzVector.h>
 #include <TMap.h>
+#include <TTimeStamp.h>
+#include <TRefArray.h>
 
 //ROOT-AliEn
 #include <TGrid.h>
@@ -42,6 +44,7 @@
 #include "AliESDEvent.h"
 #include "AliESDVertex.h"
 #include "AliLog.h"
+#include "AliGRPObject.h"
 
 #include "AliESDTagCreator.h"
 
@@ -193,7 +196,7 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
   //private method that creates tag files
   TString fSession = type;
   TString fguid, fmd5, fturl;
-  TString fTempGuid = 0;
+  TString fTempGuid;
 
   /////////////
   //muon code//
@@ -206,11 +209,11 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
   Int_t fCharge;
   TLorentzVector fEPvector;
 
-  Float_t fZVertexCut = 10.0; 
-  Float_t fRhoVertexCut = 2.0; 
+  Float_t fZVertexCut    = 10.0; 
+  Float_t fRhoVertexCut  =  2.0; 
 
-  Float_t fLowPtCut = 1.0;
-  Float_t fHighPtCut = 3.0;
+  Float_t fLowPtCut      =  1.0;
+  Float_t fHighPtCut     =  3.0;
   Float_t fVeryHighPtCut = 10.0;
   ////////////
 
@@ -219,13 +222,13 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
   // Creates the tags for all the events in a given ESD file
   Bool_t fIsSim = kTRUE;
   Int_t ntrack;
-  Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
+  Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
   Int_t nPos, nNeg, nNeutr;
   Int_t nK0s, nNeutrons, nPi0s, nGamas;
   Int_t nCh1GeV, nCh3GeV, nCh10GeV;
   Int_t nMu1GeV, nMu3GeV, nMu10GeV;
   Int_t nEl1GeV, nEl3GeV, nEl10GeV;
-  Float_t maxPt = .0, meanPt = .0, totalP = .0;
+  Float_t maxPt = .0, etamaxPt = -999., phimaxPt = -999., meanPt = .0, totalP = .0;
   Int_t fVertexflag;
   Int_t iRunNumber = 0;
   TString fVertexName;
@@ -255,7 +258,8 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
   localFileName += ".ESD.tag.root";
 
   TString fileName;
-  
+  TRefArray tmp;
   if(fStorage == 0) {
     fileName = localFileName.Data();      
     AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
@@ -276,19 +280,23 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
 
   AliRunTag *tag = new AliRunTag();
   AliEventTag *evTag = new AliEventTag();
-  TTree ttag("T","A Tree with event tags");
-  TBranch * btag = ttag.Branch("AliTAG", &tag);
+  TTree * ttag = new TTree("T","A Tree with event tags");
+  TBranch * btag = ttag->Branch("AliTAG", &tag);
   btag->SetCompressionLevel(9);
-
+  // Run related information
+  tag->SetMagneticField(esd->GetMagneticField());
+  tag->SetBeamEnergy(esd->GetBeamEnergy());
+  tag->SetBeamType(TString(esd->GetBeamType()));
+  
   for(Int_t iEventNumber = 0; iEventNumber < chain->GetEntries(); iEventNumber++) {
     ntrack = 0; nPos = 0; nNeg = 0; nNeutr =0;
     nK0s = 0; nNeutrons = 0; nPi0s = 0;
     nGamas = 0; nProtons = 0; nKaons = 0;
-    nPions = 0; nMuons = 0; nElectrons = 0;      
+    nPions = 0; nMuons = 0; nElectrons = 0; nFWMuons = 0;        
     nCh1GeV = 0; nCh3GeV = 0; nCh10GeV = 0;
     nMu1GeV = 0; nMu3GeV = 0; nMu10GeV = 0;
     nEl1GeV = 0; nEl3GeV = 0; nEl10GeV = 0;
-    maxPt = .0; meanPt = .0; totalP = .0;
+    maxPt = .0; etamaxPt = -999.; phimaxPt = -999.; meanPt = .0; totalP = .0;
     fVertexflag = 1;
     
     chain->GetEntry(iEventNumber);    
@@ -327,11 +335,16 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
       if ((status&AliESDtrack::kESDpid)==0) continue;
       Double_t p[3];
       esdTrack->GetPxPyPz(p);
-      Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
-      Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2));
+      Double_t pt2 = p[0]*p[0]+p[1]*p[1];
+      Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
+      Double_t fPt = TMath::Sqrt(pt2);
       totalP += momentum;
       meanPt += fPt;
-      if(fPt > maxPt) maxPt = fPt;
+      if(fPt > maxPt) {
+         maxPt = fPt;
+         phimaxPt = esdTrack->Phi();
+         etamaxPt = esdTrack->Eta();
+      }
       
       if(esdTrack->GetSign() > 0) {
        nPos++;
@@ -405,6 +418,7 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
       // total number of muons inside a vertex cut 
       if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
        nMuons++;
+       nFWMuons++;
        if(fEPvector.Pt() > fLowPtCut) {
          nMu1GeV++; 
          if(fEPvector.Pt() > fHighPtCut) {
@@ -424,10 +438,25 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
     //AliInfo(Form("URL: %s - GUID: %s",fturl.Data(),fguid.Data()));
     //AliInfo(Form("====================================="));
 
-    evTag->SetEventId(iEventNumber+1);
+    //First physics data
+    const AliMultiplicity *spdMult = esd->GetMultiplicity();
+    evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
+    evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
+    evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
+
+    AliESDVZERO *vzeroData = esd->GetVZEROData();
+    evTag->SetMTotV0A(vzeroData->GetMTotV0A());
+    evTag->SetMTotV0C(vzeroData->GetMTotV0C());
+    evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
+    evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
+
+    //evTag->SetEventId(iEventNumber+1);
+    evTag->SetPeriodNumber(esd->GetPeriodNumber());
+    evTag->SetOrbitNumber(esd->GetOrbitNumber());
+    evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
     evTag->SetGUID(fguid);
     if(fSession == "grid") {
-      evTag->SetMD5(0);
+      evTag->SetMD5("");
       evTag->SetTURL(fturl);
       evTag->SetSize(0);
     }
@@ -466,6 +495,7 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
     evTag->SetNumOfKaons(nKaons);
     evTag->SetNumOfPions(nPions);
     evTag->SetNumOfMuons(nMuons);
+    evTag->SetNumOfFWMuons(nFWMuons);
     evTag->SetNumOfElectrons(nElectrons);
     evTag->SetNumOfPhotons(nGamas);
     evTag->SetNumOfPi0s(nPi0s);
@@ -482,12 +512,16 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
     evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
     evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
     
-    evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters());
-    evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters());
+    tmp.Clear();
+    evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
+    tmp.Clear();
+    evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
     
     evTag->SetTotalMomentum(totalP);
     evTag->SetMeanPt(meanPt);
     evTag->SetMaxPt(maxPt);
+    evTag->SetEtaMaxPt(etamaxPt);
+    evTag->SetPhiMaxPt(phimaxPt);
     
     tag->SetRunId(iInitRunNumber);
     if(fIsSim) tag->SetDataType(0);
@@ -495,13 +529,13 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
 
     if(fguid != fTempGuid) {
       fTempGuid = fguid;
-      ttag.Fill();
+      ttag->Fill();
       tag->Clear("");
     }
     tag->AddEventTag(*evTag);
     if(iEventNumber+1 == chain->GetEntries()) {
       //AliInfo(Form("File: %s",fturl.Data()));
-      ttag.Fill();
+      ttag->Fill();
       tag->Clear("");
     }      
   }//event loop
@@ -519,7 +553,7 @@ void AliESDTagCreator::CreateTag(TChain* chain, const char *type) {
 
   ftag->cd();
   tag->Clear();
-  ttag.Write();
+  ttag->Write();
   ftag->Close();
 
   //gSystem->GetMemInfo(meminfo);
@@ -563,21 +597,22 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5,
   // Creates the tags for all the events in a given ESD file
   Bool_t fIsSim = kTRUE;
   Int_t ntrack;
-  Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
+  Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
   Int_t nPos, nNeg, nNeutr;
   Int_t nK0s, nNeutrons, nPi0s, nGamas;
   Int_t nCh1GeV, nCh3GeV, nCh10GeV;
   Int_t nMu1GeV, nMu3GeV, nMu10GeV;
   Int_t nEl1GeV, nEl3GeV, nEl10GeV;
-  Float_t maxPt = .0, meanPt = .0, totalP = .0;
+  Float_t maxPt = .0, etamaxPt = -999., phimaxPt = -999., meanPt = .0, totalP = .0;
   Int_t fVertexflag;
   Int_t iRunNumber = 0;
   TString fVertexName;
+  TRefArray tmp;
 
   AliRunTag *tag = new AliRunTag();
   AliEventTag *evTag = new AliEventTag();
-  TTree ttag("T","A Tree with event tags");
-  TBranch * btag = ttag.Branch("AliTAG", &tag);
+  TTree * ttag = new TTree("T","A Tree with event tags");
+  TBranch * btag = ttag->Branch("AliTAG", &tag);
   btag->SetCompressionLevel(9);
   gSystem->GetMemInfo(meminfo);
   AliInfo(Form("After the tag initialization - Memory used: %d MB",meminfo->fMemUsed));
@@ -611,6 +646,7 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5,
     nKaons = 0;
     nPions = 0;
     nMuons = 0;
+    nFWMuons = 0;
     nElectrons = 0;      
     nCh1GeV = 0;
     nCh3GeV = 0;
@@ -622,6 +658,8 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5,
     nEl3GeV = 0;
     nEl10GeV = 0;
     maxPt = .0;
+    etamaxPt = -999.;
+    phimaxPt = -999.;
     meanPt = .0;
     totalP = .0;
     fVertexflag = 1;
@@ -648,12 +686,18 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5,
       if ((status&AliESDtrack::kESDpid)==0) continue;
       Double_t p[3];
       esdTrack->GetPxPyPz(p);
-      Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
-      Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2));
+      Double_t pt2 = p[0]*p[0]+p[1]*p[1];
+      Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
+      Double_t fPt = TMath::Sqrt(pt2);
       totalP += momentum;
       meanPt += fPt;
-      if(fPt > maxPt) maxPt = fPt;
+      if(fPt > maxPt) {
+         maxPt = fPt;
+         etamaxPt = esdTrack->Eta();
+         phimaxPt = esdTrack->Phi();
+      }
       
+             
       if(esdTrack->GetSign() > 0) {
        nPos++;
        if(fPt > fLowPtCut) nCh1GeV++;
@@ -726,6 +770,7 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5,
       // total number of muons inside a vertex cut 
       if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
        nMuons++;
+       nFWMuons++;
        if(fEPvector.Pt() > fLowPtCut) {
          nMu1GeV++; 
          if(fEPvector.Pt() > fHighPtCut) {
@@ -741,7 +786,23 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5,
     // Fill the event tags 
     if(ntrack != 0) meanPt = meanPt/ntrack;
     
-    evTag->SetEventId(iEventNumber+1);
+    //First physics data
+    const AliMultiplicity *spdMult = esd->GetMultiplicity();
+    evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
+    evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
+    evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
+
+    AliESDVZERO *vzeroData = esd->GetVZEROData();
+    evTag->SetMTotV0A(vzeroData->GetMTotV0A());
+    evTag->SetMTotV0C(vzeroData->GetMTotV0C());
+    evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
+    evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
+
+    //evTag->SetEventId(iEventNumber+1);
+    evTag->SetPeriodNumber(esd->GetPeriodNumber());
+    evTag->SetOrbitNumber(esd->GetOrbitNumber());
+    evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
+
     evTag->SetGUID(fguid);
     evTag->SetMD5(fmd5);
     evTag->SetTURL(fturl);
@@ -779,6 +840,7 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5,
     evTag->SetNumOfKaons(nKaons);
     evTag->SetNumOfPions(nPions);
     evTag->SetNumOfMuons(nMuons);
+    evTag->SetNumOfFWMuons(nFWMuons);
     evTag->SetNumOfElectrons(nElectrons);
     evTag->SetNumOfPhotons(nGamas);
     evTag->SetNumOfPi0s(nPi0s);
@@ -795,12 +857,16 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5,
     evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
     evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
     
-    evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters());
-    evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters());
+    tmp.Clear();
+    evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
+    tmp.Clear();
+    evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
     
     evTag->SetTotalMomentum(totalP);
     evTag->SetMeanPt(meanPt);
     evTag->SetMaxPt(maxPt);
+    evTag->SetEtaMaxPt(etamaxPt);
+    evTag->SetPhiMaxPt(phimaxPt);
     
     tag->SetRunId(iInitRunNumber);
     if(fIsSim) tag->SetDataType(0);
@@ -842,9 +908,9 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *guid, const char *md5,
 
   TFile* ftag = TFile::Open(fileName, "recreate");
   ftag->cd();
-  ttag.Fill();
+  ttag->Fill();
   tag->Clear();
-  ttag.Write();
+  ttag->Write();
   ftag->Close();
 
   gSystem->GetMemInfo(meminfo);
@@ -886,21 +952,22 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
   // Creates the tags for all the events in a given ESD file
   Bool_t fIsSim = kTRUE;
   Int_t ntrack;
-  Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
+  Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
   Int_t nPos, nNeg, nNeutr;
   Int_t nK0s, nNeutrons, nPi0s, nGamas;
   Int_t nCh1GeV, nCh3GeV, nCh10GeV;
   Int_t nMu1GeV, nMu3GeV, nMu10GeV;
   Int_t nEl1GeV, nEl3GeV, nEl10GeV;
-  Float_t maxPt = .0, meanPt = .0, totalP = .0;
+  Float_t maxPt = .0, etamaxPt = -999, phimaxPt = -999., meanPt = .0, totalP = .0;
   Int_t fVertexflag;
   Int_t iRunNumber = 0;
   TString fVertexName;
+  TRefArray tmp;
 
   AliRunTag *tag = new AliRunTag();
   AliEventTag *evTag = new AliEventTag();
-  TTree ttag("T","A Tree with event tags");
-  TBranch * btag = ttag.Branch("AliTAG", &tag);
+  TTree * ttag = new TTree("T","A Tree with event tags");
+  TBranch * btag = ttag->Branch("AliTAG", &tag);
   btag->SetCompressionLevel(9);
   
   AliInfo(Form("Creating the ESD tags......."));       
@@ -928,6 +995,7 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
     nKaons = 0;
     nPions = 0;
     nMuons = 0;
+    nFWMuons = 0;
     nElectrons = 0;      
     nCh1GeV = 0;
     nCh3GeV = 0;
@@ -939,6 +1007,8 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
     nEl3GeV = 0;
     nEl10GeV = 0;
     maxPt = .0;
+    etamaxPt = -999.;
+    phimaxPt = -999.;
     meanPt = .0;
     totalP = .0;
     fVertexflag = 1;
@@ -965,11 +1035,17 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
       if ((status&AliESDtrack::kESDpid)==0) continue;
       Double_t p[3];
       esdTrack->GetPxPyPz(p);
-      Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
-      Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2));
+      Double_t pt2 = p[0]*p[0]+p[1]*p[1];
+      Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
+      Double_t fPt = TMath::Sqrt(pt2);
       totalP += momentum;
       meanPt += fPt;
-      if(fPt > maxPt) maxPt = fPt;
+      if(fPt > maxPt) {
+         maxPt = fPt;
+         etamaxPt = esdTrack->Eta();
+         phimaxPt = esdTrack->Phi();
+      }
+      
       
       if(esdTrack->GetSign() > 0) {
        nPos++;
@@ -1043,6 +1119,7 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
       // total number of muons inside a vertex cut 
       if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
        nMuons++;
+       nFWMuons++;
        if(fEPvector.Pt() > fLowPtCut) {
          nMu1GeV++; 
          if(fEPvector.Pt() > fHighPtCut) {
@@ -1058,7 +1135,22 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
     // Fill the event tags 
     if(ntrack != 0) meanPt = meanPt/ntrack;
     
-    evTag->SetEventId(iEventNumber+1);
+    //First physics data
+    const AliMultiplicity *spdMult = esd->GetMultiplicity();
+    evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
+    evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
+    evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
+
+    AliESDVZERO *vzeroData = esd->GetVZEROData();
+    evTag->SetMTotV0A(vzeroData->GetMTotV0A());
+    evTag->SetMTotV0C(vzeroData->GetMTotV0C());
+    evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
+    evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
+
+    //evTag->SetEventId(iEventNumber+1);
+    evTag->SetPeriodNumber(esd->GetPeriodNumber());
+    evTag->SetOrbitNumber(esd->GetOrbitNumber());
+    evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
     evTag->SetPath(filepath);
  
     evTag->SetVertexX(vertexIn->GetXv());
@@ -1094,6 +1186,7 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
     evTag->SetNumOfKaons(nKaons);
     evTag->SetNumOfPions(nPions);
     evTag->SetNumOfMuons(nMuons);
+    evTag->SetNumOfFWMuons(nFWMuons);
     evTag->SetNumOfElectrons(nElectrons);
     evTag->SetNumOfPhotons(nGamas);
     evTag->SetNumOfPi0s(nPi0s);
@@ -1110,12 +1203,16 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
     evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
     evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
     
-    evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters());
-    evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters());
+    tmp.Clear();
+    evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
+    tmp.Clear();
+    evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
     
     evTag->SetTotalMomentum(totalP);
     evTag->SetMeanPt(meanPt);
     evTag->SetMaxPt(maxPt);
+    evTag->SetEtaMaxPt(etamaxPt);
+    evTag->SetPhiMaxPt(phimaxPt);
     
     tag->SetRunId(iInitRunNumber);
     if(fIsSim) tag->SetDataType(0);
@@ -1150,9 +1247,9 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
 
   TFile* ftag = TFile::Open(fileName, "recreate");
   ftag->cd();
-  ttag.Fill();
+  ttag->Fill();
   tag->Clear();
-  ttag.Write();
+  ttag->Write();
   ftag->Close();
 
   delete ftag;
@@ -1162,11 +1259,21 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
 }
 
 //_____________________________________________________________________________
-void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TMap */* grpData */) {
+void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, AliGRPObject *grpData, ULong_t * qa, Bool_t * es, Int_t qalength, Int_t eslength) {
   //GRP
   Float_t lhcLuminosity = 0.0;
   TString lhcState = "test";
-  UInt_t detectorMask = 0;
+  //UInt_t detectorMask = 0;
+  Int_t detectorMask = 0;
+
+  detectorMask = grpData->GetDetectorMask();
+  time_t startTime = grpData->GetTimeStart();
+  TTimeStamp *t1 = new TTimeStamp(startTime);
+  time_t endTime = grpData->GetTimeEnd();
+  TTimeStamp *t2 = new TTimeStamp(endTime);
+  const char* beamtype = grpData->GetBeamType();
+  Float_t beamenergy = grpData->GetBeamEnergy();
+
 
   /////////////
   //muon code//
@@ -1191,16 +1298,17 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TMap *
 
   // Creates the tags for all the events in a given ESD file
   Int_t ntrack;
-  Int_t nProtons, nKaons, nPions, nMuons, nElectrons;
+  Int_t nProtons, nKaons, nPions, nMuons, nElectrons, nFWMuons;
   Int_t nPos, nNeg, nNeutr;
   Int_t nK0s, nNeutrons, nPi0s, nGamas;
   Int_t nCh1GeV, nCh3GeV, nCh10GeV;
   Int_t nMu1GeV, nMu3GeV, nMu10GeV;
   Int_t nEl1GeV, nEl3GeV, nEl10GeV;
-  Float_t maxPt = .0, meanPt = .0, totalP = .0;
+  Float_t maxPt = .0, etamaxPt = -999., phimaxPt = -999., meanPt = .0, totalP = .0;
   Int_t fVertexflag;
   Int_t iRunNumber = 0;
   TString fVertexName("default");
+  TRefArray tmp;
   
   AliInfo(Form("Creating the ESD tags......."));       
 
@@ -1232,8 +1340,8 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TMap *
  
   AliRunTag *tag = new AliRunTag();
   AliEventTag *evTag = new AliEventTag();
-  TTree ttag("T","A Tree with event tags");
-  TBranch * btag = ttag.Branch("AliTAG", &tag);
+  TTree * ttag = new TTree("T","A Tree with event tags");
+  TBranch * btag = ttag->Branch("AliTAG", &tag);
   btag->SetCompressionLevel(9);
 
   if(fLastEvent != -1) iNumberOfEvents = fLastEvent + 1;
@@ -1250,6 +1358,7 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TMap *
     nKaons = 0;
     nPions = 0;
     nMuons = 0;
+    nFWMuons = 0;
     nElectrons = 0;      
     nCh1GeV = 0;
     nCh3GeV = 0;
@@ -1261,6 +1370,8 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TMap *
     nEl3GeV = 0;
     nEl10GeV = 0;
     maxPt = .0;
+    etamaxPt = -999.;
+    phimaxPt = -999.;
     meanPt = .0;
     totalP = .0;
     fVertexflag = 0;
@@ -1285,11 +1396,16 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TMap *
       if ((status&AliESDtrack::kESDpid)==0) continue;
       Double_t p[3];
       esdTrack->GetPxPyPz(p);
-      Double_t momentum = sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
-      Double_t fPt = sqrt(pow(p[0],2) + pow(p[1],2));
+      Double_t pt2 = p[0]*p[0]+p[1]*p[1];
+      Double_t momentum = TMath::Sqrt(pt2+p[2]*p[2]);
+      Double_t fPt = TMath::Sqrt(pt2);
       totalP += momentum;
       meanPt += fPt;
-      if(fPt > maxPt) maxPt = fPt;
+      if(fPt > maxPt) {
+         maxPt = fPt;
+         phimaxPt = esdTrack->Eta();
+         etamaxPt = esdTrack->Phi();
+      }
       
       if(esdTrack->GetSign() > 0) {
        nPos++;
@@ -1363,6 +1479,7 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TMap *
       // total number of muons inside a vertex cut 
       if((TMath::Abs(fZ)<fZVertexCut) && (TMath::Sqrt(fY*fY+fX*fX)<fRhoVertexCut)) {
        nMuons++;
+       nFWMuons++;
        if(fEPvector.Pt() > fLowPtCut) {
          nMu1GeV++; 
          if(fEPvector.Pt() > fHighPtCut) {
@@ -1374,12 +1491,28 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TMap *
        }
       }
     }//muon track loop
+
     
     // Fill the event tags 
     if(ntrack != 0)
       meanPt = meanPt/ntrack;
-    
-    evTag->SetEventId(iEventNumber+1);
+
+    //First physics data
+    const AliMultiplicity *spdMult = esd->GetMultiplicity();
+    evTag->SetNumberOfFiredChipsLayer1(spdMult->GetNumberOfFiredChips(0));
+    evTag->SetNumberOfFiredChipsLayer2(spdMult->GetNumberOfFiredChips(1));
+    evTag->SetNumberOfSPDTracklets(spdMult->GetNumberOfTracklets());
+
+    AliESDVZERO *vzeroData = esd->GetVZEROData();
+    evTag->SetMTotV0A(vzeroData->GetMTotV0A());
+    evTag->SetMTotV0C(vzeroData->GetMTotV0C());
+    evTag->SetNbPMV0A(vzeroData->GetNbPMV0A());
+    evTag->SetNbPMV0C(vzeroData->GetNbPMV0C());
+
+    //evTag->SetEventId(iEventNumber+1);
+    evTag->SetPeriodNumber(esd->GetPeriodNumber());
+    evTag->SetOrbitNumber(esd->GetOrbitNumber());
+    evTag->SetBunchCrossNumber(esd->GetBunchCrossNumber());
     if (vertexIn) {
       evTag->SetVertexX(vertexIn->GetXv());
       evTag->SetVertexY(vertexIn->GetYv());
@@ -1415,6 +1548,7 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TMap *
     evTag->SetNumOfKaons(nKaons);
     evTag->SetNumOfPions(nPions);
     evTag->SetNumOfMuons(nMuons);
+    evTag->SetNumOfFWMuons(nFWMuons);
     evTag->SetNumOfElectrons(nElectrons);
     evTag->SetNumOfPhotons(nGamas);
     evTag->SetNumOfPi0s(nPi0s);
@@ -1431,24 +1565,37 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TMap *
     evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
     evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
     
-    evTag->SetNumOfPHOSClusters(esd->GetNumberOfPHOSClusters());
-    evTag->SetNumOfEMCALClusters(esd->GetNumberOfEMCALClusters());
+    tmp.Clear();
+    evTag->SetNumOfPHOSClusters(esd->GetPHOSClusters(&tmp));
+    tmp.Clear();
+    evTag->SetNumOfEMCALClusters(esd->GetEMCALClusters(&tmp));
     
     evTag->SetTotalMomentum(totalP);
     evTag->SetMeanPt(meanPt);
     evTag->SetMaxPt(maxPt);
+    evTag->SetEtaMaxPt(etamaxPt);
+    evTag->SetPhiMaxPt(phimaxPt);
     
     tag->SetLHCTag(lhcLuminosity,lhcState);
     tag->SetDetectorTag(detectorMask);
 
     tag->SetRunId(iInitRunNumber);
+    tag->SetRunStartTime(t1->GetDate());
+    tag->SetRunStopTime(t2->GetDate());
+    tag->SetBeamEnergy(beamenergy);
+    tag->SetBeamType(beamtype);
+    
+    //QA setting 
+    tag->SetQAArray(qa, qalength) ; 
+    tag->SetEventSpecies(es, eslength) ;
+
     tag->AddEventTag(*evTag);
   }
        
   ftag->cd();
-  ttag.Fill();
+  ttag->Fill();
   tag->Clear();
-  ttag.Write();
+  ttag->Write();
   ftag->Close();
   file->cd();
   delete tag;