--- PamelaLevel2/src/PamLevel2.cpp 2011/12/15 08:54:12 1.91 +++ PamelaLevel2/src/PamLevel2.cpp 2015/11/02 09:59:54 1.112 @@ -30,7 +30,7 @@ void GPamela::Delete() { Clear(); - + /* EM all these are in the stack not in the heap, so no need to delete by hand... delete[] Ipltof; delete[] Ipaddle; delete[] Ipartof; @@ -131,9 +131,9 @@ delete[] Timecard; delete[] Pathcard; delete[] P0card; - + */ } -; + void GPamela::SetBranchAddress(TChain* fhBookTree) { @@ -278,6 +278,7 @@ */ PamTrack::PamTrack() { trk_track = 0; + trk_ext_track = 0; calo_track = 0; tof_track = 0; orb_track = 0; @@ -295,6 +296,7 @@ */ PamTrack::PamTrack(TrkTrack* t, CaloTrkVar* c, ToFTrkVar* o, OrbitalInfoTrkVar *r) { + trk_ext_track = 0; trk_track = 0; calo_track = 0; tof_track = 0; @@ -302,30 +304,123 @@ // 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 (t) +// trk_track = t; +// if (c) +// calo_track = c; +// if (o) +// tof_track = o; +// if (r) +// orb_track = r; + +// candeleteobj = 0; + +// cout << t<<"--"<ExtTrack::Clear(option); if (trk_track) trk_track->TrkTrack::Clear(); if (calo_track) @@ -351,6 +469,7 @@ orb_track->OrbitalInfoTrkVar::Clear();//??? } else { + trk_ext_track = 0; trk_track = 0; calo_track = 0; tof_track = 0; @@ -363,6 +482,11 @@ void PamTrack::Delete() { // cout << "PamTrack::Delete() "<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) { trk_track->TrkTrack::Clear(); delete trk_track; @@ -384,6 +508,10 @@ Clear(); } } + + + + //-------------------------------------- // // @@ -417,7 +545,7 @@ GetPamTree(listf, detlist); if (listf) GetRunTree(listf); - this->SetMaxShift(-1); + SetMaxShift(-1); } @@ -425,7 +553,7 @@ Initialize(); GetPamTree(llist, detlist); GetRunTree(llist); - this->SetMaxShift(-1); + SetMaxShift(-1); } /** @@ -437,10 +565,12 @@ */ PamLevel2::PamLevel2(TString ddir, TString llist) { Initialize(); - TList* listf = GetListOfLevel2Files(ddir, llist); + TList* listf = GetListOfLevel2Files(ddir, llist); + cout << "GetPamTree: "<SetMaxShift(-1); + SetMaxShift(-1); } @@ -455,16 +585,41 @@ trkh_obj = 0; calo1_obj = 0; calo2_obj = 0; - tof_obj = 0; + tof2_obj = 0; trig_obj = 0; s4_obj = 0; nd_obj = 0; ac_obj = 0; - orb_obj = 0; + orb2_obj = 0; gp_obj = 0; + extAlgFlag=0; + + trk_ext_obj = 0; + trk_ext_nuc_obj = 0; + trk_nuc_obj = 0; + + calo_ext_obj = 0; + calo_ext_nuc_obj = 0; + calo_nuc_obj = 0; + + tof_ext_obj = 0; + tof_ext_nuc_obj = 0; + tof_nuc_obj = 0; + + orb_ext_obj = 0; + orb_ext_nuc_obj = 0; + orb_nuc_obj = 0; + + trk2_nuc_obj = 0; + calo2_nuc_obj = 0; + tof2_nuc_obj = 0; + orb2_nuc_obj = 0; + + run_obj = 0;//new GL_RUN(); soft_obj = 0;// Emiliano + proc_obj = 0;// Emiliano irun = -1LL; irunt = -1LL; totrunentry = 0LL; @@ -474,6 +629,8 @@ runlastentry = 0LL; gltsync = 0; // Emiliano fUpdateRunInfo = true; // Emiliano + fUseDBinRunInfo = true; // Emiliano + fDiscarded = false; //EM isSync = false; // by default assume that the level2 file(s) is(are) not sinchronized between L0/DB and L2, that is we miss some packets in L2 due to nested/DV-skipped events il0entry = 0LL; // hasL0EE = true; @@ -489,6 +646,10 @@ run_tree = NULL; run_tree_clone = NULL; + + proc_tree = NULL; + proc_tree_clone = NULL; + sel_tree = NULL; sel_tree_clone = NULL; @@ -520,6 +681,8 @@ if (strcmp(pamdbpsw, "")) psw = pamdbpsw; + customString = ""; + // sorted_tracks = 0;//new TRefArray(); CAL0 = false; @@ -536,8 +699,13 @@ ND = true; AC = true; ORB = true; + PROC = true; GP = false; + EXT = false; + NUC = false; + trkAlg = "STD";//default tracking algorythm + RUN = true; SELLI = -1; @@ -548,6 +716,11 @@ tsorted = 0; timage = 0; + text = 0 ; + + tsorted_nuc = 0; + timage_nuc = 0; + text_nuc = 0 ; howtosort = "+CAL+TOF"; //howtosort = "+TOF"; @@ -555,6 +728,8 @@ issorted = false; lastsorted = -1; + issorted_new = false; + lastsorted_new = -1; } ; @@ -567,6 +742,8 @@ delete run_obj; if (soft_obj) delete soft_obj; //Emiliano + if (proc_obj) + delete proc_obj; //Emiliano // cout << "void PamLevel2::Clear()"<Delete(); + if(trk_ext_obj)trk_ext_obj->Delete(); + if(trk_ext_nuc_obj)trk_ext_nuc_obj->Delete(); + + if(calo_nuc_obj)calo_nuc_obj->Delete(); + if(calo_ext_obj)calo_ext_obj->Delete(); + if(calo_ext_nuc_obj)calo_ext_nuc_obj->Delete(); + + if(tof_nuc_obj)tof_nuc_obj->Delete(); + if(tof_ext_obj)tof_ext_obj->Delete(); + if(tof_ext_nuc_obj)tof_ext_nuc_obj->Delete(); + + if(orb_nuc_obj)orb_nuc_obj->Delete(); + if(orb_ext_obj)orb_ext_obj->Delete(); + if(orb_ext_nuc_obj)orb_ext_nuc_obj->Delete(); + + + if(trk2_nuc_obj)trk2_nuc_obj->Delete();; + if( calo2_nuc_obj)calo2_nuc_obj->Delete();; + if(tof2_nuc_obj)tof2_nuc_obj->Delete();; + if(orb2_nuc_obj)orb2_nuc_obj->Delete();; + + + if (tsorted) { tsorted->Delete(); delete tsorted; @@ -608,6 +809,24 @@ timage->Delete(); delete timage; } + if (text) { + text->Delete(); + delete text; + } + if (tsorted_nuc) { + tsorted_nuc->Delete(); + delete tsorted_nuc; + } + if (timage_nuc) { + timage_nuc->Delete(); + delete timage_nuc; + } + if (text_nuc) { + text_nuc->Delete(); + delete text_nuc; + } + + if (dbc) { dbc->Close(); @@ -675,6 +894,9 @@ if (irunoffset) delete[] irunoffset; + + Initialize(); + } ; @@ -708,8 +930,8 @@ calo1_obj->Clear(); if (calo2_obj) calo2_obj->Clear(); - if (tof_obj) - tof_obj->Clear(); + if (tof2_obj) + tof2_obj->Clear(); if (trig_obj) trig_obj->Clear(); if (s4_obj) @@ -718,20 +940,44 @@ nd_obj->Clear(); if (ac_obj) ac_obj->Clear(); - if (orb_obj) - orb_obj->Clear(); + if (orb2_obj) + orb2_obj->Clear(); if (gp_obj) gp_obj->Clear(); + if (proc_obj) + proc_obj->Clear(); // if(sorted_tracks)sorted_tracks->Clear(); // sorted_tracks.Clear(); - if (tsorted) { - tsorted->Delete(); - } - if (timage) { - timage->Delete(); - } + if(trk_nuc_obj)trk_nuc_obj->Clear(); + if(trk_ext_obj)trk_ext_obj->Clear(); + if(trk_ext_nuc_obj)trk_ext_nuc_obj->Clear(); + + if(calo_nuc_obj)calo_nuc_obj->Clear(); + if(calo_ext_obj)calo_ext_obj->Clear(); + if(calo_ext_nuc_obj)calo_ext_nuc_obj->Clear(); + + if(tof_nuc_obj)tof_nuc_obj->Clear(); + if(tof_ext_obj)tof_ext_obj->Clear(); + if(tof_ext_nuc_obj)tof_ext_nuc_obj->Clear(); + + if(orb_nuc_obj)orb_nuc_obj->Clear(); + if(orb_ext_obj)orb_ext_obj->Clear(); + if(orb_ext_nuc_obj)orb_ext_nuc_obj->Clear(); + + if(trk2_nuc_obj)trk2_nuc_obj->Clear();; + if( calo2_nuc_obj)calo2_nuc_obj->Clear();; + if(tof2_nuc_obj)tof2_nuc_obj->Clear();; + if(orb2_nuc_obj)orb2_nuc_obj->Clear();; + + if (tsorted)tsorted->Delete(); + if (timage)timage->Delete(); + if (text) text->Delete(); + + if (tsorted_nuc)tsorted_nuc->Delete(); + if (timage_nuc)timage_nuc->Delete(); + if (text_nuc) text_nuc->Delete(); } ; @@ -780,6 +1026,10 @@ if (sel_tree) sel_tree->Delete();; sel_tree = NULL; + + if (proc_tree) + proc_tree->Delete(); + proc_tree = NULL; // // Close file // @@ -796,18 +1046,46 @@ trkh_obj = 0; calo1_obj = 0; calo2_obj = 0; - tof_obj = 0; + tof2_obj = 0; trig_obj = 0; s4_obj = 0; nd_obj = 0; ac_obj = 0; - orb_obj = 0; + orb2_obj = 0; gp_obj = 0; + proc_obj = 0; + + trk_ext_obj = 0; + trk_ext_nuc_obj = 0; + trk_nuc_obj = 0; + + calo_ext_obj = 0; + calo_ext_nuc_obj = 0; + calo_nuc_obj = 0; + + tof_ext_obj = 0; + tof_ext_nuc_obj = 0; + tof_nuc_obj = 0; + + orb_ext_obj = 0; + orb_ext_nuc_obj = 0; + orb_nuc_obj = 0; + + trk2_nuc_obj = 0; + calo2_nuc_obj = 0; + tof2_nuc_obj = 0; + orb2_nuc_obj = 0; + + trk2_nuc_obj = 0; + calo2_nuc_obj = 0; + tof2_nuc_obj = 0; + orb2_nuc_obj = 0; // // Reset run pointers // run_obj = 0;//new GL_RUN(); soft_obj = 0;// Emiliano + proc_obj = 0;// Emiliano irun = -1; irunt = -1; totrunentry = 0LL; @@ -837,7 +1115,7 @@ if (strict) { if (trk2_obj && trk2_obj->UnpackError() != 0) goodev = false; - if (tof_obj && tof_obj->unpackError != 0) + if (tof2_obj && tof2_obj->unpackError != 0) goodev = false; if (trig_obj && trig_obj->unpackError != 0) goodev = false; @@ -847,7 +1125,7 @@ goodev = false; if (ac_obj && (ac_obj->unpackError != 0 || ((ac_obj->status[0] >> 2) & 1) || ((ac_obj->status[1] >> 2) & 1))) goodev = false; - // if(orb_obj) + // if(orb2_obj) } else { if (nd_obj && nd_obj->unpackError != 0) @@ -878,7 +1156,7 @@ printf("PamLevel2::SetMaxShift(Int_t) --WARNING-- the default is optimized by checking the level2 file\n it is strongly suggested to let PamLevel2 choose the max shift!\n"); maxshift = sh; } else { - ULong64_t nev = this->GetEntries(); + ULong64_t nev = GetEntries(); ULong64_t runnev = 0ULL; for (Int_t r=0; r< run_tree->GetEntries();r++){ run_tree->GetEntry(r);//update runinfo @@ -933,11 +1211,11 @@ return &calo2_obj; }; if (!objname.CompareTo("ToFLevel2")) { - if (!tof_obj) { - tof_obj = new ToFLevel2(); - tof_obj->Set(); + if (!tof2_obj) { + tof2_obj = new ToFLevel2(); + tof2_obj->Set(); } - return &tof_obj; + return &tof2_obj; }; if (!objname.CompareTo("TrigLevel2")) { if (!trig_obj) @@ -960,15 +1238,15 @@ return &ac_obj; }; if (!objname.CompareTo("OrbitalInfo")) { - if (!orb_obj) { - orb_obj = new OrbitalInfo(); - orb_obj->Set(); + if (!orb2_obj) { + orb2_obj = new OrbitalInfo(); + orb2_obj->Set(); } - return &orb_obj; + return &orb2_obj; }; // if(!objname.CompareTo("OrbitalInfo")){ - // if(!orb_obj) orb_obj = new OrbitalInfo(); - // return &orb_obj; + // if(!orb2_obj) orb2_obj = new OrbitalInfo(); + // return &orb2_obj; // }; if (!objname.CompareTo("GPamela")) { if (!gp_obj) @@ -982,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; } ; @@ -999,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; @@ -1014,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; }; @@ -1032,10 +1318,10 @@ */ ToFTrkVar *PamLevel2::GetToFStoredTrack(int seqno) { - if (!tof_obj) + if (!tof2_obj) return 0; - if (tof_obj->ToFLevel2::ntrk() == 0) { + if (tof2_obj->ToFLevel2::ntrk() == 0) { cout << "PamLevel2::GetToFStoredTrack(int) : requested tracker SeqNo " << seqno << " but no ToF tracks are stored" << endl; return NULL; @@ -1045,9 +1331,9 @@ Int_t it_tof = 0; do { - c = tof_obj->ToFLevel2::GetToFTrkVar(it_tof); + c = tof2_obj->ToFLevel2::GetToFTrkVar(it_tof); it_tof++; - } while (c && seqno != c->trkseqno && it_tof < tof_obj->ToFLevel2::ntrk()); + } while (c && seqno != c->trkseqno && it_tof < tof2_obj->ToFLevel2::ntrk()); if (!c || seqno != c->trkseqno) { c = 0; @@ -1070,17 +1356,17 @@ */ OrbitalInfoTrkVar *PamLevel2::GetOrbitalInfoStoredTrack(int seqno) { - if (!orb_obj) + if (!orb2_obj) return 0; - if (orb_obj->OrbitalInfo::ntrk() == 0) { + if (orb2_obj->OrbitalInfo::ntrk() == 0) { // // TRICK BEGIN // OrbitalInfoTrkVar *r = new OrbitalInfoTrkVar(); // TEMPORARY TRICK // Int_t nn = 0; - // TClonesArray &tor = *orb_obj->OrbitalInfoTrk; - // for(Int_t nt=0; nt < tof_obj->ToFLevel2::ntrk(); nt++){ + // TClonesArray &tor = *orb2_obj->OrbitalInfoTrk; + // for(Int_t nt=0; nt < tof2_obj->ToFLevel2::ntrk(); nt++){ // // - // ToFTrkVar *ptt = tof_obj->ToFLevel2::GetToFTrkVar(nt); + // ToFTrkVar *ptt = tof2_obj->ToFLevel2::GetToFTrkVar(nt); // if ( ptt->trkseqno != -1 ){ // // // r->trkseqno = ptt->trkseqno; @@ -1102,7 +1388,7 @@ // }; // delete r; // OrbitalInfoTrkVar *c = 0; - // c = orb_obj->OrbitalInfo::GetOrbitalInfoTrkVar(0); + // c = orb2_obj->OrbitalInfo::GetOrbitalInfoTrkVar(0); // return c; // //TRICK END cout << "PamLevel2::GetOrbitalInfoStoredTrack(int) : requested tracker SeqNo " << seqno @@ -1114,9 +1400,9 @@ Int_t it_tof = 0; do { - c = orb_obj->OrbitalInfo::GetOrbitalInfoTrkVar(it_tof); + c = orb2_obj->OrbitalInfo::GetOrbitalInfoTrkVar(it_tof); it_tof++; - } while (c && seqno != c->trkseqno && it_tof < orb_obj->OrbitalInfo::ntrk()); + } while (c && seqno != c->trkseqno && it_tof < orb2_obj->OrbitalInfo::ntrk()); if (!c || seqno != c->trkseqno) { c = 0; @@ -1133,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) { +// /** +// * 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; +// 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; +// 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()); +// if (CAL2) +// c = GetCaloStoredTrack(t->GetSeqNo()); +// if (TOF) +// o = GetToFStoredTrack(t->GetSeqNo()); +// if (ORB) +// r = GetOrbitalInfoStoredTrack(t->GetSeqNo()); - // if(t && c && o)track = new PamTrack(t,c,o); - PamTrack *track = new PamTrack(t, c, o, r); +// // if(t && c && o)track = new PamTrack(t,c,o); +// PamTrack *track = new PamTrack(t, c, o, r); - return track; +// return track; -} -; +// } +// ; //-------------------------------------- // // //-------------------------------------- -/** - * Retrieves the it-th stored track. - * It override TrkLevel2::GetTrack(int it). - * @param itrk Track number, ranging from 0 to GetNTracks(). - */ +// /** +// * 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) { +// 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; -} +// } //-------------------------------------- // @@ -1245,16 +1531,24 @@ Int_t ObjectNumber = TProcessID::GetObjectCount(); // create TCloneArrays to store tracks and its images - if (!tsorted) - tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); - tsorted->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(tsorted)delete tsorted; + if(timage) delete timage; + tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); + timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); - if (!timage) - timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); - timage->Delete(); + + TClonesArray &ttsorted = *tsorted; TClonesArray &ttimage = *timage; + + //-------------------------------------------------- // retrieve sorting method //-------------------------------------------------- @@ -1370,7 +1664,7 @@ // ----------------------------------------------------------------------------------------- // check the number of hit pmts along the track // on S12 S21 and S32, where paddles are parallel to Y axis - if ((use_TOF || use_S1 || use_S2 || use_S3) && !tof_obj) { + if ((use_TOF || use_S1 || use_S2 || use_S3) && !tof2_obj) { cout << "void PamLevel2::SortTracks(): howtosort= " << how << " but ToFLevel2 not loaded !!!"; return; }; @@ -1387,12 +1681,12 @@ // Float_t sen = 0.; for (Int_t ih = 0; ih < op->npmtadc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((op->pmtadc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((op->pmtadc).At(ih)); if (pl == 2 || pl == 3 || pl == 4 || pl == 5) sen += (op->dedx).At(ih); }; for (Int_t ih = 0; ih < oi->npmtadc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((oi->pmtadc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((oi->pmtadc).At(ih)); if (pl == 2 || pl == 3 || pl == 4 || pl == 5) sen += (oi->dedx).At(ih); }; @@ -1405,7 +1699,7 @@ Int_t nz = 6; Float_t zin[6]; // << define TOF z-coordinates for (Int_t ip = 0; ip < nz; ip++) - zin[ip] = tof_obj->ToFLevel2::GetZTOF(tof_obj->ToFLevel2::GetToFPlaneID(ip)); // << read ToF plane z-coordinates + zin[ip] = tof2_obj->ToFLevel2::GetZTOF(tof2_obj->ToFLevel2::GetToFPlaneID(ip)); // << read ToF plane z-coordinates Trajectory *tr = new Trajectory(nz, zin); // Int_t nphit_p = 0; @@ -1414,7 +1708,7 @@ Float_t enhit_i = 0.; // for (Int_t ih = 0; ih < op->npmtadc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((op->pmtadc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((op->pmtadc).At(ih)); if (pl == 1 || pl == 2 || pl == 5) { nphit_p++; enhit_p += (op->dedx).At(ih); @@ -1425,7 +1719,7 @@ // if (fabs(tr->y[0] - oi->ytofpos[0]) < 2.) { for (Int_t ih = 0; ih < op->npmtadc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((op->pmtadc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((op->pmtadc).At(ih)); if (pl == 0) { nphit_p++; enhit_p += (op->dedx).At(ih); @@ -1434,7 +1728,7 @@ }; if (fabs(tr->y[3] - oi->ytofpos[1]) < 2.) { for (Int_t ih = 0; ih < op->npmtadc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((op->pmtadc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((op->pmtadc).At(ih)); if (pl == 3) { nphit_p++; enhit_p += (op->dedx).At(ih); @@ -1443,7 +1737,7 @@ }; if (fabs(tr->y[4] - oi->ytofpos[2]) < 2.) { for (Int_t ih = 0; ih < op->npmtadc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((op->pmtadc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((op->pmtadc).At(ih)); if (pl == 4) { nphit_p++; enhit_p += (op->dedx).At(ih); @@ -1452,7 +1746,7 @@ }; for (Int_t ih = 0; ih < oi->npmtadc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((oi->pmtadc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((oi->pmtadc).At(ih)); if (pl == 1 || pl == 2 || pl == 5) { nphit_i++; enhit_i += (op->dedx).At(ih); @@ -1463,7 +1757,7 @@ // if (fabs(tr->y[0] - oi->ytofpos[0]) < 2.) { for (Int_t ih = 0; ih < oi->npmtadc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((oi->pmtadc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((oi->pmtadc).At(ih)); if (pl == 0) { nphit_i++; enhit_i += (op->dedx).At(ih); @@ -1472,7 +1766,7 @@ }; if (fabs(tr->y[3] - oi->ytofpos[1]) < 2.) { for (Int_t ih = 0; ih < oi->npmtadc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((oi->pmtadc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((oi->pmtadc).At(ih)); if (pl == 3) { nphit_i++; enhit_i += (op->dedx).At(ih); @@ -1481,7 +1775,7 @@ }; if (fabs(tr->y[4] - oi->ytofpos[2]) < 2.) { for (Int_t ih = 0; ih < oi->npmtadc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((oi->pmtadc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((oi->pmtadc).At(ih)); if (pl == 4) { nphit_i++; enhit_i += (op->dedx).At(ih); @@ -1525,18 +1819,18 @@ cout << "image: npmttdc "<< oi->npmttdc << endl;*/ // for (Int_t ih=0; ih < op->npmtadc; ih++){ - // Int_t pl = tof_obj->GetPlaneIndex( (op->pmtadc).At(ih) ); + // Int_t pl = tof2_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 = tof_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); + // Int_t pl = tof2_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); // if(pl == 1 || pl == 2 || pl == 5)nphit_i++; // }; // --- modified to count tdc signals (more efficient?) // --- and to implement check on tdcflag for (Int_t ih = 0; ih < op->npmttdc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((op->pmttdc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((op->pmttdc).At(ih)); // if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++; if ((use_S1 && (pl == 0 || pl == 1)) || (use_S2 && (pl == 2 || pl == 3)) || (use_S3 && (pl == 4 || pl == 5))) { @@ -1546,7 +1840,7 @@ }; for (Int_t ih = 0; ih < oi->npmttdc; ih++) { - Int_t pl = tof_obj->GetPlaneIndex((oi->pmttdc).At(ih)); + Int_t pl = tof2_obj->GetPlaneIndex((oi->pmttdc).At(ih)); // if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++; if ((use_S1 && (pl == 0 || pl == 1)) || (use_S2 && (pl == 2 || pl == 3)) || (use_S3 && (pl == 4 || pl == 5))) { @@ -1692,6 +1986,9 @@ // cout<<"o "<GetNTracks()); +// tsorted->Clear("C+C");//Delete(); +// // track images from standard alg +// if (!timage) +// timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); +// timage->Clear("C+C");//Delete(); +// // tracks from extended algorythm +// if(EXT && !text) +// text = new TClonesArray("PamTrack",trk_ext_obj->GetEntries()); +// if(text)text->Clear("C+C");//Delete(); + + if(tsorted)delete tsorted; + if(timage) delete timage; + if(text) delete text; + tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); + timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); + text = new TClonesArray("PamTrack",trk_ext_obj->GetEntries()); + + //----------------------------------------------------------- + // create/reset TCloneArrays to store tracks and their images + //----------------------------------------------------------- + if(NUC){ + + + if(tsorted_nuc)delete tsorted_nuc; + if(timage_nuc) delete timage_nuc; + if(text_nuc) delete text_nuc; + tsorted_nuc = new TClonesArray("PamTrack", trk2_nuc_obj->GetNTracks()); + timage_nuc = new TClonesArray("PamTrack", trk2_nuc_obj->GetNTracks()); + text_nuc = new TClonesArray("PamTrack",trk_ext_nuc_obj->GetEntries()); + + // main tracks from standard alg +// if (!tsorted_nuc) +// tsorted_nuc = new TClonesArray("PamTrack", trk2_nuc_obj->GetNTracks()); +// tsorted_nuc->Clear("C+C");//Delete(); +// // track images from standard alg +// if (!timage_nuc) +// timage_nuc = new TClonesArray("PamTrack", trk2_nuc_obj->GetNTracks()); +// timage_nuc->Clear("C+C");//Delete(); +// // tracks from extended algorythm +// if(EXT && !text_nuc) +// text_nuc = new TClonesArray("PamTrack",trk_ext_nuc_obj->GetEntries()); +// if(text_nuc)text_nuc->Clear("C+C");//Delete(); + + } + //-------------------------------------------------- + // retrieve sorting method + //-------------------------------------------------- + Bool_t use_TRK = how.Contains("TRK", TString::kIgnoreCase); + Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); + Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); + Bool_t use_S1 = how.Contains("S1", TString::kIgnoreCase); + Bool_t use_S2 = how.Contains("S2", TString::kIgnoreCase); + Bool_t use_S3 = how.Contains("S3", TString::kIgnoreCase); + Bool_t use_GP = how.Contains("GP", TString::kIgnoreCase); + + if (use_TOF) { + use_S1 = true; + use_S2 = true; + use_S3 = true; + }; + if (!CAL2 && use_CAL) + use_CAL = false; + if (!TOF) { + use_TOF = false; + use_S1 = false; + use_S2 = false; + use_S3 = false; + } + if (!GP) { + use_GP = false; + } + + if (!TRK2) { + cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; + return; + }; + + + /////////////////////////////////////////////////////////////////////////////////// + // + // sort tracks and fill PamTrack arrays + // + /////////////////////////////////////////////////////////////////////////////////// + for(int doit=0; doit<2; doit++){ + +// cout << "doit "<TrkLevel2::GetNTracks(); i++) { + + TrkTrack *ts = 0; + CaloTrkVar *cs = 0; + ToFTrkVar *os = 0; + OrbitalInfoTrkVar *rs = 0; + + // get tracker tracks + 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="<HasImage()) { + + ti = (TRK2 ? trk2->GetTrackImage(i) : NULL); //tracker (image) + ci = (CAL2 ? calo2->GetCaloStoredTrack(ti->GetSeqNo()): NULL); + oi = (TOF ? tof2->GetToFStoredTrack(ti->GetSeqNo()): NULL); + ri = (ORB ? orb2->GetOrbitalInfoStoredTrack(ti->GetSeqNo()): NULL); + + // cout << "its image "<npresh > ci->npresh && true) { + tp_score++; + totp_score++; + }; + if (cp->npresh < ci->npresh && true) { + ti_score++; + toti_score++; + }; + + // cout << "CALO "<npmtadc; ih++) { + Int_t pl = tof2->GetPlaneIndex((op->pmtadc).At(ih)); + if (pl == 2 || pl == 3 || pl == 4 || pl == 5) + sen += (op->dedx).At(ih); + }; + for (Int_t ih = 0; ih < oi->npmtadc; ih++) { + Int_t pl = tof2->GetPlaneIndex((oi->pmtadc).At(ih)); + if (pl == 2 || pl == 3 || pl == 4 || pl == 5) + sen += (oi->dedx).At(ih); + }; + // + if (sen >= sortthr && false) { // temporary disabled NUCLEI special algorithm since the new one should work for every particle (to be checked!) + //printf(" IS A NUCLEUS! en = %f \n",sen); + // + // is a nucleus use a different algorithm + // + Int_t nz = 6; + Float_t zin[6]; // << define TOF z-coordinates + for (Int_t ip = 0; ip < nz; ip++) + zin[ip] = tof2->GetZTOF(tof2->GetToFPlaneID(ip)); // << read ToF plane z-coordinates + Trajectory *tr = new Trajectory(nz, zin); + // + Int_t nphit_p = 0; + Int_t nphit_i = 0; + Float_t enhit_p = 0.; + Float_t enhit_i = 0.; + // + for (Int_t ih = 0; ih < op->npmtadc; ih++) { + Int_t pl = tof2->GetPlaneIndex((op->pmtadc).At(ih)); + if (pl == 1 || pl == 2 || pl == 5) { + nphit_p++; + enhit_p += (op->dedx).At(ih); + }; + }; + // + tp->DoTrack2(tr); + // + if (fabs(tr->y[0] - oi->ytofpos[0]) < 2.) { + for (Int_t ih = 0; ih < op->npmtadc; ih++) { + Int_t pl = tof2->GetPlaneIndex((op->pmtadc).At(ih)); + if (pl == 0) { + nphit_p++; + enhit_p += (op->dedx).At(ih); + }; + }; + }; + if (fabs(tr->y[3] - oi->ytofpos[1]) < 2.) { + for (Int_t ih = 0; ih < op->npmtadc; ih++) { + Int_t pl = tof2->GetPlaneIndex((op->pmtadc).At(ih)); + if (pl == 3) { + nphit_p++; + enhit_p += (op->dedx).At(ih); + }; + }; + }; + if (fabs(tr->y[4] - oi->ytofpos[2]) < 2.) { + for (Int_t ih = 0; ih < op->npmtadc; ih++) { + Int_t pl = tof2->GetPlaneIndex((op->pmtadc).At(ih)); + if (pl == 4) { + nphit_p++; + enhit_p += (op->dedx).At(ih); + }; + }; + }; + + for (Int_t ih = 0; ih < oi->npmtadc; ih++) { + Int_t pl = tof2->GetPlaneIndex((oi->pmtadc).At(ih)); + if (pl == 1 || pl == 2 || pl == 5) { + nphit_i++; + enhit_i += (op->dedx).At(ih); + }; + }; + // + ti->DoTrack2(tr); + // + if (fabs(tr->y[0] - oi->ytofpos[0]) < 2.) { + for (Int_t ih = 0; ih < oi->npmtadc; ih++) { + Int_t pl = tof2->GetPlaneIndex((oi->pmtadc).At(ih)); + if (pl == 0) { + nphit_i++; + enhit_i += (op->dedx).At(ih); + }; + }; + }; + if (fabs(tr->y[3] - oi->ytofpos[1]) < 2.) { + for (Int_t ih = 0; ih < oi->npmtadc; ih++) { + Int_t pl = tof2->GetPlaneIndex((oi->pmtadc).At(ih)); + if (pl == 3) { + nphit_i++; + enhit_i += (op->dedx).At(ih); + }; + }; + }; + if (fabs(tr->y[4] - oi->ytofpos[2]) < 2.) { + for (Int_t ih = 0; ih < oi->npmtadc; ih++) { + Int_t pl = tof2->GetPlaneIndex((oi->pmtadc).At(ih)); + if (pl == 4) { + nphit_i++; + enhit_i += (op->dedx).At(ih); + }; + }; + }; + + if ((use_TOF || use_S1 || use_S2 || use_S3) && (nphit_p + nphit_i) != 0 && true) { + + // printf(" seqno %i nphit_p %i nphit_i %i enhit_p %f enhit_i %f \n",trk2_obj->TrkLevel2::GetSeqNo(i),nphit_p,nphit_i,enhit_p,enhit_i); + // printf(" score p %i score i %i \n",tp_score,ti_score); + // if( enhit_p > enhit_i ) tp_score++; + // if( nphit_p >= nphit_i && enhit_p > enhit_i ) tp_score++; + if (nphit_p > nphit_i) + tp_score++; + if (nphit_p < nphit_i) + ti_score++; + if (nphit_p == nphit_i) { + if (enhit_p > enhit_i) + tp_score++; + else + ti_score++; + }; + // printf(" dopo score p %i score i %i \n",tp_score,ti_score); + }; + delete tr; + // + } + else { + // ------------- + // NOT a NUCLEUS + // ------------- + //printf(" NOT a NUCLEUS! en = %f \n",sen); + + Int_t nphit_p = 0; + Int_t nphit_i = 0; + + /* cout << "track: npmtadc "<< op->npmtadc << endl; + cout << "track: npmttdc "<< op->npmttdc << endl; + cout << "image: npmtadc "<< oi->npmtadc << endl; + cout << "image: npmttdc "<< oi->npmttdc << endl;*/ + + // for (Int_t ih=0; ih < op->npmtadc; ih++){ + // Int_t pl = tof2_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 = tof2_obj->GetPlaneIndex( (oi->pmtadc).At(ih) ); + // if(pl == 1 || pl == 2 || pl == 5)nphit_i++; + // }; + // --- modified to count tdc signals (more efficient?) + // --- and to implement check on tdcflag + for (Int_t ih = 0; ih < op->npmttdc; ih++) { + Int_t pl = tof2->GetPlaneIndex((op->pmttdc).At(ih)); + // if( (op->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_p++; + if ((use_S1 && (pl == 0 || pl == 1)) || (use_S2 && (pl == 2 || pl == 3)) + || (use_S3 && (pl == 4 || pl == 5))) { + if ((op->tdcflag).At(ih) == 0) + nphit_p++; + }; + }; + + for (Int_t ih = 0; ih < oi->npmttdc; ih++) { + Int_t pl = tof2->GetPlaneIndex((oi->pmttdc).At(ih)); + // if( (oi->tdcflag).At(ih)==0 && (pl == 1 || pl == 2 || pl == 5) )nphit_i++; + if ((use_S1 && (pl == 0 || pl == 1)) || (use_S2 && (pl == 2 || pl == 3)) + || (use_S3 && (pl == 4 || pl == 5))) { + if ((oi->tdcflag).At(ih) == 0) + nphit_i++; + }; + }; + + if ((nphit_p + nphit_i) != 0 && true) { + + if (nphit_p != nphit_i) { + totp_score += nphit_p; + toti_score += nphit_i; + tp_score += nphit_p; + ti_score += nphit_i; + }; + // if ( nphit_p > nphit_i) tp_score+=nphit_p; + // else if( nphit_p < nphit_i) ti_score+=nphit_i; + // else ;//niente + }; + }; + // cout << "TOF "<chi2 > 0 && tp->chi2 < ti->chi2 ) tp_score++ ; + // else if( ti->chi2 > 0 && ti->chi2 < tp->chi2 ) ti_score++ ; + + // CHECK 1 : number of points along X + if (tp->GetNX() >= ti->GetNX()) { + tp_score++; + totp_score++; + }; + if (tp->GetNX() <= ti->GetNX()) { + ti_score++; + toti_score++; + }; + // CHECK 2 : number of points along Y + if (tp->GetNY() >= ti->GetNY()) { + tp_score++; + totp_score++; + }; + if (tp->GetNY() <= ti->GetNY()) { + ti_score++; + toti_score++; + }; + + // cout << "TRK "<Nthspe; ih++) { + int ip = (Int_t) GetGPamela()->Itrpb[ih] - 1; + if (tp && tp->YGood(ip) && fabs(tp->ym[ip] - GetGPamela()->Yavspe[ih]) < toll && true) + ngphits_p++; + if (ti && ti->YGood(ip) && fabs(ti->ym[ip] - GetGPamela()->Yavspe[ih]) < toll && true) + ngphits_i++; + } + if (ngphits_p > ngphits_i && true) { + tp_score++; + totp_score++; + } + if (ngphits_p < ngphits_i && true) { + ti_score++; + toti_score++; + } + } + + // *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* + // the winner is.... + // *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* + if (tp_score > ti_score) { + + } + else if (tp_score < ti_score) { + + ts = ti;//its image!! + cs = ci; + os = oi; + rs = ri; + Int_t totis = toti_score; + + ti = tp;//its image!! + ci = cp; + oi = op; + ri = rp; + + tp = ts;//its image!! + cp = cs; + op = os; + rp = rs; + + toti_score = totp_score; + totp_score = totis; + + } + else { + + // cout << "Warning - track image ambiguity not solved" << endl; + + }; + + } + else { + totp_score = 1; + toti_score = 0; + + // 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(tp);//save the track in the sorted array + // cout << "SortTracks:: sorted_tracks->Add(it) "<SetPScore(totp_score); + ((PamTrack*) (ttsorted[i]))->SetIScore(toti_score); + ((PamTrack*) (ttimage[i]))->SetPScore(totp_score); + ((PamTrack*) (ttimage[i]))->SetIScore(toti_score); + }; + + + + + +// if (tsorted->GetEntries() != trk2->GetNTracks()) { +// cout << "void PamLevel2::SortTracks(): tsorted->GetEntries() " << tsorted->GetEntries() +// << " != trk2->GetNTracks() = " << trk2->GetNTracks() << endl; +// tsorted->Delete(); +// tsorted = 0; +// timage->Delete(); +// timage = 0; +// } + + + // cout << "text "<GetEntries(); 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() : 0)<GetEntries() : 0)<GetEntries() : 0)<=0 && it < trk2_obj->TrkLevel2::GetNTracks() && itGetEntries()) - return 0; + return track; +// if (!tsorted->GetEntries()) +// return track; + if (tsorted->GetEntries()==0) + return track; - PamTrack *track = 0; - 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]; - track = (PamTrack*)((*tsorted)[it]); + if ( + tsorted && + it >= 0 && + it < trk2_obj->TrkLevel2::GetNTracks() && + it < tsorted->GetEntries() && + true) { + track = (PamTrack*)((*tsorted)[it]); } else { - cout << "PamLevel2::GetTrack(int) : tracker track SeqNo " << it << " does not exist (GetNTracks() = " + cout << "PamLevel2::GetTrackOld(int) : tracker track SeqNo " << it << " does not exist (GetNTracks() = " << trk2_obj->TrkLevel2::GetNTracks() << ")" << endl; }; return track; +}; + +//PamTrack *PamLevel2::GetTrack(int it) { return GetTrack(it,trkAlg); }; + +/** + * Retrieves the it-th Pamela "physical" track. + * It override TrkLevel2::GetTrack(int it). + * @param it Track number, ranging from 0 to GetNTracks(). + * @param alg Algorythm, see SetTrakingAlgorythm(char *alg) for explanation. + */ +PamTrack *PamLevel2::GetTrack(int it, const char* alg) { + + TString s(alg); + if(!s.CompareTo("") ||!s.CompareTo("STD") )return GetTrackOld(it); //old algorythm + + + SortTracksNew(); + // >> fill tsorted, timage and text + + if ( ( !s.Contains("EXTF", TString::kIgnoreCase) || !EXT )){ //not forced exteded-alg requested (or exteded-data missing) + + if( s.Contains("NUC")){ + if( + tsorted_nuc && + it < tsorted_nuc->GetEntries() && //enough tracks found + it >= 0 && //valid index + true) return (PamTrack*)((*tsorted_nuc)[it]); //ok return the track + }else{ + if( + tsorted && + it < tsorted->GetEntries() && //enough tracks found + it >= 0 && //valid index + true )return (PamTrack*)((*tsorted)[it]); //ok return the track + } + + } + + + ///////////////////////////////////////////////////////////////////////// + /// if requested get track from extended algorythm output + ///////////////////////////////////////////////////////////////////////// + + if(s.Contains("EXT", TString::kIgnoreCase) && EXT){//if exteded-alg requested + + if(s.Contains("NUC")){ + if( + text_nuc && + it < text_nuc->GetEntries() && //enough tracks found + it >= 0 && //valid index + true) return (PamTrack*)((*text_nuc)[it]); + }else{ + if( + text && + it < text->GetEntries() && //enough tracks found + it >= 0 && //valid index + true) return (PamTrack*)((*text)[it]); + } + + }; + + + cout << "PamTrack *PamLevel2::GetTrack("<GetEntries() "<GetEntries()<<" trk2_nuc_obj->GetNTracks() "<GetNTracks()<TrkLevel2::GetNTracks(); //standard algorythm + + if(s.Contains("EXTF", TString::kIgnoreCase) && EXT){ + if(s.Contains("NUC", TString::kIgnoreCase) && NUC)return trk_ext_nuc_obj->GetEntries();//ok + return trk_ext_obj->GetEntries();//ok + } + if( s.Contains("EXT", TString::kIgnoreCase) && EXT) { + if(s.Contains("NUC", TString::kIgnoreCase) && NUC) + return (trk2_nuc_obj->TrkLevel2::GetNTracks() ? trk2_nuc_obj->TrkLevel2::GetNTracks() : trk_ext_nuc_obj->GetEntries() ); + return (trk2_obj->TrkLevel2::GetNTracks() ? trk2_obj->TrkLevel2::GetNTracks() : trk_ext_obj->GetEntries() ); + } + if(s.Contains("NUC", TString::kIgnoreCase) && NUC ) + return trk2_nuc_obj->TrkLevel2::GetNTracks(); + + cout << "Int_t PamLevel2::GetNTracks("<> fill tsorted, timage and text + + if ( ( !s.Contains("EXTF", TString::kIgnoreCase) || !EXT )){ //not forced exteded-alg requested (or exteded-data missing) + + if( s.Contains("NUC")){ + if( + tsorted_nuc && + it < tsorted_nuc->GetEntries() && //enough tracks found + it >= 0 && //valid index + true){ + TClonesArray &t = *(tsorted_nuc); + PamTrack *temp = (PamTrack*) t[it]; + if (temp->GetTrkTrack()->HasImage()) { + return (PamTrack*)((*timage_nuc)[it]); //ok return the track + }else{ + return NULL; + } + + } + }else{ + if( + tsorted && + it < tsorted->GetEntries() && //enough tracks found + it >= 0 && //valid index + true ){ + TClonesArray &t = *(tsorted); + PamTrack *temp = (PamTrack*) t[it]; + if (temp->GetTrkTrack()->HasImage()) { + return (PamTrack*)((*timage)[it]); //ok return the track + }else{ + return NULL; + } + } + } + + } + +// cout << "PamTrack *PamLevel2::GetTrackImage("<AddFriend(T); + Trout->AddFriend(T); } else { cout << "Tracker : missing tree" << endl; @@ -2299,6 +3423,7 @@ TChain *G = 0; TChain *L = 0; + TChain *P = 0; if (TRK2 || TRK1 || TRKh) T = new TChain("Tracker"); @@ -2318,6 +3443,8 @@ B = new TChain("OrbitalInfo"); if (GP) G = new TChain("h20"); + if (PROC) + P = new TChain("ProcessingInfo"); L = new TChain("SelectionList"); // loop over files and create chains @@ -2345,13 +3472,15 @@ B->Add(name); if (GP) G->Add(name); + if (P) + P->Add(name); if (SELLI == 1) L->Add(name); - }; + }; }; - cout << "done chains\n"; - cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; + cout << "done data-tree chains "<< T->GetNtrees() <<" \n"; + cout << "----------------------------------------------------" << endl; // ------------------------------------------- // make friends @@ -2434,14 +3563,14 @@ // ===================================== // SET BRANCH-ADDRESS AFTER CHAIN+FRIEND // ===================================== - SetBranchAddress(Trout); + if( Trout->GetNtrees() )SetBranchAddress(Trout); // ------------------------------------ // finally handle selection trees... // (it is not friend of pamela tree) // ------------------------------------ - cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; + cout << "----------------------------------------------------" << endl; // Selection List if (L && SELLI == 1) { @@ -2462,7 +3591,7 @@ // if(!Trout)Trout=O; // else Trout->AddFriend("SelectionList"); cout << "+SelectionList" << endl; - cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; + cout << "----------------------------------------------------" << endl; } else { // cout << "SelectionList : missing tree"<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; } @@ -2488,18 +3630,19 @@ */ void PamLevel2::SetBranchAddress(TTree *t) { - TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); - TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); - TRKh = TRKh & t->GetBranchStatus("TrkHough"); - CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2"); - CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1"); - TOF = TOF & t->GetBranchStatus("ToFLevel2"); - TRG = TRG & t->GetBranchStatus("TrigLevel2"); - S4 = S4 & t->GetBranchStatus("S4Level2"); - ND = ND & t->GetBranchStatus("NDLevel2"); - AC = AC & t->GetBranchStatus("AcLevel2"); - ORB = ORB & t->GetBranchStatus("OrbitalInfo"); - GP = GP & t->GetBranchStatus("h20"); +// TRK2 = TRK2 & t->GetBranchStatus("TrkLevel2"); +// TRK1 = TRK1 & t->GetBranchStatus("TrkLevel1"); +// TRKh = TRKh & t->GetBranchStatus("TrkHough"); +// CAL2 = CAL2 & t->GetBranchStatus("CaloLevel2"); +// CAL1 = CAL1 & t->GetBranchStatus("CaloLevel1"); +// TOF = TOF & t->GetBranchStatus("ToFLevel2"); +// TRG = TRG & t->GetBranchStatus("TrigLevel2"); +// S4 = S4 & t->GetBranchStatus("S4Level2"); +// ND = ND & t->GetBranchStatus("NDLevel2"); +// AC = AC & t->GetBranchStatus("AcLevel2"); +// ORB = ORB & t->GetBranchStatus("OrbitalInfo"); +// GP = GP & t->GetBranchStatus("h20"); + // Tracker if (TRK1) { @@ -2509,6 +3652,8 @@ if (TRK2) { t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel1")); cout << "Tracker : set branch address TrkLevel2" << endl; + NUC = t->GetBranchStatus("TrackNuclei"); + EXT = t->GetBranchStatus("RecoveredTrack") && (NUC ? t->GetBranchStatus("RecoveredTrackNuclei"): true ); }; if (TRKh) { t->SetBranchAddress("TrkHough", GetPointerTo("TrkHough")); @@ -2569,7 +3714,64 @@ cout << "h20 : set branch address GPamela " << endl; }; + if(NUC){ + + cout << "Found nuclei-track branches" << endl; + + if( !trk_nuc_obj )trk_nuc_obj = new TClonesArray("TrkTrack"); + if( !calo_nuc_obj)calo_nuc_obj= new TClonesArray("CaloTrkVar"); + if( !tof_nuc_obj)tof_nuc_obj= new TClonesArray("ToFTrkVar"); + if( !orb_nuc_obj)orb_nuc_obj= new TClonesArray("OrbitalInfoTrkVar"); + if (TRK2)t-> SetBranchAddress("TrackNuclei",&trk_nuc_obj); + if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("TrackNuclei",&calo_nuc_obj); + if (TOF )t->GetFriend("ToF")-> SetBranchAddress("TrackNuclei",&tof_nuc_obj); + if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("TrackNuclei",&orb_nuc_obj); + + ///copy the vector content inside a "fake" object (all aother info are missing) + + if( !trk2_nuc_obj )trk2_nuc_obj = new TrkLevel2(); + if( !calo2_nuc_obj )calo2_nuc_obj = new CaloLevel2(); + if( !tof2_nuc_obj )tof2_nuc_obj = new ToFLevel2(); + if( !orb2_nuc_obj )orb2_nuc_obj = new OrbitalInfo(); +// *(trk2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*trk_nuc_obj); +// *(calo2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*calo_nuc_obj); +// *(tof2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*tof_nuc_obj); +// *(orb2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*orb_nuc_obj); + + trk2_nuc_obj->SetTrackArray( trk_nuc_obj ); + calo2_nuc_obj->SetTrackArray( calo_nuc_obj ); + tof2_nuc_obj->SetTrackArray( tof_nuc_obj ); + orb2_nuc_obj->SetTrackArray( orb_nuc_obj ); + + } + + if(EXT){ + + cout << "Found extended tracking algorythm branches" << endl; + + if( !trk_ext_obj )trk_ext_obj = new TClonesArray("ExtTrack"); + if( !calo_ext_obj)calo_ext_obj= new TClonesArray("CaloTrkVar"); + if( !tof_ext_obj)tof_ext_obj= new TClonesArray("ToFTrkVar"); + if( !orb_ext_obj)orb_ext_obj= new TClonesArray("OrbitalInfoTrkVar"); + + if (TRK2)t-> SetBranchAddress("RecoveredTrack",&trk_ext_obj); + if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("RecoveredTrack",&calo_ext_obj); + if (TOF )t->GetFriend("ToF")-> SetBranchAddress("RecoveredTrack",&tof_ext_obj); + if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("RecoveredTrack",&orb_ext_obj); + + + if(NUC){ + if( !trk_ext_nuc_obj )trk_ext_nuc_obj = new TClonesArray("ExtTrack"); + if( !calo_ext_nuc_obj)calo_ext_nuc_obj= new TClonesArray("CaloTrkVar"); + if( !tof_ext_nuc_obj)tof_ext_nuc_obj= new TClonesArray("ToFTrkVar"); + if( !orb_ext_nuc_obj)orb_ext_nuc_obj= new TClonesArray("OrbitalInfoTrkVar"); + if (TRK2)t-> SetBranchAddress("RecoveredTrackNuclei",&trk_ext_nuc_obj); + if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("RecoveredTrackNuclei",&calo_ext_nuc_obj); + if (TOF )t->GetFriend("ToF")-> SetBranchAddress("RecoveredTrackNuclei",&tof_ext_nuc_obj); + if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("RecoveredTrackNuclei",&orb_ext_nuc_obj); + } + } } /** * Set branch addresses for Pamela friend trees @@ -2593,6 +3795,8 @@ if (TRK2) { t->SetBranchAddress("TrkLevel2", GetPointerTo("TrkLevel2")); cout << "Tracker : set branch address TrkLevel2" << endl; + NUC = t->GetBranchStatus("TrackNuclei"); + EXT = t->GetBranchStatus("RecoveredTrack") && (NUC ? t->GetBranchStatus("RecoveredTrackNuclei"): true ); }; if (TRK1) { t->SetBranchAddress("TrkLevel1", GetPointerTo("TrkLevel1")); @@ -2606,7 +3810,7 @@ // Calorimeter if (CAL2) { t->SetBranchAddress("CaloLevel2", GetPointerTo("CaloLevel2")); - cout << "Calorimeter : set branch address CaloLevel2" << endl; + cout << "Calorimeter : set branch address CaloLevel2" << endl; }; if (CAL1) { t->SetBranchAddress("CaloLevel1", GetPointerTo("CaloLevel1")); @@ -2664,9 +3868,110 @@ // cout << "SelectionList: set branch address EventEntry"< SetBranchAddress("TrackNuclei",&trk_nuc_obj); + if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("TrackNuclei",&calo_nuc_obj); + if (TOF )t->GetFriend("ToF")-> SetBranchAddress("TrackNuclei",&tof_nuc_obj); + if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("TrackNuclei",&orb_nuc_obj); + + ///copy the vector content inside a "fake" object (all aother info are missing) + + if( !trk2_nuc_obj )trk2_nuc_obj = new TrkLevel2(); + if( !calo2_nuc_obj )calo2_nuc_obj = new CaloLevel2(); + if( !tof2_nuc_obj )tof2_nuc_obj = new ToFLevel2(); + if( !orb2_nuc_obj )orb2_nuc_obj = new OrbitalInfo(); + +// *(trk2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*trk_nuc_obj); +// *(calo2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*calo_nuc_obj); +// *(tof2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*tof_nuc_obj); +// *(orb2_nuc_obj->GetPointerToTrackArray()) = new TClonesArray(*orb_nuc_obj); + trk2_nuc_obj->SetTrackArray( trk_nuc_obj ); + calo2_nuc_obj->SetTrackArray( calo_nuc_obj ); + tof2_nuc_obj->SetTrackArray( tof_nuc_obj ); + orb2_nuc_obj->SetTrackArray( orb_nuc_obj ); + + } + if(EXT){ + + cout << "Found extended tracking algorythm branches" << endl; + t->SetBranchAddress("extAlgFlag",&extAlgFlag); + + if( !trk_ext_obj )trk_ext_obj = new TClonesArray("ExtTrack"); + if( !calo_ext_obj)calo_ext_obj= new TClonesArray("CaloTrkVar"); + if( !tof_ext_obj)tof_ext_obj= new TClonesArray("ToFTrkVar"); + if( !orb_ext_obj)orb_ext_obj= new TClonesArray("OrbitalInfoTrkVar"); + + if (TRK2)t-> SetBranchAddress("RecoveredTrack",&trk_ext_obj); + if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("RecoveredTrack",&calo_ext_obj); + if (TOF )t->GetFriend("ToF")-> SetBranchAddress("RecoveredTrack",&tof_ext_obj); + if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("RecoveredTrack",&orb_ext_obj); + + if(NUC){ + if( !trk_ext_nuc_obj )trk_ext_nuc_obj = new TClonesArray("ExtTrack"); + if( !calo_ext_nuc_obj)calo_ext_nuc_obj= new TClonesArray("CaloTrkVar"); + if( !tof_ext_nuc_obj)tof_ext_nuc_obj= new TClonesArray("ToFTrkVar"); + if( !orb_ext_nuc_obj)orb_ext_nuc_obj= new TClonesArray("OrbitalInfoTrkVar"); + if (TRK2)t-> SetBranchAddress("RecoveredTrackNuclei",&trk_ext_nuc_obj); + if (CAL2)t->GetFriend("Calorimeter")->SetBranchAddress("RecoveredTrackNuclei",&calo_ext_nuc_obj); + if (TOF )t->GetFriend("ToF")-> SetBranchAddress("RecoveredTrackNuclei",&tof_ext_nuc_obj); + if (ORB )t->GetFriend("OrbitalInfo")->SetBranchAddress("RecoveredTrackNuclei",&orb_ext_nuc_obj); + } + } + } +/** + * Set the tracking algorythm + * @param alg String to choose the track. + * "" --> take the output of the standard tracking algorythm + * "STD" --> take the output of the standard tracking algorythm + * "NUC" --> take the output of the standard tracking algorythm for nuclei cluster selection + * "EXT" --> in case the standard tracking algorythm has not found any track, take the output of the extended one + * "EXTF" --> force the extended tracking algorythm + * "NUCEXT" --> as "EXT", but for nuclei + * "NUCEXTF" --> as "EXTF", but for nuclei + */ +// void PamLevel2::SetTrackingAlgorythm(const char *alg){ + + +// TString s(alg); +// if(s.Contains("NUC", TString::kIgnoreCase) && !NUC) +// cout << "Warning! NUC algorythm requested, but branches are missing"< take the output of the standard tracking algorythm"; +// cout< take the output of the standard tracking algorythm for nuclei cluster selection"; +// cout< in case the standard tracking algorythm has not found any track,"; +// cout< force the extended tracking algorythm"; +// cout< as \"EXT\", but for nuclei "; +// cout< as \"EXTF\", but for nuclei"; + +// cout<> "<GetNtrees() <<" \n"; + + if (RUN && R->GetNtrees()) { R->SetBranchAddress("RunInfo", GetPointerTo("RunInfo")); @@ -2739,10 +4047,10 @@ cout << "----------------------------------------------------" << endl; } - else { - delete R; - R = 0; - } +// else { +// delete R; +// R = 0; +// } run_tree = R; @@ -2819,18 +4127,20 @@ isFragment = false; run_tree->GetEntry(irun); if (!GetOrbitalInfo()) - cout << "** WARNING ** missing OrbitalInfo ---> run info might be not correctly updated " << endl; - if (gltsync) - delete gltsync; //Emiliano - if (!dbc || (dbc && !dbc->IsConnected())) - SetDBConnection(); //Emiliano - gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); //Emiliano // the "false" means not to use level0 file (not necessary here) - if (dbc){ - dbc->Close();// Emiliano - delete dbc; - dbc=0; - }; - }; + cout << "PamLevel2::UpdateRunInfo(Long64_t "<Close();// Emiliano + delete dbc; + dbc=0; + } + } + } // --------------------------------------------------------------- // retrieve OBT and absolute time of the event // --------------------------------------------------------------- @@ -2839,12 +4149,12 @@ prevpktnum = pktnum; if (GetOrbitalInfo()) { abstime = GetOrbitalInfo()->absTime; - obt = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano + if ( fUseDBinRunInfo ) obt = gltsync->DBobt(GetOrbitalInfo()->OBT); // Emiliano pktnum = GetOrbitalInfo()->pkt_num; // Emiliano } else { abstime = GetRunInfo()->RUNHEADER_TIME; - obt = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano + if ( fUseDBinRunInfo ) obt = gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT); // Emiliano pktnum = GetRunInfo()->RUNHEADER_PKT; // Emiliano } @@ -2852,7 +4162,7 @@ printf("0abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); printf("0 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); printf("0 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); - printf("0 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); + if ( fUseDBinRunInfo ) printf("0 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); printf("0 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); printf("0 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); } @@ -2875,11 +4185,19 @@ } // + bool a = true; + bool b = true; + if ( fUseDBinRunInfo ){ + a = false; + b = false; + if ( obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) a = true; + if ( obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) b = true; + } if ( iev < totrunentrymin || iev > totrunentrymax // entry is outside run limits || iev == 0 // or it is the first entry || (!isSync && ( - (abstime <= GetRunInfo()->RUNHEADER_TIME && obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) // or it is outside obt limits (and abstime limits for security reasons) - || (abstime >= GetRunInfo()->RUNTRAILER_TIME && obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) ))// or it is outside obt limits (and abstime limits for security reasons) + (abstime <= GetRunInfo()->RUNHEADER_TIME && a ) // or it is outside obt limits (and abstime limits for security reasons) + || (abstime >= GetRunInfo()->RUNTRAILER_TIME && b ) ))// or it is outside obt limits (and abstime limits for security reasons) ){ // check on abstime and obt needed to handle nested+DV_skipped packets // check for a new run (ma prima il primo!) @@ -2887,7 +4205,7 @@ printf("1abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); printf("1 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); printf("1 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); - printf("1 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); + if ( fUseDBinRunInfo ) printf("1 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); printf("1 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); printf("1 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); } @@ -2914,11 +4232,16 @@ totrunentry += GetRunInfo()->NEVENTS; totrunentrymax = totrunentry - 1 - prevshift; // prevshift is needed to handle nested+DV_skipped packets irun = r; - + if ( fUseDBinRunInfo ){ + a = false; + b = false; + if ( obt < gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) ) a = true; + if ( obt > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT) ) b = true; + } if ( (iev >= totrunentrymin && iev <= totrunentrymax) || // entry is inside run limits ( !isSync && - ( abstime >= GetRunInfo()->RUNHEADER_TIME && obt >= gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) // or it is inside obt limits (and abstime limits for security reasons) - && abstime <= GetRunInfo()->RUNTRAILER_TIME && obt <= gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT))) // or it is inside obt limits (and abstime limits for security reasons) + ( abstime >= GetRunInfo()->RUNHEADER_TIME && a // or it is inside obt limits (and abstime limits for security reasons) + && abstime <= GetRunInfo()->RUNTRAILER_TIME && b)) // or it is inside obt limits (and abstime limits for security reasons) ){ // check on abstime and obt needed to handle nested+DV_skipped packets if ( totrunentrymin > iev ){ // there is a shift (nested+DV_skipped packets) if ( !isSync ){ @@ -2943,22 +4266,25 @@ // - if (gltsync) - delete gltsync; // Emiliano - if (!dbc || (dbc && !dbc->IsConnected())) - SetDBConnection(); //Emiliano - gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano - if (dbc){ - dbc->Close(); // Emiliano - delete dbc; - dbc=0; - } - if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano - cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun - << " has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl; - cout - << " (NB!! in this case some events could be assigned to a wrong run)" - << endl; + if ( fUseDBinRunInfo ){ + if (gltsync) + delete gltsync; // Emiliano + if (!dbc || (dbc && !dbc->IsConnected())) + SetDBConnection(); //Emiliano + gltsync = new GL_TIMESYNC(GetRunInfo()->ID_ROOT_L0, "ID", dbc, false); // Emiliano + TrkParams::Set(GetRunInfo(), dbc); + if (dbc){ + dbc->Close(); // Emiliano + delete dbc; + dbc=0; + } + if (gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT) > gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)) { // Emiliano + cout << "Bool_t PamLevel2::UpdateRunInfo(Long64_t iev) -- WARNING -- irun " << irun + << " has RUNHEADER_OBT>=RUNTRAILER_OBT " << endl; + cout + << " (NB!! in this case some events could be assigned to a wrong run)" + << endl; + } } // if (DBG) printf(" found \n"); @@ -3015,7 +4341,7 @@ printf("2abstime %lld %lld pktnum %d %d obt %lld \n",abstime,prevabstime,pktnum,prevpktnum,obt); printf("2 rth %d %d nevents %d \n",GetRunInfo()->RUNHEADER_TIME,GetRunInfo()->RUNTRAILER_TIME,GetRunInfo()->NEVENTS); printf("2 rto %d %d \n",GetRunInfo()->RUNHEADER_OBT,GetRunInfo()->RUNTRAILER_OBT); - printf("2 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); + if ( fUseDBinRunInfo ) printf("2 rto2 %lld %lld \n",gltsync->DBobt(GetRunInfo()->RUNHEADER_OBT),gltsync->DBobt(GetRunInfo()->RUNTRAILER_OBT)); printf("2 bo irunentry %lld prevshift %lld irun %lld \n",irunentry,prevshift,irun); printf("2 min %lld iev %lld max %lld tot %lld \n",totrunentrymin,iev,totrunentrymax,totrunentry); } @@ -3106,14 +4432,16 @@ // update the tracker parameters // (non ho trovato nessun altro modo sicuro di farlo...) // ---------------------------------------------------- - if (!dbc || (dbc && !dbc->IsConnected())) - SetDBConnection(); - TrkParams::Set(GetRunInfo(), dbc); - if (dbc){ - dbc->Close(); - delete dbc; - dbc=0; - }; + if ( fUseDBinRunInfo ){ + if (!dbc || (dbc && !dbc->IsConnected())) + SetDBConnection(); + TrkParams::Set(GetRunInfo(), dbc); + if (dbc){ + dbc->Close(); + delete dbc; + dbc=0; + } + } // cout << endl; prevshift = 0; yprevshift = 0; @@ -3381,6 +4709,7 @@ // cout << "Checking file: "<GetName()<IsZombie()) { cout << "File: " << f->GetName() << " Non valid root file" << endl; + fDiscarded = true; return; } @@ -3587,6 +4916,7 @@ TFile *f = new TFile(name.Data()); if (!f || f->IsZombie()) { cout << "File: " << f->GetName() << " discarded ---- Non valid root file" << endl; + fDiscarded = true; return false; } // cout << "Get list of keys: "<GetName() << " discarded ---- SelectionList tree has " << nevt << " events instead of " << nev << endl; + fDiscarded = true; return false; } nev = nevt; @@ -3639,6 +4970,7 @@ if (nev && nevt != nev) { cout << "File: " << f->GetName() << " discarded ---- Trigger tree has " << nevt << " events instead of " << nev << endl; + fDiscarded = true; return false; } nev = nevt; @@ -3652,6 +4984,7 @@ if (nev && nevt != nev) { cout << "File: " << f->GetName() << " discarded ---- ToF tree has " << nevt << " events instead of " << nev << endl; + fDiscarded = true; return false; } nev = nevt; @@ -3665,6 +4998,7 @@ if (nev && nevt != nev) { cout << "File: " << f->GetName() << " discarded ---- S4 tree has " << nevt << " events instead of " << nev << endl; + fDiscarded = true; return false; } nev = nevt; @@ -3679,6 +5013,7 @@ if (nev && nevt != nev) { cout << "File: " << f->GetName() << " discarded ---- NeutronD tree has " << nevt << " events instead of " << nev << endl; + fDiscarded = true; return false; } nev = nevt; @@ -3692,6 +5027,7 @@ if (nev && nevt != nev) { cout << "File: " << f->GetName() << " discarded ---- Anticounter tree has " << nevt << " events instead of " << nev << endl; + fDiscarded = true; return false; } nev = nevt; @@ -3705,6 +5041,7 @@ if (nev && nevt != nev) { cout << "File: " << f->GetName() << " discarded ---- OrbitalInfo tree has " << nevt << " events instead of " << nev << endl; + fDiscarded = true; return false; } nev = nevt; @@ -3718,6 +5055,7 @@ if (nev && nevt != nev) { cout << "File: " << f->GetName() << " discarded ---- Tracker tree has " << nevt << " events instead of " << nev << endl; + fDiscarded = true; return false; } nev = nevt; @@ -3741,6 +5079,7 @@ if (nev && nevt != nev) { cout << "File: " << f->GetName() << " discarded ---- Calorimeter tree has " << nevt << " events instead of " << nev << endl; + fDiscarded = true; return false; } nev = nevt; @@ -3763,6 +5102,7 @@ if (nev && nevt != nev) { cout << "File: " << f->GetName() << " discarded ---- h20 tree has " << nevt << " events instead of " << nev << endl; + fDiscarded = true; return false; } nev = nevt; @@ -3775,10 +5115,12 @@ SELLI = (Int_t) SELLI__ok; if (SELLI == 0 && SELLI__ok) { cout << "File: " << f->GetName() << " discarded ---- found SelectionList (it is not a full-event file)" << endl; + fDiscarded = true; return false; } if (SELLI == 1 && !SELLI__ok) { cout << "File: " << f->GetName() << " discarded ---- SelectionList missing" << endl; + fDiscarded = true; return false; } @@ -3817,51 +5159,63 @@ if (CAL1 && !CAL1__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing CaloLevel1 branch" << endl; + fDiscarded = true; return false; }; if (CAL2 && !CAL2__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing CaloLevel2 branch" << endl; + fDiscarded = true; return false; }; if (TRK2 && !TRK2__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing TrkLevel2 branch" << endl; + fDiscarded = true; return false; }; if (TRK1 && !TRK1__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing TrkLevel1 branch" << endl; + fDiscarded = true; return false; }; if (TRKh && !TRKh__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing TrkHough branch" << endl; + fDiscarded = true; return false; }; if (ORB && !ORB__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing ORB tree" << endl; + fDiscarded = true; return false; }; if (AC && !AC__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing AC tree" << endl; + fDiscarded = true; return false; }; if (S4 && !S4__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing S4 tree" << endl; + fDiscarded = true; return false; }; if (TOF && !TOF__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing ToF tree" << endl; + fDiscarded = true; return false; }; if (ND && !ND__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing ND tree" << endl; + fDiscarded = true; return false; }; if (TRG && !TRG__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing Trigger tree" << endl; + fDiscarded = true; return false; }; if (GP && !GP__ok) { cout << "File: " << f->GetName() << " discarded ---- Missing h20 tree" << endl; + fDiscarded = true; return false; }; @@ -3961,8 +5315,39 @@ // cout << i<< "\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 // ------------------------------------ @@ -3994,6 +5379,20 @@ pam_tree_clone[i]->Branch("TrkHough", "TrkHough", GetPointerTo("TrkHough")); cout << "Tracker : branch TrkHough" << endl; }; + if(NUC){ + pam_tree_clone[i]->Branch("TrackNuclei","TClonesArray",&trk_nuc_obj); + cout << "Tracker : branch TrackNuclei" << endl; + } + if(EXT){ + pam_tree_clone[i]->Branch("extAlgFlag",&extAlgFlag,"extAlgFlag/I"); + pam_tree_clone[i]->Branch("RecoveredTrack","TClonesArray",&trk_ext_obj); + cout << "Tracker : branch RecoveredTrack" << endl; + if(NUC){ + pam_tree_clone[i]->Branch("RecoveredTrackNuclei","TClonesArray",&trk_ext_nuc_obj); + cout << "Tracker : branch RecoveredTrackNuclei" << endl; + } + } + i++; } @@ -4008,6 +5407,18 @@ pam_tree_clone[i]->Branch("CaloLevel2", "CaloLevel2", GetPointerTo("CaloLevel2")); cout << "Calorimeter : branch CaloLevel2" << endl; }; + if(NUC){ + pam_tree_clone[i]->Branch("TrackNuclei","TClonesArray",&calo_nuc_obj); + cout << "Calorimeter : branch TrackNuclei" << endl; + } + if(EXT){ + pam_tree_clone[i]->Branch("RecoveredTrack","TClonesArray",&calo_ext_obj); + cout << "Calorimeter : branch RecoveredTrack" << endl; + if(NUC){ + pam_tree_clone[i]->Branch("RecoveredTrackNuclei","TClonesArray",&calo_ext_nuc_obj); + cout << "Calorimeter : branch RecoveredTrackNuclei" << endl; + } + } i++; } @@ -4016,6 +5427,18 @@ pam_tree_clone[i] = new TTree("ToF", "PAMELA ToF level2 data "); pam_tree_clone[i]->Branch("ToFLevel2", "ToFLevel2", GetPointerTo("ToFLevel2")); cout << "ToF : branch ToFLevel2" << endl; + if(NUC){ + pam_tree_clone[i]->Branch("TrackNuclei","TClonesArray",&tof_nuc_obj); + cout << "ToF : branch TrackNuclei" << endl; + } + if(EXT){ + pam_tree_clone[i]->Branch("RecoveredTrack","TClonesArray",&tof_ext_obj); + cout << "ToF : branch RecoveredTrack" << endl; + if(NUC){ + pam_tree_clone[i]->Branch("RecoveredTrackNuclei","TClonesArray",&tof_ext_nuc_obj); + cout << "ToF : branch RecoveredTrackNuclei" << endl; + } + } i++; }; // Trigger @@ -4051,6 +5474,18 @@ pam_tree_clone[i] = new TTree("OrbitalInfo", "PAMELA orbital info "); pam_tree_clone[i]->Branch("OrbitalInfo", "OrbitalInfo", GetPointerTo("OrbitalInfo")); cout << "OrbitalInfo : branch OrbitalInfo" << endl; + if(NUC){ + pam_tree_clone[i]->Branch("TrackNuclei","TClonesArray",&orb_nuc_obj); + cout << "OrbitalInfo : branch TrackNuclei" << endl; + } + if(EXT){ + pam_tree_clone[i]->Branch("RecoveredTrack","TClonesArray",&orb_ext_obj); + cout << "OrbitalInfo : branch RecoveredTrack" << endl; + if(NUC){ + pam_tree_clone[i]->Branch("RecoveredTrackNuclei","TClonesArray",&orb_ext_nuc_obj); + cout << "OrbitalInfo : branch RecoveredTrackNuclei" << endl; + } + } i++; }; // GPamela @@ -4060,6 +5495,8 @@ cout << "GPamela : branch GPamela" << endl; i++; }; + + cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; } @@ -4101,6 +5538,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; } @@ -4120,9 +5562,13 @@ for (Int_t i = 0; i < NCLONES; i++) { if (pam_tree_clone[i]) { cout << pam_tree_clone[i]->GetName() << endl; - pam_tree_clone[i]->Write(); + pam_tree_clone[i]->Write(pam_tree_clone[i]->GetName(),TObject::kOverwrite); }; } + + if ( PROC ){//EMEMEMEM + proc_tree_clone->Write("ProcessingInfo",TObject::kOverwrite); + } cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; } @@ -4385,7 +5831,7 @@ cout << " " << endl; } if (shift > 0) { - cout << " PKTNUM L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl; + if (DBG) cout << " PKTNUM L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl; if (DBG) cout << " RUN: ID " << GetRunInfo()->ID << " ID_ROOT_L0 " << run_obj->ID_ROOT_L0 << " ID_RUN_FRAG " << GetRunInfo()->ID_RUN_FRAG << " EV_FROM " << GetRunInfo()->EV_FROM << endl; @@ -4567,7 +6013,7 @@ while ( (obt != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetOrbitalTime()) || pktn != (UInt_t)(GetEventHeader()->GetPscuHeader()->GetCounter())) && (quellagiusta + (Long64_t) shift) < GetYodaTree()->GetEntries() && shift < maxshift ){ if (shift > 0) { - cout << " PKTNUM L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl; + if (DBG) cout << " PKTNUM L2 --- " << pktn << " --- L0 --- " << GetEventHeader()->GetPscuHeader()->GetCounter() << endl; if (DBG) cout << " RUN: ID " << GetRunInfo()->ID << " ID_ROOT_L0 " << run_obj->ID_ROOT_L0 << " ID_RUN_FRAG " << GetRunInfo()->ID_RUN_FRAG << " EV_FROM " << GetRunInfo()->EV_FROM << endl; @@ -4744,6 +6190,7 @@ void PamLevel2::SetSortingMethod(TString how) { if (howtosort != how) { issorted = false; + issorted_new = false; } howtosort = how; }