-- LuciaAnnaHusova - 2017-08-03


Analysis with NanoAODs

NanoAODs are duplicate of AODs 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 (CentrTRK,CentrCL0,CentrCL1,cstCentr)
      • magnetic field (MagField)
      • run number (RunNumber)
    • the stored parameters are defined in the the wagon settings:
__R_ADDTASK__->SetVarListHead("Centr,RunNumber"); 

You can store your custom variables as well.

How to implement new custom variables to AliNanoAODTrack

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 pt2 and rapidity.

Pt2 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 (all variables have an index, which represent the name of the certain 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:

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

5. Finally use your custom variable in your AnalysisTask

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

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:

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 NanoAliAODHeader is set by the method AliNanoAODSimpleSetter::SetNanoHeader, so the new custom variables, which should be stored in the AliNanoAODHeader, have to be defined and added to the array of header variables here. The procedure is very similar to the one of implementing new variable to AliNanoAODTrack. If you have already made a copy of AliNanoAODCuts, implement the custom variable in the method SetNanoHeader. If not make a copy and do the same. 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, 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 < r19 < r18 < r17 < r16 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r17 - 2017-08-21 - 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