--- PamelaLevel2/src/PamLevel2.cpp 2014/10/17 15:08:35 1.99 +++ PamelaLevel2/src/PamLevel2.cpp 2016/04/20 09:29:29 1.113 @@ -315,17 +315,34 @@ // candeleteobj = 0; +// cout << t<<"--"<ExtTrack::Clear("C"); +// trk_ext_track->ExtTrack::Clear("C");//Clear is called for all the array elements + trk_ext_track->ExtTrack::Clear("C+C");//Clear is called for all the array elements passing option 'C' delete trk_ext_track; } if (trk_track) { @@ -566,6 +619,7 @@ run_obj = 0;//new GL_RUN(); soft_obj = 0;// Emiliano + proc_obj = 0;// Emiliano irun = -1LL; irunt = -1LL; totrunentry = 0LL; @@ -592,6 +646,10 @@ run_tree = NULL; run_tree_clone = NULL; + + proc_tree = NULL; + proc_tree_clone = NULL; + sel_tree = NULL; sel_tree_clone = NULL; @@ -623,6 +681,8 @@ if (strcmp(pamdbpsw, "")) psw = pamdbpsw; + customString = ""; + // sorted_tracks = 0;//new TRefArray(); CAL0 = false; @@ -639,6 +699,7 @@ ND = true; AC = true; ORB = true; + PROC = true; GP = false; EXT = false; @@ -681,6 +742,8 @@ delete run_obj; if (soft_obj) delete soft_obj; //Emiliano + if (proc_obj) + delete proc_obj; //Emiliano // cout << "void PamLevel2::Clear()"<Clear(); if (gp_obj) gp_obj->Clear(); + if (proc_obj) + proc_obj->Clear(); // if(sorted_tracks)sorted_tracks->Clear(); // sorted_tracks.Clear(); @@ -961,6 +1026,10 @@ if (sel_tree) sel_tree->Delete();; sel_tree = NULL; + + if (proc_tree) + proc_tree->Delete(); + proc_tree = NULL; // // Close file // @@ -984,6 +1053,7 @@ ac_obj = 0; orb2_obj = 0; gp_obj = 0; + proc_obj = 0; trk_ext_obj = 0; trk_ext_nuc_obj = 0; @@ -1015,6 +1085,7 @@ // run_obj = 0;//new GL_RUN(); soft_obj = 0;// Emiliano + proc_obj = 0;// Emiliano irun = -1; irunt = -1; totrunentry = 0LL; @@ -1189,6 +1260,12 @@ if (!objname.CompareTo("SoftInfo")) return &soft_obj; // Emiliano + if (!objname.CompareTo("ProcInfo")){ + if (!proc_obj) + proc_obj = new ProcInfo(); + return &proc_obj; // Emiliano + } + return NULL; } ; @@ -1206,9 +1283,11 @@ return 0; if (calo2_obj->CaloLevel2::ntrk() == 0) { - cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo " << seqno - << " but no Calorimeter tracks are stored" << endl; - return NULL; + if( seqno >=0 ){ + cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo " << seqno; + cout << " but no Calorimeter tracks are stored" << endl; + } + return NULL; }; CaloTrkVar *c = 0; @@ -1221,7 +1300,7 @@ if (!c || seqno != c->trkseqno) { c = 0; - if (seqno != -1) + if (seqno != -1 && seqno>=0) cout << "PamLevel2::GetCaloStoredTrack(int) : requested tracker SeqNo " << seqno << " does not match Calorimeter stored tracks" << endl; }; @@ -1340,65 +1419,65 @@ // // //-------------------------------------- -/** - * Give the pamela track associated to a tracker track, retrieving related calorimeter, orbitalinfo and tof track information. - */ -PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t) { - - cout << "PamLevel2::GetPamTrackAlong(TrkTrack* t) **obsolete** " << endl; - cout << "(if you use it, remember to delete the PamTrack object)" << endl; +// /** +// * Give the pamela track associated to a tracker track, retrieving related calorimeter, orbitalinfo and tof track information. +// */ +// PamTrack* PamLevel2::GetPamTrackAlong(TrkTrack* t) { + +// cout << "PamLevel2::GetPamTrackAlong(TrkTrack* t) **obsolete** " << endl; +// cout << "(if you use it, remember to delete the PamTrack object)" << endl; + +// CaloTrkVar *c = 0; +// ToFTrkVar *o = 0; +// OrbitalInfoTrkVar *r = 0; + +// if (CAL2) +// c = GetCaloStoredTrack(t->GetSeqNo()); +// if (TOF) +// o = GetToFStoredTrack(t->GetSeqNo()); +// if (ORB) +// r = GetOrbitalInfoStoredTrack(t->GetSeqNo()); - CaloTrkVar *c = 0; - ToFTrkVar *o = 0; - OrbitalInfoTrkVar *r = 0; +// // if(t && c && o)track = new PamTrack(t,c,o); +// PamTrack *track = new PamTrack(t, c, o, r); - if (CAL2) - c = GetCaloStoredTrack(t->GetSeqNo()); - if (TOF) - o = GetToFStoredTrack(t->GetSeqNo()); - if (ORB) - r = GetOrbitalInfoStoredTrack(t->GetSeqNo()); +// return track; - // if(t && c && o)track = new PamTrack(t,c,o); - PamTrack *track = new PamTrack(t, c, o, r); - - return track; - -} -; +// } +// ; //-------------------------------------- // // //-------------------------------------- -/** - * Retrieves the it-th stored track. - * It override TrkLevel2::GetTrack(int it). - * @param itrk Track number, ranging from 0 to GetNTracks(). - */ - -PamTrack* PamLevel2::GetStoredTrack(Int_t itrk) { +// /** +// * Retrieves the it-th stored track. +// * It override TrkLevel2::GetTrack(int it). +// * @param itrk Track number, ranging from 0 to GetNTracks(). +// */ + +// PamTrack* PamLevel2::GetStoredTrack(Int_t itrk) { + +// cout << "PamLevel2::GetStoredTrack(Int_t itrk) **to-be-updated** " << endl; +// cout +// << "for the moment, better use separately the methods: TrkLevel2::GetStoredTrack(seqno) CaloLevel2::GetCaloTrkVar(Int_t notrack) ToFLevel2::GetToFTrkVar(Int_t notrack) OrbitalInfo::GetOrbitalInfoTrkVar(Int_t notrack)" +// << endl; +// cout << "(if you use it, remember to delete the PamTrack object)" << endl; +// PamTrack *track = 0; - cout << "PamLevel2::GetStoredTrack(Int_t itrk) **to-be-updated** " << endl; - cout - << "for the moment, better use separately the methods: TrkLevel2::GetStoredTrack(seqno) CaloLevel2::GetCaloTrkVar(Int_t notrack) ToFLevel2::GetToFTrkVar(Int_t notrack) OrbitalInfo::GetOrbitalInfoTrkVar(Int_t notrack)" - << endl; - cout << "(if you use it, remember to delete the PamTrack object)" << endl; - PamTrack *track = 0; +// if (itrk >= 0 && itrk < trk2_obj->TrkLevel2::ntrk()) { - if (itrk >= 0 && itrk < trk2_obj->TrkLevel2::ntrk()) { +// TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(itrk); +// track = GetPamTrackAlong(t); - TrkTrack *t = trk2_obj->TrkLevel2::GetStoredTrack(itrk); - track = GetPamTrackAlong(t); - - } - else { - cout << "PamLevel2::GetStoredTrack(int) : tracker track SeqNo " << itrk << " does not exist (GetNTracks() = " - << trk2_obj->TrkLevel2::GetNTracks() << ")" << endl; - }; +// } +// else { +// cout << "PamLevel2::GetStoredTrack(int) : tracker track SeqNo " << itrk << " does not exist (GetNTracks() = " +// << trk2_obj->TrkLevel2::GetNTracks() << ")" << endl; +// }; - return track; +// return track; -} +// } //-------------------------------------- // @@ -1452,14 +1531,20 @@ Int_t ObjectNumber = TProcessID::GetObjectCount(); // create TCloneArrays to store tracks and its images - if (!tsorted) - tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); - tsorted->Clear("C+C");//Delete(); - TClonesArray &ttsorted = *tsorted; +// if (!tsorted) +// tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); +// tsorted->Clear("C+C");//Delete(); +// if (!timage) +// timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); +// timage->Clear("C+C");//Delete(); - if (!timage) - timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); - timage->Clear("C+C");//Delete(); + if(tsorted)delete tsorted; + if(timage) delete timage; + tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); + timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); + + + TClonesArray &ttsorted = *tsorted; TClonesArray &ttimage = *timage; @@ -1901,6 +1986,9 @@ // cout<<"o "<GetTrack(i); //tracker - CaloTrkVar *cp = calo2->GetCaloStoredTrack(tp->GetSeqNo()); - ToFTrkVar *op = tof2->GetToFStoredTrack(tp->GetSeqNo()); - OrbitalInfoTrkVar *rp = orb2->GetOrbitalInfoStoredTrack(tp->GetSeqNo()); + TrkTrack *tp = (TRK2 ? trk2->GetTrack(i): NULL); //tracker + CaloTrkVar *cp = (CAL2 ? calo2->GetCaloStoredTrack(tp->GetSeqNo()) : NULL); + ToFTrkVar *op = (TOF ? tof2->GetToFStoredTrack(tp->GetSeqNo()) : NULL); + OrbitalInfoTrkVar *rp = (ORB ? orb2->GetOrbitalInfoStoredTrack(tp->GetSeqNo()) : NULL); + +// cout << "ORB="<GetEntries(); it++){ - new (ttext[it]) PamTrack((ExtTrack*)(*trkext)[it], (CaloTrkVar*)(*caloext)[it], (ToFTrkVar*)(*tofext)[it], (OrbitalInfoTrkVar*)(*orbext)[it]); +// if( +// it < caloext->GetEntries() && +// it < tofext->GetEntries() && +// it < orbext->GetEntries() && +// true){ + + ExtTrack *t = (trkext ?(ExtTrack*)(*trkext)[it]:NULL ); + CaloTrkVar *c =(caloext ?(CaloTrkVar*)(*caloext)[it]:NULL ); + ToFTrkVar *o = (tofext ?(ToFTrkVar*)(*tofext)[it]:NULL ); + OrbitalInfoTrkVar *r =(orbext ?(OrbitalInfoTrkVar*)(*orbext)[it]:NULL ); +// cout <<"ext:"<< t<<"--"< ORRORE E RACCAPRICCIO!!!"<GetEntries()) +// if (!tsorted->GetEntries()) +// return track; + if (tsorted->GetEntries()==0) return track; - if (it >= 0 && it < trk2_obj->TrkLevel2::GetNTracks()) { - track = (PamTrack*)((*tsorted)[it]); + if ( + tsorted && + it >= 0 && + it < trk2_obj->TrkLevel2::GetNTracks() && + it < tsorted->GetEntries() && + true) { + track = (PamTrack*)((*tsorted)[it]); } else { cout << "PamLevel2::GetTrackOld(int) : tracker track SeqNo " << it << " does not exist (GetNTracks() = " @@ -2667,6 +2786,7 @@ TString s(alg); if(!s.CompareTo("") ||!s.CompareTo("STD") )return GetTrackOld(it); //old algorythm + SortTracksNew(); // >> fill tsorted, timage and text @@ -2844,7 +2964,7 @@ } - cout << "PamTrack *PamLevel2::GetTrackImage("<Add(name); if (GP) G->Add(name); + if (P) + P->Add(name); if (SELLI == 1) L->Add(name); }; @@ -3475,12 +3600,25 @@ L->Delete(); }; + //ProcessingInfo EM + if ( P && P->GetEntries() ){ + cout << "----------------------------------------------------" << endl; + cout << ">>> Found ProcessingInfo <<<" << endl; + // L->SetBranchAddress("RunEntry",&irun); + P->SetBranchAddress("ProcInfo", &proc_obj);//NEWNEW + proc_tree = P; + } else { + // proc_tree = new TChain("ProcessingInfo","Log of data processing"); + // proc_tree->Branch("ProcInfo", "ProcInfo", &proc_obj); + cout << "----------------------------------------------------" << endl; + cout << ">>> ProcessingInfo not found, PROC set to false and continue (not 10RED files?)<<<" << endl; + PROC = false; + } // -------------------------------------------- // return the pamela chain with all the friends // -------------------------------------------- pam_tree = Trout; - return Trout; } @@ -3990,7 +4128,7 @@ isFragment = false; run_tree->GetEntry(irun); if (!GetOrbitalInfo()) - cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated " << endl; + cout << "PamLevel2::UpdateRunInfo(Long64_t "<ID<<"\t "<NEVENTS<< "\t "<RUNHEADER_TIME<<" <---> "<RUNTRAILER_TIME<Fill(); } - cout << "----------------------------------------------------" << endl; - + // + // replicate processinginfo tree + // + if ( PROC ){ // EMEMEM + proc_tree_clone = new TTree("ProcessingInfo","Log of data processing"); + proc_tree_clone->Branch("ProcInfo", "ProcInfo", GetPointerTo("ProcInfo")); + cout << "ProcessingInfo: branch ProcessingInfo" << endl; + // ------------------ + // replicate processinginfo tree + // ------------------ + // cout << "----------------------------------------------------"<GetEntries(); i++) { + proc_tree->GetEntry(i); + // cout << i<< "\t | "<Fill(); + } + if ( SELLI != 2 ){ + proc_obj->runID = 0; + TTimeStamp *dt = new TTimeStamp(); + proc_obj->date = dt->AsString(); + delete dt; + proc_obj->commandLine = Form("PamelaLevel2 was called: CAL2 %i CAL1 %i CAL0 %i TRK2 %i TRK1 %i TRKh %i TRK0 %i TOF %i TOF0 %i TRG %i \n S4 %i ND %i AC %i ORB %i GP %i EXT %i NUC %i RUN %i ISGP %i SELLI %i \n Custom string = %s",CAL2,CAL1,CAL0,TRK2,TRK1,TRKh,TRK0,TOF,TOF0,TRG,S4,ND,AC,ORB,GP,EXT,NUC,RUN,ISGP,SELLI,customString.Data()); + proc_obj->outputFilename = ofile->GetName(); + proc_obj->localDir = gSystem->WorkingDirectory(); + proc_obj->uname = gSystem->GetFromPipe("uname -a"); + if (!dbc || (dbc && !dbc->IsConnected())) SetDBConnection(); + proc_obj->DB = Form("mysql://%s/%s",dbc->GetHost(),dbc->GetDB()); + dbc->Close(); + proc_tree_clone->Fill(); + } + cout << "----------------------------------------------------" << endl; + } // ------------------------------------ // add branch with dead and live times // ------------------------------------ @@ -5370,6 +5539,11 @@ if (!name.CompareTo(na)) return sel_tree_clone; } + if (proc_tree_clone && PROC) { + TString na = proc_tree_clone->GetName(); + if (!name.CompareTo(na)) + return proc_tree_clone; + } return NULL; } @@ -5392,6 +5566,10 @@ pam_tree_clone[i]->Write(pam_tree_clone[i]->GetName(),TObject::kOverwrite); }; } + + if ( PROC ){//EMEMEMEM + proc_tree_clone->Write("ProcessingInfo",TObject::kOverwrite); + } cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; }