Mitglied der HelmholtzGemeinschaft Time based simulation Workshop in
Mitglied der Helmholtz-Gemeinschaft Time based simulation Workshop in Torino 25. 07. 2012 20. Januar 2022 | Tobias Stockmanns
Event Mixing (Mohammad’s work) MC Files: Background Digiti zation Signal 1 Event 0: Signal 2 from BG with time 50. 3 Event 1: from BG with time 72. 4 …………………. Event 102: from Signal 1 with time 10230. 1 • MC file does not know anything about time structure • Time structure is calculated in Digitization stage • Many different signal files can be added to one background file • Where the data is coming from is stored in Event. Header • No overlap (pileup) of events • See presentation of Mohammad (last EVO Meeting) • Not topic of this workshop … 20. Januar 2022 Tobias Stockmanns Folie 2
How do events overlap? • Problem: In the current version of the software each event can be treated completely independent of each other and time between events does not play a role. This is not the reality in experiments: • Sensor elements are still blocked from previous hits • Electronic is still busy • Hits to close in time cannot be distinguished • … • Special problem for PANDA: • Continuous beam with Poisson statistics many events with short time between them • No hardware trigger 20. Januar 2022 Tobias Stockmanns Folie 3
Event Structure and Detector Response ev 1 ev 2 ev 3 time Sci. Til EMC MVD STT . . . 20. Januar 2022 = detector hits from different events Tobias Stockmanns Folie 4
Event Structure and Detector Response ev 1 ev 2 ev 3 time STT . . . 20. Januar 2022 = detector hits from different events Tobias Stockmanns Folie 5
Event Structure and Detector Response ev 1 ev 2 ev 3 time Wanted data structure STT = detector hits from different events 20. Januar 2022 Tobias Stockmanns Folie 6
Event Structure and Detector Response ev 1 ev 2 ev 3 time Wanted data structure STT Data structure in Tree Event 1 Event 2 Event 3 . . . 20. Januar 2022 = detector hits from different events Tobias Stockmanns Folie 7
Times to take into account Event. Time [ns] 20. Januar 2022 Tobias Stockmanns Folie 9
Times to take into account Event. Time 20. Januar 2022 Tobias Stockmanns Folie 10
Times to take into account Event. Time S en s o r 20. Januar 2022 Tobias Stockmanns Folie 11
Times to take into account Event. Time. Of. Flight e. O m i T 20. Januar 2022 ht g i l f. F S en s o r Tobias Stockmanns Folie 12
Times to take into account Event. Time U Time. Of. Flight Time. Stamp Uthr Time. Stamp S en s o r 20. Januar 2022 Tobias Stockmanns t Electronics Folie 13
Times to take into account Event. Time U Signal with different charge Time. Of. Flight Time. Stamp Uthr S en s o r 20. Januar 2022 Tobias Stockmanns Time. Stamp is charge dependent t Electronics Folie 14
Times to take into account Event. Time U Time. Of. Flight Time. Stamp Uthr t S en s o r 20. Januar 2022 Tobias Stockmanns Electronics Folie 15
Times to take into account Event. Time 2 nd hit in same detector elemet U Time. Of. Flight Time. Stamp Uthr t S en s o r 20. Januar 2022 Tobias Stockmanns Electronics Folie 16
Times to take into account Event. Time U Start Time Active Time. Of. Flight Time. Stamp Uthr Start/Active. Time t S en s o r 20. Januar 2022 Tobias Stockmanns Electronics Folie 17
Necessary Times • 4 times necessary: • Event Time • Assigned to Events in digitization if f. Run->Set. Event. Mean. Time(Double_t) is set in the digi macro • Value can be accessed in tasks via: Fair. Root. Manager: : Instance()-> Get. Event. Time() 20. Januar 2022 Tobias Stockmanns Folie 18
Necessary Times • 4 times necessary: • Event Time § Time Of Flight: • Automatically stored in the MC points of each detector 20. Januar 2022 Tobias Stockmanns Folie 19
Necessary Times • 4 times necessary: • Event Time § Time Of Flight § Time Stamp: • Time assigned to each detector hit (MANDATORY for PANDA!) • Absolute time! (includes Event Time, To. F , Electornics) • Resolution and offset depends on individuall detector 20. Januar 2022 Tobias Stockmanns Folie 20
Necessary Times • 4 times necessary: • Event Time § Time Of Flight § Time Stamp § Start/Active Time: • Time window an event can influence any other event happening in the same detector element • Strongly detector dependent • 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, …) • Absolute time! 20. Januar 2022 Tobias Stockmanns Folie 21
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 • Let’s start implementing it 20. Januar 2022 Tobias Stockmanns Folie 22
STORING THE DATA 20. Januar 2022 Tobias Stockmanns Folie 23
STEP 0 • Commit your changes on your torino. Detector into the SVN • Switch to: https: //subversion. gsi. de/fairroot/pandaroot/development/tstoc kmanns/Torino/version 4 b/torino. Detector and https: //subversion. gsi. de/fairroot/pandaroot/development/tstoc kmanns/Torino/version 4 b/macro/torino. Detector • Compile the code. • Have a look at the new classes Pnd. Torino. Detector. Digi. Task and Pnd. Torino. Detector. Reco. Task. What are they doing? • Run the macros run_sim. C, run_digi. C, run_reco. C • Look at the results. Are they what you expect? 20. Januar 2022 Tobias Stockmanns Folie 24
STEP 1 • 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 Pnd. Sds. Digi. Pixel 20. Januar 2022 Tobias Stockmanns Folie 25
STEP 2 • Derive your own buffer class from Fair. Writeout. Buffer • In the class header you have to add: • • std: : map<your. Data. Class, double> f. Data_map; your. Writeout. Buffer: : your. Writeout. Buffer(TString branch. Name, TString folder. Name, Bool_t persistance): Fair. Writeout. Buffer(branch. Name, “your. Data. Class", folder. Name, persistance) • Implement the pure virtual methods: • • void 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. Branch. Name); new ((*my. Array)[my. Array->Get. Entries()]) yourclass(*(yourclass*)(data)); } Double Find. Time. For. Data(Fair. Time. Stamp* data) { std: : map<yourclass, double>: : itertor it; yourclass my. Data = *(yourclass)data; it = f. Data_map. find(my. Data); if (it == f. Data_map. end()) return -1; else return it->second; } 20. Januar 2022 Tobias Stockmanns Folie 26
STEP 2 b • Implement the pure virtual methods: • void Fill. Data. Map(Fair. Time. Stamp* data, double active. Time) { yourclass my. Data = *(yourclass*)data; f. Data_Map[my. Data] = active. Time; } • void Erase. Data. From. Data. Map(Fair. Time. Stamp* data) { yourclass my. Data = *(yourclass*)data; if (f. Data_map. find(my. Data) != f. Data_map. end()) f. Data_map. erase(f. Data_map. find(my. Data)); } 20. Januar 2022 Tobias Stockmanns Folie 27
Modify • Overwrite Modify(…) if you want to have a different Pile. Up behavior (optional) • 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 • Input is the old data already in the buffer and the new data which goes into the buffer • Output is a vector of data which will be stored in the buffer plus the new active time of the data 20. Januar 2022 Tobias Stockmanns Folie 28
STEP 3 • Open your digi task: • Add to the header file: • Your. Writeout. Buffer* your. Buffer. Name; • void Run. Time. Based(){f. Time. Ordered. Digi = k. TRUE; } • Bool_t f. Time. Ordered. Digi; • Replace in Init() the creation of the TClones. Array for your data class by: : your. Buffer. Name = new Your. Writeout. Buffer(Output. Branch. Name, Folder. Name, Persistance); your. Buffer. Name = (Your. Writeout. Buffer*)ioman-> Register. Writeout. Buffer(Output. Branch. Name, you. Buffer. Name); your. Buffer. Name->Activate. Buffering(f. Time. Ordered. Digi); 20. Januar 2022 Tobias Stockmanns Folie 29
STEP 3 • Replace in Exec() the filling of the TClones. Array of your data object by: your. Buffer. Name->Fill. New. Data(your. Data, the. Absolute. Start. Time. Of. The. Data, the. Absolute. Active. Time. Of. The. Data); • The writeout buffer replaces the usual TClones. Array used to store the data • If the variable f. Time. Ordered. Digi is set to k. FALSE the behaviour of the buffer is identical to the standard TClones. Array storage of data 20. Januar 2022 Tobias Stockmanns Folie 30
STEP 4 • Add to your CMake. Lists. txt and …Link. Def. h file the new classes • Make sure that you store a Time. Stamp including error with your data! • Now add in your digi macro the line f. Run->Set. Event. Mean. Time(your. Value); to assign a time to the events. • To use now the buffer you just need to set in your digi macro your. Task->Run. Time. Based(); • This data has to go to a root file before you can continue analysing the digitized data! • That’s it. 20. Januar 2022 Tobias Stockmanns Folie 31
STEP 5 • Compile it, run it, test it • If you look at the output data you should see that the digis are not any longer stored in the same entry of the branch as the MC data but at later entries. • You should have one entry more in the digi file as in the MC file 20. Januar 2022 Tobias Stockmanns Folie 32
SORTING THE DATA 20. Januar 2022 Tobias Stockmanns Folie 33
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 20. Januar 2022 Tobias Stockmanns Folie 34
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 20. Januar 2022 Tobias Stockmanns Folie 35
STEP 6 • 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 • Here is an example: Fair. Time. Stamp* Pnd. Sds. Digi. Pixel. Ring. Sorter: : Create. Element(Fair. Time. Stamp* data) { return new Pnd. Sds. Digi. Pixel(*(Pnd. Sds. Digi. Pixel*)data); } 20. Januar 2022 Tobias Stockmanns Folie 36
STEP 7 • For the Fair. Ring. Sorter. Task two methods have to be overwritten: Init. Sorter and Add. New. Data. To. TClones. Array • Here is an example of Init. Sorter: Fair. Ring. Sorter* Pnd. Sds. Digi. Pixel. Sorter. Task: : Init. Sorter (Int_t number. Of. Cells, Double_t width. Of. Cells) { return new Pnd. Sds. Digi. Pixel. Ring. Sorter(number. Of. Cells, width. Of. Cells); } • And for Add. New. Data. To. TClones. Array: void Pnd. Sds. Digi. Pixel. 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()])Pnd. Sds. Digi. Pixel (*(Pnd. Sds. Digi. Pixel*)(data)); } 20. Januar 2022 Tobias Stockmanns Folie 37
Test it • Compile it. • Add to your digi task the new sorter task after your digitization task. • Run your digi macro. • Compare the sorted digis with the unsorted digis. In which entry of the Tree are they stored? • What happens if you change the size of the Ring. Sorter? 20. Januar 2022 Tobias Stockmanns Folie 38
READING BACK THE DATA 20. Januar 2022 Tobias Stockmanns Folie 39
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 20. Januar 2022 Tobias Stockmanns Folie 40
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. • The functor is true if it gets data which does not fit into the selection criterion • 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 20. Januar 2022 Tobias Stockmanns Folie 41
STEP 8 • Add in your reco task header: #include “Fair. TSBuffer. Functional. h“ and Binary. Functor* f. Functor; //! • In Init() of your task cxx file add: f. Functor = new Stop. Time(); • In Exec() of Task: if (Fair. Run. Ana: : Instance()->Is. Time. Stamp()){ f. Digi. Array = Fair. Root. Manager: : Instance()-> Get. Data(your. Digi. Branch. Name, f. Functor, Fair. Run. Manager: : Instance()->Get. Event. Time() + 10); } 20. Januar 2022 Tobias Stockmanns Folie 42
STEP 8 • At the end of Exec() add: • f. Hitarray->Sort(); • f. Digi. Array->Delete(); 20. Januar 2022 Tobias Stockmanns Folie 43
STEP 9 • 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 digi branch • Run your macro. • What happens if you set Run. With. Time. Stamps or leave it away? • What happens if you modify the functor parameters? • Test the other functor. 20. Januar 2022 Tobias Stockmanns Folie 44
MVD Examples • Examples of the time ordered simulation can be found in /macro/mvd/Time. Ordered. Sim • To check that everything is working you should start a Tree. Viewer and scan the Time. Stamp variable of your data. If it is randomized before your Ring. Sorter and it is sorted afterwards it works. 20. Januar 2022 Tobias Stockmanns Folie 45
- Slides: 44