--- PamelaLevel2/src/PamLevel2.cpp 2014/10/15 08:51:51 1.95 +++ PamelaLevel2/src/PamLevel2.cpp 2014/10/17 15:58:09 1.100 @@ -374,14 +374,18 @@ PamTrack::PamTrack(const PamTrack& track) { TrkTrack *t = track.trk_track; + ExtTrack *e = track.trk_ext_track; CaloTrkVar *c = track.calo_track; ToFTrkVar *o = track.tof_track; OrbitalInfoTrkVar *r = track.orb_track; - trk_track = 0; - calo_track = 0; - tof_track = 0; - orb_track = 0; + trk_ext_track = 0; + trk_track = 0; + calo_track = 0; + tof_track = 0; + orb_track = 0; + if(e) + trk_ext_track = new ExtTrack(*e); if (t) trk_track = new TrkTrack(*t); if (c) @@ -390,18 +394,19 @@ tof_track = new ToFTrkVar(*o); if (r) orb_track = new OrbitalInfoTrkVar(*r); + candeleteobj = 1; pscore = 0; iscore = 0; } -void PamTrack::Clear() { +void PamTrack::Clear(Option_t *option) { - // cout << "PamTrack::Clear() "<ExtTrack::Clear(); + trk_ext_track->ExtTrack::Clear(option); if (trk_track) trk_track->TrkTrack::Clear(); if (calo_track) @@ -426,7 +431,7 @@ // cout << "PamTrack::Delete() "<ExtTrack::Clear(); + trk_ext_track->ExtTrack::Clear("C"); delete trk_ext_track; } if (trk_track) { @@ -561,6 +566,7 @@ run_obj = 0;//new GL_RUN(); soft_obj = 0;// Emiliano + proc_obj = 0;// Emiliano irun = -1LL; irunt = -1LL; totrunentry = 0LL; @@ -571,6 +577,7 @@ 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; @@ -586,6 +593,10 @@ run_tree = NULL; run_tree_clone = NULL; + + proc_tree = NULL; + proc_tree_clone = NULL; + sel_tree = NULL; sel_tree_clone = NULL; @@ -633,11 +644,12 @@ ND = true; AC = true; ORB = true; + PROC = true; GP = false; EXT = false; NUC = false; - trkAlg = "";//default tracking algorythm + trkAlg = "STD";//default tracking algorythm RUN = true; @@ -675,6 +687,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(); @@ -978,6 +994,7 @@ ac_obj = 0; orb2_obj = 0; gp_obj = 0; + proc_obj = 0; trk_ext_obj = 0; trk_ext_nuc_obj = 0; @@ -1009,6 +1026,7 @@ // run_obj = 0;//new GL_RUN(); soft_obj = 0;// Emiliano + proc_obj = 0;// Emiliano irun = -1; irunt = -1; totrunentry = 0LL; @@ -1183,6 +1201,12 @@ if (!objname.CompareTo("SoftInfo")) return &soft_obj; // Emiliano + if (!objname.CompareTo("ProcessingInfo")){ + if (!proc_obj) + proc_obj = new ProcInfo(); + return &proc_obj; // Emiliano + } + return NULL; } ; @@ -1448,12 +1472,12 @@ // create TCloneArrays to store tracks and its images if (!tsorted) tsorted = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); - tsorted->Delete(); + tsorted->Clear("C+C");//Delete(); TClonesArray &ttsorted = *tsorted; if (!timage) timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); - timage->Delete(); + timage->Clear("C+C");//Delete(); TClonesArray &ttimage = *timage; @@ -1989,36 +2013,55 @@ //----------------------------------------------------------- // create/reset TCloneArrays to store tracks and their images //----------------------------------------------------------- + +// cout << " PamLevel2::SortTracksNew() --- Clear TClonesArray objects"<GetNTracks()); - tsorted->Delete(); - // track images from standard alg - if (!timage) - timage = new TClonesArray("PamTrack", trk2_obj->GetNTracks()); - timage->Delete(); - // tracks from extended algorythm - if(EXT && !text) - text = new TClonesArray("PamTrack",trk_ext_obj->GetEntries()); - if(text)text->Delete(); +// if (!tsorted) +// tsorted = new TClonesArray("PamTrack", trk2_obj->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->Delete(); - // track images from standard alg - if (!timage_nuc) - timage_nuc = new TClonesArray("PamTrack", trk2_nuc_obj->GetNTracks()); - timage_nuc->Delete(); - // tracks from extended algorythm - if(EXT && !text_nuc) - text_nuc = new TClonesArray("PamTrack",trk_ext_nuc_obj->GetEntries()); - if(text_nuc)text_nuc->Delete(); +// 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 @@ -2580,7 +2623,7 @@ /** * 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(){ @@ -2598,12 +2641,13 @@ // // //-------------------------------------- + /** * Retrieves the it-th Pamela "physical" track. * It override TrkLevel2::GetTrack(int it). * @param it Track number, ranging from 0 to GetNTracks(). */ -PamTrack *PamLevel2::GetTrack(int it) { +PamTrack *PamLevel2::GetTrackOld(int it) { PamTrack *track = NULL; @@ -2620,7 +2664,7 @@ 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; }; @@ -2636,10 +2680,10 @@ * @param it Track number, ranging from 0 to GetNTracks(). * @param alg Algorythm, see SetTrakingAlgorythm(char *alg) for explanation. */ -PamTrack *PamLevel2::GetTrack(int it, char* alg) { +PamTrack *PamLevel2::GetTrack(int it, const char* alg) { TString s(alg); - if(!s.CompareTo("") ||!s.CompareTo("STD") )return GetTrack(it); //old algorythm + if(!s.CompareTo("") ||!s.CompareTo("STD") )return GetTrackOld(it); //old algorythm SortTracksNew(); @@ -2687,6 +2731,7 @@ }; + cout << "PamTrack *PamLevel2::GetTrack("<GetEntries() "<GetEntries()<<" trk2_nuc_obj->GetNTracks() "<GetNTracks()<TrkLevel2::GetNTracks(); + cout << "Int_t PamLevel2::GetNTracks("<GetTrkTrack()->HasImage()) { return (PamTrack*)((*timage_nuc)[it]); //ok return the track + }else{ + return NULL; } } @@ -2805,11 +2854,15 @@ PamTrack *temp = (PamTrack*) t[it]; if (temp->GetTrkTrack()->HasImage()) { return (PamTrack*)((*timage)[it]); //ok return the track + }else{ + return NULL; } } } } + + cout << "PamTrack *PamLevel2::GetTrackImage("<Add(name); if (GP) G->Add(name); + if (P) + P->Add(name); if (SELLI == 1) L->Add(name); }; @@ -3440,6 +3498,13 @@ L->Delete(); }; + //ProcessingInfo EM + if ( P && P->GetEntries() ){ + cout << "----------------------------------------------------" << endl; + cout << ">>> Found ProcessingInfo <<<" << endl; + // L->SetBranchAddress("RunEntry",&irun); + P->SetBranchAddress("ProcInfo", &proc_obj);//NEWNEW + } // -------------------------------------------- // return the pamela chain with all the friends // -------------------------------------------- @@ -3767,36 +3832,36 @@ * "NUCEXT" --> as "EXT", but for nuclei * "NUCEXTF" --> as "EXTF", but for nuclei */ -void PamLevel2::SetTrakingAlgorythm(char *alg){ +// 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<> "< 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<> "<GetName()<IsZombie()) { cout << "File: " << f->GetName() << " Non valid root file" << endl; + fDiscarded = true; return; } @@ -4743,6 +4809,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; @@ -4795,6 +4863,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; @@ -4808,6 +4877,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; @@ -4821,6 +4891,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; @@ -4835,6 +4906,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; @@ -4848,6 +4920,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; @@ -4861,6 +4934,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; @@ -4874,6 +4948,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; @@ -4897,6 +4972,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; @@ -4919,6 +4995,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; @@ -4931,10 +5008,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; } @@ -4973,51 +5052,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; }; @@ -5117,8 +5208,33 @@ // cout << i<< "\t | "<ID<<"\t "<NEVENTS<< "\t "<RUNHEADER_TIME<<" <---> "<RUNTRAILER_TIME<Fill(); } - cout << "----------------------------------------------------" << endl; - + if ( PROC ){ + proc_tree_clone->Branch("ProcessingInfo", "ProcInfo", GetPointerTo("ProcessingInfo")); + cout << "ProcessingInfo: branch ProcessingInfo" << endl; + // ------------------ + // replicate processinginfo tree + // ------------------ + // cout << "----------------------------------------------------"<GetEntries(); i++) { + proc_tree->GetEntry(i); + // cout << i<< "\t | "<ID<<"\t "<NEVENTS<< "\t "<RUNHEADER_TIME<<" <---> "<RUNTRAILER_TIME<Fill(); + } + if ( SELLI != 2 || true ){ + proc_obj->runID = 0; + TTimeStamp *dt = new TTimeStamp(); + proc_obj->date = dt->AsString(); + delete dt; + proc_obj->commandLine = Form("PamelaLevel2 was called"); + proc_obj->outputFilename = ""; + proc_obj->localDir = gSystem->WorkingDirectory(); + proc_obj->uname = gSystem->GetFromPipe("uname -a"); + proc_obj->DB = Form("mysql://%s/%s",dbc->GetHost(),dbc->GetDB()); + proc_tree_clone->Fill(); + } + cout << "----------------------------------------------------" << endl; + } // ------------------------------------ // add branch with dead and live times // ------------------------------------ @@ -5309,6 +5425,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; } @@ -5328,9 +5449,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 ){ + proc_tree_clone->Write("ProcessingInfo",TObject::kOverwrite); + } cout << "+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" << endl; }