181 |
CaloTrkVar *c = 0; |
CaloTrkVar *c = 0; |
182 |
ToFTrkVar *o = 0; |
ToFTrkVar *o = 0; |
183 |
|
|
184 |
c = GetCaloStoredTrack(t->GetSeqNo()); |
if(CAL) c = GetCaloStoredTrack(t->GetSeqNo()); |
185 |
o = GetToFStoredTrack(t->GetSeqNo()); |
if(TOF) o = GetToFStoredTrack(t->GetSeqNo()); |
186 |
|
|
187 |
// if(t && c && o)track = new PamTrack(t,c,o); |
// if(t && c && o)track = new PamTrack(t,c,o); |
188 |
PamTrack *track = new PamTrack(t,c,o); |
PamTrack *track = new PamTrack(t,c,o); |
243 |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
Bool_t use_CAL = how.Contains("CAL", TString::kIgnoreCase); |
244 |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
Bool_t use_TOF = how.Contains("TOF", TString::kIgnoreCase); |
245 |
|
|
246 |
|
if( !CAL && use_CAL) use_CAL = false; |
247 |
|
if( !TOF && use_TOF) use_TOF = false; |
248 |
|
|
249 |
|
if( !TRK ){ |
250 |
|
cout << "SortTracks() : without tracker does not work!!! (not yet)" << endl; |
251 |
|
return; |
252 |
|
}; |
253 |
|
|
254 |
for(Int_t i=0; i < TrkLevel2::GetNTracks(); i++){ |
for(Int_t i=0; i < TrkLevel2::GetNTracks(); i++){ |
255 |
|
|
257 |
|
|
258 |
// get tracker tracks |
// get tracker tracks |
259 |
TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker |
TrkTrack *tp = TrkLevel2::GetTrack(i); //tracker |
260 |
CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
// CaloTrkVar *cp = GetCaloStoredTrack(tp->GetSeqNo()); |
261 |
ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
// ToFTrkVar *op = GetToFStoredTrack(tp->GetSeqNo()); |
262 |
|
CaloTrkVar *cp = 0; |
263 |
|
ToFTrkVar *op = 0; |
264 |
|
|
265 |
// if track has an image, check image selection |
// if track has an image, check image selection |
266 |
if(tp->HasImage()){ |
if(tp->HasImage()){ |
267 |
|
|
268 |
TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image) |
TrkTrack *ti = TrkLevel2::GetTrackImage(i); //tracker (image) |
269 |
CaloTrkVar *ci = GetCaloStoredTrack(ti->GetSeqNo()); |
// CaloTrkVar *ci = GetCaloStoredTrack(ti->GetSeqNo()); |
270 |
ToFTrkVar *oi = GetToFStoredTrack(ti->GetSeqNo()); |
// ToFTrkVar *oi = GetToFStoredTrack(ti->GetSeqNo()); |
271 |
|
CaloTrkVar *ci = 0; |
272 |
|
ToFTrkVar *oi = 0; |
273 |
|
|
274 |
//assign starting scores |
//assign starting scores |
275 |
Int_t tp_score = 0; //main track sorted by the tracker |
Int_t tp_score = 0; //main track sorted by the tracker |
286 |
varcfit[1] < 1000. && //fit variance on Y view |
varcfit[1] < 1000. && //fit variance on Y view |
287 |
true){ |
true){ |
288 |
|
|
289 |
|
cp = GetCaloStoredTrack(tp->GetSeqNo()); |
290 |
|
ci = GetCaloStoredTrack(ti->GetSeqNo()); |
291 |
|
|
292 |
Float_t resy_p = cp->tbar[0][1] - cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
Float_t resy_p = cp->tbar[0][1] - cbar[0][1]; if(resy_p < 0)resy_p= - resy_p; |
293 |
Float_t resy_i = ci->tbar[0][1] - cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
Float_t resy_i = ci->tbar[0][1] - cbar[0][1]; if(resy_i < 0)resy_i= - resy_i; |
294 |
|
|
300 |
// ------------------------ |
// ------------------------ |
301 |
// check the number of hit pmts along the track |
// check the number of hit pmts along the track |
302 |
// on S12 S21 and S32, where paddles are parallel to Y axis |
// on S12 S21 and S32, where paddles are parallel to Y axis |
303 |
Int_t nphit_p =0; |
if( use_TOF ){ |
|
Int_t nphit_i =0; |
|
|
|
|
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
|
|
Int_t pl = GetPlaneIndex( (op->pmtadc).At(ih) ); |
|
|
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
|
|
}; |
|
|
|
|
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
|
|
Int_t pl = GetPlaneIndex( (oi->pmtadc).At(ih) ); |
|
|
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
|
|
}; |
|
304 |
|
|
305 |
if( |
Int_t nphit_p =0; |
306 |
use_TOF && |
Int_t nphit_i =0; |
307 |
(nphit_p+nphit_i) !=0 && |
|
308 |
true){ |
op = GetToFStoredTrack(tp->GetSeqNo()); |
309 |
|
oi = GetToFStoredTrack(ti->GetSeqNo()); |
310 |
if( nphit_p >= nphit_i) tp_score++; |
|
311 |
else ti_score++; |
/* cout << "track: npmtadc "<< op->npmtadc << endl; |
312 |
|
cout << "track: npmttdc "<< op->npmttdc << endl; |
313 |
|
cout << "image: npmtadc "<< oi->npmtadc << endl; |
314 |
|
cout << "image: npmttdc "<< oi->npmttdc << endl;*/ |
315 |
|
|
316 |
|
for (Int_t ih=0; ih < op->npmtadc; ih++){ |
317 |
|
Int_t pl = GetPlaneIndex( (op->pmtadc).At(ih) ); |
318 |
|
if(pl == 1 || pl == 2 || pl == 5)nphit_p++; |
319 |
|
}; |
320 |
|
|
321 |
|
for (Int_t ih=0; ih < oi->npmtadc; ih++){ |
322 |
|
Int_t pl = GetPlaneIndex( (oi->pmtadc).At(ih) ); |
323 |
|
if(pl == 1 || pl == 2 || pl == 5)nphit_i++; |
324 |
|
}; |
325 |
|
|
326 |
|
if( |
327 |
|
use_TOF && |
328 |
|
(nphit_p+nphit_i) !=0 && |
329 |
|
true){ |
330 |
|
|
331 |
|
if( nphit_p >= nphit_i) tp_score++; |
332 |
|
else ti_score++; |
333 |
|
}; |
334 |
}; |
}; |
|
|
|
335 |
if(tp_score == ti_score) use_TRK = true; |
if(tp_score == ti_score) use_TRK = true; |
336 |
// ------------------------ |
// ------------------------ |
337 |
// tracker check |
// tracker check |
381 |
*/ |
*/ |
382 |
TRefArray *PamLevel2::GetTracks(){ |
TRefArray *PamLevel2::GetTracks(){ |
383 |
// |
// |
384 |
SortTracks("+CAL+TOF"); |
// SortTracks("+CAL+TOF"); |
385 |
|
SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!! |
386 |
// |
// |
387 |
return sorted_tracks; |
return sorted_tracks; |
388 |
}; |
}; |
398 |
PamTrack *PamLevel2::GetTrack(int it){ |
PamTrack *PamLevel2::GetTrack(int it){ |
399 |
|
|
400 |
// *-*-*-*-*-*-* |
// *-*-*-*-*-*-* |
401 |
SortTracks("+CAL+TOF"); |
// SortTracks("+CAL+TOF"); |
402 |
|
SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!! |
403 |
// *-*-*-*-*-*-* |
// *-*-*-*-*-*-* |
404 |
|
|
405 |
PamTrack *track = 0; |
PamTrack *track = 0; |
426 |
*/ |
*/ |
427 |
PamTrack *PamLevel2::GetTrackImage(int it){ |
PamTrack *PamLevel2::GetTrackImage(int it){ |
428 |
|
|
429 |
SortTracks("+CAL+TOF"); |
// SortTracks("+CAL+TOF"); |
430 |
|
SortTracks("+CAL+TRK");//TEMP!!!!!!!!!!!!! |
431 |
|
|
432 |
PamTrack *image = 0; |
PamTrack *image = 0; |
433 |
|
|
458 |
*/ |
*/ |
459 |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist="+ALL"){ |
TTree *PamLevel2::GetPamTree(TFile *f, TString detlist="+ALL"){ |
460 |
|
|
461 |
cout << "WARNING!!! -- obsolete method -- \n"; |
// cout << "WARNING!!! -- obsolete method -- \n"; |
462 |
cout << "better use TChain *PamLevel2::GetPamTree(TList*, TString) \n"; |
// cout << "better use TChain *PamLevel2::GetPamTree(TList*, TString) \n"; |
463 |
|
|
464 |
TTree *Trout =0; |
TTree *Trout =0; |
465 |
|
|
473 |
}; |
}; |
474 |
T->SetBranchAddress("TrkLevel2", GetPointerToTrk(2)); |
T->SetBranchAddress("TrkLevel2", GetPointerToTrk(2)); |
475 |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
cout << "Tracker : set branch address TrkLevel2"<<endl; |
476 |
|
Trout=T; |
477 |
}else{ |
}else{ |
478 |
cout << "Tracker : missing tree"<<endl; |
cout << "Tracker : missing tree"<<endl; |
479 |
}; |
}; |
548 |
cout << "OrbitalInfo : missing tree"<<endl; |
cout << "OrbitalInfo : missing tree"<<endl; |
549 |
}; |
}; |
550 |
|
|
551 |
return Trout; |
cout<<endl<<" Number of entries: "<<Trout->GetEntries()<<endl<<endl; |
|
|
|
|
} |
|
|
//-------------------------------------- |
|
|
// |
|
|
// |
|
|
//-------------------------------------- |
|
|
/** |
|
|
* Get all the Pamela detector trees in a single file and make them friends. |
|
|
* @param f TFile pointer |
|
|
* @return Pointer to a TTree |
|
|
*/ |
|
|
/*TTree *PamLevel2::GetPamTree(TFile *f){ |
|
|
|
|
552 |
|
|
553 |
TTree *Tout =0; |
return Trout; |
|
|
|
|
SetWhichTrees("+ALL"); |
|
|
|
|
|
// Tracker |
|
|
TTree *T = (TTree*)f->Get("Tracker"); |
|
|
if(T && TRK) { |
|
|
T->SetBranchAddress("TrkLevel2", GetPointerToTrk()); |
|
|
cout << "Tracker : set branch address TrkLevel2"<<endl; |
|
|
if(!Tout)Tout=T; |
|
|
}else{ |
|
|
cout << "Tracker : missing tree"<<endl; |
|
|
}; |
|
|
// Calorimeter |
|
|
TTree *C = (TTree*)f->Get("Calorimeter"); |
|
|
if(C && CAL) { |
|
|
C->SetBranchAddress("CaloLevel2", GetPointerToCalo()); |
|
|
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
|
|
if(!Tout)Tout=C; |
|
|
else Tout->AddFriend(C); |
|
|
}else{ |
|
|
cout << "Calorimeter : missing tree"<<endl; |
|
|
}; |
|
|
// ToF |
|
|
TTree *O = (TTree*)f->Get("ToF"); |
|
|
if(O && TOF) { |
|
|
O->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
|
|
cout << "ToF : set branch address ToFLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(O); |
|
|
}else{ |
|
|
cout << "ToF : missing tree"<<endl; |
|
|
}; |
|
|
// Trigger |
|
|
TTree *R = (TTree*)f->Get("Trigger"); |
|
|
if(R && TRG) { |
|
|
R->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
|
|
cout << "Trigger : set branch address TrigLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(R); |
|
|
}else{ |
|
|
cout << "Trigger : missing tree"<<endl; |
|
|
}; |
|
|
// S4 |
|
|
TTree *S = (TTree*)f->Get("S4"); |
|
|
if(S && S4) { |
|
|
S->SetBranchAddress("S4Level2", GetPointerToS4()); |
|
|
cout << "S4 : set branch address S4Level2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(S); |
|
|
}else{ |
|
|
cout << "S4 : missing tree"<<endl; |
|
|
}; |
|
|
// Neutron Detector |
|
|
TTree *N = (TTree*)f->Get("NeutronD"); |
|
|
if(N && ND) { |
|
|
N->SetBranchAddress("NDLevel2", GetPointerToND()); |
|
|
cout << "NeutronD : set branch address NDLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(N); |
|
|
}else{ |
|
|
cout << "NeutronD : missing tree"<<endl; |
|
|
}; |
|
|
// Anticounters |
|
|
TTree *A = (TTree*)f->Get("Anticounter"); |
|
|
if(A && AC) { |
|
|
A->SetBranchAddress("AcLevel2", GetPointerToAc()); |
|
|
cout << "Anticounter : set branch address AcLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(A); |
|
|
}else{ |
|
|
cout << "Anticounter : missing tree"<<endl; |
|
|
}; |
|
|
// Orbital Info |
|
|
TTree *B = (TTree*)f->Get("OrbitalInfo"); |
|
|
if(B && ORB) { |
|
|
B->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
|
|
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend(B); |
|
|
}else{ |
|
|
cout << "OrbitalInfo : missing tree"<<endl; |
|
|
}; |
|
|
|
|
|
return Tout; |
|
554 |
|
|
555 |
}*/ |
} |
556 |
//-------------------------------------- |
//-------------------------------------- |
557 |
// |
// |
558 |
// |
// |
570 |
|
|
571 |
if(ddir=="")ddir = wdir; |
if(ddir=="")ddir = wdir; |
572 |
// TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
// TSystemDirectory *datadir = new TSystemDirectory(gSystem->BaseName(ddir),ddir); |
573 |
cout << "Level2 data directory : "<< endl << ddir << endl; |
cout << "Level2 data directory : "<< ddir << endl; |
574 |
|
|
575 |
TList *contents = new TList; // create output list |
TList *contents = new TList; // create output list |
576 |
contents->SetOwner(); |
contents->SetOwner(); |
587 |
|
|
588 |
if( !gSystem->ChangeDirectory(ddir) )return 0; |
if( !gSystem->ChangeDirectory(ddir) )return 0; |
589 |
|
|
590 |
cout <<"Input file list : "<< endl << flisttxt <<endl; |
cout <<"Input file list : " << flisttxt <<endl; |
591 |
ifstream in; |
ifstream in; |
592 |
in.open(flisttxt, ios::in); //open input file list |
in.open(flisttxt, ios::in); //open input file list |
593 |
while (1) { |
while (1) { |
632 |
|
|
633 |
}; |
}; |
634 |
gSystem->ChangeDirectory(wdir); // back to the working directory |
gSystem->ChangeDirectory(wdir); // back to the working directory |
635 |
cout << endl << "Selected files:" << endl; |
// cout << endl << "Selected files:" << endl; |
636 |
contents->Print(); |
// contents->Print(); |
637 |
cout << endl; |
cout << contents->GetEntries()<<" files selected\n"; |
638 |
|
// cout << endl; |
639 |
// cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; |
// cout << "Working directory: "<< gSystem->WorkingDirectory()<< endl; |
640 |
return contents; |
return contents; |
641 |
}; |
}; |
692 |
if(ORB) B->Add(name); |
if(ORB) B->Add(name); |
693 |
}; |
}; |
694 |
} |
} |
|
|
|
|
/* // Tracker |
|
|
if(TRK) { |
|
|
if(TRK_L1){ |
|
|
T->SetBranchAddress("TrkLevel1", GetPointerToTrk(1)); |
|
|
cout << "Tracker : set branch address TrkLevel1"<<endl; |
|
|
}; |
|
|
T->SetBranchAddress("TrkLevel2", GetPointerToTrk(2)); |
|
|
cout << "Tracker : set branch address TrkLevel2"<<endl; |
|
695 |
|
|
|
if(!Tout)Tout=T; |
|
|
}; |
|
|
|
|
|
// Calorimeter |
|
|
if(CAL) { |
|
|
C->SetBranchAddress("CaloLevel2", GetPointerToCalo()); |
|
|
cout << "Calorimeter : set branch address CaloLevel2"<<endl; |
|
|
if(!Tout)Tout=C; |
|
|
else Tout->AddFriend("Calorimeter"); |
|
|
}; |
|
|
|
|
|
// ToF |
|
|
if(TOF) { |
|
|
O->SetBranchAddress("ToFLevel2", GetPointerToToF()); |
|
|
cout << "ToF : set branch address ToFLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend("ToF"); |
|
|
}; |
|
|
// Trigger |
|
|
if(TRG) { |
|
|
R->SetBranchAddress("TrigLevel2", GetPointerToTrig()); |
|
|
cout << "Trigger : set branch address TrigLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend("Trigger"); |
|
|
}; |
|
|
// S4 |
|
|
if(S4) { |
|
|
S->SetBranchAddress("S4Level2", GetPointerToS4()); |
|
|
cout << "S4 : set branch address S4Level2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend("S4"); |
|
|
}; |
|
|
// Neutron Detector |
|
|
if(ND) { |
|
|
N->SetBranchAddress("NDLevel2", GetPointerToND()); |
|
|
cout << "NeutronD : set branch address NDLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend("NeutronD"); |
|
|
}; |
|
|
// Anticounters |
|
|
if(AC) { |
|
|
A->SetBranchAddress("AcLevel2", GetPointerToAc()); |
|
|
cout << "Anticounter : set branch address AcLevel2"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend("Anticounter"); |
|
|
}; |
|
|
// OrbitalInfo |
|
|
if(ORB) { |
|
|
B->SetBranchAddress("OrbitalInfo", GetPointerToOrb()); |
|
|
cout << "OrbitalInfo : set branch address OrbitalInfo"<<endl; |
|
|
if(!Tout)Tout=O; |
|
|
else Tout->AddFriend("OrbitalInfo"); |
|
|
}; |
|
|
|
|
|
cout<<endl<<" Number of entries: "<<Tout->GetEntries()<<endl<<endl;*/ |
|
|
|
|
696 |
// Tracker |
// Tracker |
697 |
if(TRK) if(!Tout)Tout=T; |
if(TRK) if(!Tout)Tout=T; |
698 |
|
|