]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODTagCreator.cxx
removing obsolete component from libAliHLTTrigger
[u/mrichter/AliRoot.git] / STEER / AliAODTagCreator.cxx
index b5c8f20ac229697c48aa4ec1cbe672cf0a429f3c..548fa2bf81af9ab673a36fe1efccba44180ec8f6 100644 (file)
@@ -27,6 +27,7 @@
 #include <TSystem.h>
 #include <TChain.h>
 #include <TLorentzVector.h>
+#include <TRefArray.h>
 
 //ROOT-AliEn
 #include <TGrid.h>
@@ -35,6 +36,7 @@
 //AliRoot
 #include "AliRunTag.h"
 #include "AliEventTag.h"
+#include "AliFileTag.h"
 #include "AliPID.h"
 #include "AliAODEvent.h"
 #include "AliAODVertex.h"
@@ -92,7 +94,7 @@ Bool_t AliAODTagCreator::ReadGridCollection(TGridResult *fresult) {
   }//grid result loop
   
   AliInfo(Form("AOD chain created......."));   
-  AliInfo(Form("Chain entries: %d",fChain->GetEntries()));     
+  AliInfo(Form("Chain entries: %lld",fChain->GetEntries()));   
 
   CreateTag(fChain, "grid");
   
@@ -100,20 +102,19 @@ Bool_t AliAODTagCreator::ReadGridCollection(TGridResult *fresult) {
 }
 
 //______________________________________________________________________________
-Bool_t AliAODTagCreator::ReadLocalCollection(const char *localpath) {
+Bool_t AliAODTagCreator::ReadLocalCollection(const char *localpath, const char* pattern) {
   // Checks the different subdirs of the given local path and in the
-  // case where it finds an AliAODs.root file it creates the tags
+  // case where it finds an AliAOD.root file it creates the tags
   
   void *dira =  gSystem->OpenDirectory(localpath);
-  Char_t fPath[256];
-  const char * dirname = 0x0;
+  Char_t fPath[512];
+  const char * dirname  = 0x0;
   const char * filename = 0x0;
-  const char * pattern = "AliAODs.root"; 
 
   fChain = new TChain("aodTree");
 
   while((dirname = gSystem->GetDirEntry(dira))) {
-    sprintf(fPath,"%s/%s",localpath,dirname);
+    snprintf(fPath,512,"%s/%s",localpath,dirname);
     void *dirb =  gSystem->OpenDirectory(fPath);
     while((filename = gSystem->GetDirEntry(dirb))) {
        TString bstr = dirname;
@@ -129,7 +130,7 @@ Bool_t AliAODTagCreator::ReadLocalCollection(const char *localpath) {
   } //parent directory's entry loop
   
   AliInfo(Form("AOD chain created......."));   
-  AliInfo(Form("Chain entries: %d",fChain->GetEntries()));     
+  AliInfo(Form("Chain entries: %lld",fChain->GetEntries()));   
 
   CreateTag(fChain, "local");
 
@@ -157,7 +158,7 @@ Bool_t AliAODTagCreator::ReadCAFCollection(const char *filename) {
   }
 
   AliInfo(Form("AOD chain created......."));   
-  AliInfo(Form("Chain entries: %d",fChain->GetEntries()));     
+  AliInfo(Form("Chain entries: %lld",fChain->GetEntries()));   
 
   CreateTag(fChain, "proof");
 
@@ -187,9 +188,8 @@ void AliAODTagCreator::CreateAODTags(Int_t fFirstEvent, Int_t fLastEvent, TList
     if(fLastEvent == -1) lastEvent = (Int_t)fChain->GetEntries();
     else lastEvent = fLastEvent;
 
-
     char fileName[256];
-    sprintf(fileName, "Run%d.Event%d_%d.AOD.tag.root", 
+    snprintf(fileName, 256, "Run%d.Event%d_%d.AOD.tag.root", 
            fAODEvent->GetRunNumber(), fFirstEvent, lastEvent );
     AliInfo(Form("writing tags to file %s", fileName));
     AliDebug(1, Form("writing tags to file %s", fileName));
@@ -218,8 +218,7 @@ void AliAODTagCreator::CreateTag(TChain* chain, const char *type) {
     // Private method that creates tag files
     //
 
-
-    //reading the esd tag file                                                  
+    //reading the esd tag file 
     fTreeTEsd = new TChain("T");
     const char * tagPattern = "ESD.tag";
     // Open the working directory
@@ -229,9 +228,8 @@ void AliAODTagCreator::CreateTag(TChain* chain, const char *type) {
     while((name = gSystem->GetDirEntry(dirp))) {
        if (strstr(name,tagPattern)) fTreeTEsd->Add(name);
     }//directory loop
-    AliInfo(Form("Chained tag files: %d", fTreeTEsd->GetEntries()));
-  
-    
+    AliInfo(Form("Chained tag files: %lld",fTreeTEsd->GetEntries()));
+      
     fChain = chain;
     
     TString fSession = type;
@@ -286,7 +284,7 @@ void AliAODTagCreator::CreateTag(TChain* chain, const char *type) {
     ftag->Close();
 }
 
-void AliAODTagCreator::CreateTags(const char* type)
+void AliAODTagCreator::CreateTags(const char* /*type*/)
 {
     // Event loop for tag creation
     TString fturl;
@@ -299,15 +297,17 @@ void AliAODTagCreator::CreateTags(const char* type)
     Int_t nEvents = fChain->GetEntries();
     Int_t ntags    = 0;
     Int_t tagentry = 0;
-    const TClonesArray *evTagList = 0;
+    //    const TClonesArray *evTagList = 0;
+    TString foldguid = "";
 
     for (Int_t iEventNumber = 0; iEventNumber < nEvents; iEventNumber++) {
        // Copy old tag information
        if (iEventNumber >= ntags) {
            fTreeTEsd->GetEntry(tagentry++);
            fRunTag->CopyStandardContent(fRunTagEsd);
-           evTagList = fRunTagEsd->GetEventTags();
-           ntags += evTagList->GetEntries();
+//         evTagList = fRunTagEsd->GetEventTags();
+//         ntags += evTagList->GetEntries();
+           ntags = fRunTagEsd->GetNEvents();
        }
 
        // Create a new Tag
@@ -317,29 +317,33 @@ void AliAODTagCreator::CreateTags(const char* type)
        if (iEventNumber == 0) oldRun = fAODEvent->GetRunNumber();
        // Reference to the input file
        TFile *file = fChain->GetFile();
-       const TUrl *url = file->GetEndpointUrl();
+       //      const TUrl *url = file->GetEndpointUrl();
        fguid = file->GetUUID().AsString();
 
-       if (!strcmp(type,"grid")) {
-           TString fturltemp = "alien://"; fturltemp += url->GetFile();
-           fturl = fturltemp(0,fturltemp.Index(".root",5,0,TString::kExact)+5);
-       } else {
-           fturl = url->GetFile();
-       }
+//     if (!strcmp(type,"grid")) {
+//         TString fturltemp = "alien://"; fturltemp += url->GetFile();
+//         fturl = fturltemp(0,fturltemp.Index(".root",5,0,TString::kExact)+5);
+//     } else {
+//         fturl = url->GetFile();
+//     }
+       fturl = file->GetName();
        
        fAODEvent->GetStdContent();
        
        // Fill the event tag from the aod informatiom
        FillEventTag(fAODEvent, evTag);
        // Set the event and input file references
-       evTag->SetEventId(iEventNumber+1);
-       evTag->SetGUID(fguid);
-       if(!strcmp(type,"grid")) {
-           evTag->SetMD5(0);
-           evTag->SetTURL(fturl);
-           evTag->SetSize(0);
-           }
-       else evTag->SetPath(fturl);
+       //evTag->SetEventId(iEventNumber+1);
+       
+       // **** FIXME ****
+//     evTag->SetGUID(fguid);
+//     if(!strcmp(type,"grid")) {
+//         evTag->SetMD5("");
+//         evTag->SetTURL(fturl);
+//         evTag->SetSize(0);
+//         }
+//     else evTag->SetPath(fturl);
+       //  **** FIXME ****
 
        // Check if a new run has to be created
        // File has changed
@@ -347,13 +351,58 @@ void AliAODTagCreator::CreateTags(const char* type)
            ftempGuid = fguid;
            fTreeT->Fill();
            fRunTag->Clear("");
+
+           AliFileTag *nftag = new AliFileTag();
+           
+           // if(fSession == "grid") {
+             nftag->SetMD5("");
+             nftag->SetTURL(fturl);
+             nftag->SetSize(0);
+           // }
+           // else {
+           //   nftag->SetPath(fturl);
+           //   nftag->SetSize(0);
+           //   nftag->SetMD5("");
+           //   nftag->SetTURL(fturl);
+           // }
+      
+           if (fRunTag->GetFileId(fguid) > -1)
+             AliFatal("Adding a file which is already in the RunTag.");
+           
+           fRunTag->AddFileTag(nftag);
+           
        }
+
        // Run# has changed
        if (oldRun != (fAODEvent->GetRunNumber()))
        {
            oldRun = fAODEvent->GetRunNumber();
+
            fTreeT->Fill();
            fRunTag->Clear("");
+           ftempGuid = fguid;
+           fTreeT->Fill();
+           fRunTag->Clear("");
+
+           AliFileTag *nftag = new AliFileTag();
+           
+           // if(fSession == "grid") {
+             nftag->SetMD5("");
+             nftag->SetTURL(fturl);
+             nftag->SetSize(0);
+           // }
+           // else {
+           //   nftag->SetPath(fturl);
+           //   nftag->SetSize(0);
+           //   nftag->SetMD5("");
+           //   nftag->SetTURL(fturl);
+           // }
+      
+           if (fRunTag->GetFileId(fguid) > -1)
+             AliFatal("Adding a file which is already in the RunTag.");
+           
+           fRunTag->AddFileTag(nftag);
+           
        }
        
        // Add the event tag
@@ -388,13 +437,25 @@ void AliAODTagCreator::FillEventTag(AliAODEvent* aod, AliEventTag* evTag)
     Int_t   nPos = 0, nNeg = 0, nNeutr =0;
     Int_t   nKinks = 0, nV0s = 0, nCascades = 0;
     Int_t   nK0s = 0, nNeutrons = 0, nPi0s = 0, nGamas = 0;
-    Int_t   nProtons = 0,  nKaons = 0, nPions = 0, nMuons = 0, nElectrons = 0;
+    Int_t   nProtons = 0,  nKaons = 0, nPions = 0, nMuons = 0, nElectrons = 0, nFWMuons = 0;
     Int_t   nCh1GeV = 0, nCh3GeV = 0, nCh10GeV = 0;
     Int_t   nMu1GeV = 0, nMu3GeV = 0, nMu10GeV = 0;
     Int_t   nEl1GeV = 0, nEl3GeV = 0, nEl10GeV = 0;
-    Float_t maxPt =  .0, meanPt = .0, totalP =  .0;
+    Float_t maxPt =  .0, etamaxPt = -999., phimaxPt = -999., meanPt = .0, totalP =  .0;
 
-    Int_t nTracks = fAODEvent->GetNTracks();
+    TRefArray tmp;
+
+
+    // Primary Vertex
+    AliAODVertex *pVertex = fAODEvent->GetPrimaryVertex();
+    if (pVertex) {
+       evTag->SetVertexX(pVertex->GetX());
+       evTag->SetVertexY(pVertex->GetY());
+       evTag->SetVertexZ(pVertex->GetZ());
+       Double_t covmatrix[6];
+       pVertex->GetCovarianceMatrix(covmatrix);
+       evTag->SetVertexZError(sqrt(covmatrix[5]));
+    }
     // loop over vertices 
     Int_t nVtxs = fAODEvent->GetNumberOfVertices();
     for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) {
@@ -403,11 +464,17 @@ void AliAODTagCreator::FillEventTag(AliAODEvent* aod, AliEventTag* evTag)
        if(vertex->GetType() == 2) nV0s      += 1;
        if(vertex->GetType() == 3) nCascades += 1;
     }
+    Int_t nTracks = fAODEvent->GetNTracks();
     for (Int_t nTr = 0; nTr < nTracks; nTr++) {
        AliAODTrack *track = fAODEvent->GetTrack(nTr);
        
        Double_t fPt = track->Pt();
-       if(fPt > maxPt) maxPt = fPt;
+       if(fPt > maxPt) {
+           maxPt = fPt;
+           etamaxPt = track->Eta();
+           phimaxPt = track->Phi();
+       }
+       
        if(track->Charge() > 0) {
            nPos++;
            if(fPt > fLowPtCut)      nCh1GeV++;
@@ -450,10 +517,12 @@ void AliAODTagCreator::FillEventTag(AliAODEvent* aod, AliEventTag* evTag)
            if(fPt > fHighPtCut) nEl3GeV++;
            if(fPt > fVeryHighPtCut) nEl10GeV++;
        }
-           
        totalP += track->P();
        meanPt += fPt;
        ntrack++;
+       // forward muons (in the dimuon spectrometer)
+       if(track->IsMuonTrack()) nFWMuons++;   
+                                 
     }//track loop
     //
     // Fill the event tags  
@@ -474,6 +543,7 @@ void AliAODTagCreator::FillEventTag(AliAODEvent* aod, AliEventTag* evTag)
     evTag->SetNumOfKaons(nKaons);
     evTag->SetNumOfPions(nPions);
     evTag->SetNumOfMuons(nMuons);
+    evTag->SetNumOfFWMuons(nFWMuons);
     evTag->SetNumOfElectrons(nElectrons);
     evTag->SetNumOfPhotons(nGamas);
     evTag->SetNumOfPi0s(nPi0s);
@@ -489,8 +559,15 @@ void AliAODTagCreator::FillEventTag(AliAODEvent* aod, AliEventTag* evTag)
     evTag->SetNumOfElectronsAbove1GeV(nEl1GeV);
     evTag->SetNumOfElectronsAbove3GeV(nEl3GeV);
     evTag->SetNumOfElectronsAbove10GeV(nEl10GeV);
+
+    tmp.Clear();
+    evTag->SetNumOfPHOSClusters(fAODEvent->GetPHOSClusters(&tmp));
+    tmp.Clear();
+    evTag->SetNumOfEMCALClusters(fAODEvent->GetEMCALClusters(&tmp));
        
     evTag->SetTotalMomentum(totalP);
     evTag->SetMeanPt(meanPt);
     evTag->SetMaxPt(maxPt);
+    evTag->SetEtaMaxPt(etamaxPt);
+    evTag->SetPhiMaxPt(phimaxPt);
 }