[286] | 1 | // |
---|
| 2 | // To help debugging. |
---|
| 3 | // |
---|
| 4 | // This script produces a ELYSE.root file |
---|
| 5 | // with dummy data but with the same "TTree within TTree" |
---|
| 6 | // structure than the file produced by the ELYSE_batch |
---|
| 7 | // program (see Analyis.cxx file). |
---|
| 8 | // |
---|
| 9 | // Usage : |
---|
| 10 | // OS> <setup ROOT> |
---|
| 11 | // OS> root batch_dummy.C |
---|
| 12 | // |
---|
| 13 | // G.Barrand |
---|
| 14 | // |
---|
| 15 | |
---|
| 16 | void batch_dummy() { |
---|
| 17 | |
---|
| 18 | int compress = 1; |
---|
| 19 | TFile f("ELYSE.root","recreate","JEC",compress); |
---|
| 20 | |
---|
| 21 | TTree* event = new TTree("Event",""); |
---|
| 22 | |
---|
| 23 | int eventId,inputEvtId, interMode, vtxVol,nPart,leptonIndex,protonIndex; |
---|
| 24 | event->Branch("eventId",&eventId,"eventId/I"); |
---|
| 25 | event->Branch("inputEvtId",&inputEvtId,"inputEvtId/I"); |
---|
| 26 | event->Branch("interMode",&interMode,"interMode/I"); |
---|
| 27 | event->Branch("vtxVol",&vtxVol,"vtxVol/I"); |
---|
| 28 | event->Branch("nPart",&nPart,"nPart/I"); |
---|
| 29 | event->Branch("leptonIndex",&leptonIndex,"leptonIndex/I"); |
---|
| 30 | event->Branch("protonIndex",&protonIndex,"protonIndex/I"); |
---|
| 31 | int nHits,nDigits; |
---|
| 32 | event->Branch("nHits",&nHits,"nHits/I"); |
---|
| 33 | event->Branch("nDigits",&nDigits,"nDigits/I"); |
---|
| 34 | double sumPE; |
---|
| 35 | event->Branch("sumPE",&sumPE,"sumPE/D"); |
---|
| 36 | |
---|
| 37 | TTree* vtxPos = new TTree("vtxPos",""); |
---|
| 38 | event->Branch("vtxPos",&vtxPos); |
---|
| 39 | double v_x,v_y,v_z; |
---|
| 40 | vtxPos->Branch("x",&v_x,"x/D"); |
---|
| 41 | vtxPos->Branch("y",&v_y,"y/D"); |
---|
| 42 | vtxPos->Branch("z",&v_z,"z/D"); |
---|
| 43 | |
---|
| 44 | TTree* tracks = new TTree("Tracks",""); |
---|
| 45 | event->Branch("track",&tracks); |
---|
| 46 | int pId, parent; |
---|
| 47 | tracks->Branch("pId",&pId,"pId/I"); |
---|
| 48 | tracks->Branch("parent",&parent,"parent/I"); |
---|
| 49 | float timeStart; |
---|
| 50 | tracks->Branch("timeStart",&timeStart,"timeStart/F"); |
---|
| 51 | double mass,pTot,ETot; |
---|
| 52 | tracks->Branch("mass",&mass,"mass/D"); |
---|
| 53 | tracks->Branch("pTot",&pTot,"pTot/D"); |
---|
| 54 | tracks->Branch("ETot",&ETot,"ETot/D"); |
---|
| 55 | int startVol,stopVol; |
---|
| 56 | tracks->Branch("startVol",&startVol,"startVol/I"); |
---|
| 57 | tracks->Branch("stopVol",&stopVol,"stopVol/I"); |
---|
| 58 | |
---|
| 59 | TTree* dir = new TTree("Direction",""); |
---|
| 60 | tracks->Branch("direction",&dir); |
---|
| 61 | double dx,dy,dz; |
---|
| 62 | dir->Branch("dx",&dx,"dx/D"); |
---|
| 63 | dir->Branch("dy",&dy,"dy/D"); |
---|
| 64 | dir->Branch("dz",&dz,"dz/D"); |
---|
| 65 | |
---|
| 66 | TTree* mom = new TTree("Momentum",""); |
---|
| 67 | tracks->Branch("momentum",&mom); |
---|
| 68 | double px,py,pz; |
---|
| 69 | mom->Branch("px",&px,"px/D"); |
---|
| 70 | mom->Branch("py",&py,"py/D"); |
---|
| 71 | mom->Branch("pz",&pz,"pz/D"); |
---|
| 72 | |
---|
| 73 | TTree* startPos = new TTree("startPos",""); |
---|
| 74 | tracks->Branch("startPos",&startPos); |
---|
| 75 | double start_x,start_y,start_z; |
---|
| 76 | startPos->Branch("x",&start_x,"x/D"); |
---|
| 77 | startPos->Branch("y",&start_y,"y/D"); |
---|
| 78 | startPos->Branch("z",&start_z,"z/D"); |
---|
| 79 | |
---|
| 80 | TTree* stopPos = new TTree("stopPos",""); |
---|
| 81 | tracks->Branch("stopPos",&stopPos); |
---|
| 82 | double stop_x,stop_y,stop_z; |
---|
| 83 | stopPos->Branch("x",&stop_x,"x/D"); |
---|
| 84 | stopPos->Branch("y",&stop_y,"y/D"); |
---|
| 85 | stopPos->Branch("z",&stop_z,"z/D"); |
---|
| 86 | |
---|
| 87 | TTree* hits = new TTree("hits",""); |
---|
| 88 | event->Branch("hit",&hits); |
---|
| 89 | int tubeId,totalPE; |
---|
| 90 | hits->Branch("tubeId",&tubeId,"tubeId/I"); |
---|
| 91 | hits->Branch("totalPE",&totalPE,"totalPE/I"); |
---|
| 92 | |
---|
| 93 | TTree* pe = new TTree("pe",""); |
---|
| 94 | hits->Branch("pe",&pe); |
---|
| 95 | float pe_time; |
---|
| 96 | pe->Branch("time",&time,"time/F"); |
---|
| 97 | //float trk_length; |
---|
| 98 | //pe->Branch("length",&trk_length,"length/F"); |
---|
| 99 | |
---|
| 100 | TTree* digits = new TTree("digits",""); |
---|
| 101 | event->Branch("digit",&digits); |
---|
| 102 | int digit_tubeId; |
---|
| 103 | digits->Branch("tubeId",&digit_tubeId,"tubeId/I"); |
---|
| 104 | double digit_pe,time; |
---|
| 105 | digits->Branch("pe",&digit_pe,"pe/D"); |
---|
| 106 | digits->Branch("time",&time,"time/D"); |
---|
| 107 | |
---|
| 108 | //int nrows = 10000000; |
---|
| 109 | int nrows = 10000; |
---|
| 110 | //int nrows = 10; |
---|
| 111 | for (int index=0;index<nrows;index++) { |
---|
| 112 | eventId = index+1; |
---|
| 113 | |
---|
| 114 | interMode = 0; |
---|
| 115 | vtxVol = 0; |
---|
| 116 | leptonIndex = 0; |
---|
| 117 | protonIndex = 0; |
---|
| 118 | |
---|
| 119 | vtxPos->Reset(); |
---|
| 120 | // once : |
---|
| 121 | v_x = 0; |
---|
| 122 | v_y = 0; |
---|
| 123 | v_z = 0; |
---|
| 124 | vtxPos->Fill(); |
---|
| 125 | |
---|
| 126 | nPart = 1+(int) (10.0*rand()/(RAND_MAX+1.0)); //[1,10] |
---|
| 127 | |
---|
| 128 | tracks->Reset(); |
---|
| 129 | for (int ipart=1; ipart<=nPart; ++ipart) { |
---|
| 130 | pId = -10+(int) (20.0*rand()/(RAND_MAX+1.0)); //[-10,10] |
---|
| 131 | parent = 1+(int) (ipart*rand()/(RAND_MAX+1.0)); //[1,ipart+1] |
---|
| 132 | timeStart = 0; |
---|
| 133 | mass = 0; |
---|
| 134 | pTot = 0; |
---|
| 135 | ETot = 10.; |
---|
| 136 | startVol = 0; |
---|
| 137 | stopVol = 0; |
---|
| 138 | |
---|
| 139 | dir->Reset(); |
---|
| 140 | // once : |
---|
| 141 | dx = 1; |
---|
| 142 | dy = 0; |
---|
| 143 | dz = 0; |
---|
| 144 | dir->Fill(); |
---|
| 145 | |
---|
| 146 | mom->Reset(); |
---|
| 147 | // once : |
---|
| 148 | px = 1; |
---|
| 149 | py = 2; |
---|
| 150 | pz = 3; |
---|
| 151 | mom->Fill(); |
---|
| 152 | |
---|
| 153 | startPos->Reset(); |
---|
| 154 | // once : |
---|
| 155 | start_x = 1; |
---|
| 156 | start_y = 2; |
---|
| 157 | start_z = 3; |
---|
| 158 | startPos->Fill(); |
---|
| 159 | |
---|
| 160 | stopPos->Reset(); |
---|
| 161 | // once : |
---|
| 162 | stop_x = 1; |
---|
| 163 | stop_y = 2; |
---|
| 164 | stop_z = 3; |
---|
| 165 | stopPos->Fill(); |
---|
| 166 | |
---|
| 167 | tracks->Fill(); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | //nHits = 0; |
---|
| 171 | nHits = (int) (10.0*rand()/(RAND_MAX+1.0)); |
---|
| 172 | hits->Reset(); |
---|
| 173 | for (int ihit=1; ihit<=nHits; ++ihit) { |
---|
| 174 | tubeId = 0; |
---|
| 175 | totalPE = 0; |
---|
| 176 | |
---|
| 177 | pe->Reset(); |
---|
| 178 | // once : |
---|
| 179 | pe_time = 0; |
---|
| 180 | //trk_length = 3; |
---|
| 181 | pe->Fill(); |
---|
| 182 | |
---|
| 183 | hits->Fill(); |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | //nDigits = 0; |
---|
| 187 | nDigits = (int) (10.0*rand()/(RAND_MAX+1.0)); |
---|
| 188 | digits->Reset(); |
---|
| 189 | for (int idigit=1; idigit<=nDigits; ++idigit) { |
---|
| 190 | digit_tubeId = 0; |
---|
| 191 | digit_pe = 0; |
---|
| 192 | time = 0; |
---|
| 193 | digits->Fill(); |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | sumPE = 314; |
---|
| 197 | |
---|
| 198 | event->Fill(); |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | event->AutoSave(); |
---|
| 202 | f.Close(); |
---|
| 203 | |
---|
| 204 | } |
---|