source: MEMPHYS/HEAD/run/MEMPHYS_hit.C @ 92

Last change on this file since 92 was 92, checked in by campagne, 18 years ago

new ROOT utilities (JEC)

File size: 1.9 KB
Line 
1void MEMPHYS_hit() {
2
3 
4
5
6  TFile* f = new TFile("MEMPHYS.root");
7  TTree* tEvent = (TTree*)f->Get("Event");
8
9  //declare Non subTuple part
10  Int_t eventId,inputEvtId, interMode, vtxVol;
11  tEvent->SetBranchAddress("eventId",&eventId);
12  tEvent->SetBranchAddress("inputEvtId",&inputEvtId);
13
14  Int_t nHits; 
15  tEvent->SetBranchAddress("nHits",&nHits);
16
17
18  //The Hit Event:subTuple
19  TTree* Event_hit = new TTree();
20  tEvent->SetBranchAddress("hit",&Event_hit);
21  Int_t tubeId_hit; //JEC 16/1/06
22  Int_t totalPE;
23 
24  //The Pe Hit::subTuple
25  TTree* Hit_pe = new TTree();
26  Float_t hit_time;
27
28
29  Int_t nEvent = tEvent->GetEntries();
30
31 
32  //  TList* aListOfH = new TList();
33  TNtuple* newTuple = new TNtuple("ntuple","MEMPHYS hit","i:tubeId:totalPE:time");
34
35  for (Int_t i=0; i<nEvent; ++i){
36    tEvent->GetEntry(i);
37
38    std::cout << ">>>>>>>>>>>>> Event{" << i << "}: "
39              << " evt Id " << eventId
40              << " evt Input Id " << inputEvtId
41              <<" #hits: " << nHits
42              << std::endl;
43
44    Int_t nTubeHits = Event_hit->GetEntries();
45    std::cout << " Hits = " << nTubeHits
46              << std::endl;
47
48
49    // Have a brand new overwritten hit TTree ; we have
50    // to rebind its user variables :
51    Event_hit->SetBranchAddress("tubeId",&tubeId_hit); //JEC 16/1/06   
52    Event_hit->SetBranchAddress("totalPE",&totalPE);
53    Event_hit->SetBranchAddress("pe",&Hit_pe);
54   
55
56    //--------
57    // The Hits
58    //--------
59
60    for (Int_t k=0; k<nTubeHits; ++k) {
61     
62      Event_hit->GetEntry(k);
63
64      Hit_pe->SetBranchAddress("time",&hit_time);
65      //JEC 16/1/06 add the tubeId_hit info
66      //std::cout << "----> Hit{"<<k<<"}: tube[" << tubeId_hit << "] total #PE " << totalPE << std::endl;
67      for (Int_t ki=0; ki<Hit_pe->GetEntries(); ++ki) {
68        Hit_pe->GetEntry(ki);
69        //std::cout << "<" << hit_time << ">";
70
71        ntuple->Fill(i,tubeId_hit,totalPE,hit_time);
72      }
73      //      std::cout << std::endl;
74    }//Loop on Hits
75
76  }//loop on event
77
78
79}//MEMPHYS_hit
Note: See TracBrowser for help on using the repository browser.