hi,
thank you for your reply
for a complete answer the TTree contains about 25Mevents and I am sure that they are already ordered (this was for testing the macro)
I use this macro to read the .root file ( I copy the entire Macro)
[code]#include “TTreeIndex.h”
#include “TTree.h”
#include “TFile.h”
#include <stdio.h>
#include
#include
#include <string.h>
using namespace std;
Int_t TNT2_analysis(TString s = “pippo”)
{
Int_t Channel_Number; // number of the channel in the selected TNT card. These numbers could be equal for all cards.
Int_t Card_Number; // number of the card used in the DAQ
Long64_t Energy; // energy is the channel position in the spectra
Long64_t Event_Time; // the time when the event happens
Long64_t Trigger_Number; // trigger associated to that event
Long64_t temp;
if(s == "pippo") {
cout << "nessun file da analizzare" << endl;
return 0;
}
TFile f(s);
if (f.IsZombie()) {
std::cout << "Error opening file" << std::endl;
exit(-1);
}
cout << "aperto il file" << endl;
TTree *myTree = (TTree*) f.Get("TNTtree");
myTree->SetBranchAddress("Card_Number",&Card_Number);
myTree->SetBranchAddress("Channel_Number",&Channel_Number);
myTree->SetBranchAddress("Energy",&Energy);
myTree->SetBranchAddress("Event_Time",&Event_Time);
myTree->SetBranchAddress("Trigger_Number",&Trigger_Number);
//read the number of entries in the t3
//Long64_t nentries = myTree->GetEntries();
for (Long64_t i = 0; i < 20; i++){
myTree->GetEntry(i);
cout << "normal: " << Card_Number << “\t” << Channel_Number << “\t” << Energy << “\t” << Event_Time << “\t” << Trigger_Number << endl;
}
myTree->BuildIndex(“Event_Time”);
TTreeIndex index = (TTreeIndex)myTree->GetTreeIndex();
cout << “indicizzato” << endl;
for(Long64_t i = 0; i < 20 ; i++ ) {
Long64_t local = myTree->LoadTree( index->GetIndex()[i] );
Long64_t local2 = myTree->LoadTree( index->GetIndex()[i+1] );
myTree->GetEntry(local);
cout << "I: " << local << “\t” << Card_Number << “\t” << Channel_Number << “\t” << Energy << “\t” << Event_Time << “\t” << Trigger_Number << endl;
temp = Event_Time;
myTree->GetEntry(local2);
cout << "II: " << local2 << “\t” << Card_Number << “\t” << Channel_Number << “\t” << Energy << “\t” << Event_Time << “\t” << Trigger_Number << endl;
if(temp > Event_Time)
cout << “not good” << endl;
else
cout << “good” << endl;
}
return 1;
}[/code]
here there is what it prints as output
aperto il file
normal: 232 1 1521 884419 1
normal: 232 2 1525 884419 1
normal: 232 3 1512 884419 1
normal: 232 4 1496 884419 1
normal: 232 1 1516 1883373 2
normal: 232 2 1522 1883373 2
normal: 232 3 1510 1883373 2
normal: 232 4 1496 1883373 2
normal: 232 1 1521 2882429 3
normal: 232 2 1528 2882429 3
normal: 232 3 1516 2882429 3
normal: 232 4 1497 2882429 3
normal: 232 1 1519 3881302 4
normal: 232 2 1524 3881302 4
normal: 232 3 1508 3881302 4
normal: 232 4 1494 3881302 4
normal: 232 1 1521 4880247 5
normal: 232 2 1529 4880247 5
normal: 232 3 1514 4880247 5
normal: 232 4 1498 4880247 5
indicizzato
I: 18891849 232 2 1516 4720169059241 4722966
II: 18891851 232 4 1489 4720169059241 4722966
good
I: 18891851 232 4 1489 4720169059241 4722966
II: 18891850 232 3 1504 4720169059241 4722966
good
I: 18891850 232 3 1504 4720169059241 4722966
II: 18891848 232 1 1509 4720169059241 4722966
good
I: 18891848 232 1 1509 4720169059241 4722966
II: 23467527 232 4 1497 5862630361491 5866885
good
I: 23467527 232 4 1497 5862630361491 5866885
II: 23467526 232 3 1515 5862630361491 5866885
good
I: 23467526 232 3 1515 5862630361491 5866885
II: 23467525 232 2 1525 5862630361491 5866885
good
I: 23467525 232 2 1525 5862630361491 5866885
II: 23467524 232 1 1517 5862630361491 5866885
good
I: 23467524 232 1 1517 5862630361491 5866885
II: 8200706 232 3 1506 2048699407851 2050180
not good
I: 8200706 232 3 1506 2048699407851 2050180
II: 8200704 232 1 1517 2048699407851 2050180
good
I: 8200704 232 1 1517 2048699407851 2050180
II: 8200705 232 2 1520 2048699407851 2050180
good
I: 8200705 232 2 1520 2048699407851 2050180
II: 8200707 232 4 1491 2048699407851 2050180
good
I: 8200707 232 4 1491 2048699407851 2050180
II: 21886663 232 4 1485 5467493380773 5471669
good
I: 21886663 232 4 1485 5467493380773 5471669
II: 21886662 232 3 1500 5467493380773 5471669
good
I: 21886662 232 3 1500 5467493380773 5471669
II: 21886661 232 2 1515 5467493380773 5471669
good
I: 21886661 232 2 1515 5467493380773 5471669
II: 21886660 232 1 1507 5467493380773 5471669
good
I: 21886660 232 1 1507 5467493380773 5471669
II: 17377884 232 1 1529 4342211950118 4344475
not good
I: 17377884 232 1 1529 4342211950118 4344475
II: 17377885 232 2 1534 4342211950118 4344475
good
I: 17377885 232 2 1534 4342211950118 4344475
II: 17377887 232 4 1509 4342211950118 4344475
good
I: 17377887 232 4 1509 4342211950118 4344475
II: 17377886 232 3 1525 4342211950118 4344475
good
I: 17377886 232 3 1525 4342211950118 4344475
II: 6378459 232 4 1499 1593432880855 1594618
not good
as you can see if I sue the index made with built index it prints lotto numbers (I mean, those entries are in the TTree but for sure it is not able to order it properly)
thank you for your help
ciao
Antonio