]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDTagCreator.cxx
Getter for Interaction record added
[u/mrichter/AliRoot.git] / STEER / AliESDTagCreator.cxx
index c0a8544813f7a6aa351b220dd445ed7969d175f8..cf088e1c276909a75ffe459c4bae8232a21f14ba 100644 (file)
@@ -29,6 +29,9 @@
 #include <TList.h>
 #include <TObjString.h>
 #include <TLorentzVector.h>
+#include <TMap.h>
+#include <TTimeStamp.h>
+#include <TRefArray.h>
 
 //ROOT-AliEn
 #include <TGrid.h>
@@ -41,6 +44,7 @@
 #include "AliESDEvent.h"
 #include "AliESDVertex.h"
 #include "AliLog.h"
+#include "AliGRPObject.h"
 
 #include "AliESDTagCreator.h"
 
@@ -188,11 +192,11 @@ Bool_t AliESDTagCreator::ReadCAFCollection(const char *filename) {
 }
 
 //_____________________________________________________________________________
-void AliESDTagCreator::CreateTag(TChain* fChain, const char *type) {
+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//
@@ -218,13 +222,13 @@ void AliESDTagCreator::CreateTag(TChain* fChain, 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;
@@ -237,7 +241,7 @@ void AliESDTagCreator::CreateTag(TChain* fChain, const char *type) {
   
   Int_t firstEvent = 0,lastEvent = 0;
   AliESDEvent *esd = new AliESDEvent();
-  esd->ReadFromTree(fChain);
+  esd->ReadFromTree(chain);
   AliESD *esdold = 0x0;
   
   //gSystem->GetMemInfo(meminfo);
@@ -245,16 +249,17 @@ void AliESDTagCreator::CreateTag(TChain* fChain, const char *type) {
   //tempmem = meminfo->fMemUsed;
   
   Int_t iInitRunNumber = -1;
-  fChain->GetEntry(0);
-  TFile *f = fChain->GetFile();
+  chain->GetEntry(0);
+  TFile *f = chain->GetFile();
   fTempGuid = f->GetUUID().AsString();
 
   TString localFileName = "Run"; localFileName += esd->GetRunNumber(); 
-  localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += fChain->GetEntries(); //localFileName += "."; localFileName += Counter;
+  localFileName += ".Event"; localFileName += firstEvent; localFileName += "_"; localFileName += chain->GetEntries(); //localFileName += "."; localFileName += Counter;
   localFileName += ".ESD.tag.root";
 
   TString fileName;
-  
+  TRefArray tmp;
   if(fStorage == 0) {
     fileName = localFileName.Data();      
     AliInfo(Form("Writing tags to local file: %s",fileName.Data()));
@@ -279,24 +284,24 @@ void AliESDTagCreator::CreateTag(TChain* fChain, const char *type) {
   TBranch * btag = ttag.Branch("AliTAG", &tag);
   btag->SetCompressionLevel(9);
 
-  for(Int_t iEventNumber = 0; iEventNumber < fChain->GetEntries(); iEventNumber++) {
+  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;
     
-    fChain->GetEntry(iEventNumber);    
+    chain->GetEntry(iEventNumber);    
     esdold = esd->GetAliESDOld();
     if(esdold) esd->CopyFromOldESD();
 
-    TFile *f = fChain->GetFile();
-    const TUrl *url = f->GetEndpointUrl();
-    fguid = f->GetUUID().AsString();
+    TFile *file = chain->GetFile();
+    const TUrl *url = file->GetEndpointUrl();
+    fguid = file->GetUUID().AsString();
     if(fSession == "grid") {
       TString fturltemp = "alien://"; fturltemp += url->GetFile();
       fturl = fturltemp(0,fturltemp.Index(".root",5,0,TString::kExact)+5);
@@ -326,11 +331,16 @@ void AliESDTagCreator::CreateTag(TChain* fChain, 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++;
@@ -404,6 +414,7 @@ void AliESDTagCreator::CreateTag(TChain* fChain, 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) {
@@ -423,10 +434,25 @@ void AliESDTagCreator::CreateTag(TChain* fChain, 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);
     }
@@ -465,6 +491,7 @@ void AliESDTagCreator::CreateTag(TChain* fChain, const char *type) {
     evTag->SetNumOfKaons(nKaons);
     evTag->SetNumOfPions(nPions);
     evTag->SetNumOfMuons(nMuons);
+    evTag->SetNumOfFWMuons(nFWMuons);
     evTag->SetNumOfElectrons(nElectrons);
     evTag->SetNumOfPhotons(nGamas);
     evTag->SetNumOfPi0s(nPi0s);
@@ -481,12 +508,16 @@ void AliESDTagCreator::CreateTag(TChain* fChain, 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);
@@ -498,19 +529,19 @@ void AliESDTagCreator::CreateTag(TChain* fChain, const char *type) {
       tag->Clear("");
     }
     tag->AddEventTag(*evTag);
-    if(iEventNumber+1 == fChain->GetEntries()) {
+    if(iEventNumber+1 == chain->GetEntries()) {
       //AliInfo(Form("File: %s",fturl.Data()));
       ttag.Fill();
       tag->Clear("");
     }      
   }//event loop
-  lastEvent = fChain->GetEntries();
+  lastEvent = chain->GetEntries();
   
   //gSystem->GetMemInfo(meminfo);
   //AliInfo(Form("After the event and track loop - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
   //tempmem = meminfo->fMemUsed;
 
-  //fChain->Delete("");
+  //chain->Delete("");
   
   //gSystem->GetMemInfo(meminfo);
   //AliInfo(Form("After the t->Delete - Memory used: %d MB - Increase: %d MB",meminfo->fMemUsed,meminfo->fMemUsed - tempmem));
@@ -562,16 +593,17 @@ 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();
@@ -610,6 +642,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;
@@ -621,6 +654,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;
@@ -647,12 +682,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++;
@@ -725,6 +766,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) {
@@ -740,7 +782,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);
@@ -778,6 +836,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);
@@ -794,12 +853,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);
@@ -885,16 +948,17 @@ 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();
@@ -927,6 +991,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;
@@ -938,6 +1003,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;
@@ -964,11 +1031,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++;
@@ -1042,6 +1115,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) {
@@ -1057,7 +1131,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());
@@ -1093,6 +1182,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);
@@ -1109,12 +1199,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);
@@ -1161,11 +1255,21 @@ void AliESDTagCreator::CreateTag(TFile* file, const char *filepath, Int_t Counte
 }
 
 //_____________________________________________________________________________
-void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TList */*grpList*/) {
+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//
@@ -1190,16 +1294,17 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TList
 
   // 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......."));       
 
@@ -1249,6 +1354,7 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TList
     nKaons = 0;
     nPions = 0;
     nMuons = 0;
+    nFWMuons = 0;
     nElectrons = 0;      
     nCh1GeV = 0;
     nCh3GeV = 0;
@@ -1260,6 +1366,8 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TList
     nEl3GeV = 0;
     nEl10GeV = 0;
     maxPt = .0;
+    etamaxPt = -999.;
+    phimaxPt = -999.;
     meanPt = .0;
     totalP = .0;
     fVertexflag = 0;
@@ -1284,11 +1392,16 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TList
       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++;
@@ -1362,6 +1475,7 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TList
       // 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) {
@@ -1373,12 +1487,28 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TList
        }
       }
     }//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());
@@ -1414,6 +1544,7 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TList
     evTag->SetNumOfKaons(nKaons);
     evTag->SetNumOfPions(nPions);
     evTag->SetNumOfMuons(nMuons);
+    evTag->SetNumOfFWMuons(nFWMuons);
     evTag->SetNumOfElectrons(nElectrons);
     evTag->SetNumOfPhotons(nGamas);
     evTag->SetNumOfPi0s(nPi0s);
@@ -1430,17 +1561,30 @@ void AliESDTagCreator::CreateESDTags(Int_t fFirstEvent, Int_t fLastEvent, TList
     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);
   }