00001
00002 #include <map>
00003 #include "TKey.h"
00004 #include "TList.h"
00005 #include <TROOT.h>
00006 #include <TRint.h>
00007 #include <TKey.h>
00008 #include <TList.h>
00009 #include <TTree.h>
00010 #include <TFile.h>
00011 #include <stdlib.h>
00012 #include <TSystem.h>
00013 #include <iostream>
00014 #include <sstream>
00015 #include "Log.hh"
00016
00017 #include "MicroException.hh"
00018 #include <string>
00019
00020 #include "mysql/Mysql.hh"
00021
00022
00023 #include "root/MTRun.hh"
00024 #include "root/MTTrack.hh"
00025 #include "root/MTChamber.hh"
00026 #include "root/MTDetector.hh"
00027 #include "root/MTBoard.hh"
00028 #include "root/MTChip.hh"
00029 #include "root/MTChannel.hh"
00030 #include "root/MTEvent.hh"
00031 #include "root/MTDif.hh"
00032 #include "root/MTHardroc1Chip.hh"
00033 #include "root/MTHardroc2Chip.hh"
00034 #include "root/MTDiracChip.hh"
00035 #include "root/MTMicrorocChip.hh"
00036
00037
00038 using namespace std;
00039
00040
00041 int main(int argc, char**argv){
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 if ( argc !=2 ) {
00080 FILE_LOG(logERROR) << "usage: example rootFile " << endl;
00081 exit(1);
00082 }
00083
00084 string rootName;
00085 rootName.assign(argv[1]);
00086 int nbHit = 0;
00087 int nbEvt = 0;
00088
00089 TFile f(rootName.c_str());
00090 f.ls();
00091
00092
00093
00094 TIter nextkey(f.GetListOfKeys());
00095 TKey *key;
00096 while (key = (TKey*)nextkey())
00097 {
00098 TTree *tree = (TTree*)key->ReadObj();
00099 MTRun *run=NULL;
00100 try
00101 {
00102 run=dynamic_cast<MTRun *>(tree->GetUserInfo()->First());
00103 cout << "---------------------------- NEW TTREE ---------------------------"<< endl;
00104 nbEvt =0;
00105 nbHit = 0;
00106
00107
00108 bool showConfig = false;
00109 if ( run != NULL && showConfig)
00110 {
00111 run->Info();
00112 MTDetector* det = run->GetDetector();
00113
00114
00115 const std::map<UInt_t,MTChamber*>& chambers = det->GetChambers();
00116 for( std::map<UInt_t,MTChamber*>::const_iterator ii=chambers.begin(); ii!=chambers.end(); ++ii)
00117 {
00118 const MTChamber& chamber= *((*ii).second);
00119 cout << "chamber id: " << chamber.GetId() << endl;
00120 cout << "chamber type: " << chamber.GetType() << endl;
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 const std::map<UInt_t,MTBoard*>& boards = chamber.GetBoards();
00131 for( std::map<UInt_t,MTBoard*>::const_iterator ii=boards.begin(); ii!=boards.end(); ++ii)
00132 {
00133 const MTBoard& board= *((*ii).second);
00134 board.Info();
00135
00136 cout << endl << endl << "\t\t\t**** Chips configuration ****" << endl ;
00137 cout << "DEBUG board.GetChips().size()[" << board.GetChips().size() << "]" << endl;
00138 map<UInt_t,MTChip*> chips = board.GetChips();
00139 for( map<UInt_t,MTChip*>::const_iterator iiChip=chips.begin(); iiChip!=chips.end(); ++iiChip)
00140 {
00141 const MTChip& chip = *((*iiChip).second);
00142 cout << "chip[" << chip.GetId() << "] bypass[" << chip.GetBypassed() << "] " << endl;
00143 if ( chip.IsConfigured() )
00144 {
00145 cout << endl << " -- New Chip configuration:" << chip.GetSoftId().toString() << " softId[" << chip.GetSoftId().GetValue() <<"], serial Number[" << chip.GetSerialNumber() << "]"<< endl <<endl <<endl ;
00146 try {
00147 const MTDiracChip &diracChip = dynamic_cast<const MTDiracChip &> (chip);
00148 cout << " ** Dirac Chip config **" << endl;
00149 cout << " threshold B High: " << diracChip.GetBHiThreshold() << endl;
00150 cout << " threshold B Mid : " << diracChip.GetBMidThreshold() << endl;
00151 cout << " threshold B Low : " << diracChip.GetBLoThreshold() << endl;
00152
00153 cout << " threshold A High :" << diracChip.GetAHiThreshold() << endl;
00154 cout << " threshold A Mid : " << diracChip.GetAMidThreshold() << endl;
00155 cout << " threshold A Low : " << diracChip.GetALoThreshold() << endl;
00156 cout << " ** END Dirac Chip config **" << endl;
00157 }
00158 catch (...) {}
00159
00160 try{
00161 const MTHardroc1Chip &hr1Chip = dynamic_cast<const MTHardroc1Chip &> (chip);
00162 cout << " ** Hardroc1 Chip config **" << endl;
00163 cout << " threshold dac 0: " << hr1Chip.GetThresholdDac_0() << endl;
00164 cout << " threshold dac 1: " << hr1Chip.GetThresholdDac_1() << endl;
00165 cout << " gain : " << hr1Chip.GetGain() << endl;
00166 cout << " ** END Hardroc1 Chip config **" << endl;
00167 }
00168 catch (...) {}
00169
00170 try{
00171 const MTHardroc2Chip &hr2Chip = dynamic_cast<const MTHardroc2Chip &> (chip);
00172 cout << " ** Hardroc2 Chip config **" << endl;
00173 cout << " threshold dac 0: " << hr2Chip.GetThresholdDac_0() << endl;
00174 cout << " threshold dac 1: " << hr2Chip.GetThresholdDac_1() << endl;
00175 cout << " threshold dac 2: " << hr2Chip.GetThresholdDac_2() << endl;
00176 cout << " gain : " << hr2Chip.GetGain() << endl;
00177 cout << " ** END Hardroc2 Chip config **" << endl;
00178 }
00179 catch (...) {}
00180
00181 try{
00182 const MTMicrorocChip µ2Chip = dynamic_cast<const MTMicrorocChip &> (chip);
00183 cout << " ** MicrorocChip Chip config **" << endl;
00184 cout << dec << " Serial number : " << micro2Chip.GetSerialNumber() << endl;
00185 cout << dec << " low shaper : " << micro2Chip.GetShaper_lg() << endl;
00186 cout << dec << " high shaper : " << micro2Chip.GetShaper_hg() << endl;
00187 cout << dec << " threshold dac 0: " << micro2Chip.GetThresholdDac_0() << endl;
00188 cout << dec << " threshold dac 1: " << micro2Chip.GetThresholdDac_1() << endl;
00189 cout << dec << " threshold dac 2: " << micro2Chip.GetThresholdDac_2() << endl;
00190 cout << " ** END MicrorocChip Chip config **" << endl;
00191 }
00192 catch (...) {}
00193
00194 cout << endl << endl << "* channels config **" << endl << endl;
00195 cout <<" Enable channel:" ;
00196 for ( UInt_t num = 0 ; num <=63 ; num++)
00197 {
00198 cout << "[" << dec <<num << ":"<< chip.GetEnableChannel(num) << "]";
00199 }
00200 cout << endl <<endl << endl << " Stimulate channel:";
00201 for ( UInt_t num = 0 ; num <=63 ; num++)
00202 {
00203 cout << "[" << dec <<num << ":"<< chip.GetStimulatedChannel(num) << "]";
00204 }
00205
00206 cout << endl <<endl << endl << " Mask ( Microroc Only ) channel:";
00207 for ( UInt_t num = 0 ; num <=63 ; num++)
00208 {
00209 for ( UInt_t index = 0 ; index < 3 ; index++ )
00210 {
00211 cout << "[" << dec <<num << ":MASK" << index << "-> "<< chip.GetMaskChannel(num,index) << "]";
00212 }
00213 }
00214
00215
00216 cout << endl <<endl << endl << " pedastal correction channel:";
00217 for ( UInt_t num = 0 ; num <=63 ; num++)
00218 {
00219 cout << "[" <<dec << num << ":"<< chip.GetPedestalChannel(num) << "]";
00220 }
00221 cout << endl << " -- End Chip configuration:" << endl;
00222 }
00223
00224 }
00225 cout <<endl << "\t\t\t**** END Chips configuration **** "<< endl << endl << endl;
00226 }
00227 }
00228 }
00229 }
00230 catch (MicroException e) {}
00231
00232
00233 MTEvent *evt = new MTEvent();
00234 TBranch *branch= tree->GetBranch("MTEvent");
00235 branch->SetAddress(&evt);
00236
00237 MTChannel* channel =NULL;
00238 int nbEntries = tree->GetEntries();
00239
00240 for ( int evtNum = 0; evtNum <= nbEntries ; evtNum++)
00241 {
00242 tree->GetEntry(evtNum);
00243 nbEvt++;
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271 {
00272 cout << " event id:" << evt->GetEventId() <<endl;
00273
00274 cout << " event Dif suynchro:" << evt->GetDifSynchro() <<endl;
00275 cout << " event total Trigger counter:" << evt->GetGlobalTriggerCounter() <<endl;
00276 cout << " event Dif Trigger counter:" << evt->GetDifTriggerCounter() <<endl;
00277 const map<unsigned int , float>& tempAsu1 = evt->GetTemperatureAsu1();
00278 for ( map<unsigned int , float>::const_iterator it = tempAsu1.begin() ; it != tempAsu1.end(); it++)
00279 {
00280 cout << " temperature difId: " << it->first << " Asu1:" << it->second <<endl;
00281 }
00282 const map<unsigned int , float>& tempAsu2 = evt->GetTemperatureAsu2();
00283 for ( map<unsigned int , float>::const_iterator it = tempAsu2.begin() ; it != tempAsu2.end(); it++)
00284 {
00285 cout << " temperature difId: " << it->first << " Asu2:" << it->second <<endl;
00286 }
00287
00288 const map<unsigned int , float>& tempDif = evt->GetTemperatureDif();
00289 cout << "evt->GetTemperatureDif().size[" << evt->GetTemperatureDif().size() << "]" <<endl;
00290 for ( map<unsigned int , float>::const_iterator it = tempDif.begin() ; it != tempDif.end(); it++)
00291 {
00292 cout << " temperature difId: " << it->first << " dif:" << it->second <<endl;
00293 cout << "DEBUG 1" << endl;
00294 }
00295 cout << "evt->GetTemperatureAsu1().size[" << evt->GetTemperatureAsu1().size() << "]" <<endl;
00296 cout << "evt->GetTemperatureAsu2().size[" << evt->GetTemperatureAsu2().size() << "]" <<endl;
00297 cout << " temperature:" << evt->GetTemperature() <<endl;
00298 cout << " pressure:"<< evt->GetPressure() <<endl;
00299 cout << " timestamp:"<< evt->GetTimestamp() <<endl;
00300 cout << " dif_synchro:"<< evt->GetDifSynchro() <<endl;
00301 cout << " CRC is correct:"<< evt->GetCrcIsCorrect() <<endl;
00302
00303 std::vector<UInt_t>& dtCands = evt->GetDtCandidate();
00304 for ( std::vector<UInt_t>::const_iterator it =dtCands.begin(); it!=dtCands.end(); it++)
00305 {
00306 cout << "dt canditate: [" << *it << "] " << endl;
00307 }
00308
00309
00310 const std::map<UInt_t, std::map<UInt_t, std::map<UInt_t, Float_t>* >* >& meshs = evt->GetMeshVoltage();
00311 for ( std::map<UInt_t, std::map<UInt_t, std::map<UInt_t, Float_t>* >* >::const_iterator iterChamber = meshs.begin(); iterChamber != meshs.end(); iterChamber++)
00312 {
00313 std::map<UInt_t, std::map<UInt_t, Float_t>* >&difContainer = *(iterChamber)->second;
00314 for ( std::map<UInt_t, std::map<UInt_t, Float_t>* >::const_iterator iterDif = difContainer.begin(); iterDif != difContainer.end(); iterDif++)
00315 {
00316 std::map<UInt_t, Float_t> &boardContainer = *(iterDif)->second;
00317 for ( std::map<UInt_t, Float_t>::const_iterator iterVoltage = boardContainer.begin(); iterVoltage != boardContainer.end(); iterVoltage++)
00318 {
00319 cout << " MeshVoltage for chamber [" << iterChamber->first << "]Dif = ["<< iterDif->first << "] board[" << iterVoltage->first << "] :" <<iterVoltage->second << "]" << endl;
00320 }
00321 }
00322
00323 }
00324
00325
00326 const std::map<UInt_t, std::map<UInt_t, std::map<UInt_t, Float_t>* >* >& drifts = evt->GetDriftVoltage();
00327 for ( std::map<UInt_t, std::map<UInt_t, std::map<UInt_t, Float_t>* >* >::const_iterator iterChamber = drifts.begin(); iterChamber != drifts.end(); iterChamber++)
00328 {
00329 std::map<UInt_t, std::map<UInt_t, Float_t>* >&difContainer = *(iterChamber)->second;
00330 for ( std::map<UInt_t, std::map<UInt_t, Float_t>* >::const_iterator iterDif = difContainer.begin(); iterDif != difContainer.end(); iterDif++)
00331 {
00332 std::map<UInt_t, Float_t> &boardContainer = *(iterDif)->second;
00333 for ( std::map<UInt_t, Float_t>::const_iterator iterVoltage = boardContainer.begin(); iterVoltage != boardContainer.end(); iterVoltage++)
00334 {
00335
00336 cout << " DriftVoltage for chamber [" << iterChamber->first << "]Dif = ["<< iterDif->first << "] board[" << iterVoltage->first << "] :" <<iterVoltage->second << "]" << endl;
00337
00338 }
00339 }
00340
00341 }
00342 }
00343
00344
00345
00346 {
00347 cout << " is square[" << evt->GetSquareEvt() << "]" << endl;
00348 cout << " is time info correct[" << evt->GetTimeInfo() << "]" << endl;
00349 MTTrack *track = evt->GetTrack();
00350 if ( track != NULL )
00351 {
00352 cout << " straight: " << track->GetStraight()
00353 << ", from Strip: " << track->GetFromStrip()
00354 << ", from Pad: " << track->GetFromPad()
00355 << ", single hit: " << track->GetSingleHit()
00356 << ", ax: " << track->GetAx()
00357 << ", bx: " << track->GetBx()
00358 << ", ay: " << track->GetAy()
00359 << ", by: " << track->GetBy() << endl;
00360 }
00361 }
00362 cout << " number of channel hit:" << evt->GetNchannel() <<endl;
00363 int nbChannel = evt->GetNchannel();
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405 }
00406 cout << "End of TTree[" << tree->GetName() << "]" <<endl;
00407 cout << endl << "** Nombre d Event["<< nbEvt <<"] ** "<< endl;
00408 cout << endl << "** Nombre de Hits["<< nbHit <<"] ** "<< endl;
00409
00410 }
00411 return 0 ;
00412 }
00413
00414
00415
00416