-- LuciaAnnaHusova - 2017-08-03


Analysis with NanoAODs

NanoAOD is a duplicate of AOD on the Grid, which contains only the information about tracks and events, which is really used in the analysis. Thus NanoAODs file size is smaller than for AODs and the analysis can be more than 2 times faster, where the speed depends on how much information is stored.

Use Case of Nano AODs

NanoAODs can be used in these cases:

  • For the analysis, only a limited subset of the AOD information is needed
  • Certain cuts are set on events or tracks
  • Derived variables are used, which calculation takes a long time in a future reprocessing
  • Analysis which takes a lot of computing time
  • Analysis which is often repeated

Differences between AODs and NanoAODs

Only a few changes in AnalysisTask are needed to use the NanoAODs. The information is stored in AliAODEvent, AliNanoAODTrack and AliNanoAODHeader, as is shown in the table below.

AOD Analysis

Nano AOD Analysis

AliAODTrack AliNanoAODTrack
AliNanoAODTrack inherits from AliVTrack. Thus all the functions from AliVTrack are available to use for AliNanoAODTrack, but the information has to be stored firstly. e.g.:
AliNanoAODTrack *particle = new AliNanoAODTrack();
particle = (AliNanoAODTrack *) aodEvent->GetTrack(0); 
Double_t pt = particle->Pt();

Note: some functions are not implemented at all and some are not implemented correctly, so always have a look in the class AliNanoAODTrack, if you want to use more complex function than some getters, if it's implemented correctly.

Some information, which is normally read from AliAODEvent, is stored in AliNanoAODHeader, e.g. centrality:
AliNanoAODHeader* head = (AliNanoAODHeader *)aodEvent -> GetHeader();
Double_t centV0M = head->GetCentr("V0M");

The easiest way, how to distinguish the NanoAOD dataset from others in the analysis, is to use the inherit dependence, because the AliNanoAODHeader and the AliNanoAODTrack inherits from AliNanoAODStorage. You can use this example:

TObject *head = event->GetHeader();
if(!head->InheritsFrom("AliNanoAODStorage")){ // this is the analysis part for AOD/ESD
...
}
if(head->InheritsFrom("AliNanoAODStorage")){ // this is the analysis part for nanoAOD
AliNanoAODHeader *nanohead = (AliNanoAODHeader*) head;
...
}

Which information can be stored

  • AliAODEvent
    • the primary vertex is always stored. Only in case the event is empty, the primary vertex isn't stored.
    • AliVZERO and AliAODZDC could be stored as well, but it should be added to the wagon settings:
__R_ADDTASK__->ReplicatorSaveVzero(kTRUE);
__R_ADDTASK__->ReplicatorSaveAODZDC(kTRUE);

__R_ADDTASK__->SetVarList("pt,phi,theta,covmat");
  • AliNanoAODHeader
    • list of parameters, which can be stored:
      • centrality: TRK, CL0, CL1, V0M (cstCentrTRK,cstCentrCL0,cstCentrCL1,cstCentr)
      • magnetic field (cstMagField)
      • run number (cstRunNumber)
    • the stored parameters are defined in the the wagon settings always with the prefix "cst":
__R_ADDTASK__->SetVarListHead("cstCentr,cstRunNumber"); 

How to implement a new variables to AliNanoAODTrack

If a new variable should be implemented in AliNanoAODTrack, first a new index should be implemented in AliNanoAODTrackMapping as in the example below for TOFsignal (each variable has its own index, because they are stored in an array):

1. Add in AliNanoAODMapping.h new data member, and make Set and Get functions:

...
Int_t fTOFsiggnal; //Mapping variable
...
void SetTOFsignal (Int_t var) { fTOFsiggnal = var; }
...
Int_t GetTOFsignal() {return fTOFSignal;}
...

2. Add the new data member to the both constructors in AliNanoAODMapping.cxx

...
fTOFsiggnal(-1),
...

3. Add name of the new variable to validatorString in AliNanoAODMapping.cxx

static const char * validatorString[] = { ... , "TOFsignal", ...};

4. Add the new variable to the iterating loop in AliNanoAODMapping.cxx

while ((token = (TObjString*) it.Next())) {
...
     else if(var == "TOFsignal" ) fTOFsignal = index;
...
}

5. Add the new variable in functions GetVarIndex and GetVarName in AliNanoAODMapping.cxx

Int_t AliNanoAODTrackMapping::GetVarIndex(TString varName){ 
...
   else if(varName == "TOFsignal"        ) return fTOFsignal        ;
...
}
 const char * AliNanoAODTrackMapping::GetVarName(Int_t index) const {
...
   else if(index == fTOFsignal        )  return "TOFsignal"        ;
...
}

6. Implement the new variable in the constructor in AliNanoAODTrack.cxx

for (Int_t index = 0; index < AliNanoAODTrackMapping::GetInstance()->getSize(); index++){
...
    else if(varString == "TOFsignal") SetVar(AliNanoAODTrackMapping::GetInstance()->GetTOFsignal(), aodTrack->GetTOFsignal() );
...
}    

7. Implement simple Get method for the new variable in AliNanoAODTrack.h

Double_t GetTOFsignal()const { return GetVar(AliNanoAODTrackMapping::GetInstance()->GetTOFsignal()); } 

How to implement a new variable to AliNanoAODHeader

The NanoAliAODHeader is set by the method AliNanoAODSimpleSetter::SetNanoHeader (the class AliNanoAODSimpleSetter doesn't have own file, it could be found in AliAnalysisNanoAODCuts), so the new variables, which should be stored in the AliNanoAODHeader, have to be defined and added to the array of header variables here and a new method to call this variable should be implemented in AliNanoAODHeader.h. Example for the variable runNumber:

1. Add a new variable index as a data member in AliNanoAODHeader.h

 Int_t fRunNumber;  // index of stored variable

2. Create Get and Set Functions for this index

 void SetRunNumberIndex  (Int_t var) { fRunNumber = var; }
 Int_t GetRunNumberIndex  () { return fRunNumber ; }

3. Add the new index to the constructors in AliNanoAODHeader.cxx

...
fRunNumber(-1),
...

4. Add the new variable to the validator string in AliNanoAODSimpleSetter::SetNanoHeader (it must be the same name, which you will add in the train configuration and it must begin with cst)

static const char * validatorString[] = { ... , "cstRunNumber" , ...}

5. Add the new variable to the iterating loop in AliNanoAODSimpleSetter::SetNanoHeader

while ((token = ( [[TObjString][TObjString]]*) it.Next())) {
...
else if(var == "cstRunNumber"  ) head->SetRunNumberIndex  (index);
...
}

6. Add a new variable in AliNanoAODSimpleSetter::SetNanoHeader:

Int_t runNumber = event->GetRunNumber();
if ((head->GetRunNumberIndex())!=-1) head->SetVar(head->GetRunNumberIndex(), Double_t(runNumber));

7. Implement new method for this variable in AliNanoAODHeader:

Int_t  GetRunNumber() const { return Int_t(GetVar(fRunNumber)); }

8. Finally add the new variable to the train configuration

__R_ADDTASK__->SetVarListHead(" ... cstRunNumber, ... "); 

In AliNanoAODHeader and AliNanoAODTrack, the variables can be stored only in the format of Double_t.

Events and track cuts

All cuts could be done as usually in the analysis. Thus many variables have to be stored in NanoAODs, so NanoAODs become more complex and the size of the file bigger, but it can be used by more users.

Some or all cuts could be done during the generation of NanoAODs as well. In this case, the size of NanoAODs file is even smaller and the analysis last shorter, because all the events and tracks, which are cut anyway during the analysis, aren't stored at all.

NanoAODs with customised cuts

The best way, how to implement customised cuts in the NanoAOD generation, is to create a copy of AliAnalysisNanoAODCuts in the folder $ALICE_PHYSICS/PWG/DevNanoAOD where all the cuts could be implemented, or copy to this folder your own cuts file. The new cuts have to be associated with the task in the wagon settings, where could be set the values of the cuts as well :

AliAnalysisNanoAODEventCutsExample* evt = new AliAnalysisNanoAODEventCutsExample;
evt->SetVertexRange(8);
__R_ADDTASK__->SetEvtCuts(evt);

Local generation of NanoAODs

The NanoAODs could be generated locally with the Local train test. All files could be downloaded directly from the train configuration, if such a train already exists, or you can find example files on the bottom of the page:

  • MLTrainDefinition .cfg is a configuration for the train. You'll have to add the AddTaskNanoAODFilter .C macro, define and set the event and track cuts, which should be done during the NanoAODs generation. There can be added so many cuts, you implemented before in AliAnalysisNanoAODCuts . Afterwards you'll have to define a setter for the NanoAODHeader and all the variables, you want to be stored in AliNanoAODTrack and AliNanoAODHeader . An example, you can find below.
  • Screen_Shot_2017-08-07_at_08.54.26.png
  • handlers.C: You'll have to add an OutputHandler here, as in the example below:Screen_Shot_2017-08-07_at_09.16.03.png
  • env.sh: Here you'll need to configure the train environment. You can just download the file from train test running on the datasets, which you want to generate the NanoAODs from
  • generate.C: The number of input files can be changed here. Otherwise no changes are needed here.
  • generator_customization.C, globalvariables.C and runTest.sh don't need any further changes

To run the local NanoAODs generation, you'll have to initialise the correct version of Root, AliRoot and AliPhysics and to run the runTest.sh. You will need the AliEn connection, because of the downloading of the input files. They will be saved in the same folder as runTest.sh. There will be created a new text file pointing to the input files.

Generation of NanoAODs on the Grid

The procedure is the same as for normal analysis train run, only a few changes should be done. The OutputHandler has to be defined additionally to the AOD handler and the PWG/DevNanoAOD/AddTaskNanoAODFilter.C should be used as the AddTask macro. In the NanoAOD wagon basic setting, the variables and the cuts should be defined.

Screen_Shot_2017-08-07_at_10.10.02.png

Screen_Shot_2017-08-07_at_10.10.12.png

By starting a new run, a data should be selected, which you want to create your derived dataset from and the checkbox derived data production and slow train should be marked.

Screen_Shot_2017-08-10_at_16.48.11.png

The output files are not merged and they are kept for 2 months on the Grid. If you want the files to be kept for longer, the operator can define it.

When you want to start a new analysis with the derived data set, this has to be selected in data sets by creating new dataset.

Screen_Shot_2017-08-10_at_16.48.54.png

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatcfg MLTrainDefinition.cfg r1 manage 1.3 K 2017-08-10 - 16:34 LuciaAnnaHusova  
Unix shell scriptsh env.sh r1 manage 1.6 K 2017-08-10 - 16:30 LuciaAnnaHusova  
C source code filec generate.C r1 manage 9.8 K 2017-08-10 - 16:30 LuciaAnnaHusova  
C source code filec generator_customization.C r1 manage 0.1 K 2017-08-10 - 16:30 LuciaAnnaHusova  
C source code filec globalvariables.C r1 manage 0.1 K 2017-08-10 - 16:30 LuciaAnnaHusova  
C source code filec handlers.C r1 manage 0.4 K 2017-08-10 - 16:30 LuciaAnnaHusova  
Unix shell scriptsh runTest.sh r1 manage 0.6 K 2017-08-10 - 16:30 LuciaAnnaHusova  
Edit | Attach | Watch | Print version | History: r20 | r17 < r16 < r15 < r14 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r15 - 2017-08-18 - LuciaAnnaHusova
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback