--- PamelaLevel2/src/PamLevel2.cpp 2006/12/06 11:07:35 1.10 +++ PamelaLevel2/src/PamLevel2.cpp 2007/01/18 08:51:16 1.18 @@ -7,9 +7,10 @@ * Default constructor */ PamTrack::PamTrack(){ - trk_track = this->TrkTrack::GetTrkTrack(); - calo_track = this->CaloTrkVar::GetCaloTrkVar(); - tof_track = this->ToFTrkVar::GetToFTrkVar(); + trk_track = 0; + calo_track = 0; + tof_track = 0; + candeleteobj = 0; }; //-------------------------------------- // @@ -19,14 +20,66 @@ * Constructor */ PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o){ - trk_track = this->TrkTrack::GetTrkTrack(); - calo_track = this->CaloTrkVar::GetCaloTrkVar(); - tof_track = this->ToFTrkVar::GetToFTrkVar(); - if(t) *trk_track = *t; - if(c) *calo_track = *c; - if(o) *tof_track = *o; + + trk_track = 0; + calo_track = 0; + tof_track = 0; +// if(t)trk_track = new TrkTrack(*t); +// if(c)calo_track = new CaloTrkVar(*c); +// if(o)tof_track = new ToFTrkVar(*o); + if(t)trk_track = t; + if(c)calo_track = c; + if(o)tof_track = o; + candeleteobj = 0; + }; +PamTrack::PamTrack(const PamTrack& track){ + + TrkTrack *t = track.trk_track; + CaloTrkVar *c = track.calo_track; + ToFTrkVar *o = track.tof_track; + + trk_track = 0; + calo_track = 0; + tof_track = 0; + if(t)trk_track = new TrkTrack(*t); + if(c)calo_track = new CaloTrkVar(*c); + if(o)tof_track = new ToFTrkVar(*o); + candeleteobj = 1; + +} +void PamTrack::Clear(){ +// cout << "PamTrack::Clear() "<TrkTrack::Clear(); + if(calo_track) calo_track->CaloTrkVar::Clear();//??? + if(tof_track) tof_track->ToFTrkVar::Clear();//??? + }else{ + trk_track = 0; + calo_track = 0; + tof_track = 0; + } +} +void PamTrack::Delete(){ +// cout << "PamTrack::Delete() "<TrkTrack::Clear(); + delete trk_track; + } + if(calo_track){ + calo_track->CaloTrkVar::Clear();//??? + delete calo_track; + } + if(tof_track){ + tof_track->ToFTrkVar::Clear();//??? + delete tof_track; + } + }else{ + Clear(); + } +} //-------------------------------------- // // @@ -36,44 +89,38 @@ */ PamLevel2::PamLevel2(){ - trk2_obj = TrkLevel2::GetTrkLevel2(); - trk1_obj = TrkLevel1::GetTrkLevel1(); - trkh_obj = TrkHough::GetTrkHough(); - calo1_obj = CaloLevel1::GetCaloLevel1(); - calo2_obj = CaloLevel2::GetCaloLevel2(); - tof_obj = ToFLevel2::GetToFLevel2(); - trig_obj = TrigLevel2::GetTrigLevel2(); - s4_obj = S4Level2::GetS4Level2(); - nd_obj = NDLevel2::GetNDLevel2(); - ac_obj = AcLevel2::GetAcLevel2(); - orb_obj = OrbitalInfo::GetOrbitalInfo(); - - run_obj = new GL_RUN(); - -// trk1_clone = 0; -// trk2_clone = 0; -// trkh_clone = 0; -// calo1_clone = 0; -// calo2_clone = 0; -// tof_clone = 0; -// trig_clone = 0; -// s4_clone = 0; -// nd_clone = 0; -// ac_clone = 0; -// orb_clone = 0; - -// T_clone = 0; -// C_clone = 0; -// O_clone = 0; -// R_clone = 0; -// S_clone = 0; -// N_clone = 0; -// A_clone = 0; -// B_clone = 0; +// trk2_obj = TrkLevel2::GetTrkLevel2(); +// trk1_obj = TrkLevel1::GetTrkLevel1(); +// trkh_obj = TrkHough::GetTrkHough(); +// calo1_obj = CaloLevel1::GetCaloLevel1(); +// calo2_obj = CaloLevel2::GetCaloLevel2(); +// tof_obj = ToFLevel2::GetToFLevel2(); +// trig_obj = TrigLevel2::GetTrigLevel2(); +// s4_obj = S4Level2::GetS4Level2(); +// nd_obj = NDLevel2::GetNDLevel2(); +// ac_obj = AcLevel2::GetAcLevel2(); +// orb_obj = OrbitalInfo::GetOrbitalInfo(); + trk2_obj = 0; + trk1_obj = 0; + trkh_obj = 0; + calo1_obj = 0; + calo2_obj = 0; + tof_obj = 0; + trig_obj = 0; + s4_obj = 0; + nd_obj = 0; + ac_obj = 0; + orb_obj = 0; + + run_obj = 0;//new GL_RUN(); + soft_obj = 0;// Emiliano + irun = -1; + runfirstentry = 0ULL; + runlastentry = 0ULL; for(Int_t i=0; i<8; i++ )tree_clone[i]=NULL; - sorted_tracks = new TRefArray(); +// sorted_tracks = 0;//new TRefArray(); CAL1 = true; CAL2 = true; @@ -87,44 +134,79 @@ AC = true; ORB = true; + RUN = true; + + tsorted=0; + timage=0; }; /** - * Destructor + * Delete the event (act as Dtor) */ -PamLevel2::~PamLevel2(){ - delete run_obj; - Clear(); +void PamLevel2::Delete(){ + + if(run_obj)delete run_obj; + if(soft_obj)delete soft_obj; //Emiliano + +// cout << "void PamLevel2::Clear()"<Delete(); + delete tsorted; + } + if(timage){ + timage->Delete(); + delete timage; + } }; + /** - * Clear the event + * Clear the event (NB! does not deallocate objects) */ void PamLevel2::Clear(){ - TrkLevel1::Clear(); - - TrkLevel2::Clear(); - CaloLevel2::Clear(); - ToFLevel2::Clear(); - TrigLevel2::Clear(); - S4Level2::Clear(); - NDLevel2::Clear(); - AcLevel2::Clear(); - OrbitalInfo::Clear(); - -// if(trk1_clone)trk1_clone->Clear(); -// if(trk2_clone)trk2_clone->Clear(); -// if(trkh_clone)trkh_clone->Clear(); -// if(calo1_clone)calo1_clone->Clear(); -// if(calo2_clone)calo2_clone->Clear(); -// if(tof_clone)tof_clone->Clear(); -// if(trig_clone)trig_clone->Clear(); -// if(s4_clone)s4_clone->Clear(); -// if(nd_clone)nd_clone->Clear(); -// if(ac_clone)ac_clone->Clear(); -// if(orb_clone)orb_clone->Clear(); +// cout << "void PamLevel2::Clear()"<Clear(); // Emiliano: Do not deallocate run_obj here, it will give segmentation fault! call clear instead +// if(soft_obj) soft_obj->Clear(); + + if(trk1_obj) trk1_obj->Clear(); + if(trk2_obj) trk2_obj->Clear(); + if(trkh_obj) trkh_obj->Clear(); + if(calo1_obj)calo1_obj->Clear(); + if(calo2_obj)calo2_obj->Clear(); + if(tof_obj) tof_obj->Clear(); + if(trig_obj) trig_obj->Clear(); + if(s4_obj) s4_obj->Clear(); + if(nd_obj) nd_obj->Clear(); + if(ac_obj) ac_obj->Clear(); + if(orb_obj) orb_obj->Clear(); - sorted_tracks->Delete(); // clean the reference array +// if(sorted_tracks)sorted_tracks->Clear(); +// sorted_tracks.Clear(); + + if(tsorted){ + tsorted->Delete(); + } + if(timage){ + timage->Delete(); + } }; @@ -136,18 +218,68 @@ void *PamLevel2::GetPointerTo(const char* c ){ TString objname = c; - if(!objname.CompareTo("TrkLevel1"))return &trk1_obj; - if(!objname.CompareTo("TrkLevel2"))return &trk2_obj; - if(!objname.CompareTo("TrkHough"))return &trkh_obj; - if(!objname.CompareTo("CaloLevel1"))return &calo1_obj; - if(!objname.CompareTo("CaloLevel2"))return &calo2_obj; - if(!objname.CompareTo("ToFLevel2"))return &tof_obj; - if(!objname.CompareTo("TrigLevel2"))return &trig_obj; - if(!objname.CompareTo("S4Level2"))return &s4_obj; - if(!objname.CompareTo("NDLevel2"))return &nd_obj; - if(!objname.CompareTo("AcLevel2"))return &ac_obj; - if(!objname.CompareTo("OrbitalInfo"))return &orb_obj; + + if(!objname.CompareTo("TrkLevel1")) { + if(!trk1_obj){ + trk1_obj = new TrkLevel1(); + trk1_obj->Set(); + } + return &trk1_obj; + }; + if(!objname.CompareTo("TrkLevel2")) { + if(!trk2_obj){ + trk2_obj = new TrkLevel2(); + trk2_obj->Set(); + } + return &trk2_obj; + }; + if(!objname.CompareTo("TrkHough")) { + if(!trkh_obj) trkh_obj = new TrkHough(); + return &trkh_obj; + }; + if(!objname.CompareTo("CaloLevel1")) { + if(!calo1_obj) calo1_obj = new CaloLevel1(); + return &calo1_obj; + }; + if(!objname.CompareTo("CaloLevel2")) { + if(!calo2_obj){ + calo2_obj = new CaloLevel2(); + calo2_obj->Set(); + }; + return &calo2_obj; + }; + if(!objname.CompareTo("ToFLevel2")) { + if(!tof_obj){ + tof_obj = new ToFLevel2(); + tof_obj->Set(); + } + return &tof_obj; + }; + if(!objname.CompareTo("TrigLevel2")) { + if(!trig_obj) trig_obj = new TrigLevel2(); + return &trig_obj; + }; + if(!objname.CompareTo("S4Level2")) { + if(!s4_obj) s4_obj = new S4Level2(); + return &s4_obj; + }; + if(!objname.CompareTo("NDLevel2")) { + if(!nd_obj) nd_obj = new NDLevel2(); + return &nd_obj; + }; + if(!objname.CompareTo("AcLevel2")) { + if(!ac_obj) ac_obj = new AcLevel2(); + return &ac_obj; + }; + if(!objname.CompareTo("OrbitalInfo")){ + if(!orb_obj) orb_obj = new OrbitalInfo(); + return &orb_obj; + }; + if(!objname.CompareTo("RunInfo"))return &run_obj; + + if(!objname.CompareTo("SoftInfo"))return &soft_obj; // Emiliano + return NULL; }; //-------------------------------------- @@ -159,8 +291,10 @@ * (If seqno = -1 retrieves the self-trigger calorimeter track) */ CaloTrkVar *PamLevel2::GetCaloStoredTrack(int seqno){ - - if( CaloLevel2::ntrk()==0 ){ + + if( !calo2_obj )return 0; + + if( calo2_obj->CaloLevel2::ntrk()==0 ){ cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no Calorimeter tracks are stored"<CaloLevel2::GetCaloTrkVar(it_calo); it_calo++; - } while( c && seqno != c->trkseqno && it_calo < CaloLevel2::ntrk()); + } while( c && seqno != c->trkseqno && it_calo < calo2_obj->CaloLevel2::ntrk()); if(!c || seqno != c->trkseqno){ c = 0; @@ -190,7 +324,9 @@ */ ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno){ - if( ToFLevel2::ntrk()==0 ){ + if( !tof_obj )return 0; + + if( tof_obj->ToFLevel2::ntrk()==0 ){ cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo "<< seqno <<" but no ToF tracks are stored"<ToFLevel2::GetToFTrkVar(it_tof); it_tof++; - } while( c && seqno != c->trkseqno && it_tof < ToFLevel2::ntrk()); + } while( c && seqno != c->trkseqno && it_tof < tof_obj->ToFLevel2::ntrk()); if(!c || seqno != c->trkseqno){ c = 0; @@ -219,7 +355,10 @@ * Give the pamela track associated to a tracker track, retrieving related calorimeter and tof track information. */ PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t){ - + + cout <<"PamLevel2::GetPamTrackAlong(TrkTrack* t) **obsolete** "<=0 && itrk < TrkLevel2::ntrk() ){ + if( itrk >=0 && itrk < trk2_obj->TrkLevel2::ntrk() ){ - TrkTrack *t = TrkLevel2::GetStoredTrack(itrk); + TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(itrk); track = GetPamTrackAlong(t); + + }else{ - cout << "PamLevel2::GetStoredTrack(int) : tracker track SeqNo "<< itrk <<" does not exist (GetNTracks() = "<Delete(); //temporaneo??? - + +// if(!sorted_tracks)sorted_tracks = new TRefArray(); +// sorted_tracks->Clear(); +// sorted_tracks.Clear(); + + if(!tsorted)tsorted = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); + tsorted->Delete(); + TClonesArray &ttsorted = *tsorted; + if(!timage)timage = new TClonesArray("PamTrack",trk2_obj->GetNTracks()); + timage->Delete(); + TClonesArray &ttimage = *timage; + + // loop over the tracks sorted by the tracker Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); @@ -298,22 +457,27 @@ // cout << "use_CAL "<TrkLevel2::GetNTracks(); i++){ - TrkTrack *ts = 0; + TrkTrack *ts = 0; + CaloTrkVar *cs = 0; + ToFTrkVar *os = 0; // get tracker tracks - TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker - CaloTrkVar *cp = 0; - ToFTrkVar *op = 0; - + TrkTrack *tp = trk2_obj->TrkLevel2::GetTrack(i); //tracker + CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); + ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); + + TrkTrack *ti = 0; //tracker (image) + CaloTrkVar *ci = 0; + ToFTrkVar *oi = 0; // cout << "trk track n. "<HasImage()){ - TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image) - CaloTrkVar *ci = 0; - ToFTrkVar *oi = 0; + ti = trk2_obj->TrkLevel2::GetTrackImage(i); //tracker (image) + ci = GetCaloStoredTrack(ti->GetSeqNo()); + oi = GetToFStoredTrack(ti->GetSeqNo()); // cout << "its image "< 15 && //no. of fit planes on Y view - varcfit[1] < 1000. && //fit variance on Y view + calo2_obj->npcfit[1] > 15 && //no. of fit planes on Y view + calo2_obj->varcfit[1] < 1000. && //fit variance on Y view true){ - cp = GetCaloStoredTrack(tp->GetSeqNo()); - ci = GetCaloStoredTrack(ti->GetSeqNo()); - Float_t resy_p = cp->tbar[0][1] - cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; - Float_t resy_i = ci->tbar[0][1] - cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; + Float_t resy_p = cp->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; + Float_t resy_i = ci->tbar[0][1] - calo2_obj->cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; if(resy_p <= resy_i) tp_score++; else ti_score++; @@ -349,13 +515,15 @@ // ------------------------ // check the number of hit pmts along the track // on S12 S21 and S32, where paddles are parallel to Y axis + if( use_TOF && !tof_obj ){ + cout << "void PamLevel2::SortTracks(TString how): how= "<GetSeqNo()); - oi = GetToFStoredTrack(ti->GetSeqNo()); /* cout << "track: npmtadc "<< op->npmtadc << endl; cout << "track: npmttdc "<< op->npmttdc << endl; @@ -363,12 +531,12 @@ cout << "image: npmttdc "<< oi->npmttdc << endl;*/ for (Int_t ih=0; ih < op->npmtadc; ih++){ - Int_t pl = GetPlaneIndex( (op->pmtadc).At(ih) ); + Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); if(pl == 1 || pl == 2 || pl == 5)nphit_p++; }; for (Int_t ih=0; ih < oi->npmtadc; ih++){ - Int_t pl = GetPlaneIndex( (oi->pmtadc).At(ih) ); + Int_t pl = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); if(pl == 1 || pl == 2 || pl == 5)nphit_i++; }; @@ -398,27 +566,59 @@ // ------------------------ // the winner is.... // ------------------------ - if (tp_score > ti_score) ts = tp;//the track sorted by the tracker!! - else if (tp_score < ti_score) ts = ti;//its image!! - else { - ts = tp; + if (tp_score > ti_score) { +// ts = tp;//the track sorted by the tracker!! +// cs = cp; +// os = op; + }else if (tp_score < ti_score) { + ts = ti;//its image!! + cs = ci; + os = oi; + + ti = tp;//its image!! + ci = cp; + oi = op; + + tp = ts;//its image!! + cp = cs; + op = os; + + + }else { +// ts = tp; +// cs = cp; +// os = op; // cout << "Warning - track image ambiguity not solved" << endl; // cout << ts->GetNtot() << " "<< ts->chi2 << " " << npcfit[1] << " "<< nphit_p << endl; }; }else{ - ts = tp; +// ts = tp; +// cs = cp; +// os = op; }; // cout <<" SortTracks() "<Add(ts);//save the track in the sorted array +// sorted_tracks->Add(ts);//save the track in the sorted array +// sorted_tracks.Add(ts);//save the track in the sorted array +// sorted_tracks.Add(tp);//save the track in the sorted array // cout << "SortTracks:: sorted_tracks->Add(it) "<GetEntries() != trk2_obj->GetNTracks() ){ + cout << "void PamLevel2::SortTracks(TString how): tsorted->GetEntries() "<GetEntries()<<" != trk2_obj->GetNTracks() = "<GetNTracks() <Delete(); tsorted=0; + timage->Delete(); timage=0; + } + //Restore Object count //To save space in the table keeping track of all referenced objects - //we assume that our events do not address each other. We reset the - //object count to what it was at the beginning of the event. + //We reset the object count to what it was at the beginning of the event. TProcessID::SetObjectCount(ObjectNumber); }; @@ -430,13 +630,24 @@ * This method overrides TrkLevel2::GetTracks(), where sorting is done by decreasing number of fit points and increasing chi^2. * PamLevel2::GetTracks() keeps the same track order given by TrkLevel2::GetTracks(), but checks image selection by using calorimeter and ToF tracking information. */ -TRefArray *PamLevel2::GetTracks(){ +// TRefArray *PamLevel2::GetTracks(){ + +// // *-*-*-*-*-*-*-*-*-*-*-*-* +// SortTracks("+CAL+TOF"); +// // *-*-*-*-*-*-*-*-*-*-*-*-* + +// // return sorted_tracks; +// return &sorted_tracks; + +// }; +TClonesArray *PamLevel2::GetTracks(){ // *-*-*-*-*-*-*-*-*-*-*-*-* SortTracks("+CAL+TOF"); // *-*-*-*-*-*-*-*-*-*-*-*-* - return sorted_tracks; + return tsorted; + }; //-------------------------------------- // @@ -448,18 +659,43 @@ * @param it Track number, ranging from 0 to GetNTracks(). */ PamTrack *PamLevel2::GetTrack(int it){ + +// if(!trk2_obj) return 0; +// // *-*-*-*-*-*-*-*-*-*-*-*-* +// SortTracks("+CAL+TOF"); +// // *-*-*-*-*-*-*-*-*-*-*-*-* +// // if(!sorted_tracks)return 0; +// if(sorted_tracks.IsEmpty())return 0; + +// PamTrack *track = 0; + +// if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() && itGetEntries())return 0; + PamTrack *track = 0; - if( it >=0 && it < TrkLevel2::GetNTracks() && itGetEntriesFast() ){ - TrkTrack *t = (TrkTrack*)sorted_tracks->At(it); - track = GetPamTrackAlong(t); + if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks()){ +// TrkTrack *t = (TrkTrack*)sorted_tracks.At(it); +// track = GetPamTrackAlong(t); + TClonesArray &t = *(tsorted); + track = (PamTrack*)t[it]; + }else{ - cout << "PamLevel2::GetTrack(int) : tracker track SeqNo "<< it <<" does not exist (GetNTracks() = "<=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){ +// TrkTrack *temp = (TrkTrack*)sorted_tracks.At(it); +// if( temp->HasImage() ){ +// TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); +// image = GetPamTrackAlong(t); +// }else{ +// cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<GetEntries())return 0; PamTrack *image = 0; - if( it >=0 && it < TrkLevel2::GetNTracks() ){ - TrkTrack *temp = (TrkTrack*)sorted_tracks->At(it); - if( temp->HasImage() ){ - TrkTrack *t = TrkLevel2::GetStoredTrack(temp->GetImageSeqNo()); - image = GetPamTrackAlong(t); + if( it >=0 && it < trk2_obj->TrkLevel2::GetNTracks() ){ + TClonesArray &t = *(tsorted); + PamTrack *temp = (PamTrack*)t[it]; + if( temp->GetTrkTrack()->HasImage() ){ + TClonesArray &t = *(timage); + image = (PamTrack*)t[it]; }else{ - cout <<"PamLevel2::GetTrackImage(int) : Track SeqNo "<GetName(); if(!CheckLevel2File(fname))return NULL; - + UInt_t *found=0; + + cout<< "GetPamTree(TFile*,TString): detector list --> "; + if(TRK1)cout<<"TRK1 "; + if(TRK2)cout<<"TRK2 "; + if(TRKh)cout<<"TRKH "; + if(CAL1)cout<<"CAL1 "; + if(CAL2)cout<<"CAL2 "; + if(TOF)cout<<"TOF "; + if(TRG)cout<<"TRG "; + if(AC)cout<<"AC "; + if(ND)cout<<"ND "; + if(S4)cout<<"S4 "; + if(ORB)cout<<"ORB "; + cout << endl; + + f->cd(); + // Tracker TTree *T = (TTree*)f->Get("Tracker"); if(T && (TRK2||TRK1||TRKh)) { if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); + else T->SetBranchStatus("TrkLevel2",0,found); if(TRK2)cout << "Tracker : set branch address TrkLevel2"<SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); + else T->SetBranchStatus("TrkLevel1",0,found); if(TRK1)cout << "Tracker : set branch address TrkLevel1"<SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); + else T->SetBranchStatus("TrkHough",0,found); if(TRKh)cout << "Tracker : set branch address TrkHough"<AddFriend(T); @@ -538,14 +821,17 @@ TTree *C = (TTree*)f->Get("Calorimeter"); if(C && (CAL2||CAL1)) { if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); + else C->SetBranchStatus("CaloLevel2",0,found); if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); + else C->SetBranchStatus("CaloLevel1",0,found); if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<AddFriend(C); }else{ cout << "Calorimeter : missing tree"<Get("ToF"); if(O && TOF) { @@ -597,19 +883,19 @@ cout << "Anticounter : missing tree"<Get("OrbitalInfo"); - if(B && ORB) { - B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); - cout << "OrbitalInfo : set branch address OrbitalInfo"<AddFriend(B); - }else{ - cout << "OrbitalInfo : missing tree"<Get("OrbitalInfo"); + if(B && ORB) { + B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); + cout << "OrbitalInfo : set branch address OrbitalInfo"<AddFriend(B); + }else{ + cout << "OrbitalInfo : missing tree"<GetEntries()<GetEntries()<SetOwner(); - char *fullpath; +// char *fullpath; +// const char *fullpath; // if no input file list is given: if ( flisttxt != "" ){ - if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) )return 0; - -// flisttxt = gSystem->ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); - flisttxt = fullpath; - - if( !gSystem->ChangeDirectory(ddir) )return 0; +// if( !gSystem->IsFileInIncludePath(flisttxt,&fullpath) ){ +// if( !(fullpath = gSystem->FindFile("./",flisttxt)) ){ +// cout <<"File "<ConcatFileName(gSystem->DirName(flisttxt),gSystem->BaseName(flisttxt)); + + if( !gSystem->ChangeDirectory(ddir) ){ + cout << "Cannot change directory : "<ChangeDirectory(wdir); // back to the working directory + return 0; + } int line=0; while (1) { TString file; @@ -662,13 +961,14 @@ } if(file.Contains("#"))file = file(0,file.First("#")); // cout <<"(2) " << file << endl; - if( gSystem->IsFileInIncludePath(file,&fullpath) ){ - - contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list - - }else{ +// if( gSystem->IsFileInIncludePath(file,&fullpath) ){ +// if( (fullpath = gSystem->FindFile(ddir,file)) ){ + char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(file)); + contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath)));// add file to the list + delete fullpath; +// }else{ // if(file.Data()!="")cout << "File: "< missing "<< endl; - }; +// }; }; in.close(); @@ -690,9 +990,12 @@ while ( (questo = (TSystemFile*) next()) ) { TString name = questo-> GetName(); if( name.EndsWith(".root") ){ - char *fullpath; - gSystem->IsFileInIncludePath(name,&fullpath); +// const char *fullpath = gSystem->FindFile(ddir,name); +// char *fullpath; +// gSystem->IsFileInIncludePath(name,&fullpath); + char *fullpath = gSystem->ConcatFileName(gSystem->DirName(ddir),gSystem->BaseName(name)); contents->Add(new TSystemFile(fullpath,gSystem->DirName(fullpath))); + delete fullpath; }; } delete temp; @@ -702,7 +1005,7 @@ gSystem->ChangeDirectory(wdir); // back to the working directory // cout << endl << "Selected files:" << endl; // contents->Print(); - cout << contents->GetEntries()<<" files selected\n"; + cout << contents->GetEntries()<<" files \n"; // cout << endl; // cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; return contents; @@ -717,16 +1020,27 @@ * @param detlist String to select trees to be included * @return Pointer to a TChain */ -TChain *PamLevel2::GetPamTree(TList *fl, TString detlist="+ALL"){ - -// TChain *Tout=0; -// if(Tout)Tout->Delete(); -// Tout = NULL; +TChain *PamLevel2::GetPamTree(TList *fl, TString detlist ){ - TChain *Tout =0; + TChain *Trout =0; +// if( !detlist.IsNull() )SetWhichTrees(detlist); SetWhichTrees(detlist); + cout<< "GetPamTree(TList*,TString): input detector list --> "; + if(TRK1)cout<<"TRK1 "; + if(TRK2)cout<<"TRK2 "; + if(TRKh)cout<<"TRKH "; + if(CAL1)cout<<"CAL1 "; + if(CAL2)cout<<"CAL2 "; + if(TOF)cout<<"TOF "; + if(TRG)cout<<"TRG "; + if(AC)cout<<"AC "; + if(ND)cout<<"ND "; + if(S4)cout<<"S4 "; + if(ORB)cout<<"ORB "; + cout << endl; + TChain *T = 0; TChain *C = 0; TChain *O = 0; @@ -737,81 +1051,168 @@ TChain *B = 0; if(TRK2||TRK1||TRKh) T = new TChain("Tracker"); - if(CAL2||CAL1) C = new TChain("Calorimeter"); - if(TOF) O = new TChain("ToF"); - if(TRG) R = new TChain("Trigger"); - if(S4) S = new TChain("S4"); - if(ND) N = new TChain("NeutronD"); - if(AC) A = new TChain("Anticounter"); - if(ORB) B = new TChain("OrbitalInfo"); + if(CAL2||CAL1) C = new TChain("Calorimeter"); + if(TOF) O = new TChain("ToF"); + if(TRG) R = new TChain("Trigger"); + if(S4) S = new TChain("S4"); + if(ND) N = new TChain("NeutronD"); + if(AC) A = new TChain("Anticounter"); + if(ORB) B = new TChain("OrbitalInfo"); // loop over files and create chains TIter next(fl); TSystemFile *questo = 0; while ( (questo = (TSystemFile*) next()) ) { TString name = questo->GetName(); -// cout << "File: "<< name << endl; + cout << "File: "<< name << endl; if( CheckLevel2File(name) ){ if(TRK2||TRK1||TRKh) T->Add(name); - if(CAL1||CAL2) C->Add(name); - if(TOF) O->Add(name); - if(TRG) R->Add(name); - if(S4) S->Add(name); - if(ND) N->Add(name); - if(AC) A->Add(name); - if(ORB) B->Add(name); + if(CAL1||CAL2) C->Add(name); + if(TOF) O->Add(name); + if(TRG) R->Add(name); + if(S4) S->Add(name); + if(ND) N->Add(name); + if(AC) A->Add(name); + if(ORB) B->Add(name); }; } cout << "done chain \n"; - + + UInt_t *found=0; +// Tracker + if(T && (TRK2||TRK1||TRKh)) { + if(TRK2)T->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); + else T->SetBranchStatus("TrkLevel2",0,found); + if(TRK2)cout << "Tracker : set branch address TrkLevel2"<SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); + else T->SetBranchStatus("TrkLevel1",0,found); + if(TRK1)cout << "Tracker : set branch address TrkLevel1"<SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); + else T->SetBranchStatus("TrkHough",0,found); + if(TRKh)cout << "Tracker : set branch address TrkHough"<AddFriend("Tracker"); + }else{ + cout << "Tracker : missing tree"<AddFriend("Calorimeter"); + if(C && (CAL2||CAL1)) { + if(CAL2)C->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); + else C->SetBranchStatus("CaloLevel2",0,found); + if(CAL2)cout << "Calorimeter : set branch address CaloLevel2"<SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); + else C->SetBranchStatus("CaloLevel1",0,found); + if(CAL1)cout << "Calorimeter : set branch address CaloLevel1"<AddFriend("Calorimeter"); + }else{ + cout << "Calorimeter : missing tree"<AddFriend("ToF"); + if(O && TOF) { + O->SetBranchAddress("ToFLevel2", GetPointerTo("ToFLevel2")); + cout << "ToF : set branch address ToFLevel2"<AddFriend("ToF"); + }else{ + cout << "ToF : missing tree"<AddFriend("Tracker"); - } // Trigger - if(TRG) { - if(!Tout)Tout=R; - else Tout->AddFriend("Trigger"); + if(R && TRG) { + R->SetBranchAddress("TrigLevel2", GetPointerTo("TrigLevel2")); + cout << "Trigger : set branch address TrigLevel2"<AddFriend("Trigger"); + }else{ + cout << "Trigger : missing tree"<AddFriend("S4"); + if(S && S4) { + S->SetBranchAddress("S4Level2", GetPointerTo("S4Level2")); + cout << "S4 : set branch address S4Level2"<AddFriend("S4"); + }else{ + cout << "S4 : missing tree"<AddFriend("NeutronD"); + if(N && ND) { + N->SetBranchAddress("NDLevel2", GetPointerTo("NDLevel2")); + cout << "NeutronD : set branch address NDLevel2"<AddFriend("NeutronD"); + }else{ + cout << "NeutronD : missing tree"<AddFriend("Anticounter"); + if(A && AC) { + A->SetBranchAddress("AcLevel2", GetPointerTo("AcLevel2")); + cout << "Anticounter : set branch address AcLevel2"<AddFriend("Anticounter"); + }else{ + cout << "Anticounter : missing tree"<AddFriend("OrbitalInfo"); + // Orbital Info + if(B && ORB) { + B->SetBranchAddress("OrbitalInfo", GetPointerTo("OrbitalInfo")); + cout << "OrbitalInfo : set branch address OrbitalInfo"<AddFriend("OrbitalInfo"); + }else{ + cout << "OrbitalInfo : missing tree"<GetEntries()<AddFriend("Tracker"); +// } +// // Calorimeter +// if(CAL2||CAL1) { +// if(!Tout)Tout=C; +// else Tout->AddFriend("Calorimeter"); +// }; +// // ToF +// if(TOF) { +// if(!Tout)Tout=O; +// else Tout->AddFriend("ToF"); +// }; +// // Trigger +// if(TRG) { +// if(!Tout)Tout=R; +// else Tout->AddFriend("Trigger"); +// }; +// // S4 +// if(S4) { +// if(!Tout)Tout=S; +// else Tout->AddFriend("S4"); +// }; +// // Neutron Detector +// if(ND) { +// if(!Tout)Tout=N; +// else Tout->AddFriend("NeutronD"); +// }; +// // Anticounters +// if(AC) { +// if(!Tout)Tout=A; +// else Tout->AddFriend("Anticounter"); +// }; +// // OrbitalInfo +// if(ORB) { +// if(!Tout)Tout=B; +// else Tout->AddFriend("OrbitalInfo"); +// }; + // cout<GetEntries()<GetEntries() )PamLevel2::SetBranchAddress(); - if( Tout->GetEntries() )PamLevel2::SetBranchAddress( Tout ); +// if( Tout->GetEntries() )PamLevel2::SetBranchAddress( Tout ); - return Tout; + return Trout; } @@ -913,7 +1314,7 @@ // Tracker if(TRK2) { - t->SetBranchAddress("TrkLevel2", this->GetPointerTo("TrkLevel2")); + t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); cout << "Tracker : set branch address TrkLevel2"<SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); cout << "Run : set branch address RunInfo"<SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano + cout << "Software : set branch address SoftInfo"<SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); cout << "Run : set branch address RunInfo"<SetBranchAddress("SoftInfo", GetPointerTo("SoftInfo")); // Emiliano + cout << "Software : set branch address SoftInfo"<GetEntries() <= 0 ) return(false); + // + Int_t oldrun = irun; + if ( irun < 0 ){ + irun = 0; + run->GetEntry(0); + runfirstentry = 0ULL; + runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS) - 1ULL; + }; + while ( iev > (runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS-1)) && irun < run->GetEntries() ){ + // printf(" iev %llu %u %llu \n",iev,this->GetRunInfo()->NEVENTS,(ULong64_t)(runfirstentry+(ULong64_t)(this->GetRunInfo()->NEVENTS))); + irun++; + run->GetEntry(irun); + runfirstentry = runlastentry+1ULL; + runlastentry += (ULong64_t)(this->GetRunInfo()->NEVENTS); + }; + // + if ( irun == oldrun || irun >= run->GetEntries() ) return(false); + // + // printf(" iev %llu irun %i nevents %u 1st %llu last %llu \n",iev,irun,this->GetRunInfo()->NEVENTS,(ULong64_t)runfirstentry,(ULong64_t)runlastentry); + // + return(true); + // +}; +/** + * Update the runinfo informations (to be used to have Run infos event by event basis) + * @param run Pointer to the chain/tree which contains run infos + * @return true if a new run has been read, false if it is still the same run + */ +Bool_t PamLevel2::UpdateRunInfo(TTree *run, ULong64_t iev){ + return(UpdateRunInfo((TChain*)run,iev)); +}; + //-------------------------------------- // // @@ -1053,7 +1476,7 @@ */ void PamLevel2::SetWhichTrees(TString detlist){ - if(detlist.Contains("+ALL", TString::kIgnoreCase)){ + if(detlist.IsNull() || detlist.Contains("+ALL", TString::kIgnoreCase)){ CAL1 = true; CAL2 = true; TRK2 = true; @@ -1118,17 +1541,6 @@ TRKh=false; } // ------------------------------------------------------------------------- - - - -// if( detlist.Contains("-TRK", TString::kIgnoreCase) )TRK2 = false; -// else if( detlist.Contains("+TRK", TString::kIgnoreCase) )TRK2 = true; - -// if( detlist.Contains("-TRK1", TString::kIgnoreCase) )TRK1 = false; -// else if( detlist.Contains("+TRK1", TString::kIgnoreCase) )TRK1 = true; - -// if( detlist.Contains("-TRKh", TString::kIgnoreCase) )TRKh = false; -// else if( detlist.Contains("+TRKh", TString::kIgnoreCase) )TRKh = true; if( detlist.Contains("-TRG", TString::kIgnoreCase) )TRG = false; else if( detlist.Contains("+TRG", TString::kIgnoreCase) )TRG = true; @@ -1147,8 +1559,175 @@ if( detlist.Contains("-ORB", TString::kIgnoreCase) )ORB = false; else if( detlist.Contains("+ORB", TString::kIgnoreCase) )ORB = true; + +// cout<< "Set detector list --> "; +// if(TRK1)cout<<"TRK1 "; +// if(TRK2)cout<<"TRK2 "; +// if(TRKh)cout<<"TRKH "; +// if(CAL1)cout<<"CAL1 "; +// if(CAL2)cout<<"CAL2 "; +// if(TOF)cout<<"TOF "; +// if(TRG)cout<<"TRG "; +// if(AC)cout<<"AC "; +// if(ND)cout<<"ND "; +// if(S4)cout<<"S4 "; +// if(ORB)cout<<"ORB "; +// cout << endl; + +}; + + +/** + * Set tree/branch detector flags from the content of a tree + */ +void PamLevel2::GetWhichTrees(TFile* f){ + + // ----------- + // reset flags + // ----------- + CAL1 = false; + CAL2 = false; + TRK2 = false; + TRK1 = false; + TRKh = false; + TRG = false; + TOF = false; + S4 = false; + ND = false; + AC = false; + ORB = false; + + RUN = false; + + cout << "Checking file: "<GetName()<IsZombie() ){ + cout << "File: "<< f->GetName() <<" Non valid root file"<< endl; + return; + } + + TList *lk = f->GetListOfKeys(); + TIter next(lk); + TKey *key =0; + + Int_t nev = 0; + + while( (key = (TKey*)next()) ){ + + if( !strcmp(key->GetName(),"Run" ) )RUN = true; + + //========================================================= + if( !strcmp(key->GetName(),"Trigger" ) ){ + TRG = true; + Int_t nevt = ((TTree*)f->Get("Trigger"))->GetEntries(); + if( nev && nevt!=nev){ + cout << "File: "<< f->GetName() <<" Trigger tree has "<GetName(),"ToF" ) ){ + TOF = true; + Int_t nevt = ((TTree*)f->Get("ToF"))->GetEntries(); + if( nev && nevt!=nev){ + cout << "File: "<< f->GetName() <<" ToF tree has "<GetName(),"S4" ) ){ + S4 = true; + Int_t nevt = ((TTree*)f->Get("S4"))->GetEntries(); + if( nev && nevt!=nev){ + cout << "File: "<< f->GetName() <<" S4 tree has "<GetName(),"NeutronD" ) ){ + ND = true; + Int_t nevt = ((TTree*)f->Get("NeutronD"))->GetEntries(); + if( nev && nevt!=nev){ + cout << "File: "<< f->GetName() <<"NeutronD tree has "<GetName(),"Anticounter") ){ + AC = true; + Int_t nevt = ((TTree*)f->Get("Anticounter"))->GetEntries(); + if( nev && nevt!=nev){ + cout << "File: "<< f->GetName() <<" Anticounter tree has "<GetName(),"OrbitalInfo") ){ + ORB = true; + Int_t nevt = ((TTree*)f->Get("OrbitalInfo"))->GetEntries(); + if( nev && nevt!=nev){ + cout << "File: "<< f->GetName() <<" OrbitalInfo tree has "<GetName(),"Tracker" ) ){ + TTree *T = (TTree*)f->Get("Tracker"); + for(Int_t i=0; iGetListOfBranches()->GetEntries(); i++){ + TString name = T->GetListOfBranches()->At(i)->GetName(); + if( !name.CompareTo("TrkLevel1") )TRK1=true; + if( !name.CompareTo("TrkLevel2") )TRK2=true; + if( !name.CompareTo("TrkHough") )TRKh=true; + }; + Int_t nevt = T->GetEntries(); + if( nev && nevt!=nev){ + cout << "File: "<< f->GetName() <<" Tracker tree has "<Delete(); + }; + //========================================================= + if( !strcmp(key->GetName(),"Calorimeter" ) ){ + TTree *T = (TTree*)f->Get("Calorimeter"); + for(Int_t i=0; iGetListOfBranches()->GetEntries(); i++){ + TString name = T->GetListOfBranches()->At(i)->GetName(); + if( !name.CompareTo("CaloLevel1") )CAL1=true; + if( !name.CompareTo("CaloLevel2") )CAL2=true; + }; + Int_t nevt = T->GetEntries(); + if( nev && nevt!=nev){ + cout << "File: "<< f->GetName() <<" Calorimeter tree has "<Delete(); + }; + + }; + delete lk; + +// cout<< "Get detector list from input file --> "; +// if(TRK1)cout<<"TRK1 "; +// if(TRK2)cout<<"TRK2 "; +// if(TRKh)cout<<"TRKH "; +// if(CAL1)cout<<"CAL1 "; +// if(CAL2)cout<<"CAL2 "; +// if(TOF)cout<<"TOF "; +// if(TRG)cout<<"TRG "; +// if(AC)cout<<"AC "; +// if(ND)cout<<"ND "; +// if(S4)cout<<"S4 "; +// if(ORB)cout<<"ORB "; +// cout << endl; + + return ; + }; + + //-------------------------------------- // // @@ -1191,8 +1770,8 @@ while( (key = (TKey*)next()) ){ -// cout << key->GetName() << endl; -// cout << " Get tree: " << f->Get(key->GetName())<GetName() << ""<GetClassName()<Get(key->GetName())<GetClassName()=="TTree" && nev_previous && nev != nev_previous ){ @@ -1316,6 +1895,28 @@ }; +// cout<< "CheckLevel2File(TString): detector list --> "; +// if(TRK1__ok)cout<<"TRK1 "; +// if(TRK2__ok)cout<<"TRK2 "; +// if(TRKh__ok)cout<<"TRKH "; +// if(CAL1__ok)cout<<"CAL1 "; +// if(CAL2__ok)cout<<"CAL2 "; +// if(TOF__ok)cout<<"TOF "; +// if(TRG__ok)cout<<"TRG "; +// if(AC__ok)cout<<"AC "; +// if(ND__ok)cout<<"ND "; +// if(S4__ok)cout<<"S4 "; +// if(ORB__ok)cout<<"ORB "; +// cout << endl; + + + if(TRK2 && TRK1__ok)TRK1=1; +// ---------------------------------------------------------------------------- +// NOTA +// se c'e` il level1, lo devo necessarimente leggere. +// infatti (non ho capito perche`) i cluster vengono letti e allocati in memoria +// comunque, ma non vengono disallocati da PamLevel2::Clear() +// ---------------------------------------------------------------------------- if(!RUN__ok) { @@ -1360,21 +1961,33 @@ return false; }; - if(ND && !ND__ok){ - cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; - return false; - }; - if(TRG && !TRG__ok){ - cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; - return false; - }; - - - - + if(ND && !ND__ok){ + cout << "File: "<< f->GetName() <<" discarded ---- Missing ND tree"<< endl; + return false; + }; + if(TRG && !TRG__ok){ + cout << "File: "<< f->GetName() <<" discarded ---- Missing Trigger tree"<< endl; + return false; + }; + - lk->Delete(); +// lk->Delete(); +// delete lk; f->Close(); + +// cout<< "CheckLevel2File(TString): detector list --> "; +// if(TRK1)cout<<"TRK1 "; +// if(TRK2)cout<<"TRK2 "; +// if(TRKh)cout<<"TRKH "; +// if(CAL1)cout<<"CAL1 "; +// if(CAL2)cout<<"CAL2 "; +// if(TOF)cout<<"TOF "; +// if(TRG)cout<<"TRG "; +// if(AC)cout<<"AC "; +// if(ND)cout<<"ND "; +// if(S4)cout<<"S4 "; +// if(ORB)cout<<"ORB "; +// cout << endl; return true; @@ -1384,7 +1997,7 @@ /** * Create clone-trees */ -void PamLevel2::CreateCloneTrees( TChain *fChain ){ +void PamLevel2::CreateCloneTrees0( TChain *fChain, TFile *ofile ){ cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <GetListOfFriends(); TIter next(li); TFriendElement* T_friend=0; + ofile->cd(); while( (T_friend = (TFriendElement*)next()) ){ // cout<IsA()->GetName()<<" "<GetName()<GetTree() << dec<GetTree()->GetName()<< endl; - tree_clone[i] = T_friend->GetTree()->CloneTree(0); + tree_clone[i] = T_friend->GetTree()->CloneTree(0); + tree_clone[i]->SetAutoSave(1000000); name = tree_clone[i]->GetName(); name.Append("_clone"); // tree_clone[i]->SetName(name.Data()); cout << tree_clone[i]->GetName() << endl; i++; } + + delete li; cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); -// T_clone->BranchRef(); -// cout << "Tracker : branch TrkLevel1"<Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); -// cout << "Tracker : branch TrkLevel2"<Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); -// cout << "Tracker : branch TrkHough"<Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); -// cout << "Calorimeter : branch CaloLevel1"<Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); -// cout << "Calorimeter : branch CaloLevel2"<Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); -// cout << "ToF : branch ToFLevel2"<Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); -// cout << "Trigger : branch TrigLevel2"<Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); -// cout << "S4 : branch S4Level2"<Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); -// cout << "NeutronD : branch NDLevel2"<Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); -// cout << "Anticounter : branch AcLevel2"<Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); -// cout << "OrbitalInfo : branch OrbitalInfo"<cd(); -// } + cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" <Branch("TrkLevel1","TrkLevel1", GetPointerTo("TrkLevel1")); + tree_clone[i]->BranchRef(); + cout << "Tracker : branch TrkLevel1"<Branch("TrkLevel2", "TrkLevel2",GetPointerTo("TrkLevel2")); + cout << "Tracker : branch TrkLevel2"<Branch("TrkHough","TrkHough", GetPointerTo("TrkHough")); + cout << "Tracker : branch TrkHough"<Branch("TrkLevel1","TrkLevel1", &trk1_clone); -// T_clone->BranchRef(); -// cout << "Tracker : branch TrkLevel1"<Branch("TrkLevel2", "TrkLevel2",&trk2_clone); -// cout << "Tracker : branch TrkLevel2"<Branch("TrkHough","TrkHough", &trkh_clone); -// cout << "Tracker : branch TrkHough"<Branch("CaloLevel1", "CaloLevel1", GetPointerTo("CaloLevel1")); + cout << "Calorimeter : branch CaloLevel1"<Branch("CaloLevel2","CaloLevel2", GetPointerTo("CaloLevel2")); + cout << "Calorimeter : branch CaloLevel2"<Branch("CaloLevel1", "CaloLevel1", &calo1_clone); -// cout << "Calorimeter : branch CaloLevel1"<Branch("CaloLevel2","CaloLevel2", &calo2_clone); -// cout << "Calorimeter : branch CaloLevel2"<Branch("ToFLevel2","ToFLevel2", GetPointerTo("ToFLevel2")); + cout << "ToF : branch ToFLevel2"<Branch("TrigLevel2","TrigLevel2", GetPointerTo("TrigLevel2")); + cout << "Trigger : branch TrigLevel2"<Branch("S4Level2","S4Level2", GetPointerTo("S4Level2")); + cout << "S4 : branch S4Level2"<Branch("NDLevel2","NDLevel2", GetPointerTo("NDLevel2")); + cout << "NeutronD : branch NDLevel2"<Branch("AcLevel2","AcLevel2", GetPointerTo("AcLevel2")); + cout << "Anticounter : branch AcLevel2"<Branch("OrbitalInfo","OrbitalInfo", GetPointerTo("OrbitalInfo")); + cout << "OrbitalInfo : branch OrbitalInfo"<Branch("ToFLevel2","ToFLevel2", &tof_clone); -// cout << "ToF : branch ToFLevel2"<Branch("TrigLevel2","TrigLevel2", &trig_clone); -// cout << "Trigger : branch TrigLevel2"<Branch("S4Level2","S4Level2", &s4_clone); -// cout << "S4 : branch S4Level2"<Branch("NDLevel2","NDLevel2", &nd_clone); -// cout << "NeutronD : branch NDLevel2"<Branch("AcLevel2","AcLevel2", &ac_clone); -// cout << "Anticounter : branch AcLevel2"<Branch("OrbitalInfo","OrbitalInfo", &orb_clone); -// cout << "OrbitalInfo : branch OrbitalInfo"<Clear(); -// trk2_obj->Copy(*trk2_clone); -// // *trk2_clone = *trk2_obj; -// } -// if(trkh_clone) *trkh_clone = *trkh_obj; -// if(calo1_clone){ -// // *calo1_clone = *calo1_obj; -// calo1_clone->Clear(); -// calo1_obj->Copy(*calo1_clone); -// } -// if(calo2_clone){ -// // *calo2_clone = *calo2_obj; -// calo2_clone->Clear(); -// calo2_obj->Copy(*calo2_clone); -// } -// if(tof_clone) *tof_clone = *tof_obj; -// if(trig_clone) *trig_clone = *trig_obj; -// if(s4_clone) *s4_clone = *s4_obj; -// if(nd_clone) *nd_clone = *nd_obj; -// if(ac_clone) *ac_clone = *ac_obj; -// if(orb_clone) *orb_clone = *orb_obj; - -// if(T_clone)T_clone->Fill(); -// if(C_clone)C_clone->Fill(); -// if(O_clone)O_clone->Fill(); -// if(R_clone)R_clone->Fill(); -// if(S_clone)S_clone->Fill(); -// if(N_clone)N_clone->Fill(); -// if(A_clone)A_clone->Fill(); -// if(O_clone)O_clone->Fill(); - for(Int_t i=0; i<8; i++){ if(tree_clone[i])tree_clone[i]->Fill(); }