-- LuciaAnnaHusova - 2017-08-03


Analysis with NanoAODs

NanoAODs are duplicates of AODs on the Grid, which contain only the information about tracks and events, which is really used in the analysis. Thus the NanoAODs file size is smaller than for AODs, but these are extra files to be saved. The analysis on the NanoAODs can be multiple times faster than on AODs, so the CPU time is saved. The speed up depends on the fraction of the stored information.

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
  • Same event and track cuts are used for each analysis rerun
  • Derived variables are used, which need a long time to be calculated
  • Analysis takes a lot of computing time
  • Analysis is often repeated

Differences between AODs and NanoAODs

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

AOD Analysis

Nano AOD Analysis

AliAODTrack AliNanoAODTrack
AliNanoAODTrack inherits from AliVTrack like AliAODTrack does. If the NanoAOD generation was done properly the track information can be accesed the same way like in AODs, e.g.:
AliNanoAODTrack *particle = new AliNanoAODTrack();
particle = (AliNanoAODTrack *) aodEvent->GetTrack(0); 
Double_t pt = particle->Pt();

Note: some functions are not implemented, so always have a look in the class AliNanoAODTrack, if you want to use more complex functions. Functions which were recently changed in AODTracks, might not have been changed in NanoAODTracks.

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

The easiest way to distinguish the NanoAOD dataset from other datasets in the analysis, is to check, if the Header inherits from AliNanoAODStorage. You can use this example:

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

NanoAOD Generation

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);

Functions Needed paramters
Eta() theta
Px(), Py(), Pz() pt, theta, phi
P() pt, theta, phi
PropagateToDCA() posX, posY, covmat, MagField (in AliNanoAODHeader)
ZAtDCA() IsMuonTrack, posY, posZ
DCA() posDCAx, posDCAz, posx
    • Only the parameters are stored which are defined in the the wagon settings by NanoAOD generation:

__R_ADDTASK__->SetVarList("pt,phi,theta,covmat");

  • AliNanoAODHeader
    • list of parameters, which can be stored:
      • centrality: TRK, CL0, CL1, V0M (CentrTRK,CentrCL0,CentrCL1,Centr)
      • magnetic field ( MagField)
      • run number (RunNumber)
    • Only the parameters are stored which are defined in the the wagon settings by NanoAOD generation:

 __R_ADDTASK__->SetVarListHead("Centr,RunNumber");

How to implement new custom variables to AliNanoAODTrack

The custom variables are all the variables which don't have a function in AliNanoAODTrack and differ from user to user.

The custom variables for AliNanoAODTrack should be implemented in the function AliNanoAODSimpleSetter ::SetNanoAODTrack (the class AliNanoAODSimpleSetter doesn't have own file, it could be found in AliAnalysisNanoAODCuts ). Your own variables shouldn't be in this SimpleSetter , thus make a copy of AliAnalysisNanoAODCuts with a name AliAnalysisNanoAODCutsMyTask and implement the method SetNanoAODTrack in the way, you need for your analysis. All new variables can be stored only in the format of a Double_t. There is an example of pt^2 and rapidity.

Pt^2 example

1. Get and compute your variable:

void AliNanoAODSimpleSetterMyTask::SetNanoAODTrack (const AliAODTrack * aodTrack, AliNanoAODTrack * spTrack) {
Double_t pt = aodTrack->Pt();
Double_t pt2 = TMath::Power(pt,2);

2. Get an index for this variable with which you can acces the variable. Remember, that the name has to begin with the prefix "cst":

static  Int_t Pt2Index  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstPt2");

3. Store the variable in the new AliNanoAODTrack

spTrack->SetVar(Pt2Index,pt2);
}

4. Define your setter and this variable in the wagon settings. The name of the variable has to be the same as in 2.:

AliNanoAODSimpleSetterMyTask* setter = new AliNanoAODSimpleSetterMyTask();
__R_ADDTASK__->SetSetter(setter);
__R_ADDTASK__->SetVarList("... cstPt2 ... ");

5. Finally use your custom variable in your AnalysisTask. Get the variable index at the begining of the task, so it doesn't be read for every track separately

const Int_t pt2Index =AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstPt2");
...
AliNanoAODTrack *nanoTrack = AliAODEvent -> GetTrack(i);
Double_t pt2 = nanoTrack->GetVar(pt2Index);
...

Rapidity example

1. Get and compute your variable in the method SetNanoAODTrack:

AODTrkPID_t trPID = aodTrack->GetMostProbablePID();
Double_t rapidity = aodTrack->Y(trPID);

2. Get an index for this variable

static  Int_t rapidityIndex  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstY");

3. Store the variable in the new AliNanoAODTrack

spTrack->SetVar(rapidityIndex,rapidity);

4. Define your setter and this variable in the wagon settings.The name of the variable has to be the same as in 2.:

AliNanoAODSimpleSetterMyTask* setter = new AliNanoAODSimpleSetterMyTask();
__R_ADDTASK__->SetSetter(setter);
__R_ADDTASK__->SetVarList("... cstY ... ");

5. Finally use your custom variable in your AnalysisTask

...
AliNanoAODTrack *nanoTrack = AliAODEvent -> GetTrack(i);
Double_t rapidity = nanoTrack->GetVar(AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstY"));
...

How to implement a new custom variable to AliNanoAODHeader

The AliNanoAliAODHeader is set by the method AliNanoAODSimpleSetter::SetNanoHeader. The new custom variables have to be defined and added to the array of header variables in AliNanoAODSimpleSetter. The procedure is very similar to the one of implementing new variable to AliNanoAODTrack. If you have not already made a copy of AliNanoAODCuts, do so and implement the custom variable in the method SetNanoHeader. Example for the variable Pile-Up:

1. Copy your own Pile-Up function to the class AliNanoAODSimpleSetterMyTask:

Bool_t AliNanoAODSimpleSetterMyTask::MyPileUpInfo(AliAODEvent* event){
    Bool_t pass = kTRURE;
    ...
    return pass;
}

2. Get an index for this variable:

 static Int_t pileUpIndex = head->GetVarIndex("cstPileUp");

3. Store the variable into NanoAODHeader (In that the variables can be stored only in a format of a Double_t, store 0 or 1 ):

Bool_t isPileUp = MyPileUpInfo(event);
if (isPileUp) head->SetVar(pileUpIndex,1.);
else head->SetVar(pileUpIndex,0.);

4. Add this variable in the wagon settings:

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

5. Use the new variable in your AnalysisTask:

AliNanoAODHeader *nanoHeader = (AliNanoAODHeader*) event -> GetHeader();
Double_t pileUp = nanoHeader->GetVar(nanoHeader->GetVarIndex("cstPileUp"));

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, all the useless events and tracks aren't stored, so the size of NanoAODs file is even smaller and the analysis last shorter.

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. If you have done the copy to implement some custom variables, use the same file to implemt the cuts. Some cuts are already implemented:

  • Track cuts
  • Event cuts
    • Vertex range
    • Multiplicity range

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 :

AliAnalysisNanoAODEventCutsMyTask* evt = new AliAnalysisNanoAODEventCutsMyTask;
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:

Screen_Shot_2017-08-07_at_09.16.03.png

  • env.sh: Here you'll need to configure the train environment. The dataset is selected here and the whole train configuration is done, e.g. the AliPhysics version and the run number are selected. 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. Download this file and the runTest.sh from Local train test .
  • generator_customization.C, globalvariables.C and runTest.sh

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 to download the input files. They will be saved in the same folder as runTest.sh. A new text file will be created 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.

Screen_Shot_2017-08-07_at_10.10.02.png

In the NanoAOD wagon basic setting, the variables and the cuts should be defined. With red is highlighted the important configuration part, where the stored variables are selected.

Screen_Shot_2017-08-07_at_10.10.12.png

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

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. Mark the check box "keep longer than 2 months". If you don't want to use the derived dataset anymore, please delete it by unmark this checkbox in certain train run.

Screen_Shot_2017-08-21_at_17.09.50.png

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 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  
Edit | Attach | Watch | Print version | History: r20 < r19 < r18 < r17 < r16 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r19 - 2017-08-23 - 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-2021 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