]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODTagCreator.cxx
Update the Tag system classes. Reduce memory footprint. Add information from RCT
[u/mrichter/AliRoot.git] / STEER / AliAODTagCreator.cxx
index ec457688270aaf1e80c4f68f41e628bc65a49481..6191d4858a5e69808dc63a1aad33d689f329baab 100644 (file)
@@ -36,6 +36,7 @@
 //AliRoot
 #include "AliRunTag.h"
 #include "AliEventTag.h"
+#include "AliFileTag.h"
 #include "AliPID.h"
 #include "AliAODEvent.h"
 #include "AliAODVertex.h"
@@ -93,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");
   
@@ -101,15 +102,14 @@ 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;
+  const char * dirname  = 0x0;
   const char * filename = 0x0;
-  const char * pattern = "AliAODs.root"; 
 
   fChain = new TChain("aodTree");
 
@@ -130,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");
 
@@ -158,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");
 
@@ -228,7 +228,7 @@ 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;
     
@@ -298,14 +298,16 @@ void AliAODTagCreator::CreateTags(const char* type)
     Int_t ntags    = 0;
     Int_t tagentry = 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
@@ -331,13 +333,16 @@ void AliAODTagCreator::CreateTags(const char* type)
        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);
+       
+       // **** 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
@@ -345,13 +350,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
@@ -390,11 +440,21 @@ void AliAODTagCreator::FillEventTag(AliAODEvent* aod, AliEventTag* evTag)
     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;
 
     TRefArray tmp;
 
-    Int_t nTracks = fAODEvent->GetNTracks();
+
+    // 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 +463,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++;
@@ -501,4 +567,6 @@ void AliAODTagCreator::FillEventTag(AliAODEvent* aod, AliEventTag* evTag)
     evTag->SetTotalMomentum(totalP);
     evTag->SetMeanPt(meanPt);
     evTag->SetMaxPt(maxPt);
+    evTag->SetEtaMaxPt(etamaxPt);
+    evTag->SetPhiMaxPt(phimaxPt);
 }