/[PAMELA software]/PamelaLevel2/src/PamLevel2.cpp
ViewVC logotype

Contents of /PamelaLevel2/src/PamLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Tue Dec 5 12:13:39 2006 UTC (18 years, 2 months ago) by pam-fi
Branch: MAIN
Changes since 1.8: +632 -111 lines
added methods to clone trees

1 #include <PamLevel2.h>
2 //--------------------------------------
3 //
4 //
5 //--------------------------------------
6 /**
7 * Default constructor
8 */
9 PamTrack::PamTrack(){
10 trk_track = this->TrkTrack::GetTrkTrack();
11 calo_track = this->CaloTrkVar::GetCaloTrkVar();
12 tof_track = this->ToFTrkVar::GetToFTrkVar();
13 };
14 //--------------------------------------
15 //
16 //
17 //--------------------------------------
18 /**
19 * Constructor
20 */
21 PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o){
22 trk_track = this->TrkTrack::GetTrkTrack();
23 calo_track = this->CaloTrkVar::GetCaloTrkVar();
24 tof_track = this->ToFTrkVar::GetToFTrkVar();
25 if(t) *trk_track = *t;
26 if(c) *calo_track = *c;
27 if(o) *tof_track = *o;
28 };
29
30 //--------------------------------------
31 //
32 //
33 //--------------------------------------
34 /**
35 * Constructor
36 */
37 PamLevel2::PamLevel2(){
38
39 trk2_obj = TrkLevel2::GetTrkLevel2();
40 trk1_obj = TrkLevel1::GetTrkLevel1();
41 trkh_obj = TrkHough::GetTrkHough();
42 calo1_obj = CaloLevel1::GetCaloLevel1();
43 calo2_obj = CaloLevel2::GetCaloLevel2();
44 tof_obj = ToFLevel2::GetToFLevel2();
45 trig_obj = TrigLevel2::GetTrigLevel2();
46 s4_obj = S4Level2::GetS4Level2();
47 nd_obj = NDLevel2::GetNDLevel2();
48 ac_obj = AcLevel2::GetAcLevel2();
49 orb_obj = OrbitalInfo::GetOrbitalInfo();
50
51 run_obj = new GL_RUN();
52
53 // trk1_clone = 0;
54 // trk2_clone = 0;
55 // trkh_clone = 0;
56 // calo1_clone = 0;
57 // calo2_clone = 0;
58 // tof_clone = 0;
59 // trig_clone = 0;
60 // s4_clone = 0;
61 // nd_clone = 0;
62 // ac_clone = 0;
63 // orb_clone = 0;
64
65 // T_clone = 0;
66 // C_clone = 0;
67 // O_clone = 0;
68 // R_clone = 0;
69 // S_clone = 0;
70 // N_clone = 0;
71 // A_clone = 0;
72 // B_clone = 0;
73
74 for(Int_t i=0; i<8; i++ )tree_clone[i]=NULL;
75
76 sorted_tracks = new TRefArray();
77
78 CAL1 = true;
79 CAL2 = true;
80 TRK2 = true;
81 TRK1 = false;
82 TRKh = false;
83 TRG = true;
84 TOF = true;
85 S4 = true;
86 ND = true;
87 AC = true;
88 ORB = true;
89
90
91 };
92 /**
93 * Destructor
94 */
95 PamLevel2::~PamLevel2(){
96 delete run_obj;
97 Clear();
98 };
99 /**
100 * Clear the event
101 */
102 void PamLevel2::Clear(){
103
104 TrkLevel1::Clear();
105
106 TrkLevel2::Clear();
107 CaloLevel2::Clear();
108 ToFLevel2::Clear();
109 TrigLevel2::Clear();
110 S4Level2::Clear();
111 NDLevel2::Clear();
112 AcLevel2::Clear();
113 OrbitalInfo::Clear();
114
115 // if(trk1_clone)trk1_clone->Clear();
116 // if(trk2_clone)trk2_clone->Clear();
117 // if(trkh_clone)trkh_clone->Clear();
118 // if(calo1_clone)calo1_clone->Clear();
119 // if(calo2_clone)calo2_clone->Clear();
120 // if(tof_clone)tof_clone->Clear();
121 // if(trig_clone)trig_clone->Clear();
122 // if(s4_clone)s4_clone->Clear();
123 // if(nd_clone)nd_clone->Clear();
124 // if(ac_clone)ac_clone->Clear();
125 // if(orb_clone)orb_clone->Clear();
126
127 sorted_tracks->Delete(); // clean the reference array
128
129 };
130
131
132 //--------------------------------------
133 //
134 //
135 //--------------------------------------
136 void *PamLevel2::GetPointerTo(const char* c ){
137
138 TString objname = c;
139 if(!objname.CompareTo("TrkLevel1"))return &trk1_obj;
140 if(!objname.CompareTo("TrkLevel2"))return &trk2_obj;
141 if(!objname.CompareTo("TrkHough"))return &trkh_obj;
142 if(!objname.CompareTo("CaloLevel1"))return &calo1_obj;
143 if(!objname.CompareTo("CaloLevel2"))return &calo2_obj;
144 if(!objname.CompareTo("ToFLevel2"))return &tof_obj;
145 if(!objname.CompareTo("TrigLevel2"))return &trig_obj;
146 if(!objname.CompareTo("S4Level2"))return &s4_obj;
147 if(!objname.CompareTo("NDLevel2"))return &nd_obj;
148 if(!objname.CompareTo("AcLevel2"))return &ac_obj;
149 if(!objname.CompareTo("OrbitalInfo"))return &orb_obj;
150 if(!objname.CompareTo("RunInfo"))return &run_obj;
151 return NULL;
152 };
153 //--------------------------------------
154 //
155 //
156 //--------------------------------------
157 /**
158 * Retrieves the calorimeter track matching the seqno-th tracker stored track.
159 * (If seqno = -1 retrieves the self-trigger calorimeter track)
160 */
161 CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){
162
163 if( CaloLevel2::ntrk()==0 ){
164 cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no Calorimeter tracks are stored"<<endl;
165 return NULL;
166 };
167
168 CaloTrkVar *c = 0;
169 Int_t it_calo=0;
170
171 do{
172 c = CaloLevel2::GetCaloTrkVar(it_calo);
173 it_calo++;
174 } while( c && seqno != c->trkseqno && it_calo < CaloLevel2::ntrk());
175
176 if(!c || seqno != c->trkseqno){
177 c = 0;
178 if(seqno!=-1)cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" does not match Calorimeter stored tracks"<<endl;
179 };
180 return c;
181
182 };
183 //--------------------------------------
184 //
185 //
186 //--------------------------------------
187 /**
188 * Retrieves the ToF track matching the seqno-th tracker stored track.
189 * (If seqno = -1 retrieves the tracker-independent tof track)
190 */
191 ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){
192
193 if( ToFLevel2::ntrk()==0 ){
194 cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no ToF tracks are stored"<<endl;
195 return NULL;
196 };
197
198 ToFTrkVar *c = 0;
199 Int_t it_tof=0;
200
201 do{
202 c = ToFLevel2::GetToFTrkVar(it_tof);
203 it_tof++;
204 } while( c && seqno != c->trkseqno && it_tof < ToFLevel2::ntrk());
205
206 if(!c || seqno != c->trkseqno){
207 c = 0;
208 if(seqno!=-1)cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" does not match ToF stored tracks"<<endl;
209 };
210 return c;
211
212 };
213
214 //--------------------------------------
215 //
216 //
217 //--------------------------------------
218 /**
219 * Give the pamela track associated to a tracker track, retrieving related calorimeter and tof track information.
220 */
221 PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){
222
223 CaloTrkVar *c = 0;
224 ToFTrkVar *o = 0;
225
226 if(CAL2) c = GetCaloStoredTrack(t->GetSeqNo());
227 if(TOF) o = GetToFStoredTrack(t->GetSeqNo());
228
229 // if(t && c && o)track = new PamTrack(t,c,o);
230 PamTrack *track = new PamTrack(t,c,o);
231
232 return track;
233
234 };
235 //--------------------------------------
236 //
237 //
238 //--------------------------------------
239 /**
240 * Retrieves the it-th stored track.
241 * It override TrkLevel2::GetTrack(int it).
242 * @param itrk Track number, ranging from 0 to GetNTracks().
243 */
244
245 PamTrack* PamLevel2::GetStoredTrack(Int_t itrk){
246
247 PamTrack *track = 0;
248
249 if( itrk >=0 && itrk < TrkLevel2::ntrk() ){
250
251 TrkTrack *t = TrkLevel2::GetStoredTrack(itrk);
252 track = GetPamTrackAlong(t);
253
254 }else{
255 cout << "PamLevel2::GetStoredTrack(int) : tracker track SeqNo "<< itrk <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl;
256 };
257
258 return track;
259
260 }
261 //--------------------------------------
262 //
263 //
264 //--------------------------------------
265 /**
266 * Sort physical (tracker) tracks and stores them in the TRefArray (of TrkTrack objects) which pointer is PamLevel2::sorted_tracks.
267 * @param how String to set the sorting cryterium (es: "CAL" or "TRK+CAL+TOF" ecc...).
268 * Sorting cryteria:
269 * TRK: lower chi**2
270 * CAL: lower Y spatial residual on the first calorimeter plane
271 * TOF: bigger numebr of hit PMTs along the track, on S12 S21 S32 (where paddles are along the Y axis).
272 * The default sorting cryterium is "TOF+CAL".
273 *
274 * The total number of physical tracks is always given by GetNTracks() and the it-th physical track can be retrieved by means of the methods GetTrack(int it) and GetTrack(int it, TString how).
275 */
276 void PamLevel2::SortTracks(TString how){
277
278 // cout << "call SortTracs() "<<endl;
279 //Save current Object count
280 Int_t ObjectNumber = TProcessID::GetObjectCount();
281
282 // cout << "ObjectNumber "<<ObjectNumber <<endl;
283
284 sorted_tracks->Delete(); //temporaneo???
285
286 // loop over the tracks sorted by the tracker
287 Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase);
288 Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase);
289 Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase);
290
291 if( !CAL2 && use_CAL) use_CAL = false;
292 if( !TOF && use_TOF) use_TOF = false;
293
294 if( !TRK2 ){
295 // cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl;
296 return;
297 };
298
299 // cout << "use_CAL "<<use_CAL<<" use_TOF "<<use_TOF<<" use_TRK "<<use_TRK <<endl;
300
301 for(Int_t i=0; i < TrkLevel2::GetNTracks(); i++){
302
303 TrkTrack *ts = 0;
304
305 // get tracker tracks
306 TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker
307 CaloTrkVar *cp = 0;
308 ToFTrkVar *op = 0;
309
310 // cout << "trk track n. "<<i << " "<<hex<< tp <<dec<< endl;
311 // if track has an image, check image selection
312 if(tp->HasImage()){
313
314 TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image)
315 CaloTrkVar *ci = 0;
316 ToFTrkVar *oi = 0;
317
318 // cout << "its image "<<i << " "<<hex<< ti <<dec<< endl;
319
320 //assign starting scores
321 Int_t tp_score = 0; //main track sorted by the tracker
322 Int_t ti_score = 0; //image track
323
324 // ------------------------
325 // calorimeter check
326 // ------------------------
327 // check the Y spatial residual on the first calorimeter plane
328 // (cut on calorimeter variables from Emiliano)
329 if(
330 use_CAL &&
331 npcfit[1] > 15 && //no. of fit planes on Y view
332 varcfit[1] < 1000. && //fit variance on Y view
333 true){
334
335 cp = GetCaloStoredTrack(tp->GetSeqNo());
336 ci = GetCaloStoredTrack(ti->GetSeqNo());
337
338 Float_t resy_p = cp->tbar[0][1] - cbar[0][1]; if(resy_p < 0)resy_p= - resy_p;
339 Float_t resy_i = ci->tbar[0][1] - cbar[0][1]; if(resy_i < 0)resy_i= - resy_i;
340
341 if(resy_p <= resy_i) tp_score++;
342 else ti_score++;
343
344 // cout << "CALO "<<tp_score<<ti_score<<endl;
345
346 };
347 // ------------------------
348 // TOF check
349 // ------------------------
350 // check the number of hit pmts along the track
351 // on S12 S21 and S32, where paddles are parallel to Y axis
352 if( use_TOF ){
353
354 Int_t nphit_p =0;
355 Int_t nphit_i =0;
356
357 op = GetToFStoredTrack(tp->GetSeqNo());
358 oi = GetToFStoredTrack(ti->GetSeqNo());
359
360 /* cout << "track: npmtadc "<< op->npmtadc << endl;
361 cout << "track: npmttdc "<< op->npmttdc << endl;
362 cout << "image: npmtadc "<< oi->npmtadc << endl;
363 cout << "image: npmttdc "<< oi->npmttdc << endl;*/
364
365 for (Int_t ih=0; ih < op->npmtadc; ih++){
366 Int_t pl = GetPlaneIndex( (op->pmtadc).At(ih) );
367 if(pl == 1 || pl == 2 || pl == 5)nphit_p++;
368 };
369
370 for (Int_t ih=0; ih < oi->npmtadc; ih++){
371 Int_t pl = GetPlaneIndex( (oi->pmtadc).At(ih) );
372 if(pl == 1 || pl == 2 || pl == 5)nphit_i++;
373 };
374
375 if(
376 use_TOF &&
377 (nphit_p+nphit_i) !=0 &&
378 true){
379
380 if( nphit_p >= nphit_i) tp_score++;
381 else ti_score++;
382 };
383 // cout << "TOF "<<tp_score<<ti_score<<endl;
384 };
385 if(tp_score == ti_score) use_TRK = true;
386 // ------------------------
387 // tracker check
388 // ------------------------
389 // chi**2 difference is not always large enough to distinguish among
390 // the real track and its image.
391 // Tracker check will be applied always when calorimeter and tof information is ambiguous.
392 if(use_TRK){
393 if( tp->chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ;
394 else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ;
395 // cout << "TRK "<<tp_score<<ti_score<<endl;
396 };
397
398 // ------------------------
399 // the winner is....
400 // ------------------------
401 if (tp_score > ti_score) ts = tp;//the track sorted by the tracker!!
402 else if (tp_score < ti_score) ts = ti;//its image!!
403 else {
404 ts = tp;
405 // cout << "Warning - track image ambiguity not solved" << endl;
406 // cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl;
407 };
408
409 }else{
410 ts = tp;
411 };
412
413 // cout <<" SortTracks() "<<i<<" -- "<<ts<<endl;
414 sorted_tracks->Add(ts);//save the track in the sorted array
415 // cout << "SortTracks:: sorted_tracks->Add(it) "<<i<<" "<<ts<<endl;
416
417 };
418 //Restore Object count
419 //To save space in the table keeping track of all referenced objects
420 //we assume that our events do not address each other. We reset the
421 //object count to what it was at the beginning of the event.
422 TProcessID::SetObjectCount(ObjectNumber);
423
424 };
425 //--------------------------------------
426 //
427 //
428 //--------------------------------------
429 /**
430 * This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2.
431 * PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information.
432 */
433 TRefArray *PamLevel2::GetTracks(){
434
435 // *-*-*-*-*-*-*-*-*-*-*-*-*
436 SortTracks("+CAL+TOF");
437 // *-*-*-*-*-*-*-*-*-*-*-*-*
438
439 return sorted_tracks;
440 };
441 //--------------------------------------
442 //
443 //
444 //--------------------------------------
445 /**
446 * Retrieves the it-th Pamela "physical" track.
447 * It override TrkLevel2::GetTrack(int it).
448 * @param it Track number, ranging from 0 to GetNTracks().
449 */
450 PamTrack *PamLevel2::GetTrack(int it){
451
452 // *-*-*-*-*-*-*-*-*-*-*-*-*
453 SortTracks("+CAL+TOF");
454 // *-*-*-*-*-*-*-*-*-*-*-*-*
455
456 PamTrack *track = 0;
457
458 if( it >=0 && it < TrkLevel2::GetNTracks() && it<sorted_tracks->GetEntriesFast() ){
459 TrkTrack *t = (TrkTrack*)sorted_tracks->At(it);
460 track = GetPamTrackAlong(t);
461 }else{
462 cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl;
463 };
464
465 return track;
466
467 };
468
469 //--------------------------------------
470 //
471 //
472 //--------------------------------------
473 /**
474 * Retrieves (if present) the image of the it-th Pamela "physical" track, sorted by the method PamLevel2::SortTracks().
475 * @param it Track number, ranging from 0 to GetNTracks().
476 */
477 PamTrack *PamLevel2::GetTrackImage(int it){
478
479 // *-*-*-*-*-*-*-*-*-*-*-*-*
480 SortTracks("+CAL+TOF");
481 // *-*-*-*-*-*-*-*-*-*-*-*-*
482
483 PamTrack *image = 0;
484
485 if( it >=0 && it < TrkLevel2::GetNTracks() ){
486 TrkTrack *temp = (TrkTrack*)sorted_tracks->At(it);
487 if( temp->HasImage() ){
488 TrkTrack *t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo());
489 image = GetPamTrackAlong(t);
490 }else{
491 cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<<it<<" does not have image"<<endl;
492 };
493 }else{
494 cout << "PamLevel2::GetTrackImage(int) : Tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<<TrkLevel2::GetNTracks()<<")"<<endl;
495 };
496
497 return image;
498 }
499
500 //--------------------------------------
501 //
502 //
503 //--------------------------------------
504 /**
505 * Get the Pamela detector trees in a single file and make them friends.
506 * @param f TFile pointer
507 * @param detlist String to select trees to be included
508 * @return Pointer to a TTree
509 */
510 TTree *PamLevel2::GetPamTree(TFile *f, TString detlist="+ALL"){
511
512 // cout << "WARNING!!! -- obsolete method -- \n";
513 // cout << "better use TChain *PamLevel2::GetPamTree(TList*, TString) \n";
514
515 SetWhichTrees(detlist);
516 TTree *Trout =0;
517
518
519 TString fname = f->GetName();
520 if(!CheckLevel2File(fname))return NULL;
521
522
523 // Tracker
524 TTree *T = (TTree*)f->Get("Tracker");
525 if(T && (TRK2||TRK1||TRKh)) {
526 if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2"));
527 if(TRK2)cout << "Tracker : set branch address TrkLevel2"<<endl;
528 if(TRK1)T->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1"));
529 if(TRK1)cout << "Tracker : set branch address TrkLevel1"<<endl;
530 if(TRKh)T->SetBranchAddress("TrkHough", GetPointerTo("TrkHough"));
531 if(TRKh)cout << "Tracker : set branch address TrkHough"<<endl;
532 if(!Trout)Trout=T;
533 else Trout->AddFriend(T);
534 }else{
535 cout << "Tracker : missing tree"<<endl;
536 };
537 // Calorimeter
538 TTree *C = (TTree*)f->Get("Calorimeter");
539 if(C && (CAL2||CAL1)) {
540 if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2"));
541 if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<<endl;
542 if(CAL1)C->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1"));
543 if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<<endl;
544 if(!Trout)Trout=C;
545 else Trout->AddFriend(C);
546 }else{
547 cout << "Calorimeter : missing tree"<<endl;
548 };
549 // ToF
550 TTree *O = (TTree*)f->Get("ToF");
551 if(O && TOF) {
552 O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2"));
553 cout << "ToF : set branch address ToFLevel2"<<endl;
554 if(!Trout)Trout=O;
555 else Trout->AddFriend(O);
556 }else{
557 cout << "ToF : missing tree"<<endl;
558 };
559 // Trigger
560 TTree *R = (TTree*)f->Get("Trigger");
561 if(R && TRG) {
562 R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2"));
563 cout << "Trigger : set branch address TrigLevel2"<<endl;
564 if(!Trout)Trout=O;
565 else Trout->AddFriend(R);
566 }else{
567 cout << "Trigger : missing tree"<<endl;
568 };
569 // S4
570 TTree *S = (TTree*)f->Get("S4");
571 if(S && S4) {
572 S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2"));
573 cout << "S4 : set branch address S4Level2"<<endl;
574 if(!Trout)Trout=O;
575 else Trout->AddFriend(S);
576 }else{
577 cout << "S4 : missing tree"<<endl;
578 };
579 // Neutron Detector
580 TTree *N = (TTree*)f->Get("NeutronD");
581 if(N && ND) {
582 N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2"));
583 cout << "NeutronD : set branch address NDLevel2"<<endl;
584 if(!Trout)Trout=O;
585 else Trout->AddFriend(N);
586 }else{
587 cout << "NeutronD : missing tree"<<endl;
588 };
589 // Anticounters
590 TTree *A = (TTree*)f->Get("Anticounter");
591 if(A && AC) {
592 A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2"));
593 cout << "Anticounter : set branch address AcLevel2"<<endl;
594 if(!Trout)Trout=O;
595 else Trout->AddFriend(A);
596 }else{
597 cout << "Anticounter : missing tree"<<endl;
598 };
599 // Orbital Info
600 TTree *B = (TTree*)f->Get("OrbitalInfo");
601 if(B && ORB) {
602 B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo"));
603 cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl;
604 if(!Trout)Trout=O;
605 else Trout->AddFriend(B);
606 }else{
607 cout << "OrbitalInfo : missing tree"<<endl;
608 };
609
610 cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl;
611
612 return Trout;
613
614 }
615 //--------------------------------------
616 //
617 //
618 //--------------------------------------
619 /**
620 * Get list of Level2 files.
621 * @param ddir Level2 data directory.
622 * @param flisttxt Name of txt file containing file list.
623 * @return Pointer to a TList of TSystemFiles
624 * If no input file list is given , all the Level2 files inside the directory are processed.
625 */
626 TList* PamLevel2::GetListOfLevel2Files(TString ddir, TString flisttxt = ""){
627
628 TString wdir = gSystem->WorkingDirectory();
629
630 if(ddir=="")ddir = wdir;
631 // TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir);
632 cout << "Level2 data directory : "<< ddir << endl;
633
634 TList *contents = new TList; // create output list
635 contents->SetOwner();
636
637 char *fullpath;
638
639 // if no input file list is given:
640 if ( flisttxt != "" ){
641
642 if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) )return 0;
643
644 // flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt));
645 flisttxt = fullpath;
646
647 if( !gSystem->ChangeDirectory(ddir) )return 0;
648
649 cout <<"Input file list : " << flisttxt <<endl;
650 ifstream in;
651 in.open(flisttxt, ios::in); //open input file list
652 int line=0;
653 while (1) {
654 TString file;
655 in >> file;
656 if (!in.good()) break;
657 line++;
658 // cout <<"(1) " << file << endl;
659 if(file.Contains("#"))file = file(0,file.First("#"));
660 // cout <<"(2) " << file << endl;
661 if(file.IsNull()){
662 cout << "-- list interrupted at line "<<line <<endl;
663 break;
664 }
665 if( gSystem->IsFileInIncludePath(file,&fullpath) ){
666
667 contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list
668
669 }else{
670 if(file.Data()!="")cout << "File: "<<file<<" ---> missing "<< endl;
671 };
672 };
673 in.close();
674
675 }else{
676
677 cout << "No input file list given."<<endl;
678 cout << "Check for existing root files."<<endl;
679 // cout << "Warking directory: "<< gSystem->WorkingDirectory()<< endl;
680
681 TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir);
682 TList *temp = datadir->GetListOfFiles();
683 // temp->Print();
684 // cout << "*************************************" << endl;
685
686 TIter next(temp);
687 TSystemFile *questo = 0;
688
689
690 while ( (questo = (TSystemFile*) next()) ) {
691 TString name = questo-> GetName();
692 if( name.EndsWith(".root") ){
693 char *fullpath;
694 gSystem->IsFileInIncludePath(name,&fullpath);
695 contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));
696 };
697 }
698 delete temp;
699 delete datadir;
700
701 };
702 gSystem->ChangeDirectory(wdir); // back to the working directory
703 // cout << endl << "Selected files:" << endl;
704 // contents->Print();
705 cout << contents->GetEntries()<<" files selected\n";
706 // cout << endl;
707 // cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl;
708 return contents;
709 };
710 //--------------------------------------
711 //
712 //
713 //--------------------------------------
714 /**
715 * Get the Pamela detector chains from a list of files and make them friends.
716 * @param fl Pointer to a TList of TSystemFiles
717 * @param detlist String to select trees to be included
718 * @return Pointer to a TChain
719 */
720 TChain *PamLevel2::GetPamTree(TList *fl, TString detlist="+ALL"){
721
722 // TChain *Tout=0;
723 // if(Tout)Tout->Delete();
724 // Tout = NULL;
725
726 TChain *Tout =0;
727
728 SetWhichTrees(detlist);
729
730 TChain *T = 0;
731 TChain *C = 0;
732 TChain *O = 0;
733 TChain *R = 0;
734 TChain *S = 0;
735 TChain *N = 0;
736 TChain *A = 0;
737 TChain *B = 0;
738
739 if(TRK2||TRK1||TRKh) T = new TChain("Tracker");
740 if(CAL2||CAL1) C = new TChain("Calorimeter");
741 if(TOF) O = new TChain("ToF");
742 if(TRG) R = new TChain("Trigger");
743 if(S4) S = new TChain("S4");
744 if(ND) N = new TChain("NeutronD");
745 if(AC) A = new TChain("Anticounter");
746 if(ORB) B = new TChain("OrbitalInfo");
747
748 // loop over files and create chains
749 TIter next(fl);
750 TSystemFile *questo = 0;
751 while ( (questo = (TSystemFile*) next()) ) {
752 TString name = questo->GetName();
753 // cout << "File: "<< name << endl;
754 if( CheckLevel2File(name) ){
755 if(TRK2||TRK1||TRKh) T->Add(name);
756 if(CAL1||CAL2) C->Add(name);
757 if(TOF) O->Add(name);
758 if(TRG) R->Add(name);
759 if(S4) S->Add(name);
760 if(ND) N->Add(name);
761 if(AC) A->Add(name);
762 if(ORB) B->Add(name);
763 };
764 }
765
766 cout << "done chain \n";
767
768 // Calorimeter
769 if(CAL2||CAL1) {
770 if(!Tout)Tout=C;
771 else Tout->AddFriend("Calorimeter");
772 };
773 // ToF
774 if(TOF) {
775 if(!Tout)Tout=O;
776 else Tout->AddFriend("ToF");
777 };
778 // Tracker
779 if(TRK2||TRK1||TRKh){
780 if(!Tout)Tout=T;
781 else Tout->AddFriend("Tracker");
782 }
783 // Trigger
784 if(TRG) {
785 if(!Tout)Tout=R;
786 else Tout->AddFriend("Trigger");
787 };
788 // S4
789 if(S4) {
790 if(!Tout)Tout=S;
791 else Tout->AddFriend("S4");
792 };
793 // Neutron Detector
794 if(ND) {
795 if(!Tout)Tout=N;
796 else Tout->AddFriend("NeutronD");
797 };
798 // Anticounters
799 if(AC) {
800 if(!Tout)Tout=A;
801 else Tout->AddFriend("Anticounter");
802 };
803 // OrbitalInfo
804 if(ORB) {
805 if(!Tout)Tout=B;
806 else Tout->AddFriend("OrbitalInfo");
807 };
808
809 // cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl;
810
811 // if( Tout->GetEntries() )PamLevel2::SetBranchAddress();
812 if( Tout->GetEntries() )PamLevel2::SetBranchAddress( Tout );
813
814 return Tout;
815 }
816
817
818
819 //--------------------------------------
820 //
821 //
822 //--------------------------------------
823 /**
824 * Set branch addresses for Pamela friend trees
825 */
826 void PamLevel2::SetBranchAddress(TTree *t){
827
828 TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2");
829 TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1");
830 TRKh = TRKh & t->GetBranchStatus("TrkHough");
831 CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2");
832 CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1");
833 TOF = TOF & t->GetBranchStatus("ToFLevel2");
834 TRG = TRG & t->GetBranchStatus("TrigLevel2");
835 S4 = S4 & t->GetBranchStatus("S4Level2");
836 ND = ND & t->GetBranchStatus("NDLevel2");
837 AC = AC & t->GetBranchStatus("AcLevel2");
838 ORB = ORB & t->GetBranchStatus("OrbitalInfo");
839
840
841 // Tracker
842 if(TRK1) {
843 t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel2"));
844 cout << "Tracker : set branch address TrkLevel1"<<endl;
845 };
846 if(TRK2) {
847 t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel1"));
848 cout << "Tracker : set branch address TrkLevel2"<<endl;
849 };
850 if(TRKh) {
851 t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough"));
852 cout << "Tracker : set branch address TrkHough"<<endl;
853 };
854
855 // Calorimeter
856 if(CAL1) {
857 t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1"));
858 cout << "Calorimeter : set branch address CaloLevel1"<<endl;
859 };
860 if(CAL2) {
861 t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2"));
862 cout << "Calorimeter : set branch address CaloLevel2"<<endl;
863 };
864
865 // ToF
866 if(TOF) {
867 t->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2"));
868 cout << "ToF : set branch address ToFLevel2"<<endl;
869 };
870 // Trigger
871 if(TRG) {
872 t->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2"));
873 cout << "Trigger : set branch address TrigLevel2"<<endl;
874 };
875 // S4
876 if(S4) {
877 t->SetBranchAddress("S4Level2", GetPointerTo("S4Level2"));
878 cout << "S4 : set branch address S4Level2"<<endl;
879 };
880 // Neutron Detector
881 if(ND) {
882 t->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2"));
883 cout << "NeutronD : set branch address NDLevel2"<<endl;
884 };
885 // Anticounters
886 if(AC) {
887 t->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2"));
888 cout << "Anticounter : set branch address AcLevel2"<<endl;
889 };
890 // OrbitalInfo
891 if(ORB) {
892 t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo"));
893 cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl;
894 };
895
896 }
897 /**
898 * Set branch addresses for Pamela friend trees
899 */
900 void PamLevel2::SetBranchAddress(TChain *t){
901
902 TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2");
903 TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1");
904 TRKh = TRKh & t->GetBranchStatus("TrkHough");
905 CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1");
906 CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2");
907 TOF = TOF & t->GetBranchStatus("ToFLevel2");
908 TRG = TRG & t->GetBranchStatus("TrigLevel2");
909 S4 = S4 & t->GetBranchStatus("S4Level2");
910 ND = ND & t->GetBranchStatus("NDLevel2");
911 AC = AC & t->GetBranchStatus("AcLevel2");
912 ORB = ORB & t->GetBranchStatus("OrbitalInfo");
913
914 // Tracker
915 if(TRK2) {
916 t->SetBranchAddress("TrkLevel2", this->GetPointerTo("TrkLevel2"));
917 cout << "Tracker : set branch address TrkLevel2"<<endl;
918 };
919 if(TRK1) {
920 t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1"));
921 cout << "Tracker : set branch address TrkLevel1"<<endl;
922 };
923 if(TRKh) {
924 t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough"));
925 cout << "Tracker : set branch address TrkHough"<<endl;
926 };
927
928 // Calorimeter
929 if(CAL2) {
930 t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2"));
931 cout << "Calorimeter : set branch address CaloLevel2"<<endl;
932 };
933 if(CAL1) {
934 t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1"));
935 cout << "Calorimeter : set branch address CaloLevel1"<<endl;
936 };
937
938 // ToF
939 if(TOF) {
940 t->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2"));
941 cout << "ToF : set branch address ToFLevel2"<<endl;
942 };
943 // Trigger
944 if(TRG) {
945 t->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2"));
946 cout << "Trigger : set branch address TrigLevel2"<<endl;
947 };
948 // S4
949 if(S4) {
950 t->SetBranchAddress("S4Level2", GetPointerTo("S4Level2"));
951 cout << "S4 : set branch address S4Level2"<<endl;
952 };
953 // Neutron Detector
954 if(ND) {
955 t->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2"));
956 cout << "NeutronD : set branch address NDLevel2"<<endl;
957 };
958 // Anticounters
959 if(AC) {
960 t->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2"));
961 cout << "Anticounter : set branch address AcLevel2"<<endl;
962 };
963 // OrbitalInfo
964 if(ORB) {
965 t->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo"));
966 cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl;
967 };
968
969 }
970
971 // void* PamLevel2::GetPointerToTrk() {return &trk2_obj;};
972 // void* PamLevel2::GetPointerToTrk(int s){
973 // switch (s) {
974 // case 1: return &trk1_obj;
975 // case 2: return &trk2_obj;
976 // case 3: return &trkh_obj;
977 // default: return 0;
978 // };
979 // };
980 // void* PamLevel2::GetPointerToCalo() {return &calo2_obj; };
981 // void* GetPointerToCalo(int s){
982 // switch (s) {
983 // case 1: return &calo1_obj;
984 // case 2: return &calo2_obj;
985 // default: return 0;
986 // };
987 // };
988 // void* GetPointerToToF() {return &tof_obj; };
989 // void* GetPointerTo("TrigLevel2") {return &trig_obj; };
990 // void* GetPointerTo("S4Level2") {return &s4_obj; };
991 // void* GetPointerTo("NDLevel2") {return &nd_obj; };
992 // void* GetPointerTo("AcLevel2") {return &ac_obj; };
993 // void* GetPointerTo("OrbitalInfo") {return &orb_obj; };
994 // void* GetPointerTo("RunInfo") {return &run_obj; };
995
996 //--------------------------------------
997 //
998 //
999 //--------------------------------------
1000 /**
1001 * Get the Run tree chain from a list of files.
1002 * @param fl Pointer to a TList of TSystemFiles
1003 * @return Pointer to a TChain
1004 */
1005 TChain *PamLevel2::GetRunTree(TList *fl){
1006
1007 TChain *R = new TChain("Run");
1008
1009 // loop over files and create chains
1010 TIter next(fl);
1011 TSystemFile *questo = 0;
1012 while ( (questo = (TSystemFile*) next()) ) {
1013 TString name = questo->GetName();
1014 // cout << "File: "<< name << endl;
1015 if( CheckLevel2File(name) ){
1016 R->Add(name);
1017 };
1018 }
1019
1020 R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo"));
1021 cout << "Run : set branch address RunInfo"<<endl;
1022
1023 return R;
1024
1025 }
1026 //--------------------------------------
1027 //
1028 //
1029 //--------------------------------------
1030 /**
1031 * Get the Run tree from a file.
1032 * @param f Pointer to a TFile
1033 * @return Pointer to a TTree
1034 */
1035 TTree *PamLevel2::GetRunTree(TFile *f){
1036
1037
1038 TTree *R = (TTree*)f->Get("Run");
1039
1040 R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo"));
1041 cout << "Run : set branch address RunInfo"<<endl;
1042
1043 return R;
1044
1045 }
1046 //--------------------------------------
1047 //
1048 //
1049 //--------------------------------------
1050 /**
1051 * Set which trees shoul be analysed
1052 * @param detlist TString containing the sequence of trees required
1053 */
1054 void PamLevel2::SetWhichTrees(TString detlist){
1055
1056 if(detlist.Contains("+ALL", TString::kIgnoreCase)){
1057 CAL1 = true;
1058 CAL2 = true;
1059 TRK2 = true;
1060 TRK1 = false;
1061 TRKh = false;
1062 TRG = true;
1063 TOF = true;
1064 S4 = true;
1065 ND = true;
1066 AC = true;
1067 ORB = true;
1068 }else if( detlist.Contains("-ALL", TString::kIgnoreCase) ){
1069 CAL1 = false;
1070 CAL2 = false;
1071 TRK2 = false;
1072 TRK1 = false;
1073 TRKh = false;
1074 TRG = false;
1075 TOF = false;
1076 S4 = false;
1077 ND = false;
1078 AC = false;
1079 ORB = false;
1080 };
1081
1082 // -------------------------------------------------------------------------
1083 if( detlist.Contains("CAL1", TString::kIgnoreCase) ){
1084 if ( detlist.Contains("-CAL1", TString::kIgnoreCase) )CAL1=false;
1085 if ( detlist.Contains("+CAL1", TString::kIgnoreCase) )CAL1=true;
1086 };
1087
1088 if( detlist.Contains("CAL2", TString::kIgnoreCase)){
1089 if ( detlist.Contains("-CAL2", TString::kIgnoreCase) )CAL2=false;
1090 if ( detlist.Contains("+CAL2", TString::kIgnoreCase) )CAL2=true;
1091 };
1092
1093 if( detlist.Contains("+CAL", TString::kIgnoreCase) && !CAL1 && !CAL2 )CAL2=true;
1094 if( detlist.Contains("-CAL", TString::kIgnoreCase) && CAL1 && CAL2 ){
1095 CAL2=false;
1096 CAL1=false;
1097 }
1098 // -------------------------------------------------------------------------
1099 if( detlist.Contains("TRK1", TString::kIgnoreCase) ){
1100 if ( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1=false;
1101 if ( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1=true;
1102 };
1103
1104 if( detlist.Contains("TRK2", TString::kIgnoreCase)){
1105 if ( detlist.Contains("-TRK2", TString::kIgnoreCase) )TRK2=false;
1106 if ( detlist.Contains("+TRK2", TString::kIgnoreCase) )TRK2=true;
1107 };
1108
1109 if( detlist.Contains("TRKh", TString::kIgnoreCase)){
1110 if ( detlist.Contains("-TRKh", TString::kIgnoreCase) )TRKh=false;
1111 if ( detlist.Contains("+TRKh", TString::kIgnoreCase) )TRKh=true;
1112 };
1113
1114 if( detlist.Contains("+TRK", TString::kIgnoreCase) && !TRK1 && !TRK2 && !TRKh )TRK2=true;
1115 if( detlist.Contains("-TRK", TString::kIgnoreCase) && TRK1 && TRK2 && TRKh){
1116 TRK2=false;
1117 TRK1=false;
1118 TRKh=false;
1119 }
1120 // -------------------------------------------------------------------------
1121
1122
1123
1124 // if( detlist.Contains("-TRK", TString::kIgnoreCase) )TRK2 = false;
1125 // else if( detlist.Contains("+TRK", TString::kIgnoreCase) )TRK2 = true;
1126
1127 // if( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1 = false;
1128 // else if( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1 = true;
1129
1130 // if( detlist.Contains("-TRKh", TString::kIgnoreCase) )TRKh = false;
1131 // else if( detlist.Contains("+TRKh", TString::kIgnoreCase) )TRKh = true;
1132
1133 if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false;
1134 else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true;
1135
1136 if( detlist.Contains("-TOF", TString::kIgnoreCase) )TOF = false;
1137 else if( detlist.Contains("+TOF", TString::kIgnoreCase) )TOF = true;
1138
1139 if( detlist.Contains("-S4", TString::kIgnoreCase) )S4 = false;
1140 else if( detlist.Contains("+S4", TString::kIgnoreCase) )S4 = true;
1141
1142 if( detlist.Contains("-ND", TString::kIgnoreCase) )ND = false;
1143 else if( detlist.Contains("+ND", TString::kIgnoreCase) )ND = true;
1144
1145 if( detlist.Contains("-AC", TString::kIgnoreCase) )AC = false;
1146 else if( detlist.Contains("+AC", TString::kIgnoreCase) )AC = true;
1147
1148 if( detlist.Contains("-ORB", TString::kIgnoreCase) )ORB = false;
1149 else if( detlist.Contains("+ORB", TString::kIgnoreCase) )ORB = true;
1150
1151 };
1152 //--------------------------------------
1153 //
1154 //
1155 //--------------------------------------
1156 /**
1157 * Check if a file contains selected Pamela Level2 trees.
1158 * @param name File name
1159 * @return true if the file is ok.
1160 */
1161 Bool_t PamLevel2::CheckLevel2File(TString name){
1162
1163 Bool_t CAL1__ok = false;
1164 Bool_t CAL2__ok = false;
1165 Bool_t TRK2__ok = false;
1166 Bool_t TRK1__ok = false;
1167 Bool_t TRKh__ok = false;
1168 Bool_t TRG__ok = false;
1169 Bool_t TOF__ok = false;
1170 Bool_t S4__ok = false;
1171 Bool_t ND__ok = false;
1172 Bool_t AC__ok = false;
1173 Bool_t ORB__ok = false;
1174
1175 Bool_t RUN__ok = false;
1176
1177
1178
1179 cout << "Checking file: "<<name<<endl;
1180 TFile *f = new TFile(name.Data());
1181 if( !f || f->IsZombie() ){
1182 cout << "File: "<< f->GetName() <<" discarded ---- Non valid root file"<< endl; return false;
1183 }
1184 // cout << "Get list of keys: "<<f<<endl;
1185 TList *lk = f->GetListOfKeys();
1186 // lk->Print();
1187 TIter next(lk);
1188 TKey *key =0;
1189
1190 Int_t nev = 0;
1191
1192 while( (key = (TKey*)next()) ){
1193
1194 // cout << key->GetName() << endl;
1195 // cout << " Get tree: " << f->Get(key->GetName())<<endl;
1196 // nev_previous = nev;
1197 // cout << " n.entries "<< nev <<endl;
1198 // if( key->GetClassName()=="TTree" && nev_previous && nev != nev_previous ){
1199 // nev = ((TTree*)f->Get(key->GetName()))->GetEntries();
1200 // cout << "File: "<< f->GetName() <<" discarded ---- "<< key->GetName() << " tree: n.entries does not match "<<nev<<" "<<nev_previous<< endl;
1201 // return false;
1202 // };
1203
1204 if( !strcmp(key->GetName(),"Run" ) )RUN__ok = true;
1205
1206 //=========================================================
1207 if( !strcmp(key->GetName(),"Trigger" ) ){
1208 TRG__ok = true;
1209 if(TRG){
1210 Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries();
1211 if( nev && nevt!=nev){
1212 cout << "File: "<< f->GetName() <<" discarded ---- Trigger tree has "<<nevt<<" events instead of "<<nev<< endl;
1213 return false;
1214 }
1215 nev=nevt;
1216 }
1217 }
1218 //=========================================================
1219 if( !strcmp(key->GetName(),"ToF" ) ){
1220 TOF__ok = true;
1221 if(TOF){
1222 Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries();
1223 if( nev && nevt!=nev){
1224 cout << "File: "<< f->GetName() <<" discarded ---- ToF tree has "<<nevt<<" events instead of "<<nev<< endl;
1225 return false;
1226 }
1227 nev=nevt;
1228 }
1229 }
1230 //=========================================================
1231 if( !strcmp(key->GetName(),"S4" ) ){
1232 S4__ok = true;
1233 if(S4){
1234 Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries();
1235 if( nev && nevt!=nev){
1236 cout << "File: "<< f->GetName() <<" discarded ---- S4 tree has "<<nevt<<" events instead of "<<nev<< endl;
1237 return false;
1238 }
1239 nev=nevt;
1240 }
1241 }
1242 //=========================================================
1243
1244 if( !strcmp(key->GetName(),"NeutronD" ) ){
1245 ND__ok = true;
1246 if(ND){
1247 Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries();
1248 if( nev && nevt!=nev){
1249 cout << "File: "<< f->GetName() <<" discarded ---- NeutronD tree has "<<nevt<<" events instead of "<<nev<< endl;
1250 return false;
1251 }
1252 nev=nevt;
1253 }
1254 }
1255 //=========================================================
1256 if( !strcmp(key->GetName(),"Anticounter") ){
1257 AC__ok = true;
1258 if(AC){
1259 Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries();
1260 if( nev && nevt!=nev){
1261 cout << "File: "<< f->GetName() <<" discarded ---- Anticounter tree has "<<nevt<<" events instead of "<<nev<< endl;
1262 return false;
1263 }
1264 nev=nevt;
1265 }
1266 }
1267 //=========================================================
1268 if( !strcmp(key->GetName(),"OrbitalInfo") ){
1269 ORB__ok = true;
1270 if(ORB){
1271 Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries();
1272 if( nev && nevt!=nev){
1273 cout << "File: "<< f->GetName() <<" discarded ---- OrbitalInfo tree has "<<nevt<<" events instead of "<<nev<< endl;
1274 return false;
1275 }
1276 nev=nevt;
1277 }
1278 }
1279 //=========================================================
1280 if( !strcmp(key->GetName(),"Tracker" ) ){
1281 TTree *T = (TTree*)f->Get("Tracker");
1282 if(TRK1||TRK2||TRKh){
1283 Int_t nevt = T->GetEntries();
1284 if( nev && nevt!=nev){
1285 cout << "File: "<< f->GetName() <<" discarded ---- Tracker tree has "<<nevt<<" events instead of "<<nev<< endl;
1286 return false;
1287 }
1288 nev=nevt;
1289 }
1290 for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){
1291 TString name = T->GetListOfBranches()->At(i)->GetName();
1292 if( !name.CompareTo("TrkLevel1") )TRK1__ok=true;
1293 if( !name.CompareTo("TrkLevel2") )TRK2__ok=true;
1294 if( !name.CompareTo("TrkHough") )TRKh__ok=true;
1295 };
1296 T->Delete();
1297 };
1298 //=========================================================
1299 if( !strcmp(key->GetName(),"Calorimeter" ) ){
1300 TTree *T = (TTree*)f->Get("Calorimeter");
1301 if(CAL1||CAL2){
1302 Int_t nevt = T->GetEntries();
1303 if( nev && nevt!=nev){
1304 cout << "File: "<< f->GetName() <<" discarded ---- Calorimeter tree has "<<nevt<<" events instead of "<<nev<< endl;
1305 return false;
1306 }
1307 nev=nevt;
1308 }
1309 for(Int_t i=0; i<T->GetListOfBranches()->GetEntries(); i++){
1310 TString name = T->GetListOfBranches()->At(i)->GetName();
1311 if( !name.CompareTo("CaloLevel1") )CAL1__ok=true;
1312 if( !name.CompareTo("CaloLevel2") )CAL2__ok=true;
1313 };
1314 T->Delete();
1315 };
1316
1317 };
1318
1319
1320
1321 if(!RUN__ok) {
1322 cout << "File: "<< f->GetName() <<" *WARNING* ---- Missing RunInfo tree"<< endl;
1323 // return false;
1324 };
1325
1326 if(CAL1 && !CAL1__ok){
1327 cout << "File: "<< f->GetName() <<" discarded ---- Missing CaloLevel1 branch"<< endl;
1328 return false;
1329 };
1330 if(CAL2 && !CAL2__ok){
1331 cout << "File: "<< f->GetName() <<" discarded ---- Missing CaloLevel2 branch"<< endl;
1332 return false;
1333 };
1334 if(TRK2 && !TRK2__ok){
1335 cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkLevel2 branch"<< endl;
1336 return false;
1337 };
1338 if(TRK1 && !TRK1__ok){
1339 cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkLevel1 branch"<< endl;
1340 return false;
1341 };
1342 if(TRKh && !TRKh__ok){
1343 cout << "File: "<< f->GetName() <<" discarded ---- Missing TrkHough branch"<< endl;
1344 return false;
1345 };
1346 if(ORB && !ORB__ok){
1347 cout << "File: "<< f->GetName() <<" discarded ---- Missing ORB tree"<< endl;
1348 return false;
1349 };
1350 if(AC && !AC__ok){
1351 cout << "File: "<< f->GetName() <<" discarded ---- Missing AC tree"<< endl;
1352 return false;
1353 };
1354 if(S4 && !S4__ok){
1355 cout << "File: "<< f->GetName() <<" discarded ---- Missing S4 tree"<< endl;
1356 return false;
1357 };
1358 if(TOF && !TOF__ok){
1359 cout << "File: "<< f->GetName() <<" discarded ---- Missing ToF tree"<< endl;
1360 return false;
1361 };
1362
1363 if(ND && !ND__ok){
1364 cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl;
1365 return false;
1366 };
1367 if(TRG && !TRG__ok){
1368 cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl;
1369 return false;
1370 };
1371
1372
1373
1374
1375
1376 lk->Delete();
1377 f->Close();
1378
1379 return true;
1380
1381 };
1382
1383
1384 /**
1385 * Create clone-trees
1386 */
1387 void PamLevel2::CreateCloneTrees( TChain *fChain ){
1388
1389 cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1390 cout << "Create clones of PAMELA trees "<<endl;
1391
1392 Int_t i=0;
1393 tree_clone[i] = fChain->GetTree()->CloneTree(0);
1394 TString name = tree_clone[i]->GetName();
1395 name.Append("_clone");
1396 // tree_clone[i]->SetName(name.Data());
1397 cout << tree_clone[i]->GetName() <<endl;
1398 i++;
1399
1400 TList *li = fChain->GetListOfFriends();
1401 TIter next(li);
1402 TFriendElement* T_friend=0;
1403 while( (T_friend = (TFriendElement*)next()) ){
1404 // cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl;
1405 // cout<<T_friend->GetTree()->GetName()<< endl;
1406 tree_clone[i] = T_friend->GetTree()->CloneTree(0);
1407 name = tree_clone[i]->GetName();
1408 name.Append("_clone");
1409 // tree_clone[i]->SetName(name.Data());
1410 cout << tree_clone[i]->GetName() << endl;
1411 i++;
1412 }
1413
1414 cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1415
1416 }
1417
1418 // /**
1419 // * Create clone-trees
1420 // */
1421 // void PamLevel2::CreateCloneTrees(){
1422
1423 // cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1424 // cout << "Create new PAMELA trees "<<endl;
1425
1426 // if(TRK1||TRK2||TRKh){
1427 // T_clone = new TTree("Tracker_clone","PAMELA tracker level2 data ");
1428 // if(TRK1) {
1429 // trk1_clone = new TrkLevel1();
1430 // T_clone->Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1"));
1431 // T_clone->BranchRef();
1432 // cout << "Tracker : branch TrkLevel1"<<endl;
1433 // };
1434 // if(TRK2) {
1435 // trk2_clone = new TrkLevel2();
1436 // T_clone->Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2"));
1437 // cout << "Tracker : branch TrkLevel2"<<endl;
1438 // };
1439 // if(TRKh) {
1440 // trkh_clone = new TrkHough();
1441 // T_clone->Branch("TrkHough","TrkHough", GetPointerTo("TrkHough"));
1442 // cout << "Tracker : branch TrkHough"<<endl;
1443 // };
1444 // cout << hex << T_clone << dec << endl;
1445 // }
1446
1447 // // Calorimeter
1448 // if(CAL1||CAL2){
1449 // C_clone = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data ");
1450 // if(CAL1) {
1451 // calo1_clone = new CaloLevel1();
1452 // C_clone->Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1"));
1453 // cout << "Calorimeter : branch CaloLevel1"<<endl;
1454 // };
1455 // if(CAL2) {
1456 // calo2_clone = new CaloLevel2();
1457 // C_clone->Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2"));
1458 // cout << "Calorimeter : branch CaloLevel2"<<endl;
1459 // };
1460 // }
1461
1462 // // ToF
1463 // if(TOF) {
1464 // O_clone = new TTree("ToF_clone","PAMELA ToF level2 data ");
1465 // tof_clone = new ToFLevel2();
1466 // O_clone->Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2"));
1467 // cout << "ToF : branch ToFLevel2"<<endl;
1468 // };
1469 // // Trigger
1470 // if(TRG) {
1471 // R_clone = new TTree("Trigger_clone","PAMELA trigger level2 data ");
1472 // trig_clone = new TrigLevel2();
1473 // R_clone->Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2"));
1474 // cout << "Trigger : branch TrigLevel2"<<endl;
1475 // };
1476 // // S4
1477 // if(S4) {
1478 // S_clone = new TTree("S4_clone","PAMELA S4 level2 data ");
1479 // s4_clone = new S4Level2();
1480 // S_clone->Branch("S4Level2","S4Level2", GetPointerTo("S4Level2"));
1481 // cout << "S4 : branch S4Level2"<<endl;
1482 // };
1483 // // Neutron Detector
1484 // if(ND) {
1485 // N_clone = new TTree("NeutronD_clone","PAMELA neutron detector level2 data ");
1486 // nd_clone = new NDLevel2();
1487 // N_clone->Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2"));
1488 // cout << "NeutronD : branch NDLevel2"<<endl;
1489 // };
1490 // // Anticounters
1491 // if(AC) {
1492 // A_clone = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data ");
1493 // ac_clone = new AcLevel2();
1494 // A_clone->Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2"));
1495 // cout << "Anticounter : branch AcLevel2"<<endl;
1496 // };
1497 // // OrbitalInfo
1498 // if(ORB) {
1499 // B_clone = new TTree("OrbitalInfo_clone","PAMELA oribital info ");
1500 // orb_clone = new OrbitalInfo();
1501 // B_clone->Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo"));
1502 // cout << "OrbitalInfo : branch OrbitalInfo"<<endl;
1503 // };
1504 // cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1505
1506 // }
1507
1508 // /**
1509 // * Create clone-trees
1510 // */
1511 // void PamLevel2::CreateCloneTrees(){
1512
1513 // cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1514 // cout << "Create new PAMELA trees "<<endl;
1515
1516 // if(TRK1||TRK2||TRKh){
1517 // T_clone = new TTree("Tracker_clone","PAMELA tracker level2 data ");
1518 // if(TRK1) {
1519 // trk1_clone = new TrkLevel1();
1520 // T_clone->Branch("TrkLevel1","TrkLevel1", &trk1_clone);
1521 // T_clone->BranchRef();
1522 // cout << "Tracker : branch TrkLevel1"<<endl;
1523 // };
1524 // if(TRK2) {
1525 // trk2_clone = new TrkLevel2();
1526 // T_clone->Branch("TrkLevel2", "TrkLevel2",&trk2_clone);
1527 // cout << "Tracker : branch TrkLevel2"<<endl;
1528 // };
1529 // if(TRKh) {
1530 // trkh_clone = new TrkHough();
1531 // T_clone->Branch("TrkHough","TrkHough", &trkh_clone);
1532 // cout << "Tracker : branch TrkHough"<<endl;
1533 // };
1534 // cout << hex << T_clone << dec << endl;
1535 // }
1536
1537 // // Calorimeter
1538 // if(CAL1||CAL2){
1539 // C_clone = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data ");
1540 // if(CAL1) {
1541 // calo1_clone = new CaloLevel1();
1542 // C_clone->Branch("CaloLevel1", "CaloLevel1", &calo1_clone);
1543 // cout << "Calorimeter : branch CaloLevel1"<<endl;
1544 // };
1545 // if(CAL2) {
1546 // calo2_clone = new CaloLevel2();
1547 // C_clone->Branch("CaloLevel2","CaloLevel2", &calo2_clone);
1548 // cout << "Calorimeter : branch CaloLevel2"<<endl;
1549 // };
1550 // }
1551
1552 // // ToF
1553 // if(TOF) {
1554 // O_clone = new TTree("ToF_clone","PAMELA ToF level2 data ");
1555 // tof_clone = new ToFLevel2();
1556 // O_clone->Branch("ToFLevel2","ToFLevel2", &tof_clone);
1557 // cout << "ToF : branch ToFLevel2"<<endl;
1558 // };
1559 // // Trigger
1560 // if(TRG) {
1561 // R_clone = new TTree("Trigger_clone","PAMELA trigger level2 data ");
1562 // trig_clone = new TrigLevel2();
1563 // R_clone->Branch("TrigLevel2","TrigLevel2", &trig_clone);
1564 // cout << "Trigger : branch TrigLevel2"<<endl;
1565 // };
1566 // // S4
1567 // if(S4) {
1568 // S_clone = new TTree("S4_clone","PAMELA S4 level2 data ");
1569 // s4_clone = new S4Level2();
1570 // S_clone->Branch("S4Level2","S4Level2", &s4_clone);
1571 // cout << "S4 : branch S4Level2"<<endl;
1572 // };
1573 // // Neutron Detector
1574 // if(ND) {
1575 // N_clone = new TTree("NeutronD_clone","PAMELA neutron detector level2 data ");
1576 // nd_clone = new NDLevel2();
1577 // N_clone->Branch("NDLevel2","NDLevel2", &nd_clone);
1578 // cout << "NeutronD : branch NDLevel2"<<endl;
1579 // };
1580 // // Anticounters
1581 // if(AC) {
1582 // A_clone = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data ");
1583 // ac_clone = new AcLevel2();
1584 // A_clone->Branch("AcLevel2","AcLevel2", &ac_clone);
1585 // cout << "Anticounter : branch AcLevel2"<<endl;
1586 // };
1587 // // OrbitalInfo
1588 // if(ORB) {
1589 // B_clone = new TTree("OrbitalInfo_clone","PAMELA oribital info ");
1590 // orb_clone = new OrbitalInfo();
1591 // B_clone->Branch("OrbitalInfo","OrbitalInfo", &orb_clone);
1592 // cout << "OrbitalInfo : branch OrbitalInfo"<<endl;
1593 // };
1594 // cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1595
1596 // }
1597
1598 /**
1599 * Fill tree (created with CreateCloneTrees)
1600 *
1601 */
1602 //void PamLevel2::FillNewPamTree(TTree *T){
1603 void PamLevel2::FillCloneTrees(){
1604
1605 // // --------------------------------------
1606 // // copy the event
1607 // // --------------------------------------
1608 // if(trk1_clone) *trk1_clone = *trk1_obj;
1609 // if(trk2_clone){
1610 // trk2_clone->Clear();
1611 // trk2_obj->Copy(*trk2_clone);
1612 // // *trk2_clone = *trk2_obj;
1613 // }
1614 // if(trkh_clone) *trkh_clone = *trkh_obj;
1615 // if(calo1_clone){
1616 // // *calo1_clone = *calo1_obj;
1617 // calo1_clone->Clear();
1618 // calo1_obj->Copy(*calo1_clone);
1619 // }
1620 // if(calo2_clone){
1621 // // *calo2_clone = *calo2_obj;
1622 // calo2_clone->Clear();
1623 // calo2_obj->Copy(*calo2_clone);
1624 // }
1625 // if(tof_clone) *tof_clone = *tof_obj;
1626 // if(trig_clone) *trig_clone = *trig_obj;
1627 // if(s4_clone) *s4_clone = *s4_obj;
1628 // if(nd_clone) *nd_clone = *nd_obj;
1629 // if(ac_clone) *ac_clone = *ac_obj;
1630 // if(orb_clone) *orb_clone = *orb_obj;
1631
1632 // if(T_clone)T_clone->Fill();
1633 // if(C_clone)C_clone->Fill();
1634 // if(O_clone)O_clone->Fill();
1635 // if(R_clone)R_clone->Fill();
1636 // if(S_clone)S_clone->Fill();
1637 // if(N_clone)N_clone->Fill();
1638 // if(A_clone)A_clone->Fill();
1639 // if(O_clone)O_clone->Fill();
1640
1641 for(Int_t i=0; i<8; i++){
1642 if(tree_clone[i])tree_clone[i]->Fill();
1643 }
1644 }
1645
1646
1647 TTree* PamLevel2::GetCloneTree(TString name){
1648
1649 for(Int_t i=0; i<8; i++){
1650 if(tree_clone[i]){
1651 TString na = tree_clone[i]->GetName();
1652 if(!name.CompareTo(na))return tree_clone[i];
1653 };
1654 }
1655 return NULL;
1656
1657 }
1658 void PamLevel2::WriteCloneTrees(){
1659 cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1660 cout << "Write clones of PAMELA trees "<<endl;
1661 for(Int_t i=0; i<8; i++){
1662 if(tree_clone[i]){
1663 cout << tree_clone[i]->GetName()<<endl;
1664 tree_clone[i]->Write();
1665 };
1666 }
1667 cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1668
1669 }
1670
1671 /**
1672 * Create a new (empty) Pamela trees
1673 */
1674 // TTree* PamLevel2::GetNewPamTree(){
1675
1676 // if(tree_clone)return tree_clone;
1677
1678 // TTree *Tout = 0;
1679
1680 // cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1681 // cout << "Create new PAMELA trees "<<endl;
1682
1683
1684 // if(TRK1||TRK2||TRKh){
1685 // TTree *T = new TTree("Tracker_clone","PAMELA tracker level2 data ");
1686 // if(TRK1) {
1687 // trk1_clone = new TrkLevel1();
1688 // T->Branch("TrkLevel1","TrkLevel1", &trk1_clone);
1689 // T->BranchRef();
1690 // cout << "Tracker : branch TrkLevel1"<<endl;
1691 // };
1692 // if(TRK2) {
1693 // trk2_clone = new TrkLevel2();
1694 // T->Branch("TrkLevel2", "TrkLevel2",&trk2_clone);
1695 // cout << "Tracker : branch TrkLevel2"<<endl;
1696 // };
1697 // if(TRKh) {
1698 // trkh_clone = new TrkHough();
1699 // T->Branch("TrkHough","TrkHough", &trkh_clone);
1700 // cout << "Tracker : branch TrkHough"<<endl;
1701 // };
1702 // if(!Tout)Tout=T;
1703 // else Tout->AddFriend("Tracker_clone");
1704 // }
1705
1706 // // Calorimeter
1707 // if(CAL1||CAL2){
1708 // TTree *C = new TTree("Calorimeter_clone","PAMELA calorimeter level2 data ");
1709 // if(CAL1) {
1710 // calo1_clone = new CaloLevel1();
1711 // C->Branch("CaloLevel1", "CaloLevel1", &calo1_clone);
1712 // cout << "Calorimeter : branch CaloLevel1"<<endl;
1713 // };
1714 // if(CAL2) {
1715 // calo2_clone = new CaloLevel2();
1716 // C->Branch("CaloLevel2","CaloLevel2", &calo2_clone);
1717 // cout << "Calorimeter : branch CaloLevel2"<<endl;
1718 // };
1719 // if(!Tout)Tout=C;
1720 // else Tout->AddFriend("Calorimeter_clone");
1721 // }
1722
1723 // // ToF
1724 // if(TOF) {
1725 // TTree *O = new TTree("ToF_clone","PAMELA ToF level2 data ");
1726 // tof_clone = new ToFLevel2();
1727 // O->Branch("ToFLevel2","ToFLevel2", &tof_clone);
1728 // cout << "ToF : branch ToFLevel2"<<endl;
1729 // if(!Tout)Tout=O;
1730 // else Tout->AddFriend("ToF_clone");
1731 // };
1732 // // Trigger
1733 // if(TRG) {
1734 // TTree *R = new TTree("Trigger_clone","PAMELA trigger level2 data ");
1735 // trig_clone = new TrigLevel2();
1736 // R->Branch("TrigLevel2","TrigLevel2", &trig_clone);
1737 // cout << "Trigger : branch TrigLevel2"<<endl;
1738 // if(!Tout)Tout=R;
1739 // else Tout->AddFriend("Trigger_clone");
1740 // };
1741 // // S4
1742 // if(S4) {
1743 // TTree *S = new TTree("S4_clone","PAMELA S4 level2 data ");
1744 // s4_clone = new S4Level2();
1745 // S->Branch("S4Level2","S4Level2", &s4_clone);
1746 // cout << "S4 : branch S4Level2"<<endl;
1747 // if(!Tout)Tout=S;
1748 // else Tout->AddFriend("S4_clone");
1749 // };
1750 // // Neutron Detector
1751 // if(ND) {
1752 // TTree *N = new TTree("NeutronD_clone","PAMELA neutron detector level2 data ");
1753 // nd_clone = new NDLevel2();
1754 // N->Branch("NDLevel2","NDLevel2", &nd_clone);
1755 // cout << "NeutronD : branch NDLevel2"<<endl;
1756 // if(!Tout)Tout=N;
1757 // else Tout->AddFriend("NeutronD_clone");
1758 // };
1759 // // Anticounters
1760 // if(AC) {
1761 // TTree *A = new TTree("Anticounter_clone","PAMELA anticounter detector level2 data ");
1762 // ac_clone = new AcLevel2();
1763 // A->Branch("AcLevel2","AcLevel2", &ac_clone);
1764 // cout << "Anticounter : branch AcLevel2"<<endl;
1765 // if(!Tout)Tout=A;
1766 // else Tout->AddFriend("Anticounter_clone");
1767 // };
1768 // // OrbitalInfo
1769 // if(ORB) {
1770 // TTree *B = new TTree("OrbitalInfo_clone","PAMELA oribital info ");
1771 // orb_clone = new OrbitalInfo();
1772 // B->Branch("OrbitalInfo","OrbitalInfo", &orb_clone);
1773 // cout << "OrbitalInfo : branch OrbitalInfo"<<endl;
1774 // if(!Tout)Tout=B;
1775 // else Tout->AddFriend("OrbitalInfo_clone");
1776 // };
1777 // cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <<endl;
1778
1779 // tree_clone = Tout;
1780 // tree_clone->SetDirectory(0);
1781
1782 // return Tout;
1783 // }
1784 // /**
1785 // * Fill a tree (created with GetNewPamTree)
1786 // *
1787 // */
1788 // //void PamLevel2::FillNewPamTree(TTree *T){
1789 // void PamLevel2::FillNewPamTree(){
1790
1791
1792 // if(trk1_clone) *trk1_clone = *trk1_obj;
1793 // if(trk2_clone){
1794 // trk2_clone->Clear();
1795 // trk2_obj->Copy(*trk2_clone);
1796 // // *trk2_clone = *trk2_obj;
1797 // }
1798 // if(trkh_clone) *trkh_clone = *trkh_obj;
1799 // if(calo1_clone){
1800 // // *calo1_clone = *calo1_obj;
1801 // calo1_clone->Clear();
1802 // calo1_obj->Copy(*calo1_clone);
1803 // }
1804 // if(calo2_clone){
1805 // // *calo2_clone = *calo2_obj;
1806 // calo2_clone->Clear();
1807 // calo2_obj->Copy(*calo2_clone);
1808 // }
1809 // if(tof_clone) *tof_clone = *tof_obj;
1810 // if(trig_clone) *trig_clone = *trig_obj;
1811 // if(s4_clone) *s4_clone = *s4_obj;
1812 // if(nd_clone) *nd_clone = *nd_obj;
1813 // if(ac_clone) *ac_clone = *ac_obj;
1814 // if(orb_clone) *orb_clone = *orb_obj;
1815
1816 // TTree *T = tree_clone;
1817
1818 // T->Fill(); //fill main tree
1819 // // cout<<T->IsA()->GetName()<<" "<<T->GetName()<<endl;
1820 // TList *li = T->GetListOfFriends();
1821 // TIter next(li);
1822 // TFriendElement* T_friend=0;
1823 // while( (T_friend = (TFriendElement*)next()) ){
1824 // // cout<<T_friend->IsA()->GetName()<<" "<<T_friend->GetName()<<hex << T_friend->GetTree() << dec<<endl;
1825 // T_friend->GetTree()->Fill();//fill friends
1826 // }
1827
1828 // }

  ViewVC Help
Powered by ViewVC 1.1.23