LCOV - code coverage report
Current view: top level - ANALYSIS/ANALYSISalice - AliTagAnalysis.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 284 0.4 %
Date: 2016-06-14 17:26:59 Functions: 1 17 5.9 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Author: Panos Christakoglou.                                           *
       3             :  * Contributors are mentioned in the code where appropriate.              *
       4             :  *                                                                        *
       5             :  * Permission to use, copy, modify and distribute this software and its   *
       6             :  * documentation strictly for non-commercial purposes is hereby granted   *
       7             :  * without fee, provided that the above copyright notice appears in all   *
       8             :  * copies and that both the copyright notice and this permission notice   *
       9             :  * appear in the supporting documentation. The authors make no claims     *
      10             :  * about the suitability of this software for any purpose. It is          *
      11             :  * provided "as is" without express or implied warranty.                  *
      12             :  **************************************************************************/
      13             : 
      14             : /* $Id$ */
      15             : 
      16             : //-----------------------------------------------------------------
      17             : //           AliTagAnalysis class
      18             : //   This is the class to deal with the tag analysis
      19             : //   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
      20             : //-----------------------------------------------------------------
      21             : 
      22             : //ROOT
      23             : #include <Riostream.h>
      24             : #include <TSystem.h>
      25             : #include <TChain.h>
      26             : #include <TFile.h>
      27             : #include <TEventList.h>
      28             : #include <TEntryList.h>
      29             : #include <TTreeFormula.h>
      30             : #include <TMap.h>
      31             : 
      32             : //ROOT-AliEn
      33             : #include <TGridResult.h>
      34             : 
      35             : #include "AliLog.h"
      36             : 
      37             : #include "AliRunTag.h"
      38             : #include "AliEventTag.h"
      39             : #include "AliTagAnalysis.h"
      40             : #include "AliEventTagCuts.h"
      41             : #include "AliDetectorTagCuts.h"
      42             : #include "AliLHCTagCuts.h"
      43             : #include "AliRunTagCuts.h"
      44             : #include "AliXMLCollection.h"
      45             : 
      46             : class TTree;
      47             : 
      48         170 : ClassImp(AliTagAnalysis)
      49             : 
      50             : //___________________________________________________________________________
      51             : AliTagAnalysis::AliTagAnalysis(): 
      52           0 :   TObject(),
      53           0 :   ftagresult(0x0),
      54           0 :   fTagDirName(),
      55           0 :   fChain(0x0),
      56           0 :   fAnalysisType(),
      57           0 :   fGlobalList(0) {
      58             :   //Default constructor for a AliTagAnalysis
      59           0 : }
      60             : 
      61             : //___________________________________________________________________________
      62             : AliTagAnalysis::AliTagAnalysis(const char* type): 
      63           0 :   TObject(),
      64           0 :   ftagresult(0x0),
      65           0 :   fTagDirName(),
      66           0 :   fChain(0x0),
      67           0 :   fAnalysisType(type),
      68           0 :   fGlobalList(0) {
      69             :   //constructor for a AliTagAnalysis
      70           0 : }
      71             : 
      72             : //___________________________________________________________________________
      73           0 : AliTagAnalysis::~AliTagAnalysis() {
      74             :   //Default destructor for a AliTagAnalysis
      75           0 :   if(ftagresult) delete ftagresult;
      76           0 :   if(fChain) delete fChain;
      77           0 :   if(fGlobalList) delete fGlobalList;
      78           0 : }
      79             : 
      80             : //___________________________________________________________________________
      81             : Bool_t  
      82             : AliTagAnalysis::AddTagsFile(const char* alienUrl, Bool_t checkFile) 
      83             : {
      84             :   /// Add a single tags file to the chain
      85             :   ///
      86             :   /// If checkFile=kTRUE (default) the file is opened to check
      87             :   /// it can be and that it contains data.
      88             :   /// It's safer but a lot longer...
      89             :   
      90           0 :   if (!fChain) fChain = new TChain("T");
      91             : 
      92           0 :   if ( checkFile )
      93             :   {
      94           0 :     return ( fChain->AddFile(alienUrl,-1) > 0 );
      95             :   }
      96             :   else
      97             :   {
      98           0 :     return ( fChain->AddFile(alienUrl) > 0 );
      99             :   }
     100             : 
     101           0 : }
     102             : 
     103             : //___________________________________________________________________________
     104             : void AliTagAnalysis::ChainLocalTags(const char *dirname) {
     105             :   //Searches the entries of the provided direcory
     106             :   //Chains the tags that are stored locally
     107           0 :   fTagDirName = dirname;
     108           0 :   TString fTagFilename;
     109             :   
     110           0 :   if (! fChain)  fChain = new TChain("T");
     111             :   const char * tagPattern = 0x0;
     112           0 :   if(fAnalysisType == "ESD") tagPattern = "ESD.tag.root";
     113           0 :   else if(fAnalysisType == "AOD") tagPattern = "AOD.tag.root";
     114           0 :   else AliFatal("Only ESD and AOD type is implemented!!!");
     115             : 
     116             :   // Open the working directory
     117           0 :   void * dirp = gSystem->OpenDirectory(fTagDirName);
     118             :   const char * name = 0x0;
     119             :   // Add all files matching *pattern* to the chain
     120           0 :   while((name = gSystem->GetDirEntry(dirp))) {
     121           0 :     if (tagPattern && strstr(name,tagPattern)) { 
     122           0 :       fTagFilename = fTagDirName;
     123           0 :       fTagFilename += "/";
     124           0 :       fTagFilename += name;
     125             :                 
     126           0 :       fChain->Add(fTagFilename);  
     127           0 :       printf("Tag file %s\n", fTagFilename.Data());
     128             :       
     129             :     }//pattern check
     130             :   }//directory loop
     131             :   //AliInfo(Form("Chained tag files: %d ",fChain->GetEntries()));
     132             :  // AliDebug(Form("Chained tag files: %d ",fChain->GetEntries()));
     133           0 :   fChain->ls();
     134             :   
     135           0 : }
     136             : 
     137             : 
     138             : //___________________________________________________________________________
     139             : TChain * AliTagAnalysis::ChainGridTags(TGridResult *res) {
     140             :   //Loops overs the entries of the TGridResult
     141             :    //Chains the tags that are stored in the GRID
     142           0 :   ftagresult = res;
     143           0 :   Int_t nEntries = ftagresult->GetEntries();
     144             :  
     145           0 :   if (! fChain)  fChain = new TChain("T");
     146             : 
     147           0 :   TString gridname = "alien://";
     148           0 :   TString alienUrl;
     149             :  
     150           0 :   for(Int_t i = 0; i < nEntries; i++) {
     151           0 :     alienUrl = ftagresult->GetKey(i,"turl");
     152           0 :     fChain->Add(alienUrl);
     153             :   }//grid result loop
     154           0 :   return fChain;
     155           0 : }
     156             : 
     157             : 
     158             : //___________________________________________________________________________
     159             : TChain *AliTagAnalysis::QueryTags(AliRunTagCuts *runTagCuts, 
     160             :                                   AliLHCTagCuts *lhcTagCuts, 
     161             :                                   AliDetectorTagCuts *detTagCuts, 
     162             :                                   AliEventTagCuts *evTagCuts) {
     163             :   //Queries the tag chain using the defined 
     164             :   //event tag cuts from the AliEventTagCuts object
     165             :   //and returns a TChain along with the associated TEventList
     166           0 :   AliInfo(Form("Querying the tags........"));
     167             : 
     168           0 :   TString aliceFile;
     169           0 :   if(fAnalysisType == "ESD") aliceFile = "esdTree";
     170           0 :   else if(fAnalysisType == "AOD") aliceFile = "aodTree";
     171           0 :   else AliFatal("Only ESD and AOD type is implemented!!!");
     172             : 
     173             :   //ESD file chain
     174           0 :   TChain *esdChain = new TChain(aliceFile.Data());
     175             :   //global entry list
     176           0 :   fGlobalList = new TEntryList();
     177             :   
     178             :   //Defining tag objects
     179           0 :   AliRunTag   *tag     = new AliRunTag;
     180             :   //  AliEventTag *evTag   = 0x0;
     181             :   AliFileTag  *flTag   = 0x0;
     182             : 
     183           0 :   fChain->SetBranchAddress("AliTAG",&tag);
     184             : 
     185           0 :   TString guid;
     186           0 :   TString turl;
     187           0 :   TString path;
     188             : 
     189           0 :   TEntryList* localList = new TEntryList();
     190             : 
     191             :   Int_t iAccepted = 0;
     192             :   
     193           0 :   for(Int_t iEntry = 0; iEntry < fChain->GetEntries(); iEntry++) {
     194           0 :     fChain->GetEntry(iEntry);
     195           0 :     evTagCuts->InitializeTriggerClasses(tag->GetActiveTriggerClasses());
     196             : 
     197           0 :     if(runTagCuts->IsAccepted(tag)) {
     198           0 :       if(lhcTagCuts->IsAccepted(tag->GetLHCTag())) {
     199           0 :         if(detTagCuts->IsAccepted(tag->GetDetectorTags())) {
     200           0 :           localList->Reset();
     201           0 :           Int_t iEvents = tag->GetNEvents();
     202             :           
     203           0 :           for (int i = 0; i < iEvents; i++) {
     204             :             //      evTag = tag->GetEventTag(i);
     205           0 :             flTag = tag->GetFileTagForEvent(i);
     206           0 :             guid = flTag->GetGUID();
     207           0 :             turl = flTag->GetTURL();
     208           0 :             path = flTag->GetPath();
     209           0 :             localList->SetTreeName(aliceFile.Data());
     210           0 :             if(turl!="") localList->SetFileName(turl.Data());
     211           0 :             else localList->SetFileName(path.Data());
     212             : 
     213           0 :             if(evTagCuts->IsAccepted(tag->GetEventTag(i))) localList->Enter(i);
     214             :           }
     215             : 
     216             : //        const TClonesArray *tagList = tag->GetEventTags();
     217             : //        for(Int_t i = 0; i < iEvents; i++) {
     218             : //          evTag = (AliEventTag *) tagList->At(i);
     219             : //          guid = evTag->GetGUID(); 
     220             : //          turl = evTag->GetTURL(); 
     221             : //          path = evTag->GetPath();
     222             : //          localList->SetTreeName(aliceFile.Data());
     223             : //          if(turl!="") localList->SetFileName(turl.Data());
     224             : //          else localList->SetFileName(path.Data());
     225             :             
     226             : //          if(evTagCuts->IsAccepted(evTag)) localList->Enter(i);
     227             : //        }//event loop
     228           0 :           iAccepted += localList->GetN();
     229           0 :           if(turl != "")      esdChain->AddFile(turl);
     230           0 :           else if(path != "") esdChain->AddFile(path);
     231           0 :           fGlobalList->Add(localList);
     232           0 :         }//detector tag cuts
     233             :       }//lhc tag cuts
     234             :     }//run tags cut
     235           0 :     tag->Clear();
     236             :   }//tag file loop
     237           0 :   AliInfo(Form("Accepted events: %d", iAccepted));
     238           0 :   esdChain->ls();
     239           0 :   esdChain->SetEntryList(fGlobalList,"ne");
     240           0 :   delete tag;
     241           0 :   delete localList;
     242             :   
     243             :   return esdChain;
     244           0 : }
     245             : 
     246             : //___________________________________________________________________________
     247             : TChain *AliTagAnalysis::QueryTags(const char *fRunCut, 
     248             :                                   const char *fLHCCut, 
     249             :                                   const char *fDetectorCut, 
     250             :                                   const char *fEventCut) {       
     251             :   //Queries the tag chain using the defined      
     252             :   //event tag cuts from the AliEventTagCuts object       
     253             :   //and returns a TChain along with the associated TEventList    
     254           0 :   AliInfo(Form("Querying the tags........"));          
     255             : 
     256           0 :   TString aliceFile;
     257           0 :   if(fAnalysisType == "ESD") aliceFile = "esdTree";
     258           0 :   else if(fAnalysisType == "AOD") aliceFile = "aodTree";
     259           0 :   else AliFatal("Only ESD and AOD type is implemented!!!");
     260             : 
     261             : 
     262             :   //ESD file chain
     263           0 :   TChain *esdChain = new TChain(aliceFile.Data());
     264             :   //global entry list
     265           0 :   fGlobalList = new TEntryList();
     266             :   
     267             :   //Defining tag objects         
     268           0 :   AliRunTag   *tag   = new AliRunTag;    
     269             :   //  AliEventTag *evTag = 0x0;
     270           0 :   fChain->SetBranchAddress("AliTAG",&tag);      
     271             :   
     272           0 :   TString guid;          
     273           0 :   TString turl;          
     274           0 :   TString path;          
     275             :   
     276           0 :   TTreeFormula *fRunFormula = new TTreeFormula("fRun",fRunCut,fChain);         
     277           0 :   TTreeFormula *fLHCFormula = new TTreeFormula("fLHC",fLHCCut,fChain);         
     278           0 :   TTreeFormula *fDetectorFormula = new TTreeFormula("fDetector",fDetectorCut,fChain);
     279           0 :   TTreeFormula *fEventFormula = new TTreeFormula("fEvent",fEventCut,fChain);
     280             :   
     281           0 :   TEntryList* localList = new TEntryList();
     282             : 
     283             :   Int_t current = -1; 
     284             :   Int_t iAccepted = 0;   
     285             :   
     286           0 :   for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) {
     287           0 :     fChain->GetEntry(iTagFiles);      
     288           0 :     if (current != fChain->GetTreeNumber()) {         
     289           0 :       fRunFormula->UpdateFormulaLeaves();     
     290           0 :       fLHCFormula->UpdateFormulaLeaves();     
     291           0 :       fDetectorFormula->UpdateFormulaLeaves();        
     292           0 :       fEventFormula->UpdateFormulaLeaves();   
     293           0 :       current = fChain->GetTreeNumber();      
     294           0 :     }    
     295             :     
     296           0 :     if(fRunFormula->EvalInstance(iTagFiles) == 1) {   
     297           0 :       if(fLHCFormula->EvalInstance(iTagFiles) == 1) {         
     298           0 :         if(fDetectorFormula->EvalInstance(iTagFiles) == 1) {
     299           0 :           localList->Reset();         
     300             :           //      Int_t iEvents = fEventFormula->GetNdata();          
     301             :           // *** FIXME ***
     302             : 
     303             : //        const TClonesArray *tagList = tag->GetEventTags();          
     304             : //        for(Int_t i = 0; i < iEvents; i++) {        
     305             : //          evTag = (AliEventTag *) tagList->At(i);   
     306             : //          guid = evTag->GetGUID();          
     307             : //          turl = evTag->GetTURL();          
     308             : //          path = evTag->GetPath();          
     309             : //          localList->SetTreeName(aliceFile.Data());
     310             : //          localList->SetFileName(turl.Data());
     311             : //          if(fEventFormula->EvalInstance(i) == 1) localList->Enter(i);
     312             : //        }//event loop          
     313             : 
     314           0 :           if(path != "")      esdChain->AddFile(path);      
     315           0 :           else if(turl != "") esdChain->AddFile(turl);      
     316           0 :           fGlobalList->Add(localList);
     317           0 :           iAccepted += localList->GetN();
     318           0 :         }//detector tag cuts
     319             :       }//lhc tag cuts
     320             :     }//run tag cut       
     321           0 :     tag->Clear();
     322             :   }//tag file loop       
     323           0 :   AliInfo(Form("Accepted events: %d", iAccepted));     
     324           0 :   esdChain->SetEntryList(fGlobalList,"ne");         
     325             : 
     326           0 :   delete tag;
     327           0 :   delete localList;
     328             :   return esdChain;       
     329           0 : }
     330             : 
     331             : //___________________________________________________________________________
     332             : Bool_t 
     333             : AliTagAnalysis::CreateXMLCollection(const char* name, 
     334             :                                     AliRunTagCuts *runTagCuts, 
     335             :                                     AliLHCTagCuts *lhcTagCuts, 
     336             :                                     AliDetectorTagCuts *detTagCuts, 
     337             :                                     AliEventTagCuts *evTagCuts) 
     338             : {
     339             :   /// Queries the tag chain using the defined run, lhc, detector and event tag objects
     340             :   /// and create a XML collection named "name.xml"
     341             :   /// if any of the runTagCuts, lhcTagCuts, detTagCuts or evTagCuts is NULL
     342             :   /// check on that object will be skipped.
     343             :   
     344           0 :   AliInfo(Form("Creating the collection........"));
     345             :   
     346           0 :   if (!fChain) 
     347             :   {
     348           0 :     AliError("fChain is NULL. Cannot make a collection from that !");
     349           0 :     return kFALSE;
     350             :   }
     351             :   
     352           0 :   AliXMLCollection collection;
     353           0 :   collection.SetCollectionName(name);
     354           0 :   collection.WriteHeader();
     355             :   
     356           0 :   TString guid;
     357           0 :   TString turl;
     358           0 :   TString lfn;
     359             :   
     360           0 :   TEntryList localList;
     361             :   Int_t iAccepted = 0;
     362             :     
     363             :   Int_t iRejectedRun = 0;
     364             :   Int_t iRejectedLHC = 0;
     365             :   Int_t iRejectedDet = 0;
     366             :   Int_t iRejectedEvt = 0;
     367             :   
     368             :   Int_t iTotalEvents = 0;
     369             :   
     370             :   Int_t iAcceptedEvtInFile = 0;
     371             :   Int_t iRejectedEvtInFile = 0;
     372             :   
     373             :   //Defining tag objects
     374           0 :   AliRunTag* tag = new AliRunTag;
     375           0 :   fChain->SetBranchAddress("AliTAG",&tag);
     376             : 
     377             :   Int_t iTagFiles = 0;
     378             :   
     379             :   //  AliEventTag *evTag = 0x0;
     380             :   AliFileTag  *flTag = 0x0;
     381             : 
     382             :   //  for(Int_t iTagFiles = 0; iTagFiles < fChain->GetListOfFiles()->GetEntries(); ++iTagFiles) 
     383           0 :   for(Int_t iRunTags = 0; iRunTags < fChain->GetEntries(); ++iRunTags) 
     384             :   {
     385           0 :     fChain->GetEntry(iRunTags);
     386             :     //Event list
     387           0 :     iTotalEvents += tag->GetNEvents();
     388           0 :     localList.Reset();
     389             :     
     390           0 :     evTagCuts->InitializeTriggerClasses(tag->GetActiveTriggerClasses());
     391             :     
     392           0 :     if ( !runTagCuts || ( runTagCuts && runTagCuts->IsAccepted(tag) ) ) 
     393             :       {
     394           0 :         if ( !lhcTagCuts || ( lhcTagCuts && lhcTagCuts->IsAccepted(tag->GetLHCTag())) ) 
     395             :           {
     396           0 :             if ( !detTagCuts || ( detTagCuts && detTagCuts->IsAccepted(tag->GetDetectorTags())) )
     397             :               {
     398           0 :                 for (int iChunk = 0; iChunk < tag->GetNFiles(); iChunk++, iTagFiles++) 
     399             :                   {
     400             :                     iRejectedEvtInFile = 0;
     401             :                     iAcceptedEvtInFile = 0;
     402             : 
     403           0 :                     localList.Reset();
     404             :                     
     405           0 :                     flTag = tag->GetFileTag(iChunk);
     406           0 :                     guid = flTag->GetGUID();
     407           0 :                     turl = flTag->GetTURL();
     408           0 :                     lfn = turl(8,turl.Length());
     409             :                     
     410           0 :                     for (int i = 0; i<flTag->GetNEvents(); i++) 
     411             :                       {
     412             :                         //                      evTag = flTag->GetEventTag(i);
     413             :                         
     414           0 :                         if( !evTagCuts || ( evTagCuts && evTagCuts->IsAccepted(flTag->GetEventTag(i))) )
     415             :                           {
     416           0 :                             localList.Enter(i);
     417           0 :                             iAcceptedEvtInFile++;
     418           0 :                           }
     419             :                         else 
     420             :                           {
     421           0 :                             ++iRejectedEvt;
     422           0 :                             ++iRejectedEvtInFile;
     423             :                           }
     424             :                       }
     425             :                     // *** FIXME ***
     426             : //              Int_t i(0);
     427             : 
     428             : //              TIter next(tag->GetEventTags());
     429             : //              AliEventTag* evTag(0x0);
     430             : //              iRejectedEvtInFile = 0;
     431             : //              iAcceptedEvtInFile = 0;
     432             : //              while ( ( evTag = static_cast<AliEventTag*>(next()) ) )
     433             : //                {
     434             : //                  guid = evTag->GetGUID(); 
     435             : //                  turl = evTag->GetTURL(); 
     436             : //                  lfn = turl(8,turl.Length());
     437             : //                  if( !evTagCuts || ( evTagCuts && evTagCuts->IsAccepted(evTag)) )
     438             : //                    {
     439             : //                      localList.Enter(i);
     440             : //                      iAcceptedEvtInFile++;
     441             : //                    }
     442             : //                  else 
     443             : //                    {
     444             : //                      ++iRejectedEvt;
     445             : //                      ++iRejectedEvtInFile;
     446             : //                    }
     447             : //                  ++i;
     448             : //                }//event loop
     449           0 :                     iAccepted += localList.GetN();
     450           0 :                     collection.WriteBody(iTagFiles+1,guid,lfn,turl,&localList,iAcceptedEvtInFile,iRejectedEvtInFile);
     451             :                   } // chunk loop
     452           0 :               }//detector tag cuts
     453             :             else {
     454           0 :               iRejectedDet += tag->GetNEvents();
     455             :             }
     456             :           }//lhc tag cuts 
     457             :         else {
     458           0 :           iRejectedLHC += tag->GetNEvents();
     459             :         }
     460             :       }//run tag cuts
     461             :     else {
     462           0 :       iRejectedRun += tag->GetNEvents();
     463             :     }
     464           0 :     tag->Clear();
     465             :   } //tag file loop
     466             :   
     467           0 :   collection.WriteSummary(iTotalEvents, iAccepted, iRejectedRun, iRejectedLHC, iRejectedDet, iRejectedEvt);
     468           0 :   collection.Export();
     469             :   
     470             :   return kTRUE;
     471           0 : }
     472             : 
     473             : //___________________________________________________________________________
     474             : Bool_t AliTagAnalysis::CreateXMLCollection(const char* name, 
     475             :                                            const char *fRunCut, 
     476             :                                            const char *fLHCCut, 
     477             :                                            const char *fDetectorCut, 
     478             :                                            const char *fEventCut) {
     479             :   //Queries the tag chain using the defined 
     480             :   //event tag cuts from the AliEventTagCuts object
     481             :   //and returns a XML collection
     482           0 :   AliInfo(Form("Creating the collection........"));
     483             : 
     484             : 
     485           0 :   AliXMLCollection *collection = new AliXMLCollection();
     486           0 :   collection->SetCollectionName(name);
     487           0 :   collection->WriteHeader();
     488             : 
     489           0 :   TString guid;
     490           0 :   TString turl;
     491           0 :   TString lfn;
     492           0 :   TEntryList* localList = new TEntryList();
     493             :   
     494             :   Int_t iAccepted = 0;
     495             : 
     496             :   Int_t iRejectedRun = 0;
     497             :   Int_t iRejectedLHC = 0;
     498             :   Int_t iRejectedDet = 0;
     499             :   Int_t iRejectedEvt = 0;
     500             : 
     501             :   Int_t iTotalEvents = 0;
     502             : 
     503             :   Int_t iAcceptedEvtInFile = 0;
     504             :   Int_t iRejectedEvtInFile = 0;
     505             : 
     506             :   //Defining tag objects
     507           0 :   AliRunTag *tag     = new AliRunTag;
     508             :   //  AliEventTag *evTag = 0x0;
     509           0 :   fChain->SetBranchAddress("AliTAG",&tag);
     510             : 
     511           0 :   TTreeFormula *fRunFormula = new TTreeFormula("fRun",fRunCut,fChain);
     512           0 :   TTreeFormula *fLHCFormula = new TTreeFormula("fLHC",fLHCCut,fChain);         
     513           0 :   TTreeFormula *fDetectorFormula = new TTreeFormula("fDetector",fDetectorCut,fChain);
     514           0 :   TTreeFormula *fEventFormula = new TTreeFormula("fEvent",fEventCut,fChain);
     515             :   
     516             :   Int_t current = -1;
     517             : 
     518           0 :   for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) {
     519             : 
     520           0 :     fChain->GetEntry(iTagFiles);
     521           0 :     if (current != fChain->GetTreeNumber()) {
     522           0 :       fRunFormula->UpdateFormulaLeaves();
     523           0 :       fLHCFormula->UpdateFormulaLeaves();
     524           0 :       fDetectorFormula->UpdateFormulaLeaves();
     525           0 :       fEventFormula->UpdateFormulaLeaves();
     526           0 :       current = fChain->GetTreeNumber();
     527           0 :      }
     528             :  
     529             :    //Event list
     530           0 :     iTotalEvents += tag->GetNEvents();
     531           0 :     localList->Reset();
     532           0 :     if(fRunFormula->EvalInstance(iTagFiles) == 1) {
     533           0 :       if(fLHCFormula->EvalInstance(iTagFiles) == 1) {         
     534           0 :         if(fDetectorFormula->EvalInstance(iTagFiles) == 1) {          
     535             :           //      Int_t iEvents = fEventFormula->GetNdata();
     536             :           // *** FIXME ***
     537             : 
     538             : 
     539             : //        const TClonesArray *tagList = tag->GetEventTags();
     540             : //        iRejectedEvtInFile = 0;
     541             : //        iAcceptedEvtInFile = 0;
     542             : //        for(Int_t i = 0; i < iEvents; i++) {
     543             : //          evTag = (AliEventTag *) tagList->At(i);
     544             : //          guid = evTag->GetGUID(); 
     545             : //          turl = evTag->GetTURL(); 
     546             : //          lfn = turl(8,turl.Length());
     547             : //          if(fEventFormula->EvalInstance(i) == 1) {
     548             : //            localList->Enter(i);
     549             : //            iAcceptedEvtInFile++;
     550             : //          }
     551             : //          else {
     552             : //            iRejectedEvt++;
     553             : //            iRejectedEvtInFile++;
     554             : //          }
     555             : //        }//event loop
     556             : 
     557           0 :           collection->WriteBody(iTagFiles+1,guid,lfn,turl,localList,iAcceptedEvtInFile, iRejectedEvtInFile);
     558           0 :           iAccepted += localList->GetN();
     559           0 :         }//detector tag cuts
     560             :         else {
     561           0 :           iRejectedDet += tag->GetNEvents();
     562             :         }
     563             :       }//lhc tag cuts 
     564             :       else {
     565           0 :         iRejectedLHC += tag->GetNEvents();
     566             :       }
     567             :     }//run tag cuts
     568             :     else {
     569           0 :       iRejectedRun += tag->GetNEvents();
     570             :     }
     571             :   }//tag file loop
     572           0 :   collection->WriteSummary(iTotalEvents, iAccepted, iRejectedRun, iRejectedLHC, iRejectedDet, iRejectedEvt);
     573           0 :   collection->Export();
     574             :   
     575           0 :   delete tag;
     576             :   return kTRUE;
     577           0 : }
     578             : 
     579             : //___________________________________________________________________________
     580             : TChain *AliTagAnalysis::GetInputChain(const char* system, const char *wn) {
     581             :   //returns the chain+event list - used in batch sessions
     582             :   // this function will be removed once the new root 
     583             :   // improvements are committed
     584           0 :   TString fsystem = system;
     585             :   Int_t iAccepted = 0;
     586             : 
     587             :   TChain *fAnalysisChain = 0;
     588           0 :   if(fAnalysisType == "ESD") fAnalysisChain = new TChain("esdTree");
     589           0 :   else if(fAnalysisType == "AOD") fAnalysisChain = new TChain("aodTree");
     590           0 :   else AliFatal("Only ESD and AOD type is implemented!!!");
     591             :   
     592             :   //Event list
     593           0 :   TEventList *fEventList = new TEventList();
     594           0 :   AliXMLCollection *collection = AliXMLCollection::Open(wn);
     595             : 
     596           0 :   collection->Reset();
     597           0 :   while (collection->Next()) {
     598           0 :     AliInfo(Form("Adding: %s",collection->GetTURL("")));
     599           0 :     if (fAnalysisChain) fAnalysisChain->Add(collection->GetTURL(""));
     600           0 :     TEntryList *list = (TEntryList *)collection->GetEventList("");
     601           0 :     for(Int_t i = 0; i < list->GetN(); i++) fEventList->Enter(iAccepted+list->GetEntry(i));
     602             : 
     603           0 :     if(fsystem == "pp") iAccepted += 100;
     604           0 :     else if(fsystem == "PbPb") iAccepted += 1;
     605             :   }
     606             : 
     607           0 :   if (fAnalysisChain) fAnalysisChain->SetEventList(fEventList);
     608             :   
     609           0 :   AliInfo(Form("Number of selected events: %d",fEventList->GetN()));
     610             : 
     611             :   return fAnalysisChain;
     612           0 : }
     613             : 
     614             : //___________________________________________________________________________
     615             : TChain*
     616             : AliTagAnalysis::CreateChainFromCollection(const char* collectionname, const char* treename)
     617             : {
     618             :   /// Build a TChain (with its TEntryList object attached) from an XML collection.
     619             :   /// Returned chain must be deleted by the client.
     620             : 
     621           0 :   TString streename(treename);
     622           0 :   if ( streename != "esdTree" && streename != "aodTree" )
     623             :   {
     624           0 :     AliErrorClass("Only esdTree and aodTree implemented so far...");
     625           0 :     return 0x0;
     626             :   }
     627             :   
     628           0 :   TChain* chain = new TChain(streename.Data());
     629             : 
     630             :   // create the event list for the chain. Will be attached to the chain
     631             :   // which thus becomes the owner of it.
     632           0 :   TEntryList* elist = new TEntryList; 
     633             :   
     634           0 :   AliXMLCollection* collection = AliXMLCollection::Open(collectionname);
     635             : 
     636             :   // Tag selection summary per file
     637           0 :   TMap* tagCutSummary = new TMap();
     638           0 :   tagCutSummary->SetName("TagCutSumm");
     639             : 
     640             :   Int_t iAccepted = 0;
     641             :   
     642           0 :   collection->Reset();
     643             :   
     644           0 :   while (collection->Next()) 
     645             :   {
     646           0 :     AliDebugClass(1,Form("Adding: %s",collection->GetTURL("")));
     647           0 :     chain->Add(collection->GetTURL(""));
     648           0 :     TEntryList *list = collection->GetEventList("");
     649           0 :     list->SetTreeName(streename.Data());
     650           0 :     list->SetFileName(collection->GetTURL(""));
     651           0 :     elist->Add(list);
     652           0 :     iAccepted += list->GetN();
     653           0 :     if (collection->GetCutSumm())
     654             :     {
     655           0 :       tagCutSummary->Add(new TObjString(collection->GetTURL("")), new TObjString(collection->GetCutSumm()));
     656             :     }
     657             :   }
     658             : 
     659           0 :   chain->SetEntryList(elist,"ne"); // ne => do not expand tree name and/or file names
     660             :   
     661           0 :   AliDebugClass(1,Form("Number of selected events: %d",iAccepted));
     662             : 
     663           0 :   TList *aUserInfo = chain->GetUserInfo();
     664           0 :   aUserInfo->Add(tagCutSummary);
     665             : 
     666           0 :   Int_t iAccEv;
     667           0 :   Int_t iTotalEvents;
     668           0 :   Int_t iRejRun;
     669           0 :   Int_t iRejLHC;
     670           0 :   Int_t iRejDet;
     671           0 :   Int_t iRejEvt;
     672             : 
     673           0 :   collection->GetCollectionSummary(&iTotalEvents, &iAccEv, &iRejRun, &iRejLHC, &iRejDet, &iRejEvt);
     674             :  
     675           0 :   char nstr[2000];
     676             : 
     677           0 :   snprintf(nstr, 2000, "TotalEvents=%i", iTotalEvents);
     678           0 :   TObjString *iTotStr = new TObjString(nstr);
     679           0 :   aUserInfo->Add(iTotStr);
     680             : 
     681           0 :   snprintf(nstr, 2000, "AcceptedEvents=%i", iAccepted);
     682           0 :   TObjString *iAccStr = new TObjString(nstr);
     683           0 :   aUserInfo->Add(iAccStr);
     684             : 
     685           0 :   snprintf(nstr, 2000, "RejectedRun=%i", iRejRun);
     686           0 :   TObjString *iRejRunStr = new TObjString(nstr);
     687           0 :   aUserInfo->Add(iRejRunStr);
     688             : 
     689           0 :   snprintf(nstr, 2000, "RejectedLHC=%i", iRejLHC);
     690           0 :   TObjString *iRejLHCStr = new TObjString(nstr);
     691           0 :   aUserInfo->Add(iRejLHCStr);
     692             : 
     693           0 :   snprintf(nstr, 2000, "RejectedDet=%i", iRejDet);
     694           0 :   TObjString *iRejDetStr = new TObjString(nstr);
     695           0 :   aUserInfo->Add(iRejDetStr);
     696             : 
     697           0 :   snprintf(nstr, 2000, "RejectedEvt=%i", iRejEvt);
     698           0 :   TObjString *iRejEvtStr = new TObjString(nstr);
     699           0 :   aUserInfo->Add(iRejEvtStr);
     700             : 
     701             :   return chain;
     702           0 : }

Generated by: LCOV version 1.11