/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/Damien/evt_cadre.C

Go to the documentation of this file.
00001 {
00002   gROOT->Reset();
00003   gROOT->SetStyle("Bold");
00004   gStyle->SetPalette(1);
00005   gSystem->Load("~/Micromegas/Analyse/trunk/lib/libMicro.so");
00006   
00007   
00008   //////////////////////
00009   //User's parameters
00010   
00011   //which event do you want to plot (0 = no plot, a number = the event you want)
00012   //Int_t plot = 0;
00013   Int_t plot = 4555;
00014   
00015   //Do you want some info ? (0 = no, 1 = yes a little, 2 = yes a lot, 3 = yes all for debug purpose)
00016   Int_t blabla = 2;
00017   
00018   //what are the id's of our asu's ? (assuming they go from first_asu to first_asu+5)
00019   Int_t asu[6];
00020   for(int it=0;it<6;it++) asu[it] = it+13;
00021   
00022   //square events
00023   Int_t nb_square = 20;
00024   Int_t list_square[nb_square] = {105,375,558,1090,1356,1600,2212,2563,2970,2985,2985,3481,3481,3633,3736,4481,4562,4606,5329,5662};
00025   
00026   //threshold
00027   Int_t threshold = 30;
00028 
00029   //input data
00030   string file = "05082011_1055_MGT.root";  
00031   //////////////////////
00032   
00033   
00034   //our data file
00035   TFile *f = new TFile(file.c_str());
00036   if(blabla==1||blabla==2||blabla==3){
00037     cout<<endl;
00038     cout<<"reading File : "<<file<<endl;
00039   }
00040   
00041   //key iterator
00042   TIter nextkey(f.GetListOfKeys());
00043   TKey *key;
00044   
00045   //counters
00046   UInt_t counter = 0;
00047   UInt_t channels_asu[6][128];
00048   UInt_t nb_border[6][128];
00049   UInt_t nb_tot;
00050   
00051   Int_t xpos;
00052   Int_t ypos;
00053 
00054 //LĂ  y'a un truc bizarre:
00055 //si la déclaration de hxy est dans le if -> ca rame, si elle est hors du if -> ca tourne bien
00056 //je comprends pas du tout pourquoi ??? 
00057   //plotting
00058   //TH2I *hxy = new TH2I("hxy","Hit position distribution;y (cm);x (cm)",96,0,96,96,0,96);
00059   if(plot != 0){
00060     TH2I *hxy = new TH2I("hxy","Hit position distribution;y (cm);x (cm)",96,0,96,96,0,96);
00061     TCanvas *c0 = new TCanvas("c0", "Prototype m2", 100, 50, 500, 500);
00062   }
00063   
00064   if(blabla==1||blabla==2||blabla==3) cout<<endl;
00065   
00066   
00067   //loop on all the events of the key
00068   while (key = (TKey*)nextkey()) {
00069     
00070     counter++;
00071     if(blabla==1||blabla==2||blabla==3) cout<<"key number = "<<counter<<endl;
00072     
00073     TTree *tree = (TTree*)key->ReadObj();                
00074     MTRun* run = (MTRun*)tree->GetUserInfo()->FindObject("MTRun");
00075     
00076     Int_t nEvent = tree.GetEntries();
00077     if(blabla==1||blabla==2||blabla==3) cout <<"Nevent = "<<nEvent<<endl;
00078     
00079     //Int_t azu = run->GetDetector()->GetChambers()->GetBoards(); 
00080     
00081     MTEvent *evt = new MTEvent();
00082     
00083     TBranch *branch= tree->GetBranch("MTEvent");
00084     branch->SetAddress(&evt);
00085     
00086     UInt_t list_event[nEvent];
00087     
00088     //at each new key, reset the event border counters
00089     for (int bd=0;bd<=5;bd++) for (int ti=0;ti<128;ti++) nb_border[bd][ti] = 0; 
00090     nb_tot=0;
00091     
00092     
00093     //loop on all the events of the key
00094     for (int i=0;i<nEvent-1;i++){
00095 
00096       //test if this event is square (if it is square, my algorythm would see it as a false border event because there are hits on the borders...)
00097       bool I_am_a_square_event = 0;
00098       for (int it=0;it<nb_square;it++) if (i+1==list_square[it]) I_am_a_square_event = 1;
00099       if (I_am_a_square_event==1) continue;
00100       
00101       //at each new event, reset the channels counter of each board_id
00102       for (int bd=0;bd<=5;bd++) for (int ti=0;ti<128;ti++) channels_asu[bd][ti] = 0; 
00103       
00104       tree.GetEntry(i);
00105       
00106       UInt_t nchannel = evt->GetNchannel();
00107       UInt_t board_id;
00108       UInt_t mem_order;
00109       
00110       if(blabla==3) cout<<"Event "<<i+1<<" / "<<nEvent<<"; nb of channels=  "<<nchannel<<endl;
00111 
00112       
00113       //loop on all the channels of the event
00114       for (int j=0;j<nchannel;j++){
00115         
00116         //Reset board_id and memory order
00117         board_id = 0;
00118         mem_order = 0;
00119         
00120         //create this channel
00121         MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00122         
00123         //get the board_id of this channel
00124         board_id = channel->GetBoardId();
00125 
00126         //get the memory order of this hit
00127         mem_order = channel->GetMemoryOrder();
00128         
00129         //if the event is on the borders of the asu upgrade the hit counter of the good board at the good time
00130         if (board_id==asu[0]) if (xpos == 000000 || xpos == 310000 || ypos == 000000 || ypos == 470000) channels_asu[0][mem_order]++;
00131         if (board_id==asu[1]) if (xpos == 000000 || xpos == 310000 || ypos == 480000 || ypos == 960000) channels_asu[1][mem_order]++;
00132         if (board_id==asu[2]) if (xpos == 320000 || xpos == 640000 || ypos == 000000 || ypos == 470000) channels_asu[2][mem_order]++;
00133         if (board_id==asu[3]) if (xpos == 320000 || xpos == 640000 || ypos == 480000 || ypos == 960000) channels_asu[3][mem_order]++;
00134         if (board_id==asu[4]) if (xpos == 650000 || xpos == 960000 || ypos == 000000 || ypos == 470000) channels_asu[4][mem_order]++;
00135         if (board_id==asu[5]) if (xpos == 650000 || xpos == 960000 || ypos == 480000 || ypos == 960000) channels_asu[5][mem_order]++;
00136         
00137         //get the position of this hit/channel
00138         xpos = channel->GetX()/10000;
00139         ypos = channel->GetY()/10000;
00140         
00141         if(blabla==3) cout<<"Channel : "<<channel<<"; hit on asu "<<board_id<<"; at memory order "<<mem_order<<", x= "<<xpos<<", y= "<<ypos<<endl;
00142         
00143         //if we want to plot this event, fill the histogramm
00144         if (plot==i+1) hxy->Fill(ypos,xpos); 
00145       }
00146       
00147       //On each board, at each time, identify the events which are on the border
00148       for (int bd=0;bd<=5;bd++) {
00149          for (int ti=0;ti<128;ti++) {
00150            if (channels_asu[bd][ti]>= threshold) {
00151 
00152              if(blabla==3) cout <<bd<<" "<<ti;
00153              if(blabla==2||blabla==3) cout <<" -> event: "<<i+1<<" = border in asu no "<<asu[bd]<<" at memory order "<<ti<<" with Nhits = "<<channels_asu[bd][ti]<<endl;
00154              
00155              //update the event border counter of the good board at the good time
00156              nb_border[bd][ti]++;
00157              //update the total event border counter of this key
00158              nb_tot++;
00159 
00160             //update the event list
00161             list_event[nb_tot-1] = i+1;
00162            }
00163          }
00164       }
00165       //if we want to plot this event, let's do it now
00166       if (plot==i+1){
00167         hxy->SetTitle("Hits position");
00168         hxy.GetXaxis()->SetTitle("X (cm)");
00169         hxy.GetYaxis()->SetTitle("Y (cm)");
00170         hxy->Draw("zcol");
00171       }  
00172     }
00173 
00174     //Now the Prints: at each key print nb of evts border
00175     if(blabla==2||blabla==3) cout<<endl;
00176     if(blabla==1||blabla==2||blabla==3) {
00177       //at each key print nb of evts border
00178       cout<<"In key "<<counter<<" Nb tot evt border = "<<nb_tot<<endl;
00179       //at each key print print the liste of border events
00180       cout<<"List of border events: "<<endl;
00181       for(int it=0;it<nb_tot;it++) cout<<" "<<list_event[it];
00182       cout<<endl<<endl;
00183     }
00184     if(blabla==2||blabla==3) {
00185       cout<<"Hereafter I show the nb of event border in each board/asu at each time:"<<endl<<endl<<"Board/asu i"<<endl<<"memory order:";
00186       for (int ti=0;ti<128;ti++) cout<<" "<<ti;
00187       cout<<endl;
00188       for (int bd=0;bd<=5;bd++) {
00189         cout<<endl;
00190         cout<<"Board/asu "<<asu[bd]<<endl;
00191         for (int ti=0;ti<128;ti++) {
00192           cout<<" "<<nb_border[bd][ti];
00193           nb_border[bd][ti] = 0; 
00194           
00195         }
00196         cout<<endl;
00197       }
00198       cout<<endl;
00199     }
00200   }
00201 }
00202 

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7