/[PAMELA software]/PamelaLevel2/inc/PamLevel2.h
ViewVC logotype

Contents of /PamelaLevel2/inc/PamLevel2.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.41 - (show annotations) (download)
Wed Apr 1 09:25:36 2009 UTC (15 years, 8 months ago) by pam-fi
Branch: MAIN
CVS Tags: v9r00
Changes since 1.40: +28 -24 lines
File MIME type: text/plain
GetReadEntry added, GetTrack optimized for sequential invocations

1
2
3 /**
4 * \file PamLevel2.h
5 * \author Elena Vannuccini
6 */
7 #ifndef pamlevel2_h
8 #define pamlevel2_h
9
10 #include <TRefArray.h>
11
12 #include <TrkStruct.h>
13 #include <TrkParams.h>
14 #include <TrkLevel0.h>
15 #include <TrkLevel1.h>
16 #include <TrkLevel2.h>
17 #include <TrkHough.h>
18 #include <CaloLevel0.h>
19 #include <CaloLevel1.h>
20 #include <CaloLevel2.h>
21 #include <ToFLevel2.h>
22 #include <TrigLevel2.h>
23 #include <S4Level2.h>
24 #include <NDLevel2.h>
25 #include <AcLevel2.h>
26 #include <OrbitalInfo.h>
27 #include <InclinationInfo.h> // EMILIANO, now this library is included in libDarthVader.so
28 // and the header installed in $PAM_INC. If you get the
29 // error "Cannot find InclinationInfo.h" update your DV installation
30 #include <OrientationInfo.h> // EMILIANO, now this library is included in libDarthVader.so
31 // and the header installed in $PAM_INC. If you get the
32 // error "Cannot find InclinationInfo.h" update your DV installation
33 #include <RunInfo.h>
34 #include <GLTables.h>
35
36
37 #include <TTree.h>
38 #include <TFriendElement.h>
39 #include <TChain.h>
40 #include <TChainElement.h>
41 #include <TFile.h>
42 #include <TList.h>
43 #include <TKey.h>
44 #include <TSystemFile.h>
45 #include <TSystemDirectory.h>
46 #include <TSQLServer.h>
47
48 #include <stdlib.h>
49 #include <iostream>
50 #include <iomanip>
51 using namespace std;
52
53 #define NCLONES 10
54
55 using namespace std;
56
57
58 /////////////////////////////////////////////////////////////////////////////
59 /////////////////////////////////////////////////////////////////////////////
60 /////////////////////////////////////////////////////////////////////////////
61 /////////////////////////////////////////////////////////////////////////////
62 /**
63 * \brief Class to describe GP output (to be moved to PamelaDigitizer)
64 *
65 */
66
67 class GPamela : public TObject {
68
69 private:
70
71 public:
72
73 // Declaration of leave types
74 Int_t Irun;
75 Int_t Ievnt;
76 Int_t Ipa;
77 Float_t X0;
78 Float_t Y0;
79 Float_t Z0;
80 Float_t Theta;
81 Float_t Phi;
82 Float_t P0;
83 Int_t Nthtof;
84 UChar_t Ipltof[100]; //[Nthtof]
85 UChar_t Ipaddle[100]; //[Nthtof]
86 UChar_t Ipartof[100]; //[Nthtof]
87 Float_t Xintof[100]; //[Nthtof]
88 Float_t Yintof[100]; //[Nthtof]
89 Float_t Zintof[100]; //[Nthtof]
90 Float_t Xouttof[100]; //[Nthtof]
91 Float_t Youttof[100]; //[Nthtof]
92 Float_t Zouttof[100]; //[Nthtof]
93 Float_t Ereltof[100]; //[Nthtof]
94 Float_t Timetof[100]; //[Nthtof]
95 Float_t Pathtof[100]; //[Nthtof]
96 Float_t P0tof[100]; //[Nthtof]
97 Int_t Nthcat;
98 UChar_t Iparcat[50]; //[Nthcat]
99 UChar_t Icat[50]; //[Nthcat]
100 Float_t Xincat[50]; //[Nthcat]
101 Float_t Yincat[50]; //[Nthcat]
102 Float_t Zincat[50]; //[Nthcat]
103 Float_t Xoutcat[50]; //[Nthcat]
104 Float_t Youtcat[50]; //[Nthcat]
105 Float_t Zoutcat[50]; //[Nthcat]
106 Float_t Erelcat[50]; //[Nthcat]
107 Float_t Timecat[50]; //[Nthcat]
108 Float_t Pathcat[50]; //[Nthcat]
109 Float_t P0cat[50]; //[Nthcat]
110 Int_t Nthcas;
111 UChar_t Iparcas[50]; //[Nthcas]
112 UChar_t Icas[50]; //[Nthcas]
113 Float_t Xincas[50]; //[Nthcas]
114 Float_t Yincas[50]; //[Nthcas]
115 Float_t Zincas[50]; //[Nthcas]
116 Float_t Xoutcas[50]; //[Nthcas]
117 Float_t Youtcas[50]; //[Nthcas]
118 Float_t Zoutcas[50]; //[Nthcas]
119 Float_t Erelcas[50]; //[Nthcas]
120 Float_t Timecas[50]; //[Nthcas]
121 Float_t Pathcas[50]; //[Nthcas]
122 Float_t P0cas[50]; //[Nthcas]
123 Int_t Nthspe;
124 UChar_t Iparspe[100]; //[Nthspe]
125 UChar_t Itrpb[100]; //[Nthspe]
126 UChar_t Itrsl[100]; //[Nthspe]
127 UChar_t Itspa[100]; //[Nthspe]
128 Float_t Xinspe[100]; //[Nthspe]
129 Float_t Yinspe[100]; //[Nthspe]
130 Float_t Zinspe[100]; //[Nthspe]
131 Float_t Xoutspe[100]; //[Nthspe]
132 Float_t Youtspe[100]; //[Nthspe]
133 Float_t Zoutspe[100]; //[Nthspe]
134 Float_t Xavspe[100]; //[Nthspe]
135 Float_t Yavspe[100]; //[Nthspe]
136 Float_t Zavspe[100]; //[Nthspe]
137 Float_t Erelspe[100]; //[Nthspe]
138 Float_t Pathspe[100]; //[Nthspe]
139 Float_t P0spe[100]; //[Nthspe]
140 UChar_t Nxmult[100]; //[Nthspe]
141 UChar_t Nymult[100]; //[Nthspe]
142 Int_t Nstrpx;
143 UChar_t Npstripx[1000]; //[Nstrpx]
144 UChar_t Ntstripx[1000]; //[Nstrpx]
145 UShort_t Istripx[1000]; //[Nstrpx]
146 //UInt_t Istripx[1000]; //[Nstrpx]
147 Float_t Qstripx[1000]; //[Nstrpx]
148 Float_t Xstripx[1000]; //[Nstrpx]
149 Int_t Nstrpy;
150 UChar_t Npstripy[1000]; //[Nstrpy]
151 UChar_t Ntstripy[1000]; //[Nstrpy]
152 UShort_t Istripy[1000]; //[Nstrpy]
153 //UInt_t Istripy[1000]; //[Nstrpy]
154 Float_t Qstripy[1000]; //[Nstrpy]
155 Float_t Ystripy[1000]; //[Nstrpy]
156 Int_t Nthcali;
157 UChar_t Icaplane[4224]; //[Nthcali]
158 UChar_t Icastrip[4224]; //[Nthcali]
159 Int_t Icamod[4224]; //[Nthcali]
160 Float_t Enestrip[4224]; //[Nthcali]
161 Int_t Nthcal;
162 UChar_t Icapl[1000]; //[Nthcal]
163 UChar_t Icasi[1000]; //[Nthcal]
164 UChar_t Icast[1000]; //[Nthcal]
165 Float_t Xincal[1000]; //[Nthcal]
166 Float_t Yincal[1000]; //[Nthcal]
167 Float_t Zincal[1000]; //[Nthcal]
168 Float_t Erelcal[1000]; //[Nthcal]
169 Int_t Nthnd;
170 UChar_t Itubend[200]; //[Nthnd]
171 UChar_t Iparnd[200]; //[Nthnd]
172 Float_t Xinnd[200]; //[Nthnd]
173 Float_t Yinnd[200]; //[Nthnd]
174 Float_t Zinnd[200]; //[Nthnd]
175 Float_t Xoutnd[200]; //[Nthnd]
176 Float_t Youtnd[200]; //[Nthnd]
177 Float_t Zoutnd[200]; //[Nthnd]
178 Float_t Erelnd[200]; //[Nthnd]
179 Float_t Timend[200]; //[Nthnd]
180 Float_t Pathnd[200]; //[Nthnd]
181 Float_t P0nd[200]; //[Nthnd]
182 Int_t Nthcard;
183 UChar_t Iparcard[100]; //[Nthcard]
184 UChar_t Icard[100]; //[Nthcard]
185 Float_t Xincard[100]; //[Nthcard]
186 Float_t Yincard[100]; //[Nthcard]
187 Float_t Zincard[100]; //[Nthcard]
188 Float_t Xoutcard[100]; //[Nthcard]
189 Float_t Youtcard[100]; //[Nthcard]
190 Float_t Zoutcard[100]; //[Nthcard]
191 Float_t Erelcard[100]; //[Nthcard]
192 Float_t Timecard[100]; //[Nthcard]
193 Float_t Pathcard[100]; //[Nthcard]
194 Float_t P0card[100]; //[Nthcard]
195
196 GPamela(){ Clear(); };
197 // ~GPamela(){ Delete(); };
198 ~GPamela(){ Clear(); };
199
200 void Clear();
201 void Delete();
202 void SetBranchAddress( TChain* );
203 void SetBranchAddress( TTree* t){ SetBranchAddress( (TChain*)t );};
204
205 GPamela* GetGPamela(){return this;};
206
207 ClassDef(GPamela,1);
208
209 };
210 /////////////////////////////////////////////////////////////////////////////
211 /////////////////////////////////////////////////////////////////////////////
212 /////////////////////////////////////////////////////////////////////////////
213 /////////////////////////////////////////////////////////////////////////////
214
215
216
217 /**
218 * \brief Class to describe particle tracks in the apparatus, including tracker and track-related variables from other detectors (calorimeter and TOF).
219 *
220 * This class inherites from TrkTrack, CaloTrkVar ecc...
221 *
222 */
223 //class PamTrack : public TrkTrack, public CaloTrkVar, public ToFTrkVar {
224 class PamTrack : public TObject {
225
226 private:
227
228 TrkTrack* trk_track;
229 CaloTrkVar* calo_track;
230 ToFTrkVar* tof_track;
231 OrbitalInfoTrkVar* orb_track;
232 Int_t pscore;
233 Int_t iscore;
234 bool candeleteobj;
235
236 // TClonesArray *Cluster; ///< clusters (if stored)
237
238 public:
239
240 PamTrack();
241 PamTrack(TrkTrack* , CaloTrkVar* , ToFTrkVar*, OrbitalInfoTrkVar* );
242 PamTrack(const PamTrack&);
243 ~PamTrack(){ Delete(); };
244
245 void Clear();
246 void Clear(Option_t *option){Clear();};
247 void Delete();
248
249 Bool_t IsSolved(){if ((pscore-iscore)>0) return true; return false;};
250 Int_t GetScore(){return (pscore-iscore);};
251 Int_t GetPScore(){return (pscore);};
252 Int_t GetIScore(){return (iscore);};
253 void SetPScore(Int_t p){pscore=p;};
254 void SetIScore(Int_t i){iscore=i;};
255
256 TrkTrack* GetTrkTrack(){return trk_track;};
257 CaloTrkVar* GetCaloTrack(){return calo_track;};
258 ToFTrkVar* GetToFTrack(){return tof_track;};
259 OrbitalInfoTrkVar* GetOrbitalInfoTrack(){return orb_track;};
260
261 ClassDef(PamTrack,2);
262 };
263
264 /**
265 * \brief Class to describe PAMELA LEVEL2 data.
266 *
267 * This class inherites from TrkLevel2, CaloLevel2 ecc... and it overrides the TrkLevel2:GetTrack(int it) and TrkLevel2:GetTrackImage(int it) methods.
268 * This allows to solve the tracker ambiguity (that is, to choose between track images) by using also information from other detectors.
269 */
270
271 //class PamLevel2 : public CaloLevel2, public CaloLevel1, public ToFLevel2, public TrkLevel2, public TrkLevel1, public TrkHough, public TrigLevel2, public S4Level2, public NDLevel2, public AcLevel2, public OrbitalInfo {
272 class PamLevel2 : public TObject {
273
274 private:
275
276 // ------------------------------
277 // variables to retrieve run info
278 // ------------------------------
279 Long64_t irun; //current run entry, relative to the TChain
280 Long64_t irunt; //current run entry, relative to the TTree in the TChain
281 Long64_t runfirstentry; //first entry of run, relative to the TChain
282 Long64_t runlastentry; //last entry of run, relative to the TChain
283 Long64_t irunentry; //position of current entry, relative to the run
284 TChain* run_tree;
285 TTree* run_tree_clone;
286 TChain* sel_tree;
287 TTree* sel_tree_clone;
288 int *irunoffset;
289 GL_TIMESYNC *gltsync; // Emiliano
290
291 // -------------------------------------------
292 // variables to store total live and dead time
293 // -------------------------------------------
294 ULong64_t totdltime[3];// 0=live 1=dead 2=n.events
295
296 // ---------------------------------
297 // variables to retrieve level0 info
298 // ---------------------------------
299 TFile* l0_file;
300 TTree* l0_tree;
301 Int_t iroot;
302 Int_t prevshift; // to remember if any shift is needed to synchronize l0 and l2 data instead of calculating any time
303 Int_t maxshift; // EMILIANO maximum discrepancy between L2 and L0 data (the bigger the better concering synch but the processing speed drops) default = 10
304 // --------------------------------------------
305 // variables to store Level0 info (if required)
306 // --------------------------------------------
307 EventHeader* h0_obj;
308 TrkLevel0* trk0_obj;
309 CaloLevel0* calo0_obj;
310
311 // ---------------------------
312 // variables to connect the DB
313 // ---------------------------
314 TSQLServer* dbc;
315 TString host;
316 TString user;
317 TString psw;
318
319 // ---------------------------------------------
320 // variables to retrieve and clone level1-2 info
321 // ---------------------------------------------
322 TChain* pam_tree;
323 TTree* pam_tree_clone[NCLONES];
324
325 // --------------------------------------------
326 // variables to store Level1-2 info
327 // --------------------------------------------
328 TrkLevel1* trk1_obj;
329 TrkLevel2* trk2_obj;
330 TrkHough* trkh_obj;
331 CaloLevel1* calo1_obj;
332 CaloLevel2* calo2_obj;
333 ToFLevel2* tof_obj;
334 TrigLevel2* trig_obj;
335 S4Level2* s4_obj;
336 NDLevel2* nd_obj;
337 AcLevel2* ac_obj;
338 OrbitalInfo* orb_obj;
339 GL_RUN* run_obj;
340 SoftInfo* soft_obj; // Emiliano
341
342 // --------------------------------------------
343 // variables to handle GP
344 // --------------------------------------------
345 GPamela* gp_obj;
346
347 // -----------------------------------
348 // variables to sort the track
349 // -----------------------------------
350 TClonesArray *tsorted;
351 TClonesArray *timage;
352 PamTrack *track; //store the last required
353 TString howtosort;
354 Float_t sortthr;
355
356 Bool_t issorted; // true if the current event has already been sorted with the current sort criteria
357 Long64_t lastsorted; // the last event whose tracks has been sorted
358 // --------------------------------------
359 // flags to load level0-1-2 trees/braches
360 // --------------------------------------
361 Bool_t CAL2; //level2 branch
362 Bool_t CAL1; //level1 branch
363 Bool_t CAL0; //yoda
364
365 Bool_t TRK2; //level2 branch
366 Bool_t TRK1; //level1 branch
367 Bool_t TRKh; //hough branch
368 Bool_t TRK0; //yoda
369
370 Bool_t TOF;
371 Bool_t TOF0;
372
373 Bool_t TRG;
374 Bool_t S4;
375 Bool_t ND;
376 Bool_t AC;
377 Bool_t ORB;
378
379 Bool_t GP; //GP simulation tree
380
381 // -----------
382 // other flags
383 // -----------
384 Bool_t RUN; // RunInfo tree
385 Bool_t ISGP; // GP simulation (...sort of patch, to skip OBT check, since OrbitalInfo is sometime missing)
386 Int_t SELLI; // tree of selected events (there is a selection list)
387
388 Bool_t DBG;
389
390 void Initialize();
391
392
393 public:
394
395 PamLevel2(TString ddir,TList *list,TString detlist);
396 PamLevel2(TString ddir,TString list,TString detlist);
397 PamLevel2(TString ddir,TString list);
398 PamLevel2();
399 ~PamLevel2(){Delete();};
400
401 void Clear();
402 void Reset();
403 void Delete();
404
405
406 // =============================================
407 // methods needed to read/write Level0-1-2 trees
408 // =============================================
409 void SetWhichTrees(TString);
410 void GetWhichTrees(TFile*);
411
412 TTree* GetPamTree(TFile*,TString);
413 TTree* GetPamTree(TFile* f){return GetPamTree(f,"");};
414
415 TList* GetListOfLevel2Files(TString, TString);
416 Bool_t CheckLevel2File(TString);
417 TChain* GetPamTree(TList*,TString);
418 TChain* GetPamTree(TString ddir,TString list,TString detlist){ return GetPamTree(GetListOfLevel2Files(ddir,list),detlist); };
419 TChain* GetPamTree(TString ddir,TString list){ return GetPamTree(GetListOfLevel2Files(ddir,list),""); };
420 TChain* AddFriend(TString);
421
422 TTree* GetRunTree(TFile*);
423 TChain* GetRunTree(TList*);
424 TChain* GetRunTree(TString ddir,TString list){ return GetRunTree(GetListOfLevel2Files(ddir,list)); };
425 Bool_t UpdateRunInfo(Long64_t);//{ return UpdateRunInfo(run_tree,iev); };
426 Bool_t UpdateRunInfo(TTree *,Long64_t);
427 Bool_t UpdateRunInfo(TChain *,Long64_t);
428
429 void CreateCloneTrees0(TChain *fChain, TFile* file);
430 void CreateCloneTrees(TFile* file);
431 void CreateCloneTrees(){CreateCloneTrees(NULL);};
432 void FillCloneTrees();
433 TTree *GetCloneTree(TString);
434 void WriteCloneTrees();
435
436 void SetBranchAddress(TTree *);
437 void SetBranchAddress(TChain *);
438
439 // Int_t GetEntry(Int_t);
440 Int_t GetEntry(Long64_t);
441 Long64_t GetReadEntry();
442 Int_t GetYodaEntry();
443
444 void SetMaxShift(Int_t sh){ maxshift = sh; return;}; // EMILIANO method to change the maxshift variable
445
446 Long64_t GetEntries(){return pam_tree->GetEntries();};
447 TChain* GetPamTree(){return pam_tree;};
448 TChain* GetRunTree(){return run_tree;};
449 TTree* GetYodaTree();
450
451 TFile* GetYodaFile(){return l0_file;}; // can be useful to know the name of level0 file we are using or similar things
452
453 // =============
454 // DB connection
455 // =============
456 void SetDBHost(TString str){host=str;};
457 void SetDBUser(TString str){user=str;};
458 void SetDBPsw(TString str){psw=str;};
459 TSQLServer* GetSQLServer(){return dbc;};
460 Bool_t SetDBConnection();
461
462 // ========================================================
463 // methods needed to retrieve subdetector general variables
464 // ========================================================
465 void* GetPointerTo(const char*);
466 EventHeader *GetEventHeader() { return h0_obj; };
467
468 /* TrkLevel0 *GetTrkLevel0() { return trk0_obj; }; */
469 /* CaloLevel0 *GetCaloLevel0() { return calo0_obj; }; */
470 TrkLevel0 *GetTrkLevel0();
471 CaloLevel0 *GetCaloLevel0();
472
473
474 TrkLevel1 *GetTrkLevel1() { return trk1_obj; };
475 TrkLevel2 *GetTrkLevel2() { return trk2_obj; };
476 TrkHough *GetTrkHough() { return trkh_obj; };
477 CaloLevel1 *GetCaloLevel1() { return calo1_obj;};
478 CaloLevel2 *GetCaloLevel2() { return calo2_obj;};
479 ToFLevel2 *GetToFLevel2() { return tof_obj; };
480 TrigLevel2 *GetTrigLevel2() { return trig_obj; };
481 S4Level2 *GetS4Level2() { return s4_obj; };
482 NDLevel2 *GetNDLevel2() { return nd_obj; };
483 AcLevel2 *GetAcLevel2() { return ac_obj; };
484 OrbitalInfo *GetOrbitalInfo(){ return orb_obj; };
485 GL_RUN *GetRunInfo() { return run_obj; };
486 SoftInfo *GetSoftInfo() { return soft_obj; }; // Emiliano
487 GPamela *GetGPamela() { return gp_obj; };
488
489 // ==============================================
490 // methods to retrieve subdetectors stored tracks
491 // ==============================================
492 TrkTrack* GetTrkStoredTrack(int seqno){return trk2_obj->TrkLevel2::GetStoredTrack(seqno); };
493 CaloTrkVar* GetCaloStoredTrack(int);
494 ToFTrkVar* GetToFStoredTrack(int);
495 OrbitalInfoTrkVar* GetOrbitalInfoStoredTrack(int);
496 //
497 PamTrack* GetPamTrackAlong(TrkTrack*);
498 // PamTrack* GetPamTrackAlong(CaloTrkVar*); //se serve
499 // PamTrack* GetPamTrackAlong(ToFTrkVar*); //se serve
500
501 // =================================
502 // methods to retrieve pamela tracks
503 // =================================
504 PamTrack* GetStoredTrack(Int_t);
505 //
506 void SortTracks(TString); //assign value to variable sorted_tracks
507 void SortTracks(); //assign value to variable sorted_tracks
508 // TRefArray* GetTracks(); //return sorted_tracks
509 TClonesArray* GetTracks(); //return sorted_tracks
510 PamTrack* GetTrack(int);
511 PamTrack* GetTrackImage(int);
512 void SetSortingMethod(TString how);
513 TString GetSortingMethod(){return howtosort;};
514 void SetNucleiSortingThreshold(Float_t nucleithr){ sortthr = nucleithr; return;};
515 Float_t GetNucleiSortingThreshold(){ return sortthr;};
516
517 // =================================
518 // other methods
519 // =================================
520 // Int_t ntrk(){ return trk2_obj->TrkLevel2::ntrk(); };
521
522
523 Long64_t GetRunID(){ return irun;};
524 Long64_t GetRunEntryID(){ return irunentry; };
525
526 // -----
527 // flags methods
528 // -----
529 Bool_t IsCAL2(){return CAL2;}; //level2 branch
530 Bool_t IsCAL1(){return CAL1;}; //level1 branch
531 Bool_t IsCAL0(){return CAL0;}; //yoda
532
533 Bool_t IsTRK2(){return TRK2;}; //level2 branch
534 Bool_t IsTRK1(){return TRK1;}; //level1 branch
535 Bool_t IsTRKh(){return TRKh;}; //hough branch
536 Bool_t IsTRK0(){return TRK0;}; //yoda
537
538 Bool_t IsTOF(){return TOF;};
539 Bool_t IsTOF0(){return TOF0;};
540
541 Bool_t IsTRG(){return TRG;};
542 Bool_t IsS4(){return S4;};
543 Bool_t IsND(){return ND;};
544 Bool_t IsAC(){return AC;};
545 Bool_t IsORB(){return ORB;};
546
547 Bool_t IsRUN(){return RUN;};
548
549 Bool_t IsGood(Bool_t strict=true);
550
551 Int_t IsSELLI(){return SELLI;}; //trees of selected events (there is a selection list)
552 void SetSELLI(Int_t selli){SELLI=selli;};
553
554 Bool_t IsGP(){return ISGP;};
555
556 void SetGP(Bool_t tt){ISGP=tt;};
557
558 void SetDebug(Bool_t set){ DBG=set; TrkParams::SetVerboseMode(); };
559
560
561 ClassDef(PamLevel2,1);
562 };
563
564 //===============================================================================================
565 //
566 //
567 //
568 //
569 //===============================================================================================
570
571
572 #endif
573

  ViewVC Help
Powered by ViewVC 1.1.23