FAIRRoot what it can do for the continuous

  • Slides: 34
Download presentation
FAIRRoot - what it can do? (for the continuous readout simulation) M. Al-Turany 9/26/2020

FAIRRoot - what it can do? (for the continuous readout simulation) M. Al-Turany 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 1

This Talk • Describe the problem of continuous readout as seen by FAIR experiments

This Talk • Describe the problem of continuous readout as seen by FAIR experiments • Describe the implantation of the continuous readout in Fair. Root 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 2

Event by event simulation • • Each collision from the event generator is treated

Event by event simulation • • Each collision from the event generator is treated as one event The product from one collision are propagated via MC engine to all detector geometries • The detector response is stored in tree entries where each detector have one or more branches and each entry correspond to a collision from the event generator • No information about the time between successive events (entries) is stored 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 3

Digitization without time information (Event by event) Detector Monte-Carlo Points Detector Digits Event number

Digitization without time information (Event by event) Detector Monte-Carlo Points Detector Digits Event number A B C 1 A 1 B 1 C 1 2 A 2 B 2 C 2 3 A 3 B 3 C 3 4 A 4 B 4 C 4 5 A 5 B 5 C 5 Event number DA DB DC 1 DA 1 DB 1 DC 1 2 DA 2 DB 2 DC 2 3 DA 3 DB 3 DC 3 4 DA 4 DB 4 DC 4 5 DA 5 DB 5 DC 5 Digitization (Detector response simulation) MC file does not know anything about time structure 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 4

BUT in experiments events do overlap? • • In Detectors: • Sensor elements are

BUT in experiments events do overlap? • • In Detectors: • Sensor elements are still blocked from previous hits • Electronic is still busy • Hits too close in time cannot be distinguished • … Special problem for CBM and PANDA: • Continuous beam with Poisson statistics (? ) many events with short time between them • No hardware trigger • Complex event reconstruction • Necessary to simulate data stream as realistic as possible 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 5

Stored in the MC points of each detector Sensor Time of flight (tof) Event

Stored in the MC points of each detector Sensor Time of flight (tof) Event Time 9/26/2020 Time Stamp is: • Time assigned to each detector hit • Absolute time that includes (Event time, Tof, Electronics time) • Resolution and offset depends on individual detector Assigned to Events in digitization Fair. Run. Ana: Set. Event. Mean. Time(Double_t) Fair. Root. Manager: : Get. Event. Time() M. Al-Turany, Time based simulation in Fair. Root 6

Time of flight (tof) Sensor U Uthr Time. Stamp t Event Time 9/26/2020 M.

Time of flight (tof) Sensor U Uthr Time. Stamp t Event Time 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 7

Time of flight (tof) Sensor U Uthr Time. Stamp is charge dependent t Event

Time of flight (tof) Sensor U Uthr Time. Stamp is charge dependent t Event Time 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 8

Time of flight (tof) Sensor U 2 nd hit in same detector element Uthr

Time of flight (tof) Sensor U 2 nd hit in same detector element Uthr t Event Time 9/26/2020 • Strongly detector dependent • Time window of an event can influence any other event happening in the same detector element • What happens if a second hit happend during the active time of a previous it is also strongly detector dependent (hit lost, new hit modified, old hit modified, new hits created, …) M. Al-Turany, Time based simulation in Fair. Root 9

Time of flight (tof) Sensor U Start Time Active Time Uthr t Event Time

Time of flight (tof) Sensor U Start Time Active Time Uthr t Event Time 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 10

We need digitization with time information ! Detector A : Fast Detector B :

We need digitization with time information ! Detector A : Fast Detector B : Slower Detector C : the slowest Detector Digits Detector Monte-Carlo Points Entry number A B C 1 A 1 B 1 C 1 2 A 2 B 2 C 2 3 A 3 B 3 C 3 4 A 4 B 4 C 4 5 A 5 B 5 C 5 9/26/2020 Digitization (Detector response simulation) time DA DB t 1 DA 1+2 DB 1 t 2 DA 3+4+5 DB 2+3 t 3 DB 4 t 4 DB 5 DC DC 1 DC 2 t 5 DC 3 t 6 DC 4 t 7 t 8 M. Al-Turany, Time based simulation in Fair. Root DC 5 11

Time based simulation by T. Stockmanns Event Structure 9/26/2020 M. Al-Turany, Time based simulation

Time based simulation by T. Stockmanns Event Structure 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 12

Implementation in Fair. Root • What is needed to make time based simulation? •

Implementation in Fair. Root • What is needed to make time based simulation? • What should be changed in user code? 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 13

Time based simulation: Technical points • TClones. Arrays are used and objects are moved

Time based simulation: Technical points • TClones. Arrays are used and objects are moved between them and not copied (no copy overhead) • TBranch: : Get. Entry() is used to read each branch separately, no size overhead • User interface is kept as it is for the event by event simulations, minimal changes of the reconstruction code 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 14

Time information • • MC file does not know anything about time structure Can

Time information • • MC file does not know anything about time structure Can be set via the Fair. Run. Ana after MC o o • Set the min and max limit for event time in ns Set. Event. Time. Interval(Double_t min, Double_t max) (Time set via Uniform Random between min and max) Set the mean time for the event in ns Set. Event. Mean. Time(Double_t m) (Event time is an exponential deviate. ) After simulation it is in Fair. Event. Header • Event time can be access via: Fair. Root. Manager: : Get. Event. Time() 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 15

From event by event to time based simulation (First Step: Data classes) • Check

From event by event to time based simulation (First Step: Data classes) • Check the data object you want to store: • Does it derive form Fair. Time. Stamp ? • Does it have an operator<< ? • Does it have an bool operator< (const your. Class& name) const ? • Does it have an equal(Fair. Time. Stamp*) method? • The equal method should return true if two identical detector elements are compared (e. g. the same pixel, pad, strip, straw, …) • It should not check if the data in the element is identical as well An example can be found in Fair. Test. Detector. Digi https: //github. com/Fair. Root. Group/Fair. Root/tree/master/example/Tutorial 3/data/Fair. T est. Detector. Digi. h 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 16

Fair. Writeout. Buffer • • Special buffer to store detector data between events You

Fair. Writeout. Buffer • • Special buffer to store detector data between events You give the data you want to store an absolute time window this data is active in your detector and can influence later events. • • If the same detector element is hit a second time the data is modified. This is an abstract base class where you have to inherit from 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 17

Fair. Test. Detector. Digi. Writeout. Buffer #include "Fair. Writeout. Buffer. h" #include "Fair. Test.

Fair. Test. Detector. Digi. Writeout. Buffer #include "Fair. Writeout. Buffer. h" #include "Fair. Test. Detector. Digi. h” class Fair. Time. Stamp; class Fair. Test. Detector. Digi. Writeout. Buffer : public Fair. Writeout. Buffer { public: Fair. Test. Detector. Digi. Writeout. Buffer(); Fair. Test. Detector. Digi. Writeout. Buffer(TString branch. Name, TString folder. Name, Bool_t persistance); virtual ~Fair. Test. Detector. Digi. Writeout. Buffer(); void Add. New. Data. To. TClones. Array(Fair. Time. Stamp*); virtual double Find. Time. For. Data(Fair. Time. Stamp* data) ; virtual void Fill. Data. Map(Fair. Time. Stamp* data, double active. Time) ; virtual void Erase. Data. From. Data. Map(Fair. Time. Stamp* data); protected: std: : map<Fair. Test. Detector. Digi, double> f. Data_map; Class. Def(Fair. Test. Detector. Digi. Writeout. Buffer, 1); }; 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 18

Fair. Writeout. Buffer: : Modify() Optional method to implement Pile. Up behavior • Modify(…)

Fair. Writeout. Buffer: : Modify() Optional method to implement Pile. Up behavior • Modify(…) is called if data should be written into the buffer of an element which already exists in the buffer (e. g. same pixel hit a second time) • The standard behavior is that the new data is just ignored 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 19

From event based to time based simulation (Setting the output buffers) Init. Status Fair.

From event based to time based simulation (Setting the output buffers) Init. Status Fair. Test. Detector. Digi. Task: : Init() { …. f. Digi. Array = new TClones. Array ("Fair. Test. Detector. Digi"); ioman->Register("Fair. Test. Detector. Digi", "Fair. Test. Detector", f. Digi. Array, k. TRUE); …} If the variable f. Time. Ordered. Digi is set to k. FALSE the behaviour of the buffer is identical to the standard storage of data Init. Status Fair. Test. Detector. Time. Digi. Task: : Init()TClones. Array { … f. Data. Buffer = new Fair. Test. Detector. Digi. Writeout. Buffer("Fair. Test. Detector. Digi", "TOY", k. TRUE); f. Data. Buffer = (Fair. Test. Detector. Digi. Writeout. Buffer*) ioman->Register. Writeout. Buffer("Fair. Test. Detector. Digi", f. Data. Buffer); f. Data. Buffer->Activate. Buffering(f. Time. Ordered. Digi); …} 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 20

From event based to time based simulation (Creating the digits) Fair. Test. Detector. Digi*

From event based to time based simulation (Creating the digits) Fair. Test. Detector. Digi* digi = new ((*f. Digi. Array)[ipnt]) Fair. Test. Detector. Digi(x. Pad, y. Pad, z. Pad, timestamp); Fair. Test. Detector. Digi* digi = new Fair. Test. Detector. Digi(x. Pad, y. Pad, z. Pad, timestamp); …… f. Data. Buffer->Fill. New. Data(digi, time. Of. Flight + event. Time, digi->Get. Time. Stamp() + 10); Data class The absolute active time of the data The absolute start time of the data U Start Time Active Time Uthr t 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 21

Sorting the data • It is essential for the later extraction of the data

Sorting the data • It is essential for the later extraction of the data that it is sorted by its time stamp • A base class for the sorter (Fair. Ring. Sorter) and a base class for a sorter task (Fair. Ring. Sorter. Task) are already implemented in the software • To use them you have to derive your own sorter classes from them and overwrite some methods • For the Fair. Ring. Sorter only the method Create. Element() has to be overwritten. (This method creates a new element of the object which was passed by a Fair. Time. Stamp pointer to the method) 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 22

Technical implementation – Ring Sorter Number of storage cells given by the spread of

Technical implementation – Ring Sorter Number of storage cells given by the spread of the time stamps within the data stream Width of one storage cell given by time resolution of detector 0 -Element Pointer Storage Pointer position calculated numerically from time stamp If a storage position is calculated which would override old data, the old data is saved to disk and the storage cell is freed 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 23

Fair. Ring. Sorter • For the Fair. Ring. Sorter only the method Create. Element()

Fair. Ring. Sorter • For the Fair. Ring. Sorter only the method Create. Element() has to be overwritten • This method creates a new element of the object which was passed by a Fair. Time. Stamp pointer to the method Fair. Time. Stamp* Fair. Test. Detector. Digi. Ring. Sorter: : Create. Element(Fair. Time. Stamp* data) { return new Fair. Test. Detector. Digi(*(Fair. Test. Detector. Digi*)data); } 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 24

Fair. Ring. Sorter. Task • For the Fair. Ring. Sorter. Task two methods have

Fair. Ring. Sorter. Task • For the Fair. Ring. Sorter. Task two methods have to be overwritten: Init. Sorter and Add. New. Data. To. TClones. Array Fair. Ring. Sorter* Fair. Test. Detector. Digi. Sorter. Task: : Init. Sorter (Int_t number. Of. Cells, Double_t width. Of. Cells) const { return new Fair. Test. Detector. Digi. Ring. Sorter(number. Of. Cells, width. Of. Cells); } void Fair. Test. Detector. Digi. Sorter. Task: : Add. New. Data. To. TClones. Array(Fair. Time. Stamp* data) { Fair. Root. Manager* ioman = Fair. Root. Manager: : Instance(); TClones. Array* my. Array = ioman->Get. TClones. Array(f. Output. Branch); new ((*my. Array)[my. Array->Get. Entries()]) Fair. Test. Detector. Digi(*(Fair. Test. Detector. Digi*)(data)); } 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 25

The digitization task Fair. Test. Detector. Digi. Task* digi. Task = new Fair. Test.

The digitization task Fair. Test. Detector. Digi. Task* digi. Task = new Fair. Test. Detector. Digi. Task(); f. Run->Add. Task(digi. Task); f. Run->Set. Event. Mean. Time(50); Fair. Test. Detector. Time. Digi. Task* digi. Task = new Fair. Test. Detector. Time. Digi. Task(); digi. Task ->Run. Time. Based(); f. Run->Add. Task(digi. Task ); Fair. Test. Detector. Digi. Sorter. Task* digi. Sorter = new Fair. Test. Detector. Digi. Sorter. Task (5000, 50, "Fair. Test. Detector. Digi", "Fair. Test. Detector. Sorted. Digi", "toy"); f. Run->Add. Task(digi. Sorter); 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 26

Reading back data • Fair. Root. Manager has new reading algorithms, which make it

Reading back data • Fair. Root. Manager has new reading algorithms, which make it possible to use the event wise implemented tasks to run on such data streams • • Different algorithms available to extract data: • All data up to a given time • All data in a time window • All data between time gaps of a certain size Other algorithms can be (easily) implemented 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 27

Reading back data • • Reading back data is done via the Fair. Root.

Reading back data • • Reading back data is done via the Fair. Root. Manager Two different methods exists Fair. Root. Manager: : Get. Data(Branch. Name, Functor, Parameter); Fair. Root. Manager: : Get. Data(Branch. Name, Start. Functor, Start. Param. , Stop. Functor, Stop. Param. ); • Get. Data with one functor/parameter runs always forward in time • • Data is only read once Get. Data with two sets of functor/parameter is able to get data within a time interval • Data can be extracted many times • Works only with special functors next page 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 28

What is a Functor? • A (binary) functor is a class with an operator()

What is a Functor? • A (binary) functor is a class with an operator() which takes two parameters as an input and has one output. • In our case the parameters are Fair. Time. Stamp*, double as input and bool as output. • • • In this way you can define your own data selectors Existing examples: • Stop. Time: Returns all data with a Time. Stamp less than the given parameter • Time. Gap: Returns all data before a time gap larger than the given parameter For the Get. Data-Method with two functors the first has to be the Stop. Time - functor 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 29

Changes in RECO Task: Fair. Test. Detector. Time. Reco. Task. h #ifndef Fair. Test.

Changes in RECO Task: Fair. Test. Detector. Time. Reco. Task. h #ifndef Fair. Test. Detector. Time. Reco. Task_H #define Fair. Test. Detector. Time. Reco. Task_H #include "Fair. Task. h" #include "Fair. TSBuffer. Functional. h” class Fair. Test. Detector. Time. Reco. Task : public Fair. Task {. . . Binary. Functor* f. Functor; //! Class. Def(Fair. Test. Detector. Time. Reco. Task, 1); }; #endif 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 30

Changes in RECO Task: Fair. Test. Detector. Time. Reco. Task. cxx • Init() f.

Changes in RECO Task: Fair. Test. Detector. Time. Reco. Task. cxx • Init() f. Functor = new Stop. Time(); • Exec(). . . if (Fair. Run. Ana: : Instance()->Is. Time. Stamp()){ f. Digi. Array = Fair. Root. Manager: : Instance()-> Get. Data( ”Fair. Test. Detector. Sorted. Digi”, f. Functor, Fair. Run. Manager: : Instance()->Get. Event. Time() + 200); }. . . f. Hitarray->Sort() 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 31

RECO Macro: • To activate the reading back of the data via the functors

RECO Macro: • To activate the reading back of the data via the functors you have to add f. Run->Run. With. Time. Stamps() in your reco macro. • If you leave Run. With. Time. Stamps() away Get. Data(…) returns the data as it is stored in the entries of your digit branch 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 32

Time based simulation summary • It is available in the Fair. Root o https:

Time based simulation summary • It is available in the Fair. Root o https: //github. com/Fair. Root. Group/Fair. Root/tree/master/example/Tutori al 3 is an example of a full detector implementation with and without time based simulation • Detector digitizers has to adapt to it, if they went to use it (with one flag you can keep the backward compatibility to event by event simulation) • • • User interface is the same as for the “event by event” simulation Most of the PANDA detectors are working in this mode now Documentation is available : https: //github. com/Fair. Root. Group/Fair. Root/wiki/Time-based-simulation 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 33

Thanks! 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 34

Thanks! 9/26/2020 M. Al-Turany, Time based simulation in Fair. Root 34